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


Java PoolMember.getIp方法代码示例

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


在下文中一共展示了PoolMember.getIp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPoolMemberForClient

import org.opendaylight.controller.samples.loadbalancer.entities.PoolMember; //导入方法依赖的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: getPoolMemberForClient

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

示例3: addPoolMember

import org.opendaylight.controller.samples.loadbalancer.entities.PoolMember; //导入方法依赖的package包/类
@Path("/{containerName}/create/poolmember")
@POST
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes( {
    @ResponseCode(code = 201, condition = "Pool member created successfully"),
    @ResponseCode(code = 404, condition = "The containerName not found"),
    @ResponseCode(code = 503, condition = "Load balancer service is unavailable"),
    @ResponseCode(code = 404, condition = "Pool not found"),
    @ResponseCode(code = 409, condition = "Pool member already exist"),
    @ResponseCode(code = 415, condition = "Invalid input data")})
public Response addPoolMember(@PathParam("containerName") String containerName,
        @TypeHint(PoolMember.class) JAXBElement<PoolMember> inPoolMember){

    PoolMember pmInput = inPoolMember.getValue();
    String name = pmInput.getName();
    String memberIP = pmInput.getIp();
    String poolName = pmInput.getPoolName();

    if(name.isEmpty() ||
            memberIP.isEmpty()||
            poolName.isEmpty()){
        throw new UnsupportedMediaTypeException(RestMessages.INVALIDDATA.toString());
    }

    IConfigManager configManager = getConfigManagerService(containerName);
    if (configManager == null) {
        throw new ServiceUnavailableException("Load Balancer "
                                    + RestMessages.SERVICEUNAVAILABLE.toString());
    }

    if(!configManager.poolExists(poolName))
        throw new ResourceNotFoundException(NBConst.RES_POOL_NOT_FOUND);

    if(!configManager.memberExists(name, memberIP, poolName)){

        PoolMember poolMember = configManager.addPoolMember(name, memberIP, poolName);
        if ( poolMember != null){
            return Response.status(Response.Status.CREATED).build();
        }
    }else{
        throw new ResourceConflictException(NBConst.RES_POOLMEMBER_ALREADY_EXIST);
    }
    throw new InternalServerErrorException(NBConst.RES_POOLMEMBER_CREATION_FAILED);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:45,代码来源:LoadBalancerNorthbound.java


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