* Created by Martin Bobak mbobak@cisco.com on 7/8/14.
*/
public class ConnectionException extends Exception {
+ private static final long serialVersionUID = 1L;
- public ConnectionException(String message){
+ public ConnectionException(final String message) {
super(message);
}
+ public ConnectionException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
}
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MessageHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.OutstandingMessageExtractor;
-import org.opendaylight.openflowplugin.api.openflow.device.listener.OpenflowMessageListenerFacade;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
* Created by Martin Bobak <mbobak@cisco.com> on 25.2.2015.
*/
public class RequestQuotaExceededException extends Exception {
+ private static final long serialVersionUID = 1L;
}
package org.opendaylight.openflowplugin.api.openflow.device.listener;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
/**
*/
package org.opendaylight.openflowplugin.api.openflow.rpc;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
import org.opendaylight.yangtools.yang.binding.RpcService;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 27.2.2015.
package org.opendaylight.openflowplugin.api.openflow.statistics;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializator;
private DataBroker dataBroker;
private OfpRole role;
private Collection<SwitchConnectionProvider> switchConnectionProviders;
- private Long rpcRequestsQuota;
+ private final Long rpcRequestsQuota;
public OpenFlowPluginProviderImpl(final Long rpcRequestsQuota) {
this.rpcRequestsQuota = rpcRequestsQuota;
TranslatorLibraryUtil.setBasicTranslatorLibrary(deviceManager);
deviceManager.initialize();
-
+
startSwitchConnections();
}
- private void registerMXBean(final MessageIntelligenceAgency messageIntelligenceAgency) {
+ private static void registerMXBean(final MessageIntelligenceAgency messageIntelligenceAgency) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
String pathToMxBean = String.format("%s:type=%s",
import java.util.concurrent.TimeUnit;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionManager;
import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
* @return
*/
private static ThreadPoolLoggingExecutor createHandshakePool(
- final String connectionIdentifier, int handshakeThreadLimit) {
+ final String connectionIdentifier, final int handshakeThreadLimit) {
return new ThreadPoolLoggingExecutor(handshakeThreadLimit,
handshakeThreadLimit, 0L, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(HELLO_LIMIT), "OFHandshake-" + connectionIdentifier);
* @return
*/
private HandshakeManager createHandshakeManager(final ConnectionAdapter connectionAdapter,
- HandshakeListener handshakeListener) {
+ final HandshakeListener handshakeListener) {
HandshakeManagerImpl handshakeManager = new HandshakeManagerImpl(connectionAdapter,
ConnectionConductor.versionOrder.get(0),
ConnectionConductor.versionOrder);
/**
* @param bitmapNegotiationEnabled the bitmapNegotiationEnabled to set
*/
- public void setBitmapNegotiationEnabled(boolean bitmapNegotiationEnabled) {
+ public void setBitmapNegotiationEnabled(final boolean bitmapNegotiationEnabled) {
this.bitmapNegotiationEnabled = bitmapNegotiationEnabled;
}
@Override
- public boolean accept(InetAddress switchAddress) {
+ public boolean accept(final InetAddress switchAddress) {
// TODO add connection accept logic based on address
return true;
}
@Override
- public void setDeviceConnectedHandler(DeviceConnectedHandler deviceConnectedHandler) {
+ public void setDeviceConnectedHandler(final DeviceConnectedHandler deviceConnectedHandler) {
this.deviceConnectedHandler = deviceConnectedHandler;
}
@Override
- public void setMessageHandler(MessageHandler arg0) {
+ public void setMessageHandler(final MessageHandler arg0) {
// TODO Auto-generated method stub
}
private final Map<Queue<T>, SettableFuture<Void>> throttledQueues = new ConcurrentHashMap<>();
private final ThreadPoolLoggingExecutor throttleWorkerPool;
private final NotificationPublishService notificationPublishService;
- private final MessageSpy<Class> messageIntelligenceAgency;
+ private final MessageSpy<Class<?>> messageIntelligenceAgency;
private boolean finishing = false;
private CountDownLatch sleeperLatch = new CountDownLatch(0);
* @param notificationPublishService
* @param messageIntelligenceAgency
*/
- public ThrottledNotificationsOffererImpl(NotificationPublishService notificationPublishService, MessageSpy<Class> messageIntelligenceAgency) {
+ public ThrottledNotificationsOffererImpl(final NotificationPublishService notificationPublishService, final MessageSpy<Class<?>> messageIntelligenceAgency) {
this.notificationPublishService = notificationPublishService;
this.messageIntelligenceAgency = messageIntelligenceAgency;
throttleWorkerPool = new ThreadPoolLoggingExecutor(
}
@Override
- public ListenableFuture<Void> applyThrottlingOnConnection(Queue<T> notificationsQueue) {
+ public ListenableFuture<Void> applyThrottlingOnConnection(final Queue<T> notificationsQueue) {
SettableFuture<Void> throttleWatching = SettableFuture.create();
throttledQueues.put(notificationsQueue, throttleWatching);
synchronized (throttledQueues) {
}
@Override
- public boolean isThrottlingEffective(Queue<T> notificationsQueue) {
+ public boolean isThrottlingEffective(final Queue<T> notificationsQueue) {
return throttledQueues.containsKey(notificationsQueue);
}
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
-import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
import org.opendaylight.openflowplugin.api.openflow.connection.ThrottledNotificationsOfferer;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
private final DeviceMeterRegistry deviceMeterRegistry;
private Timeout barrierTaskTimeout;
private NotificationService notificationService;
- private final MessageSpy<Class> messageSpy;
+ private final MessageSpy<Class<?>> messageSpy;
private DeviceDisconnectedHandler deviceDisconnectedHandler;
private final Collection<DeviceContextClosedHandler> closeHandlers = new HashSet<>();
private NotificationPublishService notificationPublishService;
private final ThrottledNotificationsOfferer throttledConnectionsHolder;
- private BlockingQueue<PacketReceived> bumperQueue;
+ private final BlockingQueue<PacketReceived> bumperQueue;
private final OutboundQueue outboundQueueProvider;
@Override
auxiliaryConnectionContexts.put(connectionDistinguisher, connectionContext);
}
- private SwitchConnectionDistinguisher createConnectionDistinguisher(final ConnectionContext connectionContext) {
+ private static SwitchConnectionDistinguisher createConnectionDistinguisher(final ConnectionContext connectionContext) {
return new SwitchConnectionCookieOFImpl(connectionContext.getFeatures().getAuxiliaryId());
}
});
}
- private void chainTableTrunkWriteOF10(final DeviceContext deviceContext, final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
+ private static void chainTableTrunkWriteOF10(final DeviceContext deviceContext, final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture) {
Futures.addCallback(deviceFeaturesFuture, new FutureCallback<List<RpcResult<List<MultipartReply>>>>() {
@Override
public void onSuccess(final List<RpcResult<List<MultipartReply>>> results) {
});
}
-
private ListenableFuture<RpcResult<List<MultipartReply>>> processReplyDesc(final DeviceContext deviceContext,
final DeviceState deviceState) {
}
}
- void submitScheduledTransaction(Timeout timeout) {
+ void submitScheduledTransaction(final Timeout timeout) {
if (timeout.isCancelled()) {
// zombie timer executed
return;
}
}
- private void hookTimeExpenseCounter(CheckedFuture<Void, TransactionCommitFailedException> submitResult, final String name) {
+ private static void hookTimeExpenseCounter(final CheckedFuture<Void, TransactionCommitFailedException> submitResult, final String name) {
final long submitFiredTime = System.currentTimeMillis();
LOG.debug("submit of {} fired", name);
Futures.addCallback(submitResult, new FutureCallback<Void>() {
@Override
- public void onSuccess(Void result) {
+ public void onSuccess(final Void result) {
LOG.debug("submit of {} finished in {} ms", name, System.currentTimeMillis() - submitFiredTime);
}
@Override
- public void onFailure(Throwable t) {
+ public void onFailure(final Throwable t) {
LOG.warn("transaction submit failed: {}", t.getMessage());
}
});
cache = initCacheBuilder(timeout).build();
}
- private RemovalListener<Long, MultiCollectorObject> getRemovalListener() {
+ private static RemovalListener<Long, MultiCollectorObject> getRemovalListener() {
return new RemovalListener<Long, MultiCollectorObject>() {
@Override
public void onRemoval(final RemovalNotification<Long, MultiCollectorObject> notification) {
};
}
- private CacheBuilder<Long, MultiCollectorObject> initCacheBuilder(final int timeout) {
+ private static CacheBuilder<Long, MultiCollectorObject> initCacheBuilder(final int timeout) {
return CacheBuilder.newBuilder()
.expireAfterAccess(timeout, TimeUnit.SECONDS)
.removalListener(getRemovalListener())
}
@Override
- public void setDeviceReplyProcessor(DeviceReplyProcessor deviceReplyProcessor) {
+ public void setDeviceReplyProcessor(final DeviceReplyProcessor deviceReplyProcessor) {
this.deviceReplyProcessor = deviceReplyProcessor;
}
replyCollection.add(reply);
}
- void publishCollection(long xid) {
+ void publishCollection(final long xid) {
deviceReplyProcessor.processReply(new Xid(xid), replyCollection);
}
*/
public class DeviceGroupRegistryImpl implements DeviceGroupRegistry {
- private final List<GroupId> groupIdList = new ArrayList();
- private final List<GroupId> marks = new ArrayList();
+ private final List<GroupId> groupIdList = new ArrayList<>();
+ private final List<GroupId> marks = new ArrayList<>();
@Override
public void store(final GroupId groupId) {
*/
public class DeviceMeterRegistryImpl implements DeviceMeterRegistry {
- private final List<MeterId> meterIds = new ArrayList();
- private final List<MeterId> marks = new ArrayList();
+ private final List<MeterId> meterIds = new ArrayList<>();
+ private final List<MeterId> marks = new ArrayList<>();
@Override
public void store(final MeterId meterId) {
private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
- public List<DataObject> translate(DeviceContext deviceContext, OfHeader msg) {
+ public List<DataObject> translate(final DeviceContext deviceContext, final OfHeader msg) {
List<DataObject> listDataObject = new CopyOnWriteArrayList<DataObject>();
final FeaturesReply features = deviceContext.getPrimaryConnectionContext().getFeatures();
if (msg instanceof MultipartReplyMessage) {
MultipartReplyMessage mpReply = (MultipartReplyMessage) msg;
- NodeId node = this.nodeIdFromDatapathId(features.getDatapathId());
+ NodeId node = SinglePurposeMultipartReplyTranslator.nodeIdFromDatapathId(features.getDatapathId());
switch (mpReply.getType()) {
case OFPMPFLOW: {
FlowsStatisticsUpdateBuilder message = new FlowsStatisticsUpdateBuilder();
statsBuilder.setPackets(packetsBuilder.build());
DurationBuilder durationBuilder = new DurationBuilder();
- if (portStats.getDurationSec() != null)
+ if (portStats.getDurationSec() != null) {
durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
- if (portStats.getDurationNsec() != null)
+ }
+ if (portStats.getDurationNsec() != null) {
durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
+ }
statsBuilder.setDuration(durationBuilder.build());
statsBuilder.setCollisionCount(portStats.getCollisions());
statsBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(statsBuilder.getNodeConnectorId()));
return listDataObject;
}
- private NodeId nodeIdFromDatapathId(BigInteger datapathId) {
+ private static NodeId nodeIdFromDatapathId(final BigInteger datapathId) {
String current = datapathId.toString();
return new NodeId("openflow:" + current);
}
- private TransactionId generateTransactionId(Long xid) {
+ private static TransactionId generateTransactionId(final Long xid) {
BigInteger bigIntXid = BigInteger.valueOf(xid);
return new TransactionId(bigIntXid);
-
}
/*
* @param actionsSupported
* @return
*/
- private List<Long> getGroupActionsSupportBitmap(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType> actionsSupported) {
+ private static List<Long> getGroupActionsSupportBitmap(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType> actionsSupported) {
List<Long> supportActionByGroups = new ArrayList<Long>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
long supportActionBitmap = 0;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
private static final Logger LOG = LoggerFactory.getLogger(StatisticsContextImpl.class);
public static final String CONNECTION_CLOSED = "Connection closed.";
- private final Collection<RequestContext> requestContexts = new HashSet<>();
+ private final Collection<RequestContext<?>> requestContexts = new HashSet<>();
private final DeviceContext deviceContext;
@Override
public ListenableFuture<Boolean> gatherDynamicData() {
- final SettableFuture settableResultingFuture = SettableFuture.create();
+ final SettableFuture<Boolean> settableResultingFuture = SettableFuture.create();
ListenableFuture<Boolean> resultingFuture = settableResultingFuture;
package org.opendaylight.openflowplugin.impl.statistics;
-import java.util.concurrent.ExecutionException;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
import com.google.common.collect.Iterables;
-import java.util.Collections;
-import com.google.common.base.Function;
+import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collections;
import java.util.List;
+import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
import org.opendaylight.openflowplugin.impl.registry.flow.FlowHashFactory;
import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
for (MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
final MeterId meterId = meterConfigStats.getMeterId();
final InstanceIdentifier<Meter> meterInstanceIdentifier = fNodeIdent.child(Meter.class, new MeterKey(meterId));
-
+
final MeterBuilder meterBuilder = new MeterBuilder(meterConfigStats);
meterBuilder.setKey(new MeterKey(meterId));
meterBuilder.addAugmentation(NodeMeterStatistics.class, new NodeMeterStatisticsBuilder().build());
final FlowBuilder flowBuilder = new FlowBuilder(flowStat);
short tableId = flowStat.getTableId();
final Short version = deviceContext.getPrimaryConnectionContext().getFeatures().getVersion();
-
+
final FlowHash flowHash = FlowHashFactory.create(flowBuilder.build(), version);
final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowHash, tableId);
private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceContext deviceContext) {
for(final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(flowTableStatisticsUpdate.getId());
-
+
for (final FlowTableAndStatisticsMap tableStat : flowTableStatisticsUpdate.getFlowTableAndStatisticsMap()) {
final InstanceIdentifier<FlowTableStatistics> tStatIdent = fNodeIdent.child(Table.class, new TableKey(tableStat.getTableId().getValue()))
.augmentation(FlowTableStatisticsData.class).child(FlowTableStatistics.class);
for ( GroupDescStatsUpdated groupDescStatsUpdated : data) {
NodeId nodeId = groupDescStatsUpdated.getId();
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
-
+
for (GroupDescStats groupDescStats : groupDescStatsUpdated.getGroupDescStats()) {
final GroupId groupId = groupDescStats.getGroupId();
-
+
final GroupBuilder groupBuilder = new GroupBuilder(groupDescStats);
groupBuilder.setKey(new GroupKey(groupId));
groupBuilder.addAugmentation(NodeGroupStatistics.class, new NodeGroupStatisticsBuilder().build());
-
+
final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupId));
-
+
deviceContext.getDeviceGroupRegistry().store(groupId);
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, groupIdent, groupBuilder.build());
}
deleteAllKnownGroups(deviceContext, fNodeIdent);
for (GroupStatisticsUpdated groupStatistics : data) {
for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
-
+
final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupStats.getGroupId()));
final InstanceIdentifier<NodeGroupStatistics> nGroupStatIdent = groupIdent
.augmentation(NodeGroupStatistics.class);
-
+
final InstanceIdentifier<GroupStatistics> gsIdent = nGroupStatIdent.child(GroupStatistics.class);
final GroupStatistics stats = new GroupStatisticsBuilder(groupStats).build();
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gsIdent, stats);
private HashedWheelTimer hashedWheelTimer;
- private ConcurrentHashMap<DeviceContext, StatisticsContext> contexts = new ConcurrentHashMap();
+ private final ConcurrentHashMap<DeviceContext, StatisticsContext> contexts = new ConcurrentHashMap<>();
private final TimeCounter timeCounter = new TimeCounter();
try {
timeCounter.markStart();
for (final StatisticsContext statisticsContext : contexts.values()) {
- ListenableFuture deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
- Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback() {
+ ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
+ Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
@Override
- public void onSuccess(final Object o) {
+ public void onSuccess(final Boolean o) {
timeCounter.addTimeMark();
}
* Class counts message of {@link org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy.STATISTIC_GROUP} type
* and provides info as debug log.
*/
-public class MessageIntelligenceAgencyImpl implements MessageIntelligenceAgency<Class>, MessageIntelligenceAgencyMXBean {
+public class MessageIntelligenceAgencyImpl implements MessageIntelligenceAgency<Class<?>>, MessageIntelligenceAgencyMXBean {
private static final Logger LOG = LoggerFactory.getLogger(MessageIntelligenceAgencyImpl.class);
}
}
- private final ConcurrentMap<STATISTIC_GROUP, ConcurrentMap<Class, MessageCounters>> inputStats = new ConcurrentHashMap<>();
+ private final ConcurrentMap<STATISTIC_GROUP, ConcurrentMap<Class<?>, MessageCounters>> inputStats = new ConcurrentHashMap<>();
@Override
- public void spyMessage(final Class message, final STATISTIC_GROUP statGroup) {
+ public void spyMessage(final Class<?> message, final STATISTIC_GROUP statGroup) {
getCounters(message, statGroup).increment();
}
* @param statGroup TODO
* @return
*/
- private MessageCounters getCounters(final Class message, final STATISTIC_GROUP statGroup) {
- ConcurrentMap<Class, MessageCounters> groupData = getOrCreateGroupData(statGroup);
+ private MessageCounters getCounters(final Class<?> message, final STATISTIC_GROUP statGroup) {
+ ConcurrentMap<Class<?>, MessageCounters> groupData = getOrCreateGroupData(statGroup);
MessageCounters counters = getOrCreateCountersPair(message, groupData);
return counters;
}
- private static MessageCounters getOrCreateCountersPair(final Class msgType, final ConcurrentMap<Class, MessageCounters> groupData) {
+ private static MessageCounters getOrCreateCountersPair(final Class<?> msgType, final ConcurrentMap<Class<?>, MessageCounters> groupData) {
final MessageCounters lookup = groupData.get(msgType);
if (lookup != null) {
return lookup;
}
- private ConcurrentMap<Class, MessageCounters> getOrCreateGroupData(final STATISTIC_GROUP statGroup) {
- final ConcurrentMap<Class, MessageCounters> lookup = inputStats.get(statGroup);
+ private ConcurrentMap<Class<?>, MessageCounters> getOrCreateGroupData(final STATISTIC_GROUP statGroup) {
+ final ConcurrentMap<Class<?>, MessageCounters> lookup = inputStats.get(statGroup);
if (lookup != null) {
return lookup;
}
- final ConcurrentMap<Class, MessageCounters> newmap = new ConcurrentHashMap<>();
- final ConcurrentMap<Class, MessageCounters> check = inputStats.putIfAbsent(statGroup, newmap);
+ final ConcurrentMap<Class<?>, MessageCounters> newmap = new ConcurrentHashMap<>();
+ final ConcurrentMap<Class<?>, MessageCounters> check = inputStats.putIfAbsent(statGroup, newmap);
return check == null ? newmap : check;
}
List<String> dump = new ArrayList<>();
for (STATISTIC_GROUP statGroup : STATISTIC_GROUP.values()) {
- Map<Class, MessageCounters> groupData = inputStats.get(statGroup);
+ Map<Class<?>, MessageCounters> groupData = inputStats.get(statGroup);
if (groupData != null) {
- for (Entry<Class, MessageCounters> statEntry : groupData.entrySet()) {
+ for (Entry<Class<?>, MessageCounters> statEntry : groupData.entrySet()) {
long amountPerInterval = statEntry.getValue().accumulate();
long cumulativeAmount = statEntry.getValue().getCumulative();
dump.add(String.format("%s: MSG[%s] -> +%d | %d",
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
-import java.math.BigInteger;
-
/**
* Created by tkubas on 4/27/15.
*/
public class AggregatedFlowStatisticsTranslator implements MessageTranslator<MultipartReply, AggregatedFlowStatistics> {
@Override
- public AggregatedFlowStatistics translate(MultipartReply input, DeviceContext deviceContext, Object connectionDistinguisher) {
+ public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceContext deviceContext, final Object connectionDistinguisher) {
AggregatedFlowStatisticsBuilder aggregatedFlowStatisticsBuilder = new AggregatedFlowStatisticsBuilder();
MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase)input.getMultipartReplyBody();
*/
public class PacketReceivedTranslator implements MessageTranslator<PacketInMessage, PacketReceived> {
@Override
- public PacketReceived translate(PacketInMessage input, DeviceContext deviceContext, Object connectionDistinguisher) {
+ public PacketReceived translate(final PacketInMessage input, final DeviceContext deviceContext, final Object connectionDistinguisher) {
PacketReceivedBuilder packetReceivedBuilder = new PacketReceivedBuilder();
BigInteger datapathId = deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId();
return packetReceivedBuilder.build();
}
- private org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(PacketInMessage input, BigInteger datapathId) {
+ private static org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
Match match = MatchConvertorImpl.fromOFMatchToSALMatch(input.getMatch(),
datapathId,
OpenflowVersion.get(input.getVersion().shortValue())).build();
return matchBuilder.build();
}
- private Long getPortNumberFromMatch(List<MatchEntry> entries) {
+ private static Long getPortNumberFromMatch(final List<MatchEntry> entries) {
Long port = null;
for (MatchEntry entry : entries) {
if (InPortCase.class.equals(entry.getMatchEntryValue().getImplementedInterface())) {
this.version = version;
}
- public TranslatorKey createTranslatorKey(Class messageClass) {
+ public TranslatorKey createTranslatorKey(final Class<?> messageClass) {
return new TranslatorKey(version, messageClass.getName().toString());
}
}
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.math.BigInteger;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/**
* @return
*/
- private AddFlowInput prepareTestingAddFlow() {
+ private static AddFlowInput prepareTestingAddFlow() {
final AddFlowInputBuilder builder = new AddFlowInputBuilder();
builder.setFlowName("dummy flow");
builder.setHardTimeout(10000);
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
return phyport;
}
- private PortStateV10 getPortStateV10() {
+ private static PortStateV10 getPortStateV10() {
final PortStateV10 portState = new PortStateV10(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
return portState;
}
pfV10Bls[7], pfV10Bls[8], pfV10Bls[9], pfV10Bls[10], pfV10Bls[11]);
}
- private MacAddress getMacAddress() {
+ private static MacAddress getMacAddress() {
return new MacAddress(MAC_ADDRESS);
}
return new PortConfig(portCfgBools[0], portCfgBools[1], portCfgBools[2], portCfgBools[3]);
}
- private void assertEqualsStateV10(final PortStateV10 psV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState state) {
+ private static void assertEqualsStateV10(final PortStateV10 psV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState state) {
assertEquals(psV10.isBlocked(), state.isBlocked());
assertEquals(psV10.isLinkDown(), state.isLinkDown());
assertEquals(psV10.isLive(), state.isLive());
}
- private void assertEqualsState(final PortState ps, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState state) {
+ private static void assertEqualsState(final PortState ps, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState state) {
assertEquals(ps.isBlocked(), state.isBlocked());
assertEquals(ps.isLinkDown(), state.isLinkDown());
assertEquals(ps.isLive(), state.isLive());
}
- private void assertEqualsPortFeaturesV10(final PortFeaturesV10 apfV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
+ private static void assertEqualsPortFeaturesV10(final PortFeaturesV10 apfV10, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
assertEquals(apfV10.is_100mbFd(), npf.isHundredMbFd());
assertEquals(apfV10.is_100mbHd(), npf.isHundredMbHd());
assertEquals(apfV10.isPauseAsym(), npf.isPauseAsym());
}
- private void assertEqualsPortFeatures(final PortFeatures apf, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
+ private static void assertEqualsPortFeatures(final PortFeatures apf, final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf) {
assertEquals(apf.is_100gbFd(), npf.isHundredGbFd());
assertEquals(apf.is_100mbFd(), npf.isHundredMbFd());
assertEquals(apf.is_100mbHd(), npf.isHundredMbHd());
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
@Before
public void setup() {
- List<FlowAndStatisticsMapList> flowAndStatisticsMapListList = new ArrayList();
+ List<FlowAndStatisticsMapList> flowAndStatisticsMapListList = new ArrayList<>();
for (int i = 1; i < 4; i++) {
FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
flowAndStatisticsMapListBuilder.setPriority(i);
public void testEquals() throws Exception {
FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
- HashSet<FlowHash> flowHashs = new HashSet();
+ HashSet<FlowHash> flowHashs = new HashSet<>();
for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
flowHashs.add(FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3));
flowHashs.add(FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3));