• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SetDlSrc类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.opendaylight.controller.sal.action.SetDlSrc的典型用法代码示例。如果您正苦于以下问题:Java SetDlSrc类的具体用法?Java SetDlSrc怎么用?Java SetDlSrc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SetDlSrc类属于org.opendaylight.controller.sal.action包,在下文中一共展示了SetDlSrc类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: installLoadBalancerFlow

点赞 2

import org.opendaylight.controller.sal.action.SetDlSrc; //导入依赖的package包/类
private boolean installLoadBalancerFlow(Client source,
                                        VIP dest,
                                        Node sourceSwitch,
                                        String destMachineIp,
                                        byte[] destMachineMac,
                                        NodeConnector outport,
                                        int flowDirection) throws UnknownHostException{

    Match match = new Match();
    List<Action> actions = new ArrayList<Action>();

    if(flowDirection == LBConst.FORWARD_DIRECTION_LB_FLOW){
        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.NW_SRC, InetAddress.getByName(source.getIp()));
        match.setField(MatchType.NW_DST, InetAddress.getByName(dest.getIp()));
        match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(dest.getProtocol()));
        match.setField(MatchType.TP_SRC, source.getPort());
        match.setField(MatchType.TP_DST, dest.getPort());

        actions.add(new SetNwDst(InetAddress.getByName(destMachineIp)));
        actions.add(new SetDlDst(destMachineMac));
    }

    if(flowDirection == LBConst.REVERSE_DIRECTION_LB_FLOW){
        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.NW_SRC, InetAddress.getByName(destMachineIp));
        match.setField(MatchType.NW_DST, InetAddress.getByName(source.getIp()));
        match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(source.getProtocol()));
        match.setField(MatchType.TP_SRC, dest.getPort());
        match.setField(MatchType.TP_DST,source.getPort());

        actions.add(new SetNwSrc(InetAddress.getByName(dest.getIp())));
        actions.add(new SetDlSrc(destMachineMac));
    }

    actions.add(new Output(outport));

    // Make sure the priority for IP switch entries is
    // set to a level just above default drop entries

    Flow flow = new Flow(match, actions);
    flow.setIdleTimeout((short) 5);
    flow.setHardTimeout((short) 0);
    flow.setPriority(LB_IPSWITCH_PRIORITY);

    String policyName = source.getIp()+":"+source.getProtocol()+":"+source.getPort();
    String flowName =null;

    if(flowDirection == LBConst.FORWARD_DIRECTION_LB_FLOW){
        flowName = "["+policyName+":"+source.getIp() + ":"+dest.getIp()+"]";
    }

    if(flowDirection == LBConst.REVERSE_DIRECTION_LB_FLOW){

        flowName = "["+policyName+":"+dest.getIp() + ":"+source.getIp()+"]";
    }

    FlowEntry fEntry = new FlowEntry(policyName, flowName, flow, sourceSwitch);

    lbsLogger.info("Install flow entry {} on node {}",fEntry.toString(),sourceSwitch.toString());

    if(!this.ruleManager.checkFlowEntryConflict(fEntry)){
        if(this.ruleManager.installFlowEntry(fEntry).isSuccess()){
            return true;
        }else{
            lbsLogger.error("Error in installing flow entry to node : {}",sourceSwitch);
        }
    }else{
        lbsLogger.error("Conflicting flow entry exists : {}",fEntry.toString());
    }
    return false;
}
 

开发者ID:lbchen,
项目名称:ODL,
代码行数:73,
代码来源:LoadBalancerService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)