public static FlowCookie getDefaultInstance(String defaultValue) { return new FlowCookie(new BigInteger(defaultValue)); }
/** * Return the flow cookie configured in the given instance. * * @param cookie A flow cookie. * @return The cookie value configured in {@code cookie}. */ public static BigInteger getCookie(FlowCookie cookie) { BigInteger value = (cookie == null) ? null : cookie.getValue(); return (value == null) ? COOKIE_DEFAULT : value; }
/** * {@inheritDoc} */ @Override public void flowStatsReceived(FlowAndStatisticsMap fstats) { if (targetCookie.equals(fstats.getCookie())) { Long time = System.currentTimeMillis(); GenericStatistics gen = fstats; FlowStatsRecord fsr = new FlowStatsRecordBuilder(gen). setTime(time).build(); future.set(fsr); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_bufferId == null) ? 0 : _bufferId.hashCode()); result = prime * result + ((_containerName == null) ? 0 : _containerName.hashCode()); result = prime * result + ((_cookie == null) ? 0 : _cookie.hashCode()); result = prime * result + ((_cookieMask == null) ? 0 : _cookieMask.hashCode()); result = prime * result + ((_flags == null) ? 0 : _flags.hashCode()); result = prime * result + ((_flowName == null) ? 0 : _flowName.hashCode()); result = prime * result + ((_hardTimeout == null) ? 0 : _hardTimeout.hashCode()); result = prime * result + ((_idleTimeout == null) ? 0 : _idleTimeout.hashCode()); result = prime * result + ((_instructions == null) ? 0 : _instructions.hashCode()); result = prime * result + ((_match == null) ? 0 : _match.hashCode()); result = prime * result + ((_node == null) ? 0 : _node.hashCode()); result = prime * result + ((_outGroup == null) ? 0 : _outGroup.hashCode()); result = prime * result + ((_outPort == null) ? 0 : _outPort.hashCode()); result = prime * result + ((_priority == null) ? 0 : _priority.hashCode()); result = prime * result + ((_tableId == null) ? 0 : _tableId.hashCode()); result = prime * result + ((_barrier == null) ? 0 : _barrier.hashCode()); result = prime * result + ((_installHw == null) ? 0 : _installHw.hashCode()); result = prime * result + ((_strict == null) ? 0 : _strict.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_bufferId == null) ? 0 : _bufferId.hashCode()); result = prime * result + ((_containerName == null) ? 0 : _containerName.hashCode()); result = prime * result + ((_cookie == null) ? 0 : _cookie.hashCode()); result = prime * result + ((_cookieMask == null) ? 0 : _cookieMask.hashCode()); result = prime * result + ((_flags == null) ? 0 : _flags.hashCode()); result = prime * result + ((_flowName == null) ? 0 : _flowName.hashCode()); result = prime * result + ((_hardTimeout == null) ? 0 : _hardTimeout.hashCode()); result = prime * result + ((_idleTimeout == null) ? 0 : _idleTimeout.hashCode()); result = prime * result + ((_instructions == null) ? 0 : _instructions.hashCode()); result = prime * result + ((_match == null) ? 0 : _match.hashCode()); result = prime * result + ((_node == null) ? 0 : _node.hashCode()); result = prime * result + ((_outGroup == null) ? 0 : _outGroup.hashCode()); result = prime * result + ((_outPort == null) ? 0 : _outPort.hashCode()); result = prime * result + ((_priority == null) ? 0 : _priority.hashCode()); result = prime * result + ((_tableId == null) ? 0 : _tableId.hashCode()); result = prime * result + ((_barrier == null) ? 0 : _barrier.hashCode()); result = prime * result + ((_installHw == null) ? 0 : _installHw.hashCode()); result = prime * result + ((_strict == null) ? 0 : _strict.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); return result; }
/** * Create a flow cookie from the given VTN flow ID. * * @param fid The identifier of the VTN data flow. * @return A {@link FlowCookie} instance. */ public static FlowCookie createCookie(VtnFlowId fid) { long value = fid.getValue().longValue() | COOKIE_BITS_VTN; return new FlowCookie(NumberUtils.getUnsigned(value)); }
public GetFlowStatisticsFromFlowTableInputBuilder setCookieMask(FlowCookie value) { if (value != null) { BigInteger _constraint = value.getValue(); boolean isValidRange = false; for (Range<BigInteger> r : _cookieMask_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _cookieMask_range)); } } this._cookieMask = value; return this; } public static List<Range<BigInteger>> _cookieMask_range() {
/** * Compares flows by cookie value */ @Override public boolean areObjectsEqual(final Flow statsFlow, final Flow storedFlow) { /* * Cookie is an optional field, so user might not set it, but if switch * get flow without cookie value , it will use 0 as a default cookie value * and return cookie=0 when openflowplugin fetch the flow stats from switch. * In this scenario flow comparison will fail. Below check make sure that * if user didn't set cookie value while flow installation, skip the comparison. */ if(storedFlow.getCookie() == null){ return true; } if (statsFlow.getCookie() == null) { if (storedFlow.getCookie() != null) { return false; } } else if (!statsFlow.getCookie().equals(storedFlow.getCookie())) { return false; } return true; } };
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_bufferId == null) ? 0 : _bufferId.hashCode()); result = prime * result + ((_byteCount == null) ? 0 : _byteCount.hashCode()); result = prime * result + ((_containerName == null) ? 0 : _containerName.hashCode()); result = prime * result + ((_cookie == null) ? 0 : _cookie.hashCode()); result = prime * result + ((_cookieMask == null) ? 0 : _cookieMask.hashCode()); result = prime * result + ((_duration == null) ? 0 : _duration.hashCode()); result = prime * result + ((_flags == null) ? 0 : _flags.hashCode()); result = prime * result + ((_flowId == null) ? 0 : _flowId.hashCode()); result = prime * result + ((_flowName == null) ? 0 : _flowName.hashCode()); result = prime * result + ((_hardTimeout == null) ? 0 : _hardTimeout.hashCode()); result = prime * result + ((_idleTimeout == null) ? 0 : _idleTimeout.hashCode()); result = prime * result + ((_instructions == null) ? 0 : _instructions.hashCode()); result = prime * result + ((_key == null) ? 0 : _key.hashCode()); result = prime * result + ((_match == null) ? 0 : _match.hashCode()); result = prime * result + ((_outGroup == null) ? 0 : _outGroup.hashCode()); result = prime * result + ((_outPort == null) ? 0 : _outPort.hashCode()); result = prime * result + ((_packetCount == null) ? 0 : _packetCount.hashCode()); result = prime * result + ((_priority == null) ? 0 : _priority.hashCode()); result = prime * result + ((_tableId == null) ? 0 : _tableId.hashCode()); result = prime * result + ((_barrier == null) ? 0 : _barrier.hashCode()); result = prime * result + ((_installHw == null) ? 0 : _installHw.hashCode()); result = prime * result + ((_strict == null) ? 0 : _strict.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); return result; }
private FlowBuilder initFlowBuilder(FlowBuilder flowBuilder, String flowName, short table, FlowID flowID) { FlowUtils.initFlowBuilder(flowBuilder, flowName, table) .setCookie(new FlowCookie(getCookie(flowID))) .setCookieMask(new FlowCookie(getCookie(flowID))); return flowBuilder; }
public GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder setCookieMask(FlowCookie value) { if (value != null) { BigInteger _constraint = value.getValue(); boolean isValidRange = false; for (Range<BigInteger> r : _cookieMask_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _cookieMask_range)); } } this._cookieMask = value; return this; } public static List<Range<BigInteger>> _cookieMask_range() {
if (snode != null) { FlowCookie cookie = notification.getCookie(); if (!COOKIE_MISS.equals(cookie)) { VtnFlowId flowId = FlowUtils.getVtnFlowId(cookie); if (flowId == null) {
result = prime * result + ((flow.getCookie() == null) ? 0 : flow.getCookie().hashCode()); result = prime * result + ((flow.getCookieMask() == null) ? 0 : flow.getCookieMask().hashCode()); result = prime * result + ((flow.getFlags() == null) ? 0 : flow.getFlags().hashCode()); result = prime * result + ((flow.getFlowName() == null) ? 0 : flow.getFlowName().hashCode());
private FlowBuilder initFlowBuilder(FlowBuilder flowBuilder, String flowName, short table, FlowID flowID, short nsp, short nsi) { FlowUtils.initFlowBuilder(flowBuilder, flowName, table) .setCookie(new FlowCookie(getCookie(flowID, nsp, nsi))) .setCookieMask(new FlowCookie(getCookie(flowID, nsp, nsi))); return flowBuilder; }
public FlowAndStatisticsMapListBuilder setCookieMask(FlowCookie value) { if (value != null) { BigInteger _constraint = value.getValue(); boolean isValidRange = false; for (Range<BigInteger> r : _cookieMask_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _cookieMask_range)); } } this._cookieMask = value; return this; } public static List<Range<BigInteger>> _cookieMask_range() {
public static FlowAdded flowAdded(final Flow sourceFlow) { Preconditions.checkArgument(sourceFlow != null); return new FlowAddedBuilder() .setHardTimeout(Integer.valueOf(sourceFlow.getHardTimeout())) .setIdleTimeout(Integer.valueOf(sourceFlow.getIdleTimeout())) .setCookie(new FlowCookie(BigInteger.valueOf(sourceFlow.getId()))) .setPriority(Integer.valueOf(sourceFlow.getPriority())) .setInstructions(MDFlowMapping.toApplyInstruction(toMDActions(sourceFlow.getActions()))) .setMatch(FromSalConversionsUtils.toMatch(sourceFlow.getMatch())) .setTableId((short)0) .build(); }
public GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder setCookie(FlowCookie value) { if (value != null) { BigInteger _constraint = value.getValue(); boolean isValidRange = false; for (Range<BigInteger> r : _cookie_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _cookie_range)); } } this._cookie = value; return this; } public static List<Range<BigInteger>> _cookie_range() {
private static FlowBuilder internalToMDFlow(final Flow sourceFlow) { Preconditions.checkArgument(sourceFlow != null); // Instruct switch to let controller know when flow is removed. FlowModFlags flags = new FlowModFlags(false, false, false, false, true); return new FlowBuilder() .setHardTimeout(Integer.valueOf(sourceFlow.getHardTimeout())) .setIdleTimeout(Integer.valueOf(sourceFlow.getIdleTimeout())) .setCookie(new FlowCookie(BigInteger.valueOf(sourceFlow.getId()))) .setPriority(Integer.valueOf((sourceFlow.getPriority()))) .setFlags(flags) .setInstructions(MDFlowMapping.toApplyInstruction(toMDActions(sourceFlow.getActions()))) .setMatch(FromSalConversionsUtils.toMatch(sourceFlow.getMatch())); }