use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput in project openflowplugin by opendaylight.
the class MeterForwarderTest method testRemove.
@Test
public void testRemove() throws Exception {
Mockito.when(salMeterService.removeMeter(removeMeterInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().setTransactionId(txId).build()).buildFuture());
Meter removeMeter = new MeterBuilder(meter).build();
final Future<RpcResult<RemoveMeterOutput>> removeResult = meterForwarder.remove(meterPath, removeMeter, flowCapableNodePath);
Mockito.verify(salMeterService).removeMeter(Matchers.<RemoveMeterInput>any());
Assert.assertTrue(removeResult.isDone());
final RpcResult<RemoveMeterOutput> meterResult = removeResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(meterResult.isSuccessful());
Assert.assertEquals(1, meterResult.getResult().getTransactionId().getValue().intValue());
final RemoveMeterInput removeMeterInput = removeMeterInputCpt.getValue();
Assert.assertEquals(meterPath, removeMeterInput.getMeterRef().getValue());
Assert.assertEquals(nodePath, removeMeterInput.getNode().getValue());
Assert.assertEquals("test-meter", removeMeterInput.getMeterName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput in project openflowplugin by opendaylight.
the class MeterForwarder method removeWithResult.
@Override
public Future<RpcResult<RemoveMeterOutput>> removeWithResult(final InstanceIdentifier<Meter> identifier, final Meter removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(removeDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setMeterRef(new MeterRef(identifier));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
return this.provider.getSalMeterService().removeMeter(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput in project openflowplugin by opendaylight.
the class MeterForwarder method remove.
@Override
public void remove(final InstanceIdentifier<Meter> identifier, final Meter removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(removeDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setMeterRef(new MeterRef(identifier));
builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
final Future<RpcResult<RemoveMeterOutput>> resultFuture = this.provider.getSalMeterService().removeMeter(builder.build());
JdkFutures.addErrorLogging(resultFuture, LOG, "removeMeter");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput in project openflowplugin by opendaylight.
the class MeterForwarder method remove.
@Override
public Future<RpcResult<RemoveMeterOutput>> remove(final InstanceIdentifier<Meter> identifier, final Meter removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Received the Meter REMOVE request [Tbl id, node Id {} {}", identifier, nodeIdent);
final RemoveMeterInputBuilder builder = new RemoveMeterInputBuilder(removeDataObj);
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
builder.setMeterRef(new MeterRef(identifier));
return salMeterService.removeMeter(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput in project openflowplugin by opendaylight.
the class SalMetersBatchServiceImpl method removeMetersBatch.
@Override
public Future<RpcResult<RemoveMetersBatchOutput>> removeMetersBatch(final RemoveMetersBatchInput input) {
LOG.trace("Removing meters @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveMeters().size());
final ArrayList<ListenableFuture<RpcResult<RemoveMeterOutput>>> resultsLot = new ArrayList<>();
for (BatchRemoveMeters addMeter : input.getBatchRemoveMeters()) {
final RemoveMeterInput removeMeterInput = new RemoveMeterInputBuilder(addMeter).setMeterRef(createMeterRef(input.getNode(), addMeter)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.removeMeter(removeMeterInput)));
}
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), MeterUtil.<RemoveMeterOutput>createCumulativeFunction(input.getBatchRemoveMeters()), MoreExecutors.directExecutor());
ListenableFuture<RpcResult<RemoveMetersBatchOutput>> removeMetersBulkFuture = Futures.transform(commonResult, MeterUtil.METER_REMOVE_TRANSFORM, MoreExecutors.directExecutor());
if (input.isBarrierAfter()) {
removeMetersBulkFuture = BarrierUtil.chainBarrier(removeMetersBulkFuture, input.getNode(), transactionService, MeterUtil.METER_REMOVE_COMPOSING_TRANSFORM);
}
return removeMetersBulkFuture;
}
Aggregations