JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements
        JcloudsLocationPublic { @Override public JcloudsLocation newSubLocation(Map<?,?> newFlags) { return newSubLocation(getClass(), newFlags); } JcloudsLocation();  JcloudsLocation(Map<?,?> conf); @Override @Deprecated JcloudsLocation configure(Map<?,?> properties); @Override void init(); @Override void rebind(); @Override JcloudsLocation newSubLocation(Map<?,?> newFlags); @Override JcloudsLocation newSubLocation(Class<? extends AbstractCloudMachineProvisioningLocation> type, Map<?,?> newFlags); @Override String toString(); @Override String toVerboseString(); @Override String getProvider(); @Override String getIdentity(); @Override String getCredential(); @Override String getRegion(); @Override String getEndpoint(); String getUser(ConfigBag config); boolean isWindows(Template template, ConfigBag config); boolean isWindows(Image image, ConfigBag config); boolean isWindows(NodeMetadata node, ConfigBag config); boolean isLocationFirewalldEnabled(SshMachineLocation location); Collection<JcloudsLocationCustomizer> getCustomizers(ConfigBag setup); ConnectivityResolver getLocationNetworkInfoCustomizer(ConfigBag setup); void setDefaultImageId(String val); void setTagMapping(Map<String,Map<String, ? extends Object>> val); @Override Map<String,Object> getProvisioningFlags(Collection<String> tags); static final Set<ConfigKey<?>> getAllSupportedProperties(); ComputeService getComputeService(); ComputeService getComputeService(Map<?,?> flags); ComputeService getComputeService(ConfigBag config); @Override Map<String, MachineManagementMixins.MachineMetadata> listMachines(); @Override MachineManagementMixins.MachineMetadata getMachineMetadata(MachineLocation l); @Override void killMachine(String cloudServiceId); @Override void killMachine(MachineLocation l); MachineLocation obtain(); MachineLocation obtain(TemplateBuilder tb); MachineLocation obtain(Map<?,?> flags, TemplateBuilder tb); @Override MachineLocation obtain(Map<?,?> flags); @Override void suspendMachine(MachineLocation rawLocation); @Override JcloudsMachineLocation resumeMachine(Map<?, ?> flags); @Deprecated Template buildTemplate(ComputeService computeService, ConfigBag config, Collection<JcloudsLocationCustomizer> customizers); Template buildTemplate(ComputeService computeService, ConfigBag config, JcloudsLocationCustomizer customizersDelegate); @Override String toStringNice(); JcloudsMachineLocation registerMachine(ConfigBag flags); JcloudsMachineLocation registerMachine(Map<?,?> flags); @Override void release(MachineLocation rawMachine); @Override PersistenceObjectStore newPersistenceObjectStore(String container); @Deprecated static File asFile(Object o); @Deprecated static String fileAsString(Object o); static final Logger LOG; static final Map<ConfigKey<?>, ? extends TemplateBuilderCustomizer> SUPPORTED_TEMPLATE_BUILDER_PROPERTIES; static final Map<ConfigKey<?>, ? extends TemplateOptionCustomizer> SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES; }
@Test public void testCreateWithFlagsSubLocation() throws Exception { BailOutJcloudsLocation jcl = BailOutJcloudsLocation.newBailOutJcloudsLocation(managementContext); jcl = (BailOutJcloudsLocation) jcl.newSubLocation(MutableMap.of(USER, "jon", MIN_CORES, 2)); jcl.tryObtainAndCheck(MutableMap.of(MIN_CORES, 3), checkerFor("jon", 16, 3)); }
@Test(groups={"Live", "Live-sanity"}) public void testCreateWithInboundPorts() { BailOutJcloudsLocation jcloudsLocation = BailOutJcloudsLocation.newBailOutJcloudsLocationForLiveTest(managementContext); jcloudsLocation = (BailOutJcloudsLocation) jcloudsLocation.newSubLocation(MutableMap.of()); jcloudsLocation.tryObtainAndCheck(MutableMap.of(), templateCheckerFor("[22, 80, 9999]")); int[] ports = new int[] {22, 80, 9999}; Assert.assertEquals(jcloudsLocation.getTemplate().getOptions().getInboundPorts(), ports); }
@Test(groups={"Live", "Live-sanity"}) public void testCreateWithInboundPortsOverride() { BailOutJcloudsLocation jcloudsLocation = BailOutJcloudsLocation.newBailOutJcloudsLocationForLiveTest(managementContext); jcloudsLocation = (BailOutJcloudsLocation) jcloudsLocation.newSubLocation(MutableMap.of()); jcloudsLocation.tryObtainAndCheck(MutableMap.of(INBOUND_PORTS, "[23, 81, 9998]"), templateCheckerFor("[23, 81, 9998]")); int[] ports = new int[] {23, 81, 9998}; Assert.assertEquals(jcloudsLocation.getTemplate().getOptions().getInboundPorts(), ports); }
@Test(groups="Integration") public void testCreateWithMaxConcurrentCallsAppliesToSubLocations() throws Exception { final int numCalls = 4; final int maxConcurrentCreations = 2; ConcurrencyTracker interceptor = new ConcurrencyTracker(); ExecutorService executor = Executors.newCachedThreadPool(); try { final BailOutJcloudsLocation jcloudsLocation = BailOutJcloudsLocation.newBailOutJcloudsLocation( managementContext, ImmutableMap.of( BailOutJcloudsLocation.BUILD_TEMPLATE_INTERCEPTOR, interceptor, MAX_CONCURRENT_MACHINE_CREATIONS, maxConcurrentCreations)); for (int i = 0; i < numCalls; i++) { final BailOutJcloudsLocation subLocation = (BailOutJcloudsLocation) jcloudsLocation.newSubLocation(MutableMap.of()); executor.execute(new Runnable() { @Override public void run() { subLocation.tryObtain(); } }); } interceptor.assertCallCountEventually(maxConcurrentCreations); interceptor.assertCallCountContinually(maxConcurrentCreations); interceptor.unblock(); interceptor.assertCallCountEventually(numCalls); executor.shutdown(); executor.awaitTermination(10, TimeUnit.SECONDS); } finally { executor.shutdownNow(); } }