/** * {@inheritDoc} */ @Override public <V extends View> void register(V view) { views.put(view.unwrap().getName(), view); }
/** * {@inheritDoc} */ @Override public <V extends View> void unregister(V view) { views.remove(view.unwrap().getName()); }
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()); } } }
public synchronized void unbind(ComputeService computeService) { if (computeService != null) { serviceContextMap.remove(computeService.getContext().unwrap().getName()); } } }
@Override public String getCacheableKey(ComputeService type) { return type.getContext().unwrap().getName(); } }
@Override public String getCacheableKey(BlobStore type) { return type.getContext().unwrap().getName(); }
protected void printComputeApis(Iterable<ApiMetadata> apis, List<ComputeService> computeServices, String indent, PrintStream out) { out.println(String.format(PROVIDERFORMAT, "[id]", "[type]", "[service]")); for (ApiMetadata api : apis) { StringBuilder sb = new StringBuilder(); sb.append("[ "); for (ComputeService computeService : computeServices) { String contextName = (String) computeService.getContext().unwrap().getName(); if (computeService.getContext().unwrap().getId().equals(api.getId()) && contextName != null) { sb.append(contextName).append(" "); } } sb.append("]"); out.println(String.format(PROVIDERFORMAT, api.getId(), "compute", sb.toString())); } }
protected void printBlobStoreApis(Iterable<ApiMetadata> apis, List<BlobStore> blobStores, String indent, PrintStream out) { out.println(String.format(PROVIDERFORMAT, "[id]", "[type]", "[service]")); for (ApiMetadata api : apis) { StringBuilder sb = new StringBuilder(); sb.append("[ "); for (BlobStore blobStore : blobStores) { String contextName = (String) blobStore.getContext().unwrap().getName(); if (blobStore.getContext().unwrap().getId().equals(api.getId())) { sb.append(contextName).append(" "); } } sb.append("]"); out.println(String.format(PROVIDERFORMAT, api.getId(), "blobstore", sb.toString())); } }
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()); } }
public BlobStoreConfigurationSource(BlobStoreContext ctx) { this.ctx = checkNotNull(ctx, "ctx"); String container = containerName.get(); checkState(ctx.getBlobStore().containerExists(container), "%s: container %s doesn't exist", ctx.unwrap() .getName(), container); }
@Override public PollResult poll(boolean initial, Object checkPoint) throws Exception { String container = containerName.get(); BlobMap blobs = ctx.createBlobMap(container); Map<String, Object> props = ImmutableMap.copyOf(filterValues(transformEntries(blobs, toStringOrNull), notNull())); log.info("{}: {} properties in container {}", new Object[] { ctx.unwrap().getName(), props.size(), container }); return PollResult.createFull(props); }
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 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); } }
@Override public int complete(String buffer, int cursor, List<String> candidates) { try { if (computeServices != null) { for (ComputeService computeService : computeServices) { String id = (String) computeService.getContext().unwrap().getName(); if (id != null) { delegate.getStrings().add(id); } } } } catch (Exception ex) { // noop } return delegate.complete(buffer, cursor, candidates); }
@Override public Context apply(@Nullable org.jclouds.Context input) { if (input == null) { return null; } return Context.builder().name(input.getName()).identity(input.getIdentity()) .providerId(input.getProviderMetadata() != null ? input.getProviderMetadata().getId() : null).build(); } }
@Test public void testContextName() { ContextBuilder withNoName = testContextBuilder().endpoint("http://${jclouds.identity}.service.com").name("mytest") .credentials("foo", "bar"); Context context = withNoName.build(); assertEquals(context.getName(), "mytest"); }
@Test public void testContextName() { ContextBuilder withNoName = testContextBuilder().endpoint("http://${jclouds.identity}.service.com").name("mytest") .credentials("foo", "bar"); Context context = withNoName.build(); assertEquals(context.getName(), "mytest"); }