import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collection;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
try {
if (LOG.isDebugEnabled()) {
- LOG.debug("Starting clustering MASTER services for node {}", this.deviceContext.getDeviceInfo().getNodeId().getValue());
- LOG.debug("===============================================");
+ LOG.debug("========== Starting clustering MASTER services for node {} ==========", this.deviceContext.getDeviceInfo().getLOGValue());
}
if (connectionInterrupted()) {
private boolean connectionInterrupted() {
if (this.deviceContext.getPrimaryConnectionContext().getConnectionState().equals(ConnectionContext.CONNECTION_STATE.RIP)) {
- LOG.warn("Node {} was disconnected, will stop starting MASTER services.", this.deviceContext.getDeviceInfo().getNodeId().getValue());
+ LOG.warn("Node {} was disconnected, will stop starting MASTER services.", this.deviceContext.getDeviceInfo().getLOGValue());
return true;
}
return false;
@Override
public ListenableFuture<Void> closeServiceInstance() {
- roleContext.stopClusterServices();
- statContext.stopClusterServices();
- rpcContext.stopClusterServices();
- return deviceContext.stopClusterServices();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("========== Stopping clustering MASTER services for node {} ==========", this.deviceContext.getDeviceInfo().getLOGValue());
+ }
+
+ final boolean connectionInterrupted =
+ this.deviceContext
+ .getPrimaryConnectionContext()
+ .getConnectionState()
+ .equals(ConnectionContext.CONNECTION_STATE.RIP);
+
+ LOG.info("Stopping role context cluster services for node {}", getIdentifier());
+ roleContext.stopClusterServices(connectionInterrupted);
+
+ LOG.info("Stopping statistics context cluster services for node {}", getIdentifier());
+ statContext.stopClusterServices(connectionInterrupted);
+
+ LOG.info("Stopping rpc context cluster services for node {}", getIdentifier());
+ rpcContext.stopClusterServices(connectionInterrupted);
+
+ LOG.info("Stopping device context cluster services for node {}", getIdentifier());
+ return deviceContext.stopClusterServices(connectionInterrupted);
}
@Override
// to DeviceFlowRegistry, because of possible duplicates.
long flowCount = Optional.fromNullable(result).asSet().stream()
.flatMap(Collection::stream)
+ .filter(Objects::nonNull)
.flatMap(flowCapableNodeOptional -> flowCapableNodeOptional.asSet().stream())
+ .filter(Objects::nonNull)
+ .filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable()))
.flatMap(flowCapableNode -> flowCapableNode.getTable().stream())
+ .filter(Objects::nonNull)
+ .filter(table -> Objects.nonNull(table.getFlow()))
.flatMap(table -> table.getFlow().stream())
+ .filter(Objects::nonNull)
.count();
- LOG.debug("Finished filling flow registry with {} flows for node: {}", flowCount, getIdentifier());
+ LOG.debug("Finished filling flow registry with {} flows for node: {}", flowCount, deviceContext.getDeviceInfo().getLOGValue());
}
}
@Override
public void onFailure(Throwable t) {
if (deviceFlowRegistryFill.isCancelled()) {
- LOG.debug("Cancelled filling flow registry with flows for node: {}", getIdentifier());
+ LOG.debug("Cancelled filling flow registry with flows for node: {}", deviceContext.getDeviceInfo().getLOGValue());
} else {
- LOG.warn("Failed filling flow registry with flows for node: {} with exception: {}", getIdentifier(), t);
+ LOG.warn("Failed filling flow registry with flows for node: {} with exception: {}", deviceContext.getDeviceInfo().getLOGValue(), t);
}
}
});