当前位置: 首页>>代码示例>>Java>>正文


Java Client类代码示例

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


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

示例1: getPoolMemberForClient

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的package包/类
@Override
public String getPoolMemberForClient(Client source, VIP dest){

    rLogger.info("Received traffic from client : {} for VIP : {} ",source, dest);

    syncWithLoadBalancerData();

    PoolMember pm= null;

    if(this.clientMemberMap.containsKey(source)){
        pm= this.clientMemberMap.get(source);
        rLogger.info("Client {} had sent traffic before,new traffic will be routed to the same pool member {}",source,pm);
    }else{
        Pool pool = null;
        pool = this.cmgr.getPool(dest.getPoolName());
        int memberNum = this.randomGenerator.nextInt(pool.getAllMembers().size()-1);
        pm = pool.getAllMembers().get(memberNum);
        this.clientMemberMap.put(source, pm );
        rLogger.info("Network traffic from client {} will be directed to pool member {}",pm);
    }
    return pm.getIp();
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:RandomLBPolicy.java

示例2: installLoadBalancerFlow

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的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

示例3: RoundRobinLBPolicy

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的package包/类
public RoundRobinLBPolicy(ConfigManager cmgr){
    this.cmgr = cmgr;
    this.clientMemberMap = new HashMap<Client, PoolMember>();
    this.nextItemFromPool = new HashMap<VIP, Integer>();
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:6,代码来源:RoundRobinLBPolicy.java

示例4: getPoolMemberForClient

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的package包/类
@Override
public String getPoolMemberForClient(Client source, VIP dest){

    rrLogger.info("Received traffic from client : {} for VIP : {} ",source, dest);

    syncWithLoadBalancerData();

    PoolMember pm= null;

    if(this.clientMemberMap.containsKey(source)){

        pm= this.clientMemberMap.get(source);
        rrLogger.info("Client {} had sent traffic before,new traffic will be routed to the same pool member {}",source,pm);
    }else{

        Pool pool = null;
        if(nextItemFromPool.containsKey(dest)){

            int memberNum = nextItemFromPool.get(dest).intValue();
            rrLogger.debug("Packet is from new client for VIP {}",dest);
            pool = this.cmgr.getPool(dest.getPoolName());
            pm = pool.getAllMembers().get(memberNum);
            this.clientMemberMap.put(source, pm );
            rrLogger.info("New client's packet will be directed to pool member {}",pm);
            memberNum++;

            if(memberNum > pool.getAllMembers().size()-1){
                memberNum = 0;
            }
            rrLogger.debug("Next pool member for new client of VIP is set to {}",pool.getAllMembers().get(memberNum));

            this.nextItemFromPool.put(dest, new Integer(memberNum));
        }else{
            rrLogger.debug("Network traffic for VIP : {} has appeared first time from client {}",dest,source);
            pool = this.cmgr.getPool(dest.getPoolName());
            pm = pool.getAllMembers().get(0);
            this.clientMemberMap.put(source, pm);

            rrLogger.info("Network traffic from client {} will be directed to pool member {}",pm);
            this.nextItemFromPool.put(dest, new Integer(1));
            rrLogger.debug("Next pool member for new client of VIP is set to {}",pool.getAllMembers().get(1));
        }
    }
    return pm.getIp();
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:46,代码来源:RoundRobinLBPolicy.java

示例5: RandomLBPolicy

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的package包/类
public RandomLBPolicy(ConfigManager cmgr){
    this.cmgr = cmgr;
    this.clientMemberMap = new HashMap<Client, PoolMember>();
    randomGenerator = new Random();
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:6,代码来源:RandomLBPolicy.java

示例6: getClientFromPacket

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的package包/类
/**
 * Extract the details of the source machine that sent this packet 'inPkt'
 * @param inPkt Packet that is received by the controller
 * @return  Details of the source machine in Client object.
 */
public Client getClientFromPacket(IPv4 inPkt){
    lbuLogger.info("Find client information from packet : {}",inPkt.toString());

    String ip = NetUtils.getInetAddress(inPkt.getSourceAddress()).getHostAddress();

    String protocol = IPProtocols.getProtocolName(inPkt.getProtocol());

    lbuLogger.info("client ip {} and protocl {}",ip,protocol);

    Packet tpFrame= inPkt.getPayload();

    lbuLogger.info("Get protocol layer {}",tpFrame.toString());

    short port = 0;

    if(protocol.equals(IPProtocols.TCP.toString())){
        TCP tcpFrame = (TCP)tpFrame;
        port = tcpFrame.getSourcePort();
    }else{
        UDP udpFrame = (UDP)tpFrame;
        port = udpFrame.getSourcePort();
    }

    lbuLogger.info("Found port {}",port);

    Client source = new Client(ip, protocol,port);

    lbuLogger.info("Client information : {}",source.toString());

    return source;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:37,代码来源:LBUtil.java

示例7: getPoolMemberForClient

import org.opendaylight.controller.samples.loadbalancer.entities.Client; //导入依赖的package包/类
/**
 * Returns IP address of the next pool member from the pool
 * to which the load balancer service can direct incoming packets.
 * @param source    source on the packet
 * @param dest      virtual IP (VIP) that is used as destination on the packet
 * @return  IP address of the next pool member which will serve
 *          all incoming traffic destined for the given VIP and with the given source
 *          information
 */
public String getPoolMemberForClient(Client source, VIP dest);
 
开发者ID:lbchen,项目名称:ODL,代码行数:11,代码来源:ILoadBalancingPolicy.java


注:本文中的org.opendaylight.controller.samples.loadbalancer.entities.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。