protected String getServiceVIP(Service service, String requestedVip) { if (service.getKind().equalsIgnoreCase(KIND.LOADBALANCERSERVICE.name()) || service.getKind().equalsIgnoreCase(KIND.SERVICE.name()) || service.getKind().equalsIgnoreCase(KIND.DNSSERVICE.name())) { Subnet vipSubnet = getServiceVipSubnet(service); PooledResourceOptions options = new PooledResourceOptions(); if (requestedVip != null) { options.setRequestedItem(requestedVip); } PooledResource resource = poolManager.allocateOneResource(vipSubnet, service, options); if (resource != null) { return resource.getName(); } } return null; }
@Override public void releaseVip(Service service) { String vip = service.getVip(); if (vip == null) { return; } List<Subnet> subnets = objectManager.find( Subnet.class, SUBNET.ACCOUNT_ID, service.getAccountId(), SUBNET.KIND, SubnetConstants.KIND_VIP_SUBNET); if (subnets.isEmpty()) { return; } Subnet subnet = subnets.get(0); poolManager.releaseResource(subnet, service); }