/** * For the given zone and client type, we add the instances created to the clients array, for the * base controller. */ private void addInstanceGroupInfo(String zone, ClientParams params) throws IOException { InstanceGroupManagersListManagedInstancesResponse response; do { response = compute.instanceGroupManagers(). listManagedInstances(projectName, zone, "cps-loadtest-" + params.getClientType() + "-" + cores).execute(); // If we are not instantiating any instances of this type, just return. if (response.getManagedInstances() == null) { return; } } while (!response.getManagedInstances().stream() .allMatch(i -> i.getCurrentAction().equals("NONE"))); for (ManagedInstance managedInstance : response.getManagedInstances()) { String instanceName = managedInstance.getInstance() .substring(managedInstance.getInstance().lastIndexOf('/') + 1); Instance instance = compute.instances().get(projectName, zone, instanceName).execute(); synchronized (this) { clients.add(new Client( params.getClientType(), instance.getNetworkInterfaces().get(0).getAccessConfigs().get(0).getNatIP(), projectName, params.subscription, executor)); } } }
@Override public List<ManagedInstance> listInstances() throws GceException { try { List<ManagedInstance> instances = this.apiClient.instanceGroupManagers() .listManagedInstances(this.group.getProject(), this.group.getZone(), this.group.getName()).execute() .getManagedInstances(); return instances != null ? instances : Collections.emptyList(); } catch (IOException e) { throw GceErrors .wrap(String.format("failed to get members of instance group %s in project %s and zone %s: %s", this.group.getName(), this.group.getProject(), this.group.getZone(), e.getMessage()), e); } }
.listManagedInstances(account.getProject(), settings.getLocation(), mig.getName()) .execute() .getManagedInstances();
.listManagedInstances(account.getProject(), settings.getLocation(), mig.getName()) .execute() .getManagedInstances();