use of org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo in project openflowplugin by opendaylight.
the class RoleContextImpl method sendRoleChangeToDevice.
private ListenableFuture<RpcResult<SetRoleOutput>> sendRoleChangeToDevice(final OfpRole newRole) {
final Boolean isEqualRole = config.isEnableEqualRole();
if (isEqualRole) {
LOG.warn("Skip sending role change request to device {} as user enabled" + " equal role for controller", deviceInfo);
return Futures.immediateFuture(null);
}
LOG.debug("Sending new role {} to device {}", newRole, deviceInfo);
if (deviceInfo.getVersion() >= OFConstants.OFP_VERSION_1_3) {
final SetRoleInput setRoleInput = new SetRoleInputBuilder().setControllerRole(newRole).setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier())).build();
final Future<RpcResult<SetRoleOutput>> setRoleOutputFuture = roleService.setRole(setRoleInput);
final TimerTask timerTask = timeout -> {
if (!setRoleOutputFuture.isDone()) {
LOG.warn("New role {} was not propagated to device {} during {} sec", newRole, deviceInfo, SET_ROLE_TIMEOUT);
setRoleOutputFuture.cancel(true);
}
};
timer.newTimeout(timerTask, SET_ROLE_TIMEOUT, TimeUnit.MILLISECONDS);
return JdkFutureAdapters.listenInPoolThread(setRoleOutputFuture);
}
LOG.info("Device: {} with version: {} does not support role {}", deviceInfo, deviceInfo.getVersion(), newRole);
return Futures.immediateFuture(null);
}
use of org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo in project openflowplugin by opendaylight.
the class DeviceManagerImplTest method close.
@Test
public void close() throws Exception {
final DeviceContext deviceContext = mock(DeviceContext.class);
final ConcurrentHashMap<DeviceInfo, DeviceContext> deviceContexts = getContextsCollection(deviceManager);
deviceContexts.put(deviceInfo, deviceContext);
Assert.assertEquals(1, deviceContexts.size());
deviceManager.close();
verify(deviceContext).close();
}
Aggregations