List of usage examples for java.util.concurrent TimeoutException TimeoutException
public TimeoutException(String message)
From source file:org.openspaces.admin.internal.gsm.DefaultGridServiceManager.java
private void verifyInstancesNotUndeploying(List<ProcessingUnitInstance> instancesPendingRemoval) throws TimeoutException { for (ProcessingUnitInstance instance : instancesPendingRemoval) { if (isProcessingUnitInstanceUndeploying(instance)) { throw new TimeoutException("Instance " + instance.getProcessingUnitInstanceName() + " UID=" + instance.getUid() + " is still undeploying."); }/*from w w w. j a v a 2 s .c o m*/ } }
From source file:org.openspaces.admin.internal.gsm.DefaultGridServiceManager.java
private void verifyUndeployComplete(ProcessingUnit[] processingUnits) throws TimeoutException { for (ProcessingUnit pu : processingUnits) { // check that all pu instances have been undiscovered and not managed by ESM int numberOfInstances = pu.getInstances().length; if (numberOfInstances > 0) { throw new TimeoutException( pu.getName() + " is still undeploying " + numberOfInstances + " instances"); }/*ww w.j av a2 s . co m*/ if (pu.getSpace() != null) { throw new TimeoutException(pu.getName() + " still has an embedded space"); } if (isManagedByElasticServiceManager(pu)) { throw new TimeoutException(pu.getName() + " undeployment is in progress (removing containers and machines if applicable)"); } } }
From source file:org.openspaces.admin.internal.gsm.DefaultGridServiceManager.java
private void verifyNotDiscovered(Iterable<? extends GridComponent> componentsPendingShutdown) throws TimeoutException { for (final GridComponent component : componentsPendingShutdown) { if (component.isDiscovered()) { throw new TimeoutException(component.getUid() + " is still discovered"); }//w w w . j a va 2 s .c o m } }
From source file:org.cloudifysource.rest.controllers.ServiceController.java
private void deployAndWait(final String serviceName, final ElasticSpaceDeployment deployment) throws TimeoutException { final ProcessingUnit pu = getGridServiceManager().deploy(deployment, 60, TimeUnit.SECONDS); if (pu == null) { throw new TimeoutException("Timed out waiting for Service " + serviceName + " deployment."); }/* ww w.j a v a 2 s. c o m*/ }
From source file:org.cloudifysource.esc.driver.provisioning.azure.client.MicrosoftAzureRestClient.java
private ClientResponse doGet(final String url) throws MicrosoftAzureException, TimeoutException { ClientResponse response = null;//w ww . j a v a2s. c om for (int i = 0; i < MAX_RETRIES; i++) { try { response = resource.path(subscriptionId + url) .header(X_MS_VERSION_HEADER_NAME, X_MS_VERSION_HEADER_VALUE) .header(CONTENT_TYPE_HEADER_NAME, CONTENT_TYPE_HEADER_VALUE).get(ClientResponse.class); break; } catch (ClientHandlerException e) { logger.warning( "Caught an exception while executing GET with url " + url + ". Message :" + e.getMessage()); logger.warning("Retrying request"); continue; } } if (response == null) { throw new TimeoutException("Timed out while executing GET after " + MAX_RETRIES); } return response; }
From source file:org.cloudifysource.esc.driver.provisioning.azure.client.MicrosoftAzureRestClient.java
private Deployment waitForDeploymentStatus(final String state, final String hostedServiceName, final String deploymentSlot, final long endTime) throws TimeoutException, MicrosoftAzureException, InterruptedException { while (true) { Deployment deployment = getDeploymentByDeploymentSlot(hostedServiceName, deploymentSlot); String status = deployment.getStatus(); if (status.equals(state)) { return deployment; } else {/*from w w w .ja v a 2 s.c o m*/ Thread.sleep(DEFAULT_POLLING_INTERVAL); } if (System.currentTimeMillis() > endTime) { throw new TimeoutException("Timed out waiting for operation to finish. last state was : " + status); } } }
From source file:org.cloudifysource.esc.driver.provisioning.azure.client.MicrosoftAzureRestClient.java
private Deployment waitForRoleInstanceStatus(final String state, final String hostedServiceName, final String deploymentSlot, final long endTime) throws TimeoutException, MicrosoftAzureException, InterruptedException { while (true) { Deployment deployment = getDeploymentByDeploymentSlot(hostedServiceName, deploymentSlot); String roleName = deployment.getRoleList().getRoles().get(0).getRoleName(); String status = deployment.getRoleInstanceList().getRoleInstances().get(0).getInstanceStatus(); boolean error = checkVirtualMachineStatusForError(status); if (error) { // bad status of VM. throw new MicrosoftAzureException( "Virtual Machine " + roleName + " was provisioned but found in status " + status); }// w w w. j a va 2s . c o m if (status.equals(state)) { return deployment; } else { Thread.sleep(DEFAULT_POLLING_INTERVAL); } if (System.currentTimeMillis() > endTime) { throw new TimeoutException("Timed out waiting for operation to finish. last state was : " + status); } } }
From source file:org.cloudifysource.esc.driver.provisioning.azure.client.MicrosoftAzureRestClient.java
private void waitForRequestToFinish(final String requestId, final long endTime) throws MicrosoftAzureException, TimeoutException, InterruptedException { while (true) { // Query Azure for operation details Operation operation = getOperation(requestId); String status = operation.getStatus(); if (!status.equals(IN_PROGRESS)) { // if operation succeeded, we are good to go if (status.equals(SUCCEEDED)) { return; }/*from ww w .j a v a 2s. com*/ if (status.equals(FAILED)) { String errorMessage = operation.getError().getMessage(); String errorCode = operation.getError().getCode(); throw new MicrosoftAzureException(errorCode, errorMessage); } } else { Thread.sleep(DEFAULT_POLLING_INTERVAL); } if (System.currentTimeMillis() > endTime) { throw new TimeoutException("Timed out waiting for operation to finish. last state was : " + status); } } }
From source file:org.cloudifysource.esc.driver.provisioning.privateEc2.PrivateEC2CloudifyDriver.java
@Override public MachineDetails[] startManagementMachines(final long duration, final TimeUnit unit) throws TimeoutException, CloudProvisioningException { if (duration < 0) { throw new TimeoutException("Starting a new machine timed out"); }//from ww w. j a va 2s. co m final long endTime = System.currentTimeMillis() + unit.toMillis(duration); logger.fine("DefaultCloudProvisioning: startMachine - management == " + management); try { final File cloudDirectory = new ProvisioningContextAccess().getManagementProvisioiningContext() .getCloudFile().getParentFile(); this.cloud.getCustom().put("###CLOUD_DIRECTORY###", cloudDirectory); this.privateEc2Template = this.getManagerPrivateEc2Template(cloudDirectory, this.managerCfnTemplateFileName); } catch (PrivateEc2ParserException e) { throw new CloudProvisioningException("Failed to read management template: " + e.getMessage(), e); } catch (IOException e) { throw new CloudProvisioningException("Failed to read management template: " + e.getMessage(), e); } final String managementMachinePrefix = this.cloud.getProvider().getManagementGroup(); if (org.apache.commons.lang.StringUtils.isBlank(managementMachinePrefix)) { throw new CloudProvisioningException( "The management group name is missing - can't locate existing servers!"); } // first check if management already exists final MachineDetails[] existingManagementServers = this.getManagementServersMachineDetails(); if (existingManagementServers.length > 0) { final String serverDescriptions = this.createExistingServersDescription(managementMachinePrefix, existingManagementServers); throw new CloudProvisioningException( "Found existing servers matching group " + managementMachinePrefix + ": " + serverDescriptions); } // launch the management machines final int numberOfManagementMachines = this.cloud.getProvider().getNumberOfManagementMachines(); MachineDetails[] createdMachines; try { createdMachines = this.doStartManagementMachines(numberOfManagementMachines, endTime, unit); } catch (final PrivateEc2ParserException e) { throw new CloudProvisioningException(e); } return createdMachines; }