本文整理匯總了Java中org.jclouds.ContextBuilder.overrides方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextBuilder.overrides方法的具體用法?Java ContextBuilder.overrides怎麽用?Java ContextBuilder.overrides使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jclouds.ContextBuilder
的用法示例。
在下文中一共展示了ContextBuilder.overrides方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: withCompute
import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private <T> T withCompute(ComputeTask<T> task) throws HekateException {
ContextBuilder builder = ContextBuilder.newBuilder(provider)
.credentialsSupplier(credentials::get)
.modules(ImmutableSet.<Module>of(new SLF4JLoggingModule()));
if (!properties.isEmpty()) {
builder.overrides(properties);
}
if (endpoint != null && !endpoint.trim().isEmpty()) {
builder.endpoint(endpoint.trim());
}
try (ComputeServiceContext ctx = builder.buildView(ComputeServiceContext.class)) {
return task.execute(ctx);
}
}
示例2: createContext
import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private BlobStoreContext createContext() {
ContextBuilder builder = ContextBuilder.newBuilder(provider)
.credentialsSupplier(credentials::get)
.modules(ImmutableSet.<Module>of(new SLF4JLoggingModule()));
if (!properties.isEmpty()) {
builder.overrides(properties);
}
return builder.buildView(BlobStoreContext.class);
}
示例3: createContextBuilder
import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
private static ContextBuilder createContextBuilder(ObjectProperties objectProperties) {
// Create a Guice module that configures binds the function
Module customLookupModule = new AbstractModule() {
@Override
protected void configure() {
bind(LoginPortForContainer.class).to(NodeSshPortLookup.class).in(Scopes.SINGLETON);
}
};
final ContextBuilder contextBuilder = ContextBuilder.newBuilder("docker")
// REST API of docker daemon
.endpoint(objectProperties.getProperty(Config.CloudProvider.Docker.ENDPOINT))
// values are only valid for TLS protected endpoints (https://...), but still must be present for plain tcp (http://...)
.credentials(
objectProperties.getProperty(Config.CloudProvider.Docker.TLS_CERT_PATH, Config.CloudProvider.Docker.TLS_CERT_PATH),
objectProperties.getProperty(Config.CloudProvider.Docker.TLS_KEY_PATH, Config.CloudProvider.Docker.TLS_KEY_PATH))
.apiVersion(objectProperties.getProperty(Config.CloudProvider.Docker.API_VERSION, "1.21"))
.modules(ImmutableSet.of(customLookupModule, new SLF4JLoggingModule(), new DynamicSshClientModule(), new SocketFinderOnlyPublicInterfacesModule()));
final String caCertPath = objectProperties.getProperty(Config.CloudProvider.Docker.TLS_CA_CERT_PATH);
if (!Strings.isNullOrEmpty(caCertPath)) {
// if provided, configure the CA cert path in the ContextBuilder overrides
Properties defaultPropertyOverrides = new Properties();
defaultPropertyOverrides.setProperty(DockerApiMetadata.DOCKER_CA_CERT_PATH, caCertPath);
contextBuilder.overrides(defaultPropertyOverrides);
}
return contextBuilder;
}
示例4: start
import org.jclouds.ContextBuilder; //導入方法依賴的package包/類
@Override
public void start() {
key2StringMapper = Util.getInstance(configuration.key2StringMapper(), initializationContext.getCache()
.getAdvancedCache().getClassLoader());
key2StringMapper.setMarshaller(initializationContext.getMarshaller());
ContextBuilder contextBuilder = ContextBuilder.newBuilder(configuration.provider()).credentials(configuration.identity(), configuration.credential());
if(configuration.overrides() != null)
contextBuilder.overrides(configuration.overrides());
if(configuration.endpoint() != null && !configuration.endpoint().isEmpty())
contextBuilder.endpoint(configuration.endpoint());
blobStoreContext = contextBuilder.buildView(BlobStoreContext.class);
blobStore = blobStoreContext.getBlobStore();
String cacheName = configuration.normalizeCacheNames() ?
initializationContext.getCache().getName().replaceAll("[^a-zA-Z0-9-]", "-")
: initializationContext.getCache().getName();
containerName = String.format("%s-%s", configuration.container(), cacheName);
if (!blobStore.containerExists(containerName)) {
Location location = null;
if (configuration.location() != null ) {
location = new LocationBuilder()
.scope(LocationScope.REGION)
.id(configuration.location())
.description(String.format("Infinispan cache store for %s", containerName))
.build();
}
blobStore.createContainerInLocation(location, containerName);
//make sure container is created
if(!blobStore.containerExists(containerName)) {
try {
log.waitingForContainer();
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
throw new PersistenceException(String.format("Aborted when creating blob container %s", containerName));
}
if(!blobStore.containerExists(containerName)) {
throw new PersistenceException(String.format("Unable to create blob container %s", containerName));
}
}
}
}