Package org.jclouds.compute

Examples of org.jclouds.compute.ComputeServiceContext


   public void testCanBuildWithOverridingProperties() {
      Properties overrides = new Properties();
      overrides.setProperty("smartos-ssh.endpoint", "http://host");
      overrides.setProperty("smartos-ssh.api-version", "1");

      ComputeServiceContext context = ContextBuilder.newBuilder("smartos-ssh")
               .modules(ImmutableSet.<Module> of(getSshModule())).overrides(overrides)
               .build(ComputeServiceContext.class);

      context.close();
   }
View Full Code Here


      context.close();
   }

   @Test
   public void testUnwrapIsCorrectType() {
      ComputeServiceContext context = ContextBuilder.newBuilder("smartos-ssh")
               .modules(ImmutableSet.<Module> of(getSshModule())).build(ComputeServiceContext.class);

      assertEquals(context.unwrap().getClass(), ContextImpl.class);

      context.close();
   }
View Full Code Here

      return Suppliers.memoize(new Supplier<ComputeService>() {

         @Override
         public ComputeService get() {
            Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null");
            ComputeServiceContext ctx = ContextBuilder.newBuilder(provider)
                  .credentials(currentCreds.identity, currentCreds.credential).overrides(overrides.get())
                  .modules(modules).buildView(ComputeServiceContext.class);
            closer.addToClose(ctx);
            return ctx.getComputeService();
         }

      });
   }
View Full Code Here

@Test
public class ComputeConversionsTest {

   private ComputeService getCompute() {
      ComputeServiceContext context = ContextBuilder.newBuilder("stub").name("test-stub").credentials("user", "pass").build(ComputeServiceContext.class);
      return context.getComputeService();
   }
View Full Code Here

    handlerMap.put("hadoop-namenode", handler);
    handlerMap.put("hadoop-datanode", handler);
    handlerMap.put("hadoop-tasktracker", handler);

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
   
    // here is a scenario when jt+nn fails once, then the retry is successful
View Full Code Here

    handlerMap.put("hadoop-namenode", handler);
    handlerMap.put("hadoop-datanode", handler);
    handlerMap.put("hadoop-tasktracker", handler);

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
   
    // here is a scenario when jt+nn does not fail
View Full Code Here

    Map<String, ClusterActionHandler> handlerMap = HandlerMapFactory.create(ImmutableSet.of(puppetHandlerFactory),
          ImmutableSet.of(handler));

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
   
    Map<Set<String>, Stack<Integer>> reaction = Maps.newHashMap();
View Full Code Here

    Map<String, ClusterActionHandler> handlerMap = HandlerMapFactory.create(
      ImmutableSet.of(puppetHandlerFactory), ImmutableSet.of(handler));

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);


    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
   
    Map<Set<String>, Stack<Integer>> reaction = Maps.newHashMap();
View Full Code Here

      assertEquals(defaultTemplate.getOptions().getClass(), SoftLayerTemplateOptions.class);
   }

   @Test
   public void testTemplateBuilderFindsGigabitUplink() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000");

         context = createView(overrides, setupModules());

         // TODO add something to the template about port speed?
         context.getComputeService().templateBuilder().build();

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      }
   }

   @Test
   public void testTemplateBuilderFindsMegabitUplink() throws IOException {
      ComputeServiceContext context = null;
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100");

         context = createView(overrides, setupModules());

         // TODO add something to the template about port speed?
         context.getComputeService().templateBuilder().build();

      } finally {
         if (context != null)
            context.close();
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.compute.ComputeServiceContext

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.