Update load balancer list

@param loadBalancerList load balancer list
@param config load balancer config
@return OperationFuture wrapper for load balancer list
962267
public OperationFuture<List<LoadBalancer>> update(
            List<LoadBalancer> loadBalancerList,
            LoadBalancerConfig config
    ) {
        loadBalancerList.forEach(loadBalancer -> update(loadBalancer, config));

        return new OperationFuture<>(
            loadBalancerList,
            new NoWaitingJobFuture()
        );
    }
816981
public OperationFuture<Server> modifyPublicIp(Server server, ModifyPublicIpConfig config) {
        checkNotNull(config, CHECK_PUBLIC_IP_CONFIG);
        List<IpAddress> ipAddresses = findByRef(server).getDetails().getIpAddresses();

        List<String> responseIds = ipAddresses.stream()
            .map(IpAddress::getPublicIp)
            .filter(notNull())
            .map(ipAddress ->
                client.modifyPublicIp(idByRef(server),
                    ipAddress,
                    publicIpConverter.createPublicIpRequest(config)))
            .map(Link::getId)
            .collect(toList());

        return new OperationFuture<>(
            server,
            responseIds,
            queueClient
        );
    }
1301803
def cli(env, identifier, allocation, port, routing_type, routing_method):
    """"""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    mgr.add_service_group(loadbal_id,
                          allocation=allocation,
                          port=port,
                          routing_type=routing_type,
                          routing_method=routing_method)

    env.fout('Load balancer service group is being added!')
1181407
private List<LoadBalancer> findLoadBalancers(@Nullable String loadBalancerId) throws CloudException, InternalException {
        APITrace.begin(getProvider(), "LB.listLoadBalancers");
        try {
            // get all vips, optionally filtered by lbId
            List<JSONObject> listeners = findAllVips(loadBalancerId);

            // get all members, optionally filtered by lbId
            List<JSONObject> members = findAllMembers(loadBalancerId);

            NovaMethod method = new NovaMethod(getProvider());
            // Unlike Horizon the OS LB API returns all tenants' load balancers, so we must filter
            JSONObject result = method.getNetworks(getLoadBalancersResource(), loadBalancerId, false, "?tenant_id="+getContext().getAccountNumber());
            List<LoadBalancer> results = new ArrayList<LoadBalancer>();
            if( loadBalancerId == null && result != null && result.has("pools") ) {
                try {
                    JSONArray loadbalancers = result.getJSONArray("pools");
                    for( int i = 0; i < loadbalancers.length(); i++ ) {
                        JSONObject lb = loadbalancers.getJSONObject(i);
                        results.add(toLoadBalancer(lb, listeners, members));
                    }
                }
                catch( JSONException e ) {
                    logger.error("Unable to understand listPools response: " + e.getMessage());
                    throw new CloudException(e);
                }
            }
            else if( result != null && result.has("pool")) {
                try {
                    return Collections.singletonList(toLoadBalancer(result.getJSONObject("pool"), listeners, members));
                }
                catch( JSONException e ) {
                    logger.error("Unable to understand getPool response: " + e.getMessage());
                    throw new CloudException(e);
                }
            }

            return results;
        }
        finally {
            APITrace.end();
        }
    }
845178
public OperationFuture<FirewallPolicy> update(FirewallPolicy firewallPolicy, FirewallPolicyConfig config) {
        FirewallPolicyMetadata metadata = findByRef(firewallPolicy);

        firewallPolicyClient.update(
            metadata.getDataCenterId(),
            metadata.getId(),
            composeFirewallPolicyRequest(config)
        );

        return new OperationFuture<>(
            firewallPolicy,
            new NoWaitingJobFuture()
        );
    }
