org.opendaylight.controller.sal.flowprogrammer.Flow类的使用及代码示例

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

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

Flow介绍

[英]Represent a flow: match + actions + flow specific properties
[中]表示流:匹配+操作+流特定属性

代码示例

代码示例来源: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.affinity/l2agent

private void installFlow(Match match, List<Action> actions, Node incoming_node, short priority) {
  Flow f = new Flow(match, actions);
  f.setPriority(priority);
  // Modify the flow on the network node
  Status status = programmer.addFlow(incoming_node, f);
  if (!status.isSuccess()) {
    logger.warn("SDN Plugin failed to program the flow: {}. The failure is: {}",
          f, status.getDescription());
    return;
  }
  logger.info("Installed flow {} in node {}", f, incoming_node);
}

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

/**
 * @param source
 * @param target
 */
private static void genericFlowToAdFlow(GenericFlowAttributes source,
    final Flow target) {
  Integer hardTimeout = source.getHardTimeout();
  if (hardTimeout != null) {
    target.setHardTimeout(hardTimeout.shortValue());
  }
  Integer idleTimeout = source.getIdleTimeout();
  if (idleTimeout != null) {
    target.setIdleTimeout(idleTimeout.shortValue());
  }
  Integer priority = source.getPriority();
  if (priority != null) {
    target.setPriority(priority.shortValue());
  }
  target.setId(source.getCookie().getValue().longValue());
}

代码示例来源: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/sal

/**
 * remove ALL actions of type actionType from the list of actions of this
 * flow
 *
 * @param actionType
 * @return false if an action of that type is present and it fails to remove
 *         it
 */
public boolean removeAction(ActionType actionType) {
  Iterator<Action> actionIter = this.getActions().iterator();
  while (actionIter.hasNext()) {
    Action action = actionIter.next();
    if (action.getType() == actionType) {
      if (!this.removeAction(action)) {
        return false;
      }
    }
  }
  return true;
}

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

Flow flow = new Flow();
Match match = new Match();
try {
flow.setMatch(match);
List<Action> actions = new ArrayList<Action>();
actions.add(a);
flow.setActions(actions);
flow.setPriority(priority++);
flow.setIdleTimeout((short) 1000);
flow.setHardTimeout((short) 2000);
flow.setId(12345);

代码示例来源: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.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.controller/troubleshoot.web

Map<String, String> row = new HashMap<String, String>();
Flow flow = flowOnNode.getFlow();
Match match = flow.getMatch();
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
    .getInstance(ISwitchManager.class, containerName, this);
row.put("nodeName", desc);
if (match.isPresent(MatchType.IN_PORT)) {
  row.put(MatchType.IN_PORT.id(), ((NodeConnector) flow.getMatch()
      .getField(MatchType.IN_PORT).getValue())
      .getNodeConnectorIdAsString());
      (HexEncode.bytesToHexString(((byte[]) flow.getMatch()
          .getField(MatchType.DL_SRC).getValue()))));
} else {
      (HexEncode.bytesToHexString(((byte[]) flow.getMatch()
          .getField(MatchType.DL_DST).getValue()))));
} else {
      EtherTypes.getEtherTypeName(((Short) flow.getMatch()
          .getField(MatchType.DL_TYPE).getValue())));
} else {
  if (((Short) flow.getMatch().getField(MatchType.DL_VLAN).getValue())
      .shortValue() < 0) {
    row.put(MatchType.DL_VLAN.id(), "0");
  } else {
    row.put(MatchType.DL_VLAN.id(), ((Short) flow.getMatch()

代码示例来源: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.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();
}

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

Match match = flow.getMatch();
MatchField fieldVlan = match.getField(MatchType.DL_VLAN);
short vlan = ((Short)(fieldVlan.getValue())).shortValue();
List<Action> actions = new ArrayList<Action>();
actions.add(new Output(oport));
Flow flown = new Flow(flow.getMatch(), actions);
return new FlowOnNode(flown);

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

public static Flow toFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source, Node node) {
  final Flow target = new Flow();
  genericFlowToAdFlow(source, target);
  target.setMatch(toMatch(source.getMatch()));
  List<Action> actions = getAction(source);
  if (actions != null) {
    target.setActions(actionFrom(actions, node));
  }
  return target;
}

代码示例来源: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.openflowplugin.legacy/sal-compatibility

/**
 * @param source notification, missing instructions
 * @param node corresponding node where the flow change occured
 * @return ad-sal node, build from given data
 */
public static Flow toFlow(SwitchFlowRemoved source, Node node) {
  final Flow target = new Flow();
  genericFlowToAdFlow(source, target);
  target.setMatch(toMatch(source.getMatch()));
  return target;
}

代码示例来源: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));
f.setActions(actions);

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

