@Override public void addToLoadBalancerService(Service lbSvc, ServiceExposeMap instanceToRegister) { if (!lbSvc .getKind() .equalsIgnoreCase(ServiceDiscoveryConstants.KIND.LOADBALANCERSERVICE.name())) { return; } if (!isActiveService(lbSvc)) { return; } if (!exposeMapDao.isActiveMap(instanceToRegister)) { return; } LoadBalancer lb = objectManager.findOne( LoadBalancer.class, LOAD_BALANCER.SERVICE_ID, lbSvc.getId(), LOAD_BALANCER.REMOVED, null); if (lb == null) { return; } ServiceConsumeMap map = consumeMapDao.findNonRemovedMap(lbSvc.getId(), instanceToRegister.getServiceId(), null); if (map == null) { return; } LoadBalancerTargetInput target = new LoadBalancerTargetInput(instanceToRegister, map, jsonMapper); lbService.addTargetToLoadBalancer(lb, target); }
private void createNewServiceMaps(Service service, Map<Long, String> newServiceLinks) { for (Long consumedServiceId : newServiceLinks.keySet()) { String linkName = newServiceLinks.get(consumedServiceId); ServiceConsumeMap map = consumeMapDao.findNonRemovedMap(service.getId(), consumedServiceId, linkName); if (map == null) { map = objectManager.create( ServiceConsumeMap.class, SERVICE_CONSUME_MAP.SERVICE_ID, service.getId(), SERVICE_CONSUME_MAP.CONSUMED_SERVICE_ID, consumedServiceId, SERVICE_CONSUME_MAP.ACCOUNT_ID, service.getAccountId(), SERVICE_CONSUME_MAP.NAME, linkName); } if (map.getState().equalsIgnoreCase(CommonStatesConstants.REQUESTED)) { objectProcessManager.scheduleProcessInstanceAsync( ServiceDiscoveryConstants.PROCESS_SERVICE_CONSUME_MAP_CREATE, map, null); } } }