import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.openflow.OFPContext;
private final List<DeviceRemovedHandler> deviceRemovedHandlers = new CopyOnWriteArrayList<>();
private final List<GuardedContext> contexts = new CopyOnWriteArrayList<>();
private final List<ConnectionContext> auxiliaryConnections = new CopyOnWriteArrayList<>();
- private final ExecutorService executorService;
+ private final Executor executor;
private final ContextChainMastershipWatcher contextChainMastershipWatcher;
private final DeviceInfo deviceInfo;
private final ConnectionContext primaryConnection;
new AtomicReference<>(ContextChainState.UNDEFINED);
private AutoCloseable registration;
- ContextChainImpl(@Nonnull final ContextChainMastershipWatcher contextChainMastershipWatcher,
- @Nonnull final ConnectionContext connectionContext,
- @Nonnull final ExecutorService executorService) {
+ ContextChainImpl(@NonNull final ContextChainMastershipWatcher contextChainMastershipWatcher,
+ @NonNull final ConnectionContext connectionContext,
+ @NonNull final Executor executor) {
this.contextChainMastershipWatcher = contextChainMastershipWatcher;
this.primaryConnection = connectionContext;
this.deviceInfo = connectionContext.getDeviceInfo();
- this.executorService = executorService;
+ this.executor = executor;
}
@Override
- public <T extends OFPContext> void addContext(@Nonnull final T context) {
+ public <T extends OFPContext> void addContext(@NonNull final T context) {
contexts.add(new GuardedContextImpl(context));
}
contexts.forEach(OFPContext::instantiateServiceInstance);
LOG.info("Started clustering services for node {}", deviceInfo);
} catch (final Exception ex) {
- LOG.warn("Not able to start clustering services for node {}", deviceInfo);
- executorService.execute(() -> contextChainMastershipWatcher
+ LOG.error("Not able to start clustering services for node {}", deviceInfo);
+ executor.execute(() -> contextChainMastershipWatcher
.onNotAbleToStartMastershipMandatory(deviceInfo, ex.toString()));
}
}
.map(OFPContext::closeServiceInstance)
.collect(Collectors.toList()));
- return Futures.transform(servicesToBeClosed, (input) -> {
+ return Futures.transform(servicesToBeClosed, input -> {
OF_EVENT_LOG.debug("Closing clustering Services, Node: {}", deviceInfo);
LOG.info("Closed clustering services for node {}", deviceInfo);
return null;
- }, executorService);
+ }, executor);
}
- @Nonnull
+ @NonNull
@Override
public ServiceGroupIdentifier getIdentifier() {
return deviceInfo.getServiceIdentifier();
}
@Override
- public boolean isMastered(@Nonnull final ContextChainMastershipState mastershipState,
+ public boolean isMastered(@NonNull final ContextChainMastershipState mastershipState,
final boolean inReconciliationFrameworkStep) {
switch (mastershipState) {
case INITIAL_SUBMIT:
}
@Override
- public boolean addAuxiliaryConnection(@Nonnull final ConnectionContext connectionContext) {
+ public boolean addAuxiliaryConnection(@NonNull final ConnectionContext connectionContext) {
return connectionContext.getFeatures().getAuxiliaryId().toJava() != 0
&& !ConnectionContext.CONNECTION_STATE.RIP.equals(primaryConnection.getConnectionState())
&& auxiliaryConnections.add(connectionContext);
}
@Override
- public boolean auxiliaryConnectionDropped(@Nonnull final ConnectionContext connectionContext) {
+ public boolean auxiliaryConnectionDropped(@NonNull final ConnectionContext connectionContext) {
return auxiliaryConnections.remove(connectionContext);
}
@Override
- public void registerDeviceRemovedHandler(@Nonnull final DeviceRemovedHandler deviceRemovedHandler) {
+ public void registerDeviceRemovedHandler(@NonNull final DeviceRemovedHandler deviceRemovedHandler) {
deviceRemovedHandlers.add(deviceRemovedHandler);
}