@Test public void testInsertTSDRMetricRecord() throws InterruptedException, ExecutionException, TimeoutException { doReturn(RpcResultBuilder.success(new StoreTSDRMetricRecordOutputBuilder().build()).buildFuture()) .when(metricDataService).storeTSDRMetricRecord(any()); final TSDRMetricRecord inputMetricRecord = createTSDRMetricRecord("Test Metric", BigDecimal.valueOf(123)); final ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> resultFuture = impl.insertTSDRMetricRecord( new InsertTSDRMetricRecordInputBuilder().setCollectorCodeName("Test") .setTSDRMetricRecord(Collections.singletonList(inputMetricRecord)).build()); assertTrue(resultFuture.get(5, TimeUnit.SECONDS).isSuccessful()); ArgumentCaptor<StoreTSDRMetricRecordInput> storeMetricInputCaptor = ArgumentCaptor.forClass(StoreTSDRMetricRecordInput.class); verify(metricDataService).storeTSDRMetricRecord(storeMetricInputCaptor.capture()); StoreTSDRMetricRecordInput storeMetricInput = storeMetricInputCaptor.getValue(); assertEquals(1, storeMetricInput.getTSDRMetricRecord().size()); org.opendaylight.yang.gen.v1.opendaylight.tsdr.metric.data.rev160325.storetsdrmetricrecord.input .TSDRMetricRecord storeMetricRecord = storeMetricInput.getTSDRMetricRecord().iterator().next(); assertEquals(inputMetricRecord.getMetricName(), storeMetricRecord.getMetricName()); assertEquals(inputMetricRecord.getMetricValue(), storeMetricRecord.getMetricValue()); assertEquals(inputMetricRecord.getNodeID(), storeMetricRecord.getNodeID()); assertEquals(inputMetricRecord.getRecordKeys(), storeMetricRecord.getRecordKeys()); assertEquals(inputMetricRecord.getTimeStamp(), storeMetricRecord.getTimeStamp()); assertEquals(inputMetricRecord.getTSDRDataCategory(), storeMetricRecord.getTSDRDataCategory()); }
@Override public ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord( InsertTSDRMetricRecordInput input) { List<TSDRMetricRecord> records = input.getTSDRMetricRecord().stream().map(inputRec -> new TSDRMetricRecordBuilder().setMetricName(inputRec.getMetricName()) .setMetricValue(inputRec.getMetricValue()) .setNodeID(inputRec.getNodeID()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRMetricRecordInput tsdrServiceInput = new StoreTSDRMetricRecordInputBuilder().setTSDRMetricRecord(records).build(); return Futures.transform(metricDataService.storeTSDRMetricRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRMetricRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRMetricRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord( InsertTSDRMetricRecordInput input) { List<TSDRMetricRecord> records = input.getTSDRMetricRecord().stream().map(inputRec -> new TSDRMetricRecordBuilder().setMetricName(inputRec.getMetricName()) .setMetricValue(inputRec.getMetricValue()) .setNodeID(inputRec.getNodeID()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRMetricRecordInput tsdrServiceInput = new StoreTSDRMetricRecordInputBuilder().setTSDRMetricRecord(records).build(); return Futures.transform(metricDataService.storeTSDRMetricRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRMetricRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRMetricRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord( InsertTSDRMetricRecordInput input) { List<TSDRMetricRecord> records = input.getTSDRMetricRecord().stream().map(inputRec -> new TSDRMetricRecordBuilder().setMetricName(inputRec.getMetricName()) .setMetricValue(inputRec.getMetricValue()) .setNodeID(inputRec.getNodeID()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRMetricRecordInput tsdrServiceInput = new StoreTSDRMetricRecordInputBuilder().setTSDRMetricRecord(records).build(); return Futures.transform(metricDataService.storeTSDRMetricRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRMetricRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRMetricRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } CollectorSPIImpl(TsdrMetricDataService metricService,TsdrLogDataService logService); }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord( InsertTSDRMetricRecordInput input) { List<TSDRMetricRecord> records = input.getTSDRMetricRecord().stream().map(inputRec -> new TSDRMetricRecordBuilder().setMetricName(inputRec.getMetricName()) .setMetricValue(inputRec.getMetricValue()) .setNodeID(inputRec.getNodeID()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRMetricRecordInput tsdrServiceInput = new StoreTSDRMetricRecordInputBuilder().setTSDRMetricRecord(records).build(); return Futures.transform(metricDataService.storeTSDRMetricRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRMetricRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRMetricRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } CollectorSPIImpl(TsdrMetricDataService metricService,TsdrLogDataService logService); @Override ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord(
            InsertTSDRMetricRecordInput input); @Override ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input); }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord( InsertTSDRMetricRecordInput input) { List<TSDRMetricRecord> records = input.getTSDRMetricRecord().stream().map(inputRec -> new TSDRMetricRecordBuilder().setMetricName(inputRec.getMetricName()) .setMetricValue(inputRec.getMetricValue()) .setNodeID(inputRec.getNodeID()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRMetricRecordInput tsdrServiceInput = new StoreTSDRMetricRecordInputBuilder().setTSDRMetricRecord(records).build(); return Futures.transform(metricDataService.storeTSDRMetricRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRMetricRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRMetricRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } CollectorSPIImpl(TsdrMetricDataService metricService,TsdrLogDataService logService); @Override ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord(
            InsertTSDRMetricRecordInput input); @Override ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input);  }