}
@Override
- public void onDeviceContextLevelUp(final DeviceContext deviceContext) {
- NodeId nodeId = deviceContext.getDeviceState().getNodeId();
- OfpRole ofpRole = deviceContext.getDeviceState().getRole();
+ public void onDeviceContextLevelUp(final DeviceContext deviceContext) throws Exception {
+ final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+ final OfpRole ofpRole = deviceContext.getDeviceState().getRole();
LOG.debug("Node:{}, deviceContext.getDeviceState().getRole():{}", nodeId, ofpRole);
contexts.put(deviceContext, rpcContext);
}
+ deviceContext.addDeviceContextClosedHandler(this);
- if (ofpRole == OfpRole.BECOMESLAVE) {
- // if slave, we need to de-register rpcs if any have been registered, in case of master to slave
- LOG.info("Unregistering RPC registration (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
- try {
- MdSalRegistratorUtils.unregisterServices(rpcContext);
- } catch (Exception e) {
- LOG.error("Exception while unregistering rpcs for slave role for node:{}. But continuing.", nodeId, e);
- }
-
- } else {
+ if (OfpRole.BECOMEMASTER.equals(ofpRole)) {
LOG.info("Registering Openflow RPCs for node:{}, role:{}", nodeId, ofpRole);
- MdSalRegistratorUtils.registerServices(rpcContext, deviceContext, ofpRole);
+ MdSalRegistratorUtils.registerMasterServices(rpcContext, deviceContext, ofpRole);
if (isStatisticsRpcEnabled) {
MdSalRegistratorUtils.registerStatCompatibilityServices(rpcContext, deviceContext,
notificationPublishService, new AtomicLong());
}
+ } else if(OfpRole.BECOMESLAVE.equals(ofpRole)) {
+ // if slave, we need to de-register rpcs if any have been registered, in case of master to slave
+ LOG.info("Unregistering RPC registration (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
+ MdSalRegistratorUtils.registerSlaveServices(rpcContext, ofpRole);
+ } else {
+ // if we don't know role, we need to unregister rpcs if any have been registered
+ LOG.info("Unregistering RPC registration (if any) for slave role for node:{}", deviceContext.getDeviceState().getNodeId());
+ MdSalRegistratorUtils.unregisterServices(rpcContext);
}
- deviceContext.addDeviceContextClosedHandler(this);
-
// finish device initialization cycle back to DeviceManager
deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);
}
@Override
- public void onDeviceContextClosed(DeviceContext deviceContext) {
- RpcContext removedContext = contexts.remove(deviceContext);
+ public void onDeviceContextClosed(final DeviceContext deviceContext) {
+ final RpcContext removedContext = contexts.remove(deviceContext);
if (removedContext != null) {
try {
LOG.info("Unregistering rpcs for device context closure");
removedContext.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
LOG.error("Exception while unregistering rpcs onDeviceContextClosed handler for node:{}. But continuing.",
deviceContext.getDeviceState().getNodeId(), e);
}
}
}
- public void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled) {
+ @Override
+ public void setStatisticsRpcEnabled(final boolean isStatisticsRpcEnabled) {
this.isStatisticsRpcEnabled = isStatisticsRpcEnabled;
}
@Override
- public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
+ public void setNotificationPublishService(final NotificationPublishService notificationPublishService) {
this.notificationPublishService = notificationPublishService;
}
}