use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class OpenflowpluginTableFeaturesTestServiceProvider method register.
public ObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(final ProviderContext ctx) {
RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx.<SalTableService>addRoutedRpcImplementation(SalTableService.class, this);
setTableRegistration(addRoutedRpcImplementation);
InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier.<Nodes>builder(Nodes.class);
NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifierBuilder<Node> nodeIndentifier = builder1.<Node, NodeKey>child(Node.class, nodeKey);
InstanceIdentifier<Node> instance = nodeIndentifier.build();
tableRegistration.registerPath(NodeContext.class, instance);
RoutedRpcRegistration<SalTableService> tableRegistration1 = this.getTableRegistration();
return new AbstractObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider>(this) {
@Override
protected void removeRegistration() {
tableRegistration1.close();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class AbstractCompatibleStatServiceTest method setUp.
@Override
public void setUp() {
rqContext = new AbstractRequestContext<Object>(42L) {
@Override
public void close() {
// NOOP
}
};
final Answer closeRequestFutureAnswer = invocation -> {
rqContext.setResult(rpcResult);
rqContext.close();
return null;
};
Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(null);
Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
Mockito.when(translatorLibrary.lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
service = AggregateFlowsInTableService.createWithOook(rqContextStack, deviceContext, new AtomicLong(20L));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class HandshakeListenerImplTest method testOnHandshakeFailure2.
@Test
public void testOnHandshakeFailure2() throws Exception {
Mockito.when(connectionAdapter.getRemoteAddress()).thenReturn(InetSocketAddress.createUnresolved("ut-ofp.example.org", 4242));
connectionContextSpy.setNodeId(new NodeId("openflow:1"));
handshakeListener.onHandshakeFailure();
Mockito.verify(handshakeContext).close();
Mockito.verify(connectionContextSpy).closeConnection(false);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class HandshakeListenerImplTest method testOnHandshakeFailure1.
@Test
public void testOnHandshakeFailure1() throws Exception {
connectionContextSpy.setNodeId(new NodeId("ut-device:10"));
handshakeListener.onHandshakeFailure();
Mockito.verify(handshakeContext).close();
Mockito.verify(connectionContextSpy).closeConnection(false);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Close in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImpl method fillFromDatastore.
private CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> fillFromDatastore(final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<FlowCapableNode> path) {
// Create new read-only transaction
final ReadOnlyTransaction transaction = dataBroker.newReadOnlyTransaction();
// Bail out early if transaction is null
if (transaction == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read transaction is null"));
}
// Prepare read operation from datastore for path
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> future = transaction.read(logicalDatastoreType, path);
// Bail out early if future is null
if (future == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Future from read transaction is null"));
}
Futures.addCallback(future, new FutureCallback<Optional<FlowCapableNode>>() {
@Override
public void onSuccess(@Nonnull Optional<FlowCapableNode> result) {
result.asSet().stream().filter(Objects::nonNull).filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable())).flatMap(flowCapableNode -> flowCapableNode.getTable().stream()).filter(Objects::nonNull).filter(table -> Objects.nonNull(table.getFlow())).flatMap(table -> table.getFlow().stream()).filter(Objects::nonNull).filter(flow -> Objects.nonNull(flow.getId())).forEach(flowConsumer);
// After we are done with reading from datastore, close the transaction
transaction.close();
}
@Override
public void onFailure(Throwable throwable) {
// Even when read operation failed, close the transaction
transaction.close();
}
}, MoreExecutors.directExecutor());
return future;
}
Aggregations