-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-import java.math.BigInteger;
-import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext.CONNECTION_STATE;
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.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RoleService;
-import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleOutput;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
implements SalRoleService {
private static final Logger LOG = LoggerFactory.getLogger(SalRoleServiceImpl.class);
- private static final BigInteger MAX_GENERATION_ID = new BigInteger("ffffffffffffffff", 16);
+ private static final Uint64 MAX_GENERATION_ID = Uint64.valueOf("ffffffffffffffff", 16);
private final DeviceContext deviceContext;
private final RoleService roleService;
}
@Override
- protected OfHeader buildRequest(final Xid xid, final SetRoleInput input) throws ServiceException {
+ protected OfHeader buildRequest(final Xid xid, final SetRoleInput input) {
return null;
}
@Override
- public Future<RpcResult<SetRoleOutput>> setRole(final SetRoleInput input) {
+ public ListenableFuture<RpcResult<SetRoleOutput>> setRole(final SetRoleInput input) {
LOG.info("SetRole called with input:{}", input);
// Check current connection state
private ListenableFuture<RpcResult<SetRoleOutput>> tryToChangeRole(final OfpRole role) {
LOG.info("RoleChangeTask called on device:{} OFPRole:{}", getDeviceInfo().getNodeId().getValue(), role);
- final Future<BigInteger> generationFuture = roleService.getGenerationIdFromDevice(getVersion());
-
- return Futures.transformAsync(JdkFutureAdapters.listenInPoolThread(generationFuture), generationId -> {
+ return Futures.transformAsync(roleService.getGenerationIdFromDevice(getVersion()), generationId -> {
LOG.debug("RoleChangeTask, GenerationIdFromDevice from device {} is {}",
getDeviceInfo().getNodeId().getValue(), generationId);
- final BigInteger nextGenerationId = getNextGenerationId(generationId);
+ final Uint64 nextGenerationId = getNextGenerationId(generationId);
LOG.debug("nextGenerationId received from device:{} is {}",
getDeviceInfo().getNodeId().getValue(), nextGenerationId);
- final Future<RpcResult<SetRoleOutput>> submitRoleFuture =
- roleService.submitRoleChange(role, getVersion(), nextGenerationId);
- return JdkFutureAdapters.listenInPoolThread(submitRoleFuture);
+ return roleService.submitRoleChange(role, getVersion(), nextGenerationId);
}, MoreExecutors.directExecutor());
}
- private static BigInteger getNextGenerationId(final BigInteger generationId) {
+ private static Uint64 getNextGenerationId(final Uint64 generationId) {
if (generationId.compareTo(MAX_GENERATION_ID) < 0) {
- return generationId.add(BigInteger.ONE);
+ return Uint64.valueOf(generationId.longValue() + 1);
} else {
- return BigInteger.ZERO;
+ return Uint64.ZERO;
}
}
-}
\ No newline at end of file
+}