org.opendaylight.controller.sal.flowprogrammer.Flow.getMatch()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.opendaylight.controller.sal.flowprogrammer.Flow.getMatch()方法的一些代码示例,展示了Flow.getMatch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flow.getMatch()方法的具体详情如下:
包路径:org.opendaylight.controller.sal.flowprogrammer.Flow
类名称:Flow
方法名:getMatch

Flow.getMatch介绍

[英]Return a copy of the Match configured on this flow
[中]返回此流上配置的匹配项的副本

代码示例

代码示例来源:origin: org.opendaylight.controller/sal

@Override
public Flow clone() {
  Flow cloned = null;
  try {
    cloned = (Flow) super.clone();
    cloned.match = this.getMatch();
    cloned.actions = this.getActions();
  } catch (CloneNotSupportedException e) {
    logger.error("", e);
  }
  return cloned;
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager

@Override
public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + ((node == null) ? 0 : node.hashCode());
  result = prime * result + ((flow == null) ? 0 : (int) flow.getPriority());
  result = prime * result + ((flow == null || flow.getMatch() == null) ? 0 : flow.getMatch().hashCode());
  return result;
}

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager

return false;
if (flow.getMatch() == null) {
  if (other.flow.getMatch() != null) {
    return false;
} else if (!flow.getMatch().equals(other.flow.getMatch())) {
  return false;

代码示例来源:origin: org.opendaylight.affinity/flatl2

InetAddress srcIp = (InetAddress) f.getMatch().getField(MatchType.NW_SRC).getValue();
InetAddress dstIp = (InetAddress) f.getMatch().getField(MatchType.NW_DST).getValue();
flowName = "[" + groupName + ":" + srcIp + ":" + dstIp + "]";
List<Action> actions = calcForwardingActions(node, srcIp, dstIp, attribs.get(groupName));

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager

/**
 * Merges the current Flow with the passed Container Flow
 *
 * Note: Container Flow merging is not an injective function. Be m1 and m2
 * two different matches, and be f() the flow merge function, such that y1 =
 * f(m1) and y2 = f(m2) are the two merged matches, we may have: y1 = y2
 *
 *
 * @param containerFlow
 * @return this merged FlowEntry
 */
public FlowEntry mergeWith(ContainerFlow containerFlow) {
  Match myMatch = flow.getMatch();
  Match filter = containerFlow.getMatch();
  // Merge
  Match merge = myMatch.mergeWithFilter(filter);
  // Replace this Flow's match with merged version
  flow.setMatch(merge);
  return this;
}

代码示例来源:origin: org.opendaylight.affinity/analytics.implementation

public void setStatsFromFlow(FlowOnNode flow) {
    MatchField protocolField = flow.getFlow().getMatch().getField(MatchType.NW_PROTO);
    Byte protocolNumber;
    if (protocolField == null)
      protocolNumber = IPProtocols.ANY.byteValue();
    else
      protocolNumber = (Byte) protocolField.getValue();

    // Prevent stats from getting overwritten by zero-byte flows.
    Long currentByteCount = this.byteCounts.get(protocolNumber);
    Long thisByteCount = flow.getByteCount();
    Long thisPacketCount = flow.getPacketCount();
    if (thisByteCount > 0 && (currentByteCount == null || currentByteCount <= thisByteCount)) {
      this.byteCounts.put(protocolNumber, thisByteCount);
      this.packetCounts.put(protocolNumber, thisPacketCount);
      this.durations.put(protocolNumber, flow.getDurationSeconds() + .000000001 * flow.getDurationNanoseconds());
    }
  }
}

代码示例来源:origin: org.opendaylight.snmp4sdn/snmp4sdn

/**
 * Returns whether the specified flow (flow match + actions)
 * belongs to the container
 *
 * @param container
 * @param node
 * @param flow
 * @return true if it belongs
 */
public boolean flowBelongToContainer(String container, Node node, Flow flow) {
  // All flows belong to the default container
  if (container.equals(GlobalConstants.DEFAULT.toString())) {
    return true;
  }
  return (flowPortsBelongToContainer(container, node, flow)
      && flowVlanBelongsToContainer(container, node, flow) && flowSpecAllowsFlow(
          container, flow.getMatch()));
}

代码示例来源:origin: org.opendaylight.affinity/analytics.implementation

protected Host getSourceHostFromFlow(Flow flow, Set<HostNodeConnector> hosts) {
  Host srcHost = null;
  Match match = flow.getMatch();
  // Flow must have IN_PORT field (DL_SRC rarely (never?)
  // exists).
  if (match.isPresent(MatchType.IN_PORT)) {
    MatchField inPort = match.getField(MatchType.IN_PORT);
    // Check cache
    Host cacheHit = this.sourceHostCache.get(inPort);
    if (cacheHit != null)
      return cacheHit;
    // Find the source host by comparing the NodeConnectors
    NodeConnector inPortNc = (NodeConnector) inPort.getValue();
    for (HostNodeConnector h : hosts) {
      NodeConnector hostNc = h.getnodeConnector();
      if (hostNc.equals(inPortNc)) {
        srcHost = h;
        this.sourceHostCache.put(inPort, h); // Add to cache
        break;
      }
    }
  }
  return srcHost;
}

代码示例来源:origin: org.opendaylight.controller/sal.implementation

public void _modifyflow(CommandInterpreter ci) throws UnknownHostException {
  Node node = null;
  String nodeId = ci.nextArgument();
  if (nodeId == null) {
    ci.print("Node id not specified");
    return;
  }
  try {
    node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
  } catch (NumberFormatException e) {
    logger.error("",e);
  } catch (ConstructionException e) {
    logger.error("",e);
  }
  Flow flowA = getSampleFlow(node);
  Flow flowB = getSampleFlow(node);
  Match matchB = flowB.getMatch();
  matchB.setField(MatchType.NW_DST,
      InetAddress.getByName("190.190.190.190"));
  flowB.setMatch(matchB);
  ci.println(this.modifyFlow(node, flowA, flowB));
}

代码示例来源:origin: org.opendaylight.controller/protocol_plugins.openflow

private void handleFlowRemovedMessage(ISwitch sw, OFFlowRemoved msg) {
  Node node = NodeCreator.createOFNode(sw.getId());
  Flow flow = new FlowConverter(msg.getMatch(),
      new ArrayList<OFAction>(0)).getFlow(node);
  flow.setPriority(msg.getPriority());
  flow.setIdleTimeout(msg.getIdleTimeout());
  flow.setId(msg.getCookie());
  Match match = flow.getMatch();
  NodeConnector inPort = match.isPresent(MatchType.IN_PORT) ? (NodeConnector) match
      .getField(MatchType.IN_PORT).getValue() : null;
  for (Map.Entry<String, IFlowProgrammerNotifier> containerNotifier : flowProgrammerNotifiers
      .entrySet()) {
    String container = containerNotifier.getKey();
    IFlowProgrammerNotifier notifier = containerNotifier.getValue();
    /*
     * Switch only provide us with the match information. For now let's
     * try to identify the container membership only from the input port
     * match field. In any case, upper layer consumers can derive
     * whether the notification was not for them. More sophisticated
     * filtering can be added later on.
     */
    if (inPort == null
        || container.equals(GlobalConstants.DEFAULT.toString())
        || (containerToNc.containsKey(container) && containerToNc.get(container).contains(inPort))) {
      notifier.flowRemoved(node, flow);
    }
  }
}

代码示例来源:origin: org.opendaylight.openflowplugin.legacy/sal-compatibility

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()));
}