1242297
public OperationFuture<List<LoadBalancerPool>> update(
            LoadBalancerPoolFilter loadBalancerPoolFilter,
            LoadBalancerPoolConfig config
    ) {
        checkNotNull(loadBalancerPoolFilter, "Load balancer pool filter must be not null");

        List<LoadBalancerPool> loadBalancerPoolList = findLazy(loadBalancerPoolFilter)
            .map(metadata -> LoadBalancerPool.refById(
                metadata.getId(),
                LoadBalancer.refById(
                    metadata.getLoadBalancerId(),
                    DataCenter.refById(metadata.getDataCenterId())
                )
            ))
            .collect(toList());

        return update(loadBalancerPoolList, config);
    }
901628
public synchronized void updateFromConfiguration(CmsUgcConfiguration config) {

        m_enabled = config.needsQueue();
        m_interval = config.getQueueInterval().isPresent() ? config.getQueueInterval().get().longValue() : 0;
        m_maxLength = config.getMaxQueueLength().isPresent()
        ? config.getMaxQueueLength().get().intValue()
        : Integer.MAX_VALUE;
    }
426012
@SuppressWarnings("unchecked")
  @VisibleForTesting
  public static List<Map<String, ?>> getLoadBalancingConfigsFromServiceConfig(
      Map<String, ?> serviceConfig) {
    /* schema as follows
    {
      "loadBalancingConfig": [
        {"xds" :
          {
            "balancerName": "balancer1",
            "childPolicy": [...],
            "fallbackPolicy": [...],
          }
        },
        {"round_robin": {}}
      ],
      "loadBalancingPolicy": "ROUND_ROBIN"  // The deprecated policy key
    }
    */
    List<Map<String, ?>> lbConfigs = new ArrayList<>();
    if (serviceConfig.containsKey(SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY)) {
      List<?> configs = getList(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY);
      for (Map<String, ?> config : checkObjectList(configs)) {
        lbConfigs.add(config);
      }
    }
    if (lbConfigs.isEmpty()) {
      // No LoadBalancingConfig found.  Fall back to the deprecated LoadBalancingPolicy
      if (serviceConfig.containsKey(SERVICE_CONFIG_LOAD_BALANCING_POLICY_KEY)) {
        // TODO(zhangkun83): check if this is null.
        String policy = getString(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_POLICY_KEY);
        // Convert the policy to a config, so that the caller can handle them in the same way.
        policy = policy.toLowerCase(Locale.ROOT);
        Map<String, ?> fakeConfig = Collections.singletonMap(policy, Collections.emptyMap());
        lbConfigs.add(fakeConfig);
      }
    }
    return Collections.unmodifiableList(lbConfigs);
  }
1232979
public OperationFuture<Server> addSecondaryNetwork(Server server, AddNetworkConfig config) {
        ServerMetadata serverMetadata = findByRef(server);

        NetworkLink link = client.addSecondaryNetwork(
            idByRef(server),
            buildSecondaryNetworkRequest(config, serverMetadata.getLocationId())
        );

        return new OperationFuture<>(
            server,
            link.getOperationId(),
            experimentalQueueClient
        );
    }
1087290
public static String getServerFromBalancer(String balancerUrl,String applicationKey, Proxy proxy) throws IOException, InvalidBalancerServerException {
		Matcher protocolMatcher = urlProtocolPattern.matcher(balancerUrl);

		String protocol = protocolMatcher.matches() ? "" : protocolMatcher.group(1);

		String parsedUrl = String.format("%s%s", protocol, balancerUrl);

		if(!Strings.isNullOrEmpty(applicationKey)){
			// CAUSE: Prefer String.format to +
			parsedUrl += String.format("?appkey=%s", applicationKey);
		}

		URL url = new URL(parsedUrl);

		String balancer = IOUtil.doGetRequest(url, proxy);
		Matcher matcher = balancerServerPattern.matcher(balancer);
		if (!matcher.matches()) {
			throw new InvalidBalancerServerException(balancer);
		}
		return matcher.group(1);
	}
86772
public OperationFuture<List<LoadBalancer>> delete(LoadBalancer... loadBalancer) {
        return delete(Arrays.asList(loadBalancer));
    }
