public class BulkOMaticUtils {
- public final static int DEFUALT_STATUS = FlowCounter.OperationStatus.INIT.status();
- public final static int DEFAULT_FLOW_COUNT = 0;
- public final static long DEFAULT_COMPLETION_TIME = 0;
- public final static String DEFAULT_UNITS = "ns";
- public final static String DEVICE_TYPE_PREFIX = "openflow:";
+ private BulkOMaticUtils () { }
+
+ public static final int DEFUALT_STATUS = FlowCounter.OperationStatus.INIT.status();
+ public static final int DEFAULT_FLOW_COUNT = 0;
+ public static final long DEFAULT_COMPLETION_TIME = 0;
+ public static final String DEFAULT_UNITS = "ns";
+ public static final String DEVICE_TYPE_PREFIX = "openflow:";
public static String ipIntToStr (int k) {
return new StringBuilder().append(((k >> 24) & 0xFF)).append(".")
private final boolean isConfigDs;
private AtomicLong flowCount = new AtomicLong(0);
private AtomicInteger readOpStatus = new AtomicInteger(FlowCounter.OperationStatus.INIT.status());
- private final String UNITS = "ns";
+ private static final String UNITS = "ns";
private FlowReader(final DataBroker dataBroker,
final Integer dpnCount,
public class FlowWriterConcurrent implements FlowCounterMBean {
private static final Logger LOG = LoggerFactory.getLogger(FlowWriterConcurrent.class);
+ public static final String USING_CONCURRENT_IMPLEMENTATION_OF_FLOW_WRITER = "Using Concurrent implementation of Flow Writer.";
private final DataBroker dataBroker;
private final ExecutorService flowPusher;
private long startTime;
private AtomicInteger writeOpStatus = new AtomicInteger(FlowCounter.OperationStatus.INIT.status());
private AtomicInteger countDpnWriteCompletion = new AtomicInteger(0);
private AtomicLong taskCompletionTime = new AtomicLong(0);
- private final String UNITS = "ns";
+ private static final String UNITS = "ns";
public FlowWriterConcurrent(final DataBroker dataBroker, ExecutorService flowPusher) {
this.dataBroker = dataBroker;
this.flowPusher = flowPusher;
- LOG.info("Using Concurrent implementation of Flow Writer.");
+ LOG.info(USING_CONCURRENT_IMPLEMENTATION_OF_FLOW_WRITER);
}
public void addFlows(Integer dpnCount, Integer flowsPerDPN, int batchSize,
int sleepMillis, int sleepAfter, short startTableId, short endTableId) {
- LOG.info("Using Concurrent implementation of Flow Writer.");
+ LOG.info(USING_CONCURRENT_IMPLEMENTATION_OF_FLOW_WRITER);
countDpnWriteCompletion.set(dpnCount);
startTime = System.nanoTime();
for (int i = 1; i <= dpnCount; i++) {
public void deleteFlows(Integer dpnCount, Integer flowsPerDPN, int batchSize,
short startTableId, short endTableId) {
- LOG.info("Using Concurrent implementation of Flow Writer.");
+ LOG.info(USING_CONCURRENT_IMPLEMENTATION_OF_FLOW_WRITER);
countDpnWriteCompletion.set(dpnCount);
for (int i = 1; i <= dpnCount; i++) {
FlowHandlerTask task = new FlowHandlerTask(Integer.toString(i), flowsPerDPN, false, batchSize,
private AtomicInteger writeOpStatus = new AtomicInteger(FlowCounter.OperationStatus.INIT.status());
private AtomicInteger countDpnWriteCompletion = new AtomicInteger(0);
private AtomicLong taskCompletionTime = new AtomicLong(0);
- private final String UNITS = "ns";
+ private static final String UNITS = "ns";
public FlowWriterSequential(final DataBroker dataBroker, ExecutorService flowPusher) {
this.dataBroker = dataBroker;
private boolean preConfigurationCheck(final InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
Preconditions.checkNotNull(nodeConnIdent, "FlowCapableNodeConnector ident can not be null!");
return true;
- //return provider.isNodeActive(nodeConnIdent);
}
}
String sNodeConnectorIdentifier = nodeConnIdent
.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
BigInteger nDpId = getDpIdFromPortName(sNodeConnectorIdentifier);
- String portName = del.getName();
dpnToPortMultiMap.remove(nDpId, sNodeConnectorIdentifier);
}
public void update(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector original, FlowCapableNodeConnector update, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
LOG.debug("Node Connector updated");
- //donot need to do anything as we are not considering updates here
+ //Don't need to do anything as we are not considering updates here
}
}
.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
BigInteger nDpId = getDpIdFromPortName(sNodeConnectorIdentifier);
- String portName = add.getName();
if(!dpnToPortMultiMap.containsEntry(nDpId,sNodeConnectorIdentifier)) {
dpnToPortMultiMap.put(nDpId, sNodeConnectorIdentifier);
}else{
private ListenerRegistration<FlowNodeReconciliationImpl> listenerRegistration;
- private final int THREAD_POOL_SIZE = 4;
+ private static final int THREAD_POOL_SIZE = 4;
ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE
private void deleteDSStaleFlows(List<InstanceIdentifier<StaleFlow>> flowsForBulkDelete){
ImmutableList.Builder<InstanceIdentifier<StaleFlow>> builder = ImmutableList.builder();
- ImmutableList<InstanceIdentifier<StaleFlow>> bulkDelFlows = builder.addAll(flowsForBulkDelete.iterator()).build();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
private void deleteDSStaleGroups(List<InstanceIdentifier<StaleGroup>> groupsForBulkDelete){
ImmutableList.Builder<InstanceIdentifier<StaleGroup>> builder = ImmutableList.builder();
- ImmutableList<InstanceIdentifier<StaleGroup>> bulkDelGroups = builder.addAll(groupsForBulkDelete.iterator()).build();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
private void deleteDSStaleMeters(List<InstanceIdentifier<StaleMeter>> metersForBulkDelete){
ImmutableList.Builder<InstanceIdentifier<StaleMeter>> builder = ImmutableList.builder();
- ImmutableList<InstanceIdentifier<StaleMeter>> bulkDelGroups = builder.addAll(metersForBulkDelete.iterator()).build();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
private void handleStaleEntityDeletionResultFuture(CheckedFuture<Void, TransactionCommitFailedException> submitFuture) {
Futures.addCallback(submitFuture, new FutureCallback<Void>() {
@Override
- public void onSuccess(Void result) { LOG.debug("Stale entity removal success");
+ public void onSuccess(Void result) {
+ LOG.debug("Stale entity removal success");
}
@Override
try {
SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
- listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<TableForwarder>>() {
- @Override
- public ListenerRegistration<TableForwarder> call() throws Exception {
- return db.registerDataTreeChangeListener(treeId, TableForwarder.this);
- }
- });
+ listenerRegistration = looper.loopUntilNoException(() -> db.registerDataTreeChangeListener(treeId, TableForwarder.this));
} catch (final Exception e) {
LOG.warn("FRM Table DataChange listener registration fail!");
LOG.debug("FRM Table DataChange listener registration fail ..", e);
final TableFeatures originalTableFeatures = original;
TableFeatures updatedTableFeatures;
- if (null == update)
+ if (null == update) {
updatedTableFeatures = original;
- else
+ }
+ else {
updatedTableFeatures = update;
-
+ }
final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
}
private static final boolean isValueUint16(int value) {
- if (value >= 0 && value <= 65535L)
+ if (value >= 0 && value <= 65535L) {
return true;
+ }
return false;
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
NiciraActionDeserializerKey other = (NiciraActionDeserializerKey) obj;
- if (subtype != other.subtype)
+ if (subtype != other.subtype) {
return false;
- if (version != other.version)
+ }
+ if (version != other.version) {
return false;
+ }
return true;
}
* @author msunal
*/
public final class NiciraUtil {
-
+ private NiciraUtil() { }
public static final ActionSerializerKey<?> createOfJavaKeyFrom(NiciraActionSerializerKey key) {
return new ActionSerializerKey<>(key.getVersion(), key.getSubtype(), NiciraConstants.NX_VENDOR_ID);
* @author Josh Hershberg (jhershbe@redhat.com)
*/
public class NiciraMatchCodecs {
+ private NiciraMatchCodecs () { }
public static final Reg0Codec REG0_CODEC = new Reg0Codec();
public static final Reg1Codec REG1_CODEC = new Reg1Codec();
*/
public abstract class AbstractActionCodec implements OFSerializer<Action>, OFDeserializer<Action> {
- protected final static void serializeHeader(final int msgLength, final int subtype, final ByteBuf outBuffer) {
+ protected static final void serializeHeader(final int msgLength, final int subtype, final ByteBuf outBuffer) {
outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE);
writeMsgLengthVendorIdSubtypeToBuffer(msgLength, subtype, outBuffer);
}
- private final static void writeMsgLengthVendorIdSubtypeToBuffer(final int msgLength, final int subtype, final ByteBuf outBuffer) {
+ private static final void writeMsgLengthVendorIdSubtypeToBuffer(final int msgLength, final int subtype, final ByteBuf outBuffer) {
outBuffer.writeShort(msgLength);
outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue());
outBuffer.writeShort(subtype);
}
- protected final static ActionBuilder deserializeHeader(final ByteBuf message) {
+ protected static final ActionBuilder deserializeHeader(final ByteBuf message) {
// size of experimenter type
message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
// size of length
return actionBuilder;
}
- protected final static ExperimenterId getExperimenterId(){
+ protected static final ExperimenterId getExperimenterId(){
return new ExperimenterId(NiciraConstants.NX_VENDOR_ID);
}
*/
public class ConntrackCodec extends AbstractActionCodec {
- private static final Logger logger = LoggerFactory.getLogger(ConntrackCodec.class);
-
public static final int LENGTH = 24;
public static final byte NXAST_CONNTRACK_SUBTYPE = 35;
public static final NiciraActionSerializerKey SERIALIZER_KEY =
@Override
public void serialize(final Action input, final ByteBuf outBuffer) {
- ActionConntrack action = ((ActionConntrack) input.getActionChoice()); //getAugmentation(OfjAugNxAction.class).getActionConntrack();
+ ActionConntrack action = ((ActionConntrack) input.getActionChoice());
serializeHeader(LENGTH, NXAST_CONNTRACK_SUBTYPE, outBuffer);
outBuffer.writeShort(action.getNxActionConntrack().getFlags().shortValue());
* Codec for the NX_MULTIPATH
*/
public class MultipathCodec extends AbstractActionCodec {
- private static final Logger logger = LoggerFactory.getLogger(MultipathCodec.class);
-
public static final int LENGTH = 32;
public static final byte NXAST_MULTIPATH_SUBTYPE = 10;
public static final NiciraActionSerializerKey SERIALIZER_KEY =
@Override
public void serialize(final Action input, final ByteBuf outBuffer) {
- ActionMultipath action = ((ActionMultipath) input.getActionChoice()); //getAugmentation(OfjAugNxAction.class).getActionMultipath();
+ ActionMultipath action = ((ActionMultipath) input.getActionChoice());
serializeHeader(LENGTH, NXAST_MULTIPATH_SUBTYPE, outBuffer);
outBuffer.writeShort(action.getNxActionMultipath().getFields().getIntValue());
*/
public class NiciraActionCodecs {
+ private NiciraActionCodecs() { }
+
public static final RegMoveCodec REG_MOVE_CODEC = new RegMoveCodec();
public static final RegLoadCodec REG_LOAD_CODEC = new RegLoadCodec();
public static final OutputRegCodec OUTPUT_REG_CODEC = new OutputRegCodec();
* Codec for the NX_RESUBMIT and NX_RESUBMIT_TABLE
*/
public class ResubmitCodec extends AbstractActionCodec {
+
public static final int LENGTH = 16;
public static final byte NXAST_RESUBMIT_SUBTYPE = 1;
public static final byte NXAST_RESUBMIT_TABLE_SUBTYPE = 14;
*/
public class SetNshc1Codec extends AbstractActionCodec {
- private static final Logger LOG = LoggerFactory.getLogger(SetNshc1Codec.class);
-
public static final int LENGTH = 16;
public static final byte NXAST_SET_NSC_SUBTYPE = 34;
public static final NiciraActionSerializerKey SERIALIZER_KEY =
* Codec for the NX_SetNsp and NX_SetNsp_TABLE
*/
public class SetNshc3Codec extends AbstractActionCodec {
+
public static final int LENGTH = 16;
public static final byte NXAST_SET_NSC_SUBTYPE = 36;
public static final NiciraActionSerializerKey SERIALIZER_KEY =
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
NxmHeader other = (NxmHeader) obj;
- if (headerAsLong != other.headerAsLong)
+ if (headerAsLong != other.headerAsLong) {
return false;
+ }
return true;
}
/** openflow protocol 1.3 - version identifier */
public static final short OFP_VERSION_1_3 = 0x04;
- public final static String OF_URI_PREFIX = "openflow:";
+ public static final String OF_URI_PREFIX = "openflow:";
/** enum ofp_table: Table numbering, wildcard table used for table config, flow stats and flow deletes. */
public static final Short OFPTT_ALL = 0xff;
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
SwitchSessionKeyOF other = (SwitchSessionKeyOF) obj;
if (datapathId == null) {
- if (other.datapathId != null)
+ if (other.datapathId != null) {
return false;
- } else if (!datapathId.equals(other.datapathId))
+ }
+ } else if (!datapathId.equals(other.datapathId)) {
return false;
+ }
return true;
}
}
* Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
*/
public class FlowRegistryKeyFactory {
+
private FlowRegistryKeyFactory() {
// Hide implicit constructor
}
import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.openflowplugin.api.openflow.OFPContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
LOG.debug("Trying to remove from operational node: {}", roleContext.getDeviceInfo().getNodeId());
removeDeviceFromOperationalDS(roleContext.getDeviceInfo(), MAX_CLEAN_DS_RETRIES);
} else {
- final NodeId nodeId = roleContext.getDeviceInfo().getNodeId();
contexts.remove(roleContext.getDeviceInfo(), roleContext);
roleContext.close();
conductor.closeConnection(roleContext.getDeviceInfo());
public class ItemLifecycleListenerImpl implements ItemLifecycleListener {
private static final Logger LOG = LoggerFactory.getLogger(ItemLifecycleListenerImpl.class);
+ public static final String NOT_ABLE_TO_WRITE_TO_TRANSACTION = "Not able to write to transaction: {}";
private final DeviceContext deviceContext;
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, itemPath, itemBody);
deviceContext.submitTransaction();
} catch (Exception e) {
- LOG.warn("Not able to write to transaction: {}", e);
+ LOG.warn(NOT_ABLE_TO_WRITE_TO_TRANSACTION, e);
}
}
deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, itemPath);
deviceContext.submitTransaction();
} catch (Exception e) {
- LOG.warn("Not able to write to transaction: {}", e);
+ LOG.warn(NOT_ABLE_TO_WRITE_TO_TRANSACTION, e);
}
}
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, itemPath, itemBody);
deviceContext.submitTransaction();
} catch (Exception e) {
- LOG.warn("Not able to write to transaction: {}", e);
+ LOG.warn(NOT_ABLE_TO_WRITE_TO_TRANSACTION, e);
}
}
}
abstract class AbstractService<I, O> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractService.class);
- private static final long WAIT_TIME = 2000;
- private static final BigInteger PRIMARY_CONNECTION = BigInteger.ZERO;
private final short version;
private final BigInteger datapathId;