protected void createListener( Service service, Map<Integer, LoadBalancerListener> listeners, LoadBalancerListenerPort port) { LoadBalancerListener listenerObj = objectManager.findOne( LoadBalancerListener.class, LOAD_BALANCER_LISTENER.SERVICE_ID, service.getId(), LOAD_BALANCER_LISTENER.SOURCE_PORT, port.getSourcePort(), LOAD_BALANCER_LISTENER.PRIVATE_PORT, port.getPrivatePort(), LOAD_BALANCER_LISTENER.TARGET_PORT, port.getTargetPort(), LOAD_BALANCER_LISTENER.REMOVED, null, LOAD_BALANCER_LISTENER.ACCOUNT_ID, service.getAccountId()); if (listenerObj == null) { listenerObj = objectManager.create( LoadBalancerListener.class, LOAD_BALANCER_LISTENER.NAME, getLoadBalancerName(service) + "_" + port.getPrivatePort(), LOAD_BALANCER_LISTENER.ACCOUNT_ID, service.getAccountId(), LOAD_BALANCER_LISTENER.SOURCE_PORT, port.getSourcePort(), LOAD_BALANCER_LISTENER.PRIVATE_PORT, port.getPrivatePort(), LOAD_BALANCER_LISTENER.TARGET_PORT, port.getTargetPort(), LOAD_BALANCER_LISTENER.SOURCE_PROTOCOL, port.getProtocol(), LOAD_BALANCER_LISTENER.TARGET_PROTOCOL, port.getProtocol(), LoadBalancerConstants.FIELD_LB_LISTENER_ALGORITHM, "roundrobin", LOAD_BALANCER_LISTENER.ACCOUNT_ID, service.getAccountId(), LOAD_BALANCER_LISTENER.SERVICE_ID, service.getId()); } objectProcessManager.executeProcess( LoadBalancerConstants.PROCESS_LB_LISTENER_CREATE, listenerObj, null); listeners.put(listenerObj.getPrivatePort(), listenerObj); }
private LoadBalancerConfig createDefaultLoadBalancerConfig( String defaultName, Map<String, Object> lbConfigData, Service service) { String name = lbConfigData.get("name") == null ? defaultName : lbConfigData.get("name").toString(); LoadBalancerConfig lbConfig = objectManager.findOne( LoadBalancerConfig.class, LOAD_BALANCER_CONFIG.REMOVED, null, LOAD_BALANCER_CONFIG.ACCOUNT_ID, service.getAccountId(), LOAD_BALANCER_CONFIG.SERVICE_ID, service.getId()); if (lbConfig == null) { lbConfigData.put("accountId", service.getAccountId()); lbConfigData.put("name", name); lbConfigData.put("serviceId", service.getId()); lbConfig = objectManager.create(LoadBalancerConfig.class, lbConfigData); } objectProcessManager.executeProcess( LoadBalancerConstants.PROCESS_LB_CONFIG_CREATE, lbConfig, null); return lbConfig; }
private void createLoadBalancer( Service service, String lbName, LoadBalancerConfig lbConfig, Map<String, Object> launchConfigData, List<? extends Long> certIds, Long defaultCertId) { LoadBalancer lb = objectManager.findOne( LoadBalancer.class, LOAD_BALANCER.SERVICE_ID, service.getId(), LOAD_BALANCER.REMOVED, null, LOAD_BALANCER.ACCOUNT_ID, service.getAccountId()); Map<String, Object> data = populateLBData(service, lbName, lbConfig, launchConfigData, certIds, defaultCertId); if (lb == null) { lb = objectManager.create(LoadBalancer.class, data); } objectProcessManager.executeProcess(LoadBalancerConstants.PROCESS_LB_CREATE, lb, data); }