Merge "Bug 8497 - Provide config knob to disable the Forwarding Rule Manager reconcil...
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / RoleService.java
index c677c53a68247079504cb9a8664125eb798020f6..446f8372a8da98e4e78bc9525b8de6430ec12870 100644 (file)
@@ -19,8 +19,8 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.role.RoleChangeException;
+import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;
@@ -42,19 +42,19 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
 
     private final DeviceContext deviceContext;
 
-    protected RoleService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<RoleRequestOutput> clazz) {
+    public RoleService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<RoleRequestOutput> clazz) {
         super(requestContextStack, deviceContext, clazz);
         this.deviceContext = deviceContext;
     }
 
     @Override
-    protected OfHeader buildRequest(final Xid xid, final RoleRequestInputBuilder input) {
+    protected OfHeader buildRequest(final Xid xid, final RoleRequestInputBuilder input) throws ServiceException {
         input.setXid(xid.getValue());
         return input.build();
     }
 
     public Future<BigInteger> getGenerationIdFromDevice(final Short version) {
-        LOG.info("getGenerationIdFromDevice called for device:{}", getNodeId().getValue());
+        LOG.info("getGenerationIdFromDevice called for device: {}", getDeviceInfo().getNodeId().getValue());
 
         // send a dummy no-change role request to get the generation-id of the switch
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
@@ -74,7 +74,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
                         finalFuture.set(roleRequestOutput.getGenerationId());
                     } else {
                         LOG.info("roleRequestOutput is null in getGenerationIdFromDevice");
-                        finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + getNodeId().getValue()));
+                        finalFuture.setException(new RoleChangeException("Exception in getting generationId for device:" + getDeviceInfo().getNodeId().getValue()));
                     }
 
                 } else {
@@ -97,7 +97,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
 
     public Future<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole, final Short version, final BigInteger generationId) {
         LOG.info("submitRoleChange called for device:{}, role:{}",
-                getNodeId(), ofpRole);
+                getDeviceInfo().getNodeId(), ofpRole);
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
         roleRequestInputBuilder.setRole(toOFJavaRole(ofpRole));
         roleRequestInputBuilder.setVersion(version);
@@ -110,7 +110,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
             @Override
             public void onSuccess(final RpcResult<RoleRequestOutput> roleRequestOutputRpcResult) {
                 LOG.info("submitRoleChange onSuccess for device:{}, role:{}",
-                        getNodeId(), ofpRole);
+                        getDeviceInfo().getNodeId(), ofpRole);
                 final RoleRequestOutput roleRequestOutput = roleRequestOutputRpcResult.getResult();
                 final Collection<RpcError> rpcErrors = roleRequestOutputRpcResult.getErrors();
                 if (roleRequestOutput != null) {
@@ -132,7 +132,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
             @Override
             public void onFailure(final Throwable throwable) {
                 LOG.error("submitRoleChange onFailure for device:{}, role:{}",
-                        getNodeId(), ofpRole, throwable);
+                        getDeviceInfo().getNodeId(), ofpRole, throwable);
                 finalFuture.setException(throwable);
             }
         });