* @param isStatisticsRpcEnabled
*/
void setIsStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
+
+ void setBarrierCountLimit(int barrierCountLimit);
+
+ void setBarrierInterval(long barrierTimeoutLimit);
+
+ void setEchoReplyTimeout(long echoReplyTimeout);
}
<switch-features-mandatory>false</switch-features-mandatory>
<global-notification-quota>64000</global-notification-quota>
<is-statistics-polling-off>false</is-statistics-polling-off>
+ <barrier-interval-timeout-limit>500</barrier-interval-timeout-limit>
+ <barrier-count-limit>25600</barrier-count-limit>
+ <echo-reply-timeout>2000</echo-reply-timeout>
</module>
</modules>
private final int rpcRequestsQuota;
private final long globalNotificationQuota;
+ private long barrierInterval;
+ private int barrierCountLimit;
+ private long echoReplyTimeout;
private DeviceManager deviceManager;
private RoleManager roleManager;
private RpcManager rpcManager;
this.entityOwnershipService = entityOwnershipService;
}
+ @Override
+ public void setBarrierCountLimit(int barrierCountLimit) {
+ this.barrierCountLimit = barrierCountLimit;
+ }
+
+ @Override
+ public void setBarrierInterval(long barrierTimeoutLimit) {
+ this.barrierInterval = barrierTimeoutLimit;
+ }
+
+ @Override
+ public void setEchoReplyTimeout(long echoReplyTimeout) {
+ this.echoReplyTimeout = echoReplyTimeout;
+ }
+
+
@Override
public void setSwitchFeaturesMandatory(final boolean switchFeaturesMandatory) {
this.switchFeaturesMandatory = switchFeaturesMandatory;
// TODO: rewrite later!
OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterManager);
- connectionManager = new ConnectionManagerImpl();
+ connectionManager = new ConnectionManagerImpl(echoReplyTimeout);
registerMXBean(messageIntelligenceAgency);
- deviceManager = new DeviceManagerImpl(dataBroker, messageIntelligenceAgency, globalNotificationQuota, switchFeaturesMandatory);
+ deviceManager = new DeviceManagerImpl(dataBroker, messageIntelligenceAgency, globalNotificationQuota,
+ switchFeaturesMandatory, barrierInterval, barrierCountLimit);
((ExtensionConverterProviderKeeper) deviceManager).setExtensionConverterProvider(extensionConverterManager);
roleManager = new RoleManagerImpl(entityOwnershipService, dataBroker, switchFeaturesMandatory);
statisticsManager = new StatisticsManagerImpl(rpcProviderRegistry, isStatisticsPollingOff);
private static final int HELLO_LIMIT = 20;
private final boolean bitmapNegotiationEnabled = true;
private DeviceConnectedHandler deviceConnectedHandler;
+ private final long echoReplyTimeout;
+
+ public ConnectionManagerImpl(long echoReplyTimeout) {
+ this.echoReplyTimeout = echoReplyTimeout;
+ }
+
@Override
public void onSwitchConnected(final ConnectionAdapter connectionAdapter) {
new OpenflowProtocolListenerInitialImpl(connectionContext, handshakeContext);
connectionAdapter.setMessageListener(ofMessageListener);
- final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext);
+ final SystemNotificationsListener systemListener = new SystemNotificationsListenerImpl(connectionContext, echoReplyTimeout);
connectionAdapter.setSystemListener(systemListener);
LOG.trace("connection ballet finished");
private static final Logger LOG = LoggerFactory.getLogger(SystemNotificationsListenerImpl.class);
@VisibleForTesting
static final long MAX_ECHO_REPLY_TIMEOUT = 2000;
+ private final long echoReplyTimeout;
- public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext) {
+ public SystemNotificationsListenerImpl(@Nonnull final ConnectionContext connectionContext, long echoReplyTimeout) {
this.connectionContext = Preconditions.checkNotNull(connectionContext);
+ this.echoReplyTimeout = echoReplyTimeout;
}
@Override
if (ConnectionContext.CONNECTION_STATE.WORKING.equals(connectionContext.getConnectionState())) {
FeaturesReply features = connectionContext.getFeatures();
- LOG.debug(
- "first idle state occured, node={}|auxId={}",
- remoteAddress, features.getAuxiliaryId());
+ LOG.debug("Switch Idle state occured, node={}|auxId={}", remoteAddress, features.getAuxiliaryId());
connectionContext.changeStateToTimeouting();
EchoInputBuilder builder = new EchoInputBuilder();
builder.setVersion(features.getVersion());
Xid xid = new Xid(0L);
builder.setXid(xid.getValue());
- Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter()
- .echo(builder.build());
+ Future<RpcResult<EchoOutput>> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build());
try {
- RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(MAX_ECHO_REPLY_TIMEOUT, TimeUnit.MILLISECONDS);
+ RpcResult<EchoOutput> echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS);
if (echoReplyValue.isSuccessful()) {
connectionContext.changeStateToWorking();
shouldBeDisconnected = false;
} else {
- for (RpcError replyError : echoReplyValue
- .getErrors()) {
+ for (RpcError replyError : echoReplyValue.getErrors()) {
Throwable cause = replyError.getCause();
- LOG.warn("while receiving echoReply [{}] in TIMEOUTING state {} ",
- remoteAddress,
- cause.getMessage());
- LOG.trace("while receiving echoReply [{}] in TIMEOUTING state ..", remoteAddress, cause);
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause.getMessage());
+ }
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Received EchoReply from [{}] in TIMEOUTING state, Error:{}", remoteAddress, cause);
+ }
+
}
}
} catch (Exception e) {
- LOG.warn("while waiting for echoReply in TIMEOUTING state: {}", e.getMessage());
- LOG.trace("while waiting for echoReply in TIMEOUTING state ..", remoteAddress, e);
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("Exception while waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e.getMessage());
+ }
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Exception while waiting for echoReply from [{}] in TIMEOUTING state: {}", remoteAddress, e);
+ }
+
}
}
if (shouldBeDisconnected) {
private static final long TICK_DURATION = 10; // 0.5 sec.
private final long globalNotificationQuota;
private final boolean switchFeaturesMandatory;
+
private ScheduledThreadPoolExecutor spyPool;
private final int spyRate = 10;
private final ConcurrentMap<NodeId, DeviceContext> deviceContexts = new ConcurrentHashMap<>();
private final MessageIntelligenceAgency messageIntelligenceAgency;
- private final long barrierNanos = TimeUnit.MILLISECONDS.toNanos(500);
- private final int maxQueueDepth = 25600;
+ private final long barrierIntervalNanos;
+ private final int barrierCountLimit;
private ExtensionConverterProvider extensionConverterProvider;
public DeviceManagerImpl(@Nonnull final DataBroker dataBroker,
@Nonnull final MessageIntelligenceAgency messageIntelligenceAgency,
- final long globalNotificationQuota, final boolean switchFeaturesMandatory) {
+ final long globalNotificationQuota, final boolean switchFeaturesMandatory,
+ final long barrierInterval, final int barrierCountLimit) {
this.switchFeaturesMandatory = switchFeaturesMandatory;
this.globalNotificationQuota = globalNotificationQuota;
this.dataBroker = Preconditions.checkNotNull(dataBroker);
}
this.messageIntelligenceAgency = messageIntelligenceAgency;
+ this.barrierIntervalNanos = TimeUnit.MILLISECONDS.toNanos(barrierInterval);
+ this.barrierCountLimit = barrierCountLimit;
}
connectionContext.setOutboundQueueProvider(outboundQueueProvider);
final OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration =
- connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
+ connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, barrierCountLimit, barrierIntervalNanos);
connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration);
final DeviceState deviceState = createDeviceState(connectionContext);
private static final Logger LOG = LoggerFactory.getLogger(OpenFlowProviderModule.class);
- public OpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public OpenFlowProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public OpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.OpenFlowProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+ public OpenFlowProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.config.openflow.plugin.impl.rev150327.OpenFlowProviderModule oldModule, final java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
public java.lang.AutoCloseable createInstance() {
LOG.info("Initializing new OFP southbound.");
OpenflowPortsUtil.init();
- OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
+ final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
openflowPluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
openflowPluginProvider.setDataBroker(getDataBrokerDependency());
openflowPluginProvider.setIsStatisticsPollingOff(getIsStatisticsPollingOff());
openflowPluginProvider.setEntityOwnershipService(getEntityOwnershipServiceDependency());
openflowPluginProvider.setIsStatisticsRpcEnabled(getIsStatisticsRpcEnabled());
+ openflowPluginProvider.setBarrierCountLimit(getBarrierCountLimit().getValue());
+ openflowPluginProvider.setBarrierInterval(getBarrierIntervalTimeoutLimit().getValue());
+ openflowPluginProvider.setEchoReplyTimeout(getEchoReplyTimeout().getValue());
openflowPluginProvider.initialize();
+ LOG.info("Configured values, StatisticsPollingOff:{}, SwitchFeaturesMandatory:{}, BarrierCountLimit:{}, BarrierTimeoutLimit:{}, EchoReplyTimeout:{}",
+ getIsStatisticsPollingOff(), getSwitchFeaturesMandatory(), getBarrierCountLimit().getValue(),
+ getBarrierIntervalTimeoutLimit().getValue(), getEchoReplyTimeout().getValue());
+
+
return openflowPluginProvider;
}
"Second openflow plugin implementation.";
}
+ typedef non-zero-uint32-type {
+ type uint32 {
+ range "1..max";
+ }
+ }
+
+ typedef non-zero-uint16-type {
+ type uint16 {
+ range "1..max";
+ }
+ }
+
identity openflow-plugin-provider-impl {
base config:module-type;
config:provided-service openflow-provider:openflow-provider;
type boolean;
default "false";
}
+ leaf barrier-interval-timeout-limit {
+ type non-zero-uint32-type;
+ default 500;
+ }
+ leaf barrier-count-limit {
+ type non-zero-uint16-type;
+ default 25600;
+ }
+ leaf echo-reply-timeout {
+ type non-zero-uint32-type;
+ default 2000;
+ }
}
}
@Captor
private ArgumentCaptor<OpenflowProtocolListener> ofpListenerAC;
+ private final static int ECHO_REPLY_TIMEOUT = 500;
+
/**
* before each test method
*/
@Before
public void setUp() {
- connectionManagerImpl = new ConnectionManagerImpl();
+ connectionManagerImpl = new ConnectionManagerImpl(ECHO_REPLY_TIMEOUT);
connectionManagerImpl.setDeviceConnectedHandler(deviceConnectedHandler);
final InetSocketAddress deviceAddress = InetSocketAddress.createUnresolved("yahoo", 42);
Mockito.when(connection.getRemoteAddress()).thenReturn(deviceAddress);
public class SystemNotificationsListenerImplTest {
public static final int SAFE_TIMEOUT = 1000;
+ private final static int ECHO_REPLY_TIMEOUT = 2000;
@Mock
private org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter connectionAdapter;
@Mock
Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
Mockito.when(connectionContext.getFeatures()).thenReturn(features);
- systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext);
+ systemNotificationsListener = new SystemNotificationsListenerImpl(connectionContext, ECHO_REPLY_TIMEOUT);
}
@After
private static final Long DUMMY_MAX_METER = 544L;
private static final String DUMMY_DATAPATH_ID = "44";
private static final Long DUMMY_PORT_NUMBER = 21L;
+ private static final int barrierCountLimit = 25600;
+ private static final int barrierIntervalNanos = 500;
@Mock
CheckedFuture<Void, TransactionCommitFailedException> mockedFuture;
final MessageIntelligenceAgency mockedMessageIntelligenceAgency = mock(MessageIntelligenceAgency.class);
final DeviceManagerImpl deviceManager = new DeviceManagerImpl(mockedDataBroker, mockedMessageIntelligenceAgency,
- TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA, false);
+ TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA, false, barrierIntervalNanos, barrierCountLimit);
+
deviceManager.setDeviceInitializationPhaseHandler(deviceInitPhaseHandler);
return deviceManager;