Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / RoleService.java
index 164e6ce153cdd15dcaf813144c310387b1a75097..6cbae9a91bdbbb534f9194e2fcf5cc47be0543ea 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -12,15 +12,12 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
-import java.math.BigInteger;
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 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.openflowplugin.impl.util.ErrorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
@@ -33,6 +30,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetR
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,21 +48,21 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
     }
 
     @Override
-    protected OfHeader buildRequest(final Xid xid, final RoleRequestInputBuilder input) throws ServiceException {
+    protected OfHeader buildRequest(final Xid xid, final RoleRequestInputBuilder input) {
         input.setXid(xid.getValue());
         return input.build();
     }
 
-    public Future<BigInteger> getGenerationIdFromDevice(final Short version) {
+    public ListenableFuture<Uint64> getGenerationIdFromDevice(final Uint8 version) {
         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();
         roleRequestInputBuilder.setRole(toOFJavaRole(OfpRole.NOCHANGE));
         roleRequestInputBuilder.setVersion(version);
-        roleRequestInputBuilder.setGenerationId(BigInteger.ZERO);
+        roleRequestInputBuilder.setGenerationId(Uint64.ZERO);
 
-        final SettableFuture<BigInteger> finalFuture = SettableFuture.create();
+        final SettableFuture<Uint64> finalFuture = SettableFuture.create();
         final ListenableFuture<RpcResult<RoleRequestOutput>> genIdListenableFuture =
                 handleServiceCall(roleRequestInputBuilder);
         Futures.addCallback(genIdListenableFuture, new FutureCallback<RpcResult<RoleRequestOutput>>() {
@@ -81,8 +80,8 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
                     }
 
                 } else {
-                    LOG.error("getGenerationIdFromDevice RPC error "
-                            roleRequestOutputRpcResult.getErrors().iterator().next().getInfo());
+                    LOG.error("getGenerationIdFromDevice RPC error {}",
+                            roleRequestOutputRpcResult.getErrors().iterator().next().getInfo());
                     finalFuture.setException(new RoleChangeException(ErrorUtil
                             .errorsToString(roleRequestOutputRpcResult.getErrors())));
                 }
@@ -90,7 +89,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
 
             @Override
             public void onFailure(final Throwable throwable) {
-                LOG.info("onFailure - getGenerationIdFromDevice RPC error {}", throwable);
+                LOG.info("onFailure - getGenerationIdFromDevice RPC error", throwable);
                 finalFuture.setException(new ExecutionException(throwable));
             }
         }, MoreExecutors.directExecutor());
@@ -98,9 +97,8 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
     }
 
 
-    public Future<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole,
-                                                             final Short version,
-                                                             final BigInteger generationId) {
+    public ListenableFuture<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole, final Uint8 version,
+                                                                       final Uint64 generationId) {
         LOG.info("submitRoleChange called for device:{}, role:{}",
                 getDeviceInfo().getNodeId(), ofpRole);
         final RoleRequestInputBuilder roleRequestInputBuilder = new RoleRequestInputBuilder();
@@ -122,7 +120,7 @@ public class RoleService extends AbstractSimpleService<RoleRequestInputBuilder,
                 if (roleRequestOutput != null) {
                     final SetRoleOutputBuilder setRoleOutputBuilder = new SetRoleOutputBuilder();
                     setRoleOutputBuilder
-                            .setTransactionId(new TransactionId(BigInteger.valueOf(roleRequestOutput.getXid())));
+                            .setTransactionId(new TransactionId(Uint64.valueOf(roleRequestOutput.getXid())));
                     finalFuture.set(RpcResultBuilder.<SetRoleOutput>success()
                             .withResult(setRoleOutputBuilder.build()).build());