/** * @return a reference to the context that created this ComputeService. */ @Override public ComputeServiceContext getContext() { return computeService.getContext(); }
/** * @return a reference to the context that created this ComputeService. */ @Override public ComputeServiceContext getContext() { return computeService.getContext(); }
/** * Close the connection */ public void closeConnection(){ compute.getContext().close(); journal.log(Level.INFO, ">> Closing connection ..."); }
public void destroy() { if (computeService != null) { this.computeService.getContext().close(); } }
/** * Close the connection */ public void closeConnection(){ compute.getContext().close(); journal.log(Level.INFO, ">> Closing connection ..."); }
public synchronized void bind(ComputeService computeService) { if (computeService != null) { serviceContextMap.put(computeService.getContext().unwrap().getName(), computeService.getContext()); } }
public synchronized void bind(ComputeService computeService) { if (computeService != null) { serviceContextMap.put(computeService.getContext().unwrap().getName(), computeService.getContext()); } }
void bindComputeService(ComputeService computeService) { String name = computeService.getContext().unwrap().getName(); if (name != null) { computeServiceMap.put(name, computeService); } }
void unbindComputeService(ComputeService computeService) { String serviceId = computeService.getContext().unwrap().getName(); if (serviceId != null) { computeServiceMap.remove(serviceId); } } }
public synchronized void unbind(ComputeService computeService) { if (computeService != null) { serviceContextMap.remove(computeService.getContext().unwrap().getName()); } } }
/** * Returns the @{link SecurityGroupApi} for the target location. */ private static Optional<? extends SecurityGroupApi> getSecurityGroup(ComputeService computeService, String location) { return computeService.getContext().unwrapApi(NovaApi.class) .getSecurityGroupExtensionForZone(location); }
@Override public String getCacheableKey(ComputeService type) { return type.getContext().unwrap().getName(); } }
private void assertComputeServiceType(JcloudsLocation loc, String expectedType) { // TODO Would be nice to do this more explicitly, rather than relying on toString. // But this is good enough. ComputeService computeService = loc.getComputeService(); ComputeServiceContext context = computeService.getContext(); assertTrue(context.toString().contains("id="+expectedType), "computeService="+computeService+"; context="+computeService.getContext()); }
@Override public int complete(String buffer, int cursor, List<String> candidates) { delegate.getStrings().clear(); if (computeServices != null && !computeServices.isEmpty()) { for(ComputeService computeService:computeServices) { delegate.getStrings().add(computeService.getContext().unwrap().getId()); } } return delegate.complete(buffer, cursor, candidates); }
void bindComputeService(ComputeService computeService) { String name = computeService.getContext().unwrap().getName(); if (!Strings.isEmpty(name)) { computeServices.putIfAbsent(name, new DynamicReference<ComputeService>(name, COMPUTE_SERVICE_WAIT, TimeUnit.MILLISECONDS)); computeServices.get(name).bind(computeService); } }
void unbindComputeService(ComputeService computeService) { String name = computeService.getContext().unwrap().getName(); if (!Strings.isEmpty(name)) { DynamicReference<ComputeService> ref = computeServices.get(name); if (ref != null) { ref.unbind(computeService); } } } }
void shutdown() { echo("Shutting down Provisioner..."); // shutdown thread pool executor.shutdown(); awaitTermination(executor, EXECUTOR_TERMINATION_TIMEOUT_SECONDS, SECONDS); // shutdown compute service (which holds another thread pool) if (computeService != null) { computeService.getContext().close(); } echo("Done!"); }
@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { MockitoAnnotations.initMocks(this); // stock mock responses when(computeService.getContext()).thenReturn(computeServiceContext); when(computeServiceContext.unwrapApi(AzureComputeApi.class)).thenReturn(azureComputeApi); when(azureComputeApi.getResourceGroupApi()).thenReturn(resourceGroupApi); when(azureComputeApi.getSubnetApi(TEST_RESOURCE_GROUP, TEST_NETWORK_NAME)).thenReturn(subnetApi); when(azureComputeApi.getVirtualNetworkApi(TEST_RESOURCE_GROUP)).thenReturn(virtualNetworkApi); when(subnet.id()).thenReturn(TEST_SUBNET_ID); }
protected Set<AvailabilityZoneInfo> getAvailabilityZones() { String regionName = loc.getRegion(); AWSEC2Client ec2Client = loc.getComputeService().getContext().unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); return ec2Client.getAvailabilityZoneAndRegionServices().describeAvailabilityZonesInRegion(regionName); }
@Test public void testSessionRefresh() throws Exception { VCloudClient connection = VCloudClient.class.cast(client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN) .getApi()); connection.getOrgClient().findOrgNamed(null); Thread.sleep(timeOut * 1000); connection.getOrgClient().findOrgNamed(null); }