List of usage examples for com.google.common.util.concurrent Atomics newReference
public static <V> AtomicReference<V> newReference(@Nullable V initialValue)
From source file:org.jclouds.googlecomputeengine.compute.GoogleComputeEngineServiceAdapter.java
private void waitOperationDone(Operation operation) { AtomicReference<Operation> operationRef = Atomics.newReference(operation); // wait for the operation to complete if (!operationDone.apply(operationRef)) { throw new UncheckedTimeoutException("operation did not reach DONE state" + operationRef.get()); }/*from ww w . j a v a2 s . c o m*/ // check if the operation failed if (operationRef.get().httpErrorStatusCode() != null) { throw new IllegalStateException( "operation failed. Http Error Code: " + operationRef.get().httpErrorStatusCode() + " HttpError: " + operationRef.get().httpErrorMessage()); } }
From source file:org.apache.stratos.cloud.controller.iaases.gce.GCEIaas.java
private Operation waitGCEOperationDone(Operation operation) { IaasProvider iaasInfo = getIaasProvider(); Injector injector = ContextBuilder.newBuilder(iaasInfo.getProvider()) .credentials(iaasInfo.getIdentity(), iaasInfo.getCredential()).buildInjector(); Predicate<AtomicReference<Operation>> zoneOperationDonePredicate = injector .getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() { }, Names.named("zone"))); AtomicReference<Operation> operationReference = Atomics.newReference(operation); retry(zoneOperationDonePredicate, MAX_WAIT_TIME, 1, SECONDS).apply(operationReference); return operationReference.get(); }
From source file:org.apache.stratos.cloud.controller.iaases.GCEIaas.java
private Operation waitGCEOperationDone(Operation operation) { int maxWaitTime = 15; // 15 seconds IaasProvider iaasInfo = getIaasProvider(); Injector injector = ContextBuilder.newBuilder(iaasInfo.getProvider()) .credentials(iaasInfo.getIdentity(), iaasInfo.getCredential()).buildInjector(); Predicate<AtomicReference<Operation>> zoneOperationDonePredicate = injector .getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() { }, Names.named("zone"))); AtomicReference<Operation> operationReference = Atomics.newReference(operation); retry(zoneOperationDonePredicate, maxWaitTime, 1, SECONDS).apply(operationReference); return operationReference.get(); }
From source file:org.jclouds.compute.internal.BaseComputeService.java
/** * {@inheritDoc}//w w w. ja v a2 s . c om */ @Override public void rebootNode(String id) { checkNotNull(id, "id"); logger.debug(">> rebooting node(%s)", id); AtomicReference<NodeMetadata> node = Atomics.newReference(rebootNodeStrategy.rebootNode(id)); boolean successful = nodeRunning.apply(node); logger.debug("<< rebooted node(%s) success(%s)", id, successful); }
From source file:org.jclouds.compute.internal.BaseComputeService.java
/** * {@inheritDoc}/* w ww .j a v a 2 s. c o m*/ */ @Override public void resumeNode(String id) { checkNotNull(id, "id"); logger.debug(">> resuming node(%s)", id); AtomicReference<NodeMetadata> node = Atomics.newReference(resumeNodeStrategy.resumeNode(id)); boolean successful = nodeRunning.apply(node); logger.debug("<< resumed node(%s) success(%s)", id, successful); }
From source file:org.jclouds.compute.internal.BaseComputeService.java
/** * {@inheritDoc}// w w w. jav a 2 s.c o m */ @Override public void suspendNode(String id) { checkNotNull(id, "id"); logger.debug(">> suspending node(%s)", id); AtomicReference<NodeMetadata> node = Atomics.newReference(suspendNodeStrategy.suspendNode(id)); boolean successful = nodeSuspended.apply(node); logger.debug("<< suspended node(%s) success(%s)", id, successful); }