@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(); } }
@Override public JcloudsLocation newSubLocation(Map<?,?> newFlags) { return newSubLocation(getClass(), newFlags); }
JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements
        JcloudsLocationConfig, MachineManagementMixins.RichMachineProvisioningLocation<MachineLocation>,
        LocationWithObjectStore, MachineManagementMixins.SuspendResumeLocation { @Override public JcloudsLocation newSubLocation(Map<?,?> newFlags) { return newSubLocation(getClass(), newFlags); } }
JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements
        JcloudsLocationConfig, MachineManagementMixins.RichMachineProvisioningLocation<MachineLocation>,
        LocationWithObjectStore, MachineManagementMixins.SuspendResumeLocation { @Override public JcloudsLocation newSubLocation(Map<?,?> newFlags) { return newSubLocation(getClass(), newFlags); } JcloudsLocation();  JcloudsLocation(Map<?,?> conf); }
JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements
        JcloudsLocationConfig, MachineManagementMixins.RichMachineProvisioningLocation<MachineLocation>,
        LocationWithObjectStore, MachineManagementMixins.SuspendResumeLocation { @Override public JcloudsLocation newSubLocation(Map<?,?> newFlags) { return newSubLocation(getClass(), newFlags); } JcloudsLocation();  JcloudsLocation(Map<?,?> conf); @Override @Deprecated JcloudsLocation configure(Map<?,?> properties); @Override void init(); @Override JcloudsLocation newSubLocation(Map<?,?> newFlags); @Override JcloudsLocation newSubLocation(Class<? extends AbstractCloudMachineProvisioningLocation> type, Map<?,?> newFlags); @Override String toString(); @Override String toVerboseString(); String getProvider(); String getIdentity(); String getCredential(); String getRegion(); 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); 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); @Deprecated Set<? extends ComputeMetadata> listNodes(); @Deprecated Set<? extends ComputeMetadata> listNodes(Map<?,?> flags); @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 MachineLocation resumeMachine(Map<?, ?> flags); Template buildTemplate(ComputeService computeService, ConfigBag config); @Deprecated JcloudsSshMachineLocation rebindMachine(NodeMetadata metadata); @Deprecated JcloudsSshMachineLocation rebindMachine(Map<?,?> flags, NodeMetadata metadata); @Deprecated JcloudsSshMachineLocation rebindMachine(ConfigBag setup); MachineLocation registerMachine(ConfigBag setup); @Deprecated JcloudsSshMachineLocation rebindMachine(Map<?, ?> flags); MachineLocation registerMachine(Map<?,?> flags); @Override void release(MachineLocation rawMachine); static File asFile(Object o); static String fileAsString(Object o); @Override PersistenceObjectStore newPersistenceObjectStore(String container); }
JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements
        JcloudsLocationConfig, MachineManagementMixins.RichMachineProvisioningLocation<MachineLocation>,
        LocationWithObjectStore, MachineManagementMixins.SuspendResumeLocation { @Override public JcloudsLocation newSubLocation(Map<?,?> newFlags) { return newSubLocation(getClass(), newFlags); } JcloudsLocation();  JcloudsLocation(Map<?,?> conf); @Override @Deprecated JcloudsLocation configure(Map<?,?> properties); @Override void init(); @Override JcloudsLocation newSubLocation(Map<?,?> newFlags); @Override JcloudsLocation newSubLocation(Class<? extends AbstractCloudMachineProvisioningLocation> type, Map<?,?> newFlags); @Override String toString(); @Override String toVerboseString(); String getProvider(); String getIdentity(); String getCredential(); String getRegion(); 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); 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); @Deprecated Set<? extends ComputeMetadata> listNodes(); @Deprecated Set<? extends ComputeMetadata> listNodes(Map<?,?> flags); @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 MachineLocation resumeMachine(Map<?, ?> flags); Template buildTemplate(ComputeService computeService, ConfigBag config); @Deprecated JcloudsSshMachineLocation rebindMachine(NodeMetadata metadata); @Deprecated JcloudsSshMachineLocation rebindMachine(Map<?,?> flags, NodeMetadata metadata); @Deprecated JcloudsSshMachineLocation rebindMachine(ConfigBag setup); MachineLocation registerMachine(ConfigBag setup); @Deprecated JcloudsSshMachineLocation rebindMachine(Map<?, ?> flags); MachineLocation registerMachine(Map<?,?> flags); @Override void release(MachineLocation rawMachine); static File asFile(Object o); static String fileAsString(Object o); @Override PersistenceObjectStore newPersistenceObjectStore(String container); static final Logger LOG; static final String ROOT_USERNAME; static final List<String> ROOT_ALIASES; static final List<String> COMMON_USER_NAMES_TO_TRY; static final Map<ConfigKey<?>,CustomizeTemplateBuilder> SUPPORTED_TEMPLATE_BUILDER_PROPERTIES; static final Map<ConfigKey<?>,CustomizeTemplateOptions> SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES; }