802001
private void addLoadBalancerListener() {
        if (!(lbContext.getLoadBalancer() instanceof BaseLoadBalancer)) {
            return;
        }
        
        ((BaseLoadBalancer) lbContext.getLoadBalancer()).addServerListChangeListener(new ServerListChangeListener() {
            @Override
            public void serverListChanged(List<Server> oldList, List<Server> newList) {
                Set<Server> removedServers = new HashSet<Server>(oldList);
                removedServers.removeAll(newList);
                for (Server server: rxClientCache.keySet()) {
                    if (removedServers.contains(server)) {
                        // this server is no longer in UP status
                        removeClient(server);
                    }
                }
            }
        });
    }
405852
public CompletableFuture<UpdateStreamStatus.Status> updateStream(String scope, String stream, StreamConfiguration newConfig,
                                                                     OperationContext contextOpt) {
        final OperationContext context = contextOpt == null ? streamMetadataStore.createContext(scope, stream) : contextOpt;
        final long requestId = requestTracker.getRequestIdFor("updateStream", scope, stream);

        // 1. get configuration
        return streamMetadataStore.getConfigurationRecord(scope, stream, context, executor)
                .thenCompose(configProperty -> {
                    // 2. post event to start update workflow
                    if (!configProperty.getObject().isUpdating()) {
                        return addIndexAndSubmitTask(new UpdateStreamEvent(scope, stream, requestId), 
                                // 3. update new configuration in the store with updating flag = true
                                // if attempt to update fails, we bail out with no harm done
                                () -> streamMetadataStore.startUpdateConfiguration(scope, stream, newConfig,
                                        context, executor))
                                // 4. wait for update to complete
                                .thenCompose(x -> checkDone(() -> isUpdated(scope, stream, newConfig, context))
                                        .thenApply(y -> UpdateStreamStatus.Status.SUCCESS));
                    } else {
                        log.warn(requestId, "Another update in progress for {}/{}",
                                scope, stream);
                        return CompletableFuture.completedFuture(UpdateStreamStatus.Status.FAILURE);
                    }
                })
                .exceptionally(ex -> {
                    log.warn(requestId, "Exception thrown in trying to update stream configuration {}",
                            ex.getMessage());
                    return handleUpdateStreamError(ex, requestId);
                });
    }
169832
public OperationFuture<List<Network>> update(NetworkFilter filter, UpdateNetworkConfig config) {
        checkFilter(filter);

        List<Network> networkList = findLazy(filter)
            .map(metadata -> Network.refById(metadata.getId()))
            .collect(toList());

        return update(networkList, config);
    }
741628
public OperationFuture<List<Server>> addPublicIp(List<Server> servers, CreatePublicIpConfig publicIpConfig) {
        checkNotNull(servers, "Server list must be not null");
        checkNotNull(publicIpConfig, CHECK_PUBLIC_IP_CONFIG);

        List<JobFuture> futures = servers.stream()
            .map(serverRef -> addPublicIp(serverRef, publicIpConfig).jobFuture())
            .collect(toList());

        return new OperationFuture<>(
            servers,
            new ParallelJobsFuture(futures)
        );
    }
1051245
public void setNetworkLoadBalancerArns(java.util.Collection<String> networkLoadBalancerArns) {
        if (networkLoadBalancerArns == null) {
            this.networkLoadBalancerArns = null;
            return;
        }

        this.networkLoadBalancerArns = new com.amazonaws.internal.SdkInternalList<String>(networkLoadBalancerArns);
    }
1070429
public OperationFuture<List<Server>> modify(List<Server> serverList, ModifyServerConfig modifyServerConfig) {
        List<JobFuture> futures = serverList.stream()
            .map(
                server ->
                    modify(server, modifyServerConfig).jobFuture()
            )
            .collect(toList());

        return new OperationFuture<>(
            serverList,
            new ParallelJobsFuture(futures)
        );
    }