private List<FlowOnNode> forwardingTableEntriesToFlows(Map<String, Integer> entries, Node node){
  List<FlowOnNode> list = new ArrayList<FlowOnNode>();
  for(Map.Entry<String, Integer> entry : entries.entrySet()){
    Match match = new Match();
    String str = entry.getKey();
    short vlan = Short.parseShort(str.substring(0, str.indexOf(".")));
    byte[] macAddrBytes = OIDToMacAddrBytes(str.substring(str.indexOf(".") + 1));
    if(macAddrBytes == null){
      logger.debug("ERROR: forwardingTableEntriesToFlows(): nodeID is {}, call OIDToMacAddrBytes() fail", (Long)node.getID());
      return null;
    }
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_DST, macAddrBytes);
    List<Action> actions = new ArrayList<Action>();
    NodeConnector oport = NodeConnectorCreator.createNodeConnector("SNMP", Short.parseShort(entry.getValue().toString()), node);
    actions.add(new Output(oport));
    Flow flow = new Flow(match, actions);
    list.add(new FlowOnNode(flow));
  }
  return list;
}

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

||*/ !oldFlow.getMatch().equals(newFlow.getMatch())) {
  msg1 = new SNMPFlowMod(SNMPFlowMod.SNMPFC_DELETE_STRICT, oldFlow.clone());//s4s
  msg2 = new SNMPFlowMod(SNMPFlowMod.SNMPFC_ADD, newFlow.clone());//s4s
} else {
  msg1 = new SNMPFlowMod(SNMPFlowMod.SNMPFC_MODIFY_STRICT, newFlow.clone());//s4s

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

((OFFlowMod) fm).setMatch(this.ofMatch);
((OFFlowMod) fm).setActions(this.actionsList);
((OFFlowMod) fm).setPriority(flow.getPriority());
((OFFlowMod) fm).setCookie(flow.getId());
((OFFlowMod) fm).setBufferId(OFPacketOut.BUFFER_ID_NONE);
((OFFlowMod) fm).setLength(U16.t(OFFlowMod.MINIMUM_LENGTH
    + actionsLength));
((OFFlowMod) fm).setIdleTimeout(flow.getIdleTimeout());
((OFFlowMod) fm).setHardTimeout(flow.getHardTimeout());
((OFFlowMod) fm).setCommand(command);
if (port != null) {
((V6FlowMod) fm).setMatch((V6Match) ofMatch);
((V6FlowMod) fm).setActions(this.actionsList);
((V6FlowMod) fm).setPriority(flow.getPriority());
((V6FlowMod) fm).setCookie(flow.getId());
((V6FlowMod) fm).setLength(U16.t(OFVendor.MINIMUM_LENGTH
    + ((V6Match) ofMatch).getIPv6ExtMinHdrLen()
    + ((V6Match) ofMatch).getIPv6MatchLen()
    + ((V6Match) ofMatch).getPadSize() + actionsLength));
((V6FlowMod) fm).setIdleTimeout(flow.getIdleTimeout());
((V6FlowMod) fm).setHardTimeout(flow.getHardTimeout());
((V6FlowMod) fm).setCommand(command);
if (port != null) {

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

for (Action action : newFlowEntry.getFlow().getActions()) {
  if (action.getType() == ActionType.OUTPUT) {
    target = action;
newFlowEntry.getFlow().removeAction(target);
newFlowEntry.getFlow().addAction(new Output(outPort));

相关文章