Package org.jclouds.compute.strategy

Examples of org.jclouds.compute.strategy.GetNodeMetadataStrategy


   @SuppressWarnings("unchecked")
   @Test
   public void testDestroyNodeSafeOnCacheExecutionExceptionThenTerminatesInstanceAndReturnsRefreshedNode()
            throws Exception {
      EC2Api client = createMock(EC2Api.class);
      GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class);
      LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);
      ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class);
      InstanceApi instanceClient = createMock(InstanceApi.class);

      NodeMetadata node = createMock(NodeMetadata.class);

      expect(elasticIpCache.get(new RegionAndName("region", "i-blah"))).andThrow(new ExecutionException(null));

      expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce();
      expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null);
      expect(getNode.getNode("region/i-blah")).andReturn(node);

      replay(client);
      replay(getNode);
      replay(elasticIpCache);
      replay(instanceClient);
View Full Code Here


   private GetNodeMetadataStrategy computeService;

   @Test
   public void testNoUpdatesAtomicReferenceOnPass() {
      NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(running);
View Full Code Here

   }

   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckPending() {
      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(pending);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(pending);
View Full Code Here

      LoginCredentials creds2 = LoginCredentials.builder().user("user").password("password2").build();

      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).credentials(creds2).build();
     
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(pending);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(newNode);
View Full Code Here

  
   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckRunning() {
      NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(running);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(pending);
View Full Code Here

      PollPeriod period = new PollPeriod();

      final NodeMetadata pendingNode = new NodeMetadataBuilder().ids(nodeId).status(Status.PENDING).build();
      final NodeMetadata runningNode = new NodeMetadataBuilder().ids(nodeId).status(Status.RUNNING).build();
      GetNodeMetadataStrategy nodeClient = createMock(GetNodeMetadataStrategy.class);
      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(nodeClient);
      Predicate<AtomicReference<NodeMetadata>> retryableNodeRunning = new ComputeServiceTimeoutsModule() {
         public Predicate<AtomicReference<NodeMetadata>> nodeRunning(AtomicNodeRunning statusRunning,
               Timeouts timeouts, PollPeriod period) {
            return super.nodeRunning(statusRunning, timeouts, period);
         }
      }.nodeRunning(nodeRunning, timeouts, period);
      AtomicReference<NodeMetadata> atomicNode = Atomics.newReference(pendingNode);

      // Simulate transient error: first call returns null; subsequent calls
      // return the running node
      EasyMock.expect(nodeClient.getNode(nodeId)).andAnswer(new IAnswer<NodeMetadata>() {
         private int count = 0;

         @Override
         public NodeMetadata answer() throws Throwable {
            count++;
View Full Code Here

   private GetNodeMetadataStrategy computeService;

   @Test
   public void testNoUpdatesAtomicReferenceOnPass() {
      NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(running);
View Full Code Here

   }

   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckPending() {
      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(pending);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(pending);
View Full Code Here

      LoginCredentials creds2 = LoginCredentials.builder().user("user").password("password2").build();

      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).credentials(creds2).build();
     
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(pending);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(newNode);
View Full Code Here

  
   @Test
   public void testRefreshUpdatesAtomicReferenceOnRecheckRunning() {
      NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
      NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
      GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);

      expect(computeService.getNode("myid")).andReturn(running);

      replay(computeService);

      AtomicNodeRunning nodeRunning = new AtomicNodeRunning(computeService);
      AtomicReference<NodeMetadata> reference = Atomics.newReference(pending);
View Full Code Here

TOP

Related Classes of org.jclouds.compute.strategy.GetNodeMetadataStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.