private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderImpl.class);
private static final MessageIntelligenceAgency messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
private static final int TICKS_PER_WHEEL = 500;
- private static final long TICK_DURATION = 10; // 0.5 sec.
+ // 0.5 sec.
+ private static final long TICK_DURATION = 10;
private final HashedWheelTimer hashedWheelTimer = new HashedWheelTimer(TICK_DURATION, TimeUnit.MILLISECONDS, TICKS_PER_WHEEL);
import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.util.Objects;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
}
@Override
- public <T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path) throws TransactionChainClosedException {
+ public <T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path) {
if (Objects.nonNull(transactionChainManager)) {
transactionChainManager.addDeleteOperationTotTxChain(store, path);
}
}
private void fillDeviceFlowRegistry() {
- // Fill device flow registry with flows from datastore
final ListenableFuture<List<Optional<FlowCapableNode>>> deviceFlowRegistryFill = deviceContext.getDeviceFlowRegistry().fill();
-
- // Start statistics scheduling only after we finished initializing device flow registry
- Futures.addCallback(deviceFlowRegistryFill, new FutureCallback<List<Optional<FlowCapableNode>>>() {
- @Override
- public void onSuccess(@Nullable List<Optional<FlowCapableNode>> result) {
- if (LOG.isDebugEnabled()) {
- // Count all flows we read from datastore for debugging purposes.
- // This number do not always represent how many flows were actually added
- // 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, deviceContext.getDeviceInfo().getLOGValue());
- }
- }
-
- @Override
- public void onFailure(Throwable t) {
- if (deviceFlowRegistryFill.isCancelled()) {
- if (LOG.isDebugEnabled()) {
- 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: {}", deviceContext.getDeviceInfo().getLOGValue(), t);
- }
- }
- });
+ Futures.addCallback(deviceFlowRegistryFill, new DeviceFlowRegistryCallback(deviceFlowRegistryFill));
}
@Override
fillDeviceFlowRegistry();
return true;
}
+
+ private class DeviceFlowRegistryCallback implements FutureCallback<List<Optional<FlowCapableNode>>> {
+ private final ListenableFuture<List<Optional<FlowCapableNode>>> deviceFlowRegistryFill;
+
+ public DeviceFlowRegistryCallback(ListenableFuture<List<Optional<FlowCapableNode>>> deviceFlowRegistryFill) {
+ this.deviceFlowRegistryFill = deviceFlowRegistryFill;
+ }
+
+ @Override
+ public void onSuccess(@Nullable List<Optional<FlowCapableNode>> result) {
+ if (LOG.isDebugEnabled()) {
+ // Count all flows we read from datastore for debugging purposes.
+ // This number do not always represent how many flows were actually added
+ // 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, deviceContext.getDeviceInfo().getLOGValue());
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ if (deviceFlowRegistryFill.isCancelled()) {
+ if (LOG.isDebugEnabled()) {
+ 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: {}", deviceContext.getDeviceInfo().getLOGValue(), t);
+ }
+ }
+ }
}
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
// FIXME : remove after ovs tableFeatures fix
private static void makeEmptyTables(final DeviceContext dContext, final InstanceIdentifier<Node> nodeII,
final Short nrOfTables) {
- LOG.debug("About to create {} empty tables.", nrOfTables);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("About to create {} empty tables.", nrOfTables);
+ }
for (int i = 0; i < nrOfTables; i++) {
final short tId = (short) i;
final InstanceIdentifier<Table> tableII = nodeII.augmentation(FlowCapableNode.class).child(Table.class,
} else {
for (RpcError rpcError : rpcResult.getErrors()) {
LOG.info("Failed to retrieve static node {} info: {}", type, rpcError.getMessage());
- if (null != rpcError.getCause()) {
+ if (LOG.isTraceEnabled() && Objects.nonNull(rpcError.getCause())) {
LOG.trace("Detailed error:", rpcError.getCause());
}
}
}
private static ListenableFuture<RpcResult<List<MultipartReply>>> getNodeStaticInfo(final MultipartType type,
- final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeII, final short version) {
+ final DeviceContext deviceContext,
+ final InstanceIdentifier<Node> nodeII,
+ final short version) {
final OutboundQueue queue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
try {
- LOG.trace("Waiting for protocol version 1.0");
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Waiting for protocol version 1.0");
+ }
List<RpcResult<List<MultipartReply>>> results = deviceFeaturesFuture.get();
boolean allSucceeded = true;
for (final RpcResult<List<MultipartReply>> rpcResult : results) {
allSucceeded &= rpcResult.isSuccessful();
}
if (allSucceeded) {
- LOG.debug("Creating emtpy flow capable node: {}", deviceContext.getDeviceInfo().getNodeId().getValue());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Creating empty flow capable node: {}", deviceContext.getDeviceInfo().getLOGValue());
+ }
createEmptyFlowCapableNodeInDs(deviceContext);
- LOG.debug("Creating emtpy tables for {}", deviceContext.getDeviceInfo().getNodeId().getValue());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Creating empty tables for {}", deviceContext.getDeviceInfo().getLOGValue());
+ }
makeEmptyTables(deviceContext, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
}
} catch (InterruptedException | ExecutionException e) {
- LOG.warn("Error occurred in preparation node {} for protocol 1.0", deviceContext.getDeviceInfo().getNodeId().getValue());
+ LOG.warn("Error occurred in preparation node {} for protocol 1.0", deviceContext.getDeviceInfo().getLOGValue());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Error for node {} : ", deviceContext.getDeviceInfo().getLOGValue(), e);
+ }
}
}
}