private final DeviceState devState;
private final ListenableFuture<Boolean> emptyFuture;
private final boolean shuttingDownStatisticsPolling;
- private final Object COLLECTION_STAT_TYPE_LOCK = new Object();
private final SinglePurposeMultipartReplyTranslator multipartReplyTranslator;
- @GuardedBy("COLLECTION_STAT_TYPE_LOCK")
+ private final Object collectionStatTypeLock = new Object();
+ @GuardedBy("collectionStatTypeLock")
private List<MultipartType> collectingStatType;
private StatisticsGatheringService statisticsGatheringService;
@Override
public void statListForCollectingInitialization() {
- synchronized (COLLECTION_STAT_TYPE_LOCK) {
+ synchronized (collectionStatTypeLock) {
final List<MultipartType> statListForCollecting = new ArrayList<>();
if (devState.isTableStatisticsAvailable()) {
statListForCollecting.add(MultipartType.OFPMPTABLE);
if (errorResultFuture != null) {
return errorResultFuture;
}
- synchronized (COLLECTION_STAT_TYPE_LOCK) {
+ synchronized (collectionStatTypeLock) {
final Iterator<MultipartType> statIterator = collectingStatType.iterator();
final SettableFuture<Boolean> settableStatResultFuture = SettableFuture.create();
}
private ListenableFuture<Boolean> chooseStat(final MultipartType multipartType, final boolean initial){
+ ListenableFuture<Boolean> result = Futures.immediateCheckedFuture(Boolean.TRUE);
+
switch (multipartType) {
case OFPMPFLOW:
- return collectFlowStatistics(multipartType, initial);
+ result = collectFlowStatistics(multipartType, initial);
+ break;
case OFPMPTABLE:
- return collectTableStatistics(multipartType);
+ result = collectTableStatistics(multipartType);
+ break;
case OFPMPPORTSTATS:
- return collectPortStatistics(multipartType);
+ result = collectPortStatistics(multipartType);
+ break;
case OFPMPQUEUE:
- return collectQueueStatistics(multipartType);
+ result = collectQueueStatistics(multipartType);
+ break;
case OFPMPGROUPDESC:
- return collectGroupDescStatistics(multipartType);
+ result = collectGroupDescStatistics(multipartType);
+ break;
case OFPMPGROUP:
- return collectGroupStatistics(multipartType);
+ result = collectGroupStatistics(multipartType);
+ break;
case OFPMPMETERCONFIG:
- return collectMeterConfigStatistics(multipartType);
+ result = collectMeterConfigStatistics(multipartType);
+ break;
case OFPMPMETER:
- return collectMeterStatistics(multipartType);
+ result = collectMeterStatistics(multipartType);
+ break;
default:
- LOG.warn("Unsuported Statistics type {}", multipartType);
- return Futures.immediateCheckedFuture(Boolean.TRUE);
+ LOG.warn("Unsupported Statistics type {}", multipartType);
}
+
+ return result;
}
@Override
public void onFailure(@Nonnull final Throwable throwable) {
timeCounter.addTimeMark();
- LOG.warn("Statistics gathering for single node was not successful: {}", throwable.getMessage());
- LOG.trace("Statistics gathering for single node was not successful.. ", throwable);
+ LOG.warn("Statistics gathering for single node was not successful: {}", throwable);
calculateTimerDelay(timeCounter);
if (throwable instanceof CancellationException) {
/* This often happens when something wrong with akka or DS, so closing connection will help to restart device **/
});
final long averageTime = TimeUnit.MILLISECONDS.toSeconds(timeCounter.getAverageTimeBetweenMarks());
- final long STATS_TIMEOUT_SEC = averageTime > 0 ? 3 * averageTime : DEFAULT_STATS_TIMEOUT_SEC;
+ final long statsTimeoutSec = averageTime > 0 ? 3 * averageTime : DEFAULT_STATS_TIMEOUT_SEC;
final TimerTask timerTask = timeout -> {
if (!deviceStatisticsCollectionFuture.isDone()) {
- LOG.info("Statistics collection for node {} still in progress even after {} secs", deviceInfo.getLOGValue(), STATS_TIMEOUT_SEC);
+ LOG.info("Statistics collection for node {} still in progress even after {} secs", deviceInfo.getLOGValue(), statsTimeoutSec);
deviceStatisticsCollectionFuture.cancel(true);
}
};
- hashedWheelTimer.newTimeout(timerTask, STATS_TIMEOUT_SEC, TimeUnit.SECONDS);
+ hashedWheelTimer.newTimeout(timerTask, statsTimeoutSec, TimeUnit.SECONDS);
}
private void scheduleNextPolling(final DeviceState deviceState,