/** * @param features {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput} * @return switch features */ public SwitchFeatures buildSwitchFeatures(GetFeaturesOutput features) { if(swFeaturesBuilders.containsKey(features.getVersion())) { LOG.debug("map contains version {}", features.getVersion()); try { return swFeaturesBuilders.get(features.getVersion()).build(features); } catch (NullPointerException e) { LOG.warn("error while building switch features: {}", e.getMessage()); LOG.debug("error while building switch features.. ", e); } } else { LOG.warn("unknown version: {}", features.getVersion()); } return null; }
/** * @return protocol version */ public Short getVersion() { return taskContext.getSession().getFeatures().getVersion(); }
public void initSession(GetFeaturesOutput featuresOutput) { if (featuresOutput != null) { sc.setFeatures(featuresOutput); ShimConductor cond = new ShimConductor(); cond.setVersion(featuresOutput.getVersion()); sc.setPrimaryConductor(cond); } }
session.getFeatures().getVersion(), session.getNextXid()); Future<RpcResult<BarrierOutput>> barrierResult = session.getPrimaryConductor().getConnectionAdapter().barrier(barrierInput); try { session.getFeatures().getVersion(), session.getNextXid()); Future<RpcResult<BarrierOutput>> barrierResult = session.getPrimaryConductor().getConnectionAdapter().barrier(barrierInput); try {
/** * @param session switch session context * @param cookie connection distinguisher cookie value * @param messageService message dispatch service instance * @return barrier response */ public static RpcInputOutputTuple<BarrierInput, ListenableFuture<RpcResult<BarrierOutput>>> sendBarrier(SessionContext session, SwitchConnectionDistinguisher cookie, IMessageDispatchService messageService) { BarrierInput barrierInput = MessageFactory.createBarrier( session.getFeatures().getVersion(), session.getNextXid()); Future<RpcResult<BarrierOutput>> barrierResult = messageService.barrier(barrierInput, cookie); ListenableFuture<RpcResult<BarrierOutput>> output = JdkFutureAdapters.listenInPoolThread(barrierResult); return new RpcInputOutputTuple<>(barrierInput, output); }
/** * @param session switch session context * @param role controller openflow role * @param generationId generate id for role negotiation * @return input builder */ public static RoleRequestInputBuilder createRoleRequestInput( final SessionContext session, OfpRole role, BigInteger generationId) { ControllerRole ofJavaRole = RoleUtil.toOFJavaRole(role); return new RoleRequestInputBuilder() .setGenerationId(generationId) .setRole(ofJavaRole) .setVersion(session.getFeatures().getVersion()) .setXid(session.getNextXid()); }
@Override public void onSessionAdded(final SwitchSessionKeyOF sessionKey, final SessionContext context) { GetFeaturesOutput features = context.getFeatures(); BigInteger datapathId = features.getDatapathId(); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); NodeRef nodeRef = new NodeRef(identifier); NodeId nodeId = nodeIdFromDatapathId(datapathId); ModelDrivenSwitch ofSwitch = new ModelDrivenSwitchImpl(nodeId, identifier, context, convertorExecutor); NotificationQueueWrapper wrappedNotification = new NotificationQueueWrapper( nodeAdded(ofSwitch, features, nodeRef), context.getFeatures().getVersion()); reqOpenflowEntityOwnership(ofSwitch, context, wrappedNotification, rpcProviderRegistry); }
@Override public void onSessionRemoved(final SessionContext context) { GetFeaturesOutput features = context.getFeatures(); BigInteger datapathId = features.getDatapathId(); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); NodeRef nodeRef = new NodeRef(identifier); NodeId nodeId = nodeIdFromDatapathId(datapathId); unregOpenflowEntityOwnership(nodeId); NodeRemoved nodeRemoved = nodeRemoved(nodeRef); ModelDrivenSwitchRegistration registration = context.getProviderRegistration(); if (null != registration) { registration.close(); context.setProviderRegistration(null); } LOG.debug("ModelDrivenSwitch for {} unregistered from MD-SAL.", datapathId); NotificationQueueWrapper wrappedNotification = new NotificationQueueWrapper( nodeRemoved, context.getFeatures().getVersion()); context.getNotificationEnqueuer().enqueueNotification(wrappedNotification); }