代码示例来源:origin: org.opendaylight.snmp4sdn/snmp4sdn

Match match1 = flow1.getMatch();
MatchField fieldDlSrc1= match1.getField(MatchType.DL_SRC);
MatchField fieldDlDest1= match1.getField(MatchType.DL_DST);
Match match2 = flow2.getMatch();
MatchField fieldDlSrc2= match2.getField(MatchType.DL_SRC);
MatchField fieldDlDest2= match2.getField(MatchType.DL_DST);

代码示例来源:origin: org.opendaylight.openflowplugin.legacy/sal-compatibility

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();
}

代码示例来源:origin: org.opendaylight.affinity/analytics.implementation

protected Host getDestinationHostFromFlow(Flow flow, Set<HostNodeConnector> hosts) {
  Match match = flow.getMatch();
  MatchField dst = null;

代码示例来源:origin: org.opendaylight.controller/forwardingrulesmanager.implementation

private boolean doesFlowContainNodeConnector(Flow flow, NodeConnector nc) {
  if (nc == null) {
    return false;
  }
  Match match = flow.getMatch();
  if (match.isPresent(MatchType.IN_PORT)) {
    NodeConnector matchPort = (NodeConnector) match.getField(MatchType.IN_PORT).getValue();
    if (matchPort.equals(nc)) {
      return true;
    }
  }
  List<Action> actionsList = flow.getActions();
  if (actionsList != null) {
    for (Action action : actionsList) {
      if (action instanceof Output) {
        NodeConnector actionPort = ((Output) action).getPort();
        if (actionPort.equals(nc)) {
          return true;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: org.opendaylight.controller/sal

Match target = flow.getMatch();

代码示例来源:origin: org.opendaylight.controller/protocol_plugins.openflow

/**
 * Check whether the ports in the flow match and flow actions for
 * the specified node belong to the container
 *
 * @param container
 * @param node
 * @param flow
 * @return
 */
private boolean flowPortsBelongToContainer(String container, Node node,
    Flow flow) {
  Match m = flow.getMatch();
  if (m.isPresent(MatchType.IN_PORT)) {
    NodeConnector inPort = (NodeConnector) m.getField(MatchType.IN_PORT).getValue();
    // If the incoming port is specified, check if it belongs to
    if (!containerOwnsNodeConnector(container, inPort)) {
      return false;
    }
  }
  // If an outgoing port is specified, it must belong to this container
  for (Action action : flow.getActions()) {
    if (action.getType() == ActionType.OUTPUT) {
      NodeConnector outPort = ((Output) action).getPort();
      if (!containerOwnsNodeConnector(container, outPort)) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: org.opendaylight.snmp4sdn/snmp4sdn

Match m = flow.getMatch();
if (m.isPresent(MatchType.IN_PORT)) {
  NodeConnector inPort = (NodeConnector) m

代码示例来源:origin: org.opendaylight.controller/protocol_plugins.openflow

private Status validateFlow(Flow flow) {
  Match m = flow.getMatch();
  boolean isIPEthertypeSet = m.isPresent(MatchType.DL_TYPE)
      && (m.getField(MatchType.DL_TYPE).getValue().equals(EtherTypes.IPv4.shortValue()) || m
          .getField(MatchType.DL_TYPE).getValue().equals(EtherTypes.IPv6.shortValue()));
  // network address check
  if ((m.isPresent(MatchType.NW_SRC) || m.isPresent(MatchType.NW_DST)) && !isIPEthertypeSet) {
    return new Status(StatusCode.NOTACCEPTABLE,
        "The match on network source or destination address cannot be accepted if the match "
         + "on proper ethertype is missing");
  }
  // transport protocol check
  if (m.isPresent(MatchType.NW_PROTO) && !isIPEthertypeSet) {
    return new Status(StatusCode.NOTACCEPTABLE,
        "The match on network protocol cannot be accepted if the match on proper ethertype is missing");
  }
  // transport ports check
  if ((m.isPresent(MatchType.TP_SRC) || m.isPresent(MatchType.TP_DST))
      && (!isIPEthertypeSet || m.isAny(MatchType.NW_PROTO))) {
    return new Status(
        StatusCode.NOTACCEPTABLE,
        "The match on transport source or destination port cannot be accepted if the match on network protocol and match on IP ethertype are missing");
  }
  return new Status(StatusCode.SUCCESS);
}

代码示例来源:origin: org.opendaylight.openflowplugin.legacy/sal-compatibility

private FlowAndStatisticsMapList toOdFlowStatistics(FlowOnNode flowOnNode) {
  FlowAndStatisticsMapListBuilder builder = new FlowAndStatisticsMapListBuilder();
  builder.setByteCount(toCounter64(flowOnNode.getByteCount()));
  builder.setPacketCount(toCounter64(flowOnNode.getPacketCount()));
  builder.setDuration(extractDuration(flowOnNode));
  builder.setMatch(FromSalConversionsUtils.toMatch(flowOnNode.getFlow().getMatch()));
  builder.setPriority((int)flowOnNode.getFlow().getPriority());
  builder.setHardTimeout((int)flowOnNode.getFlow().getHardTimeout());
  builder.setIdleTimeout((int)flowOnNode.getFlow().getIdleTimeout());
  //TODO: actions to instruction conversion
  builder.setInstructions(null);
  return builder.build();
}

相关文章