本文整理了Java中org.jclouds.Context.utils()
方法的一些代码示例,展示了Context.utils()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.utils()
方法的具体详情如下:
包路径:org.jclouds.Context
类名称:Context
方法名:utils
暂无
代码示例来源:origin: apache/jclouds
@Override
protected void initializeContext() {
super.initializeContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
publicIpAvailable = context.utils().injector().getInstance(PublicIpAvailablePredicateFactory.class);
resourceAvailable = context.utils().injector()
.getInstance(Key.get(new TypeLiteral<Predicate<Supplier<Provisionable>>>() {
}));
api = view.unwrapApi(AzureComputeApi.class);
}
代码示例来源:origin: apache/jclouds
@Override
public void initializeContext() {
super.initializeContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
}
代码示例来源:origin: apache/jclouds
@SuppressWarnings("unchecked")
@Override
protected Optional<Image> findImageWithNameInCache(String name) {
ImageCacheSupplier imageCache = (ImageCacheSupplier) context.utils().injector()
.getInstance(Key.get(new TypeLiteral<Supplier<Set<? extends Image>>>() {
}, Memoized.class));
try {
Field field = imageCache.getClass().getDeclaredField("imageCache");
field.setAccessible(true);
LoadingCache<String, Image> cache = (LoadingCache<String, Image>) field.get(imageCache);
return Optional.fromNullable(getOnlyElement(filter(cache.asMap().values(), new Predicate<Image>() {
@Override
public boolean apply(Image input) {
return imageGroup.equals(input.getName());
}
}), null));
} catch (NoSuchFieldException ex) {
throw Throwables.propagate(ex);
} catch (IllegalAccessException ex) {
throw Throwables.propagate(ex);
}
}
代码示例来源:origin: apache/jclouds
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
createResourceGroup(resourceGroupName);
}
代码示例来源:origin: apache/jclouds
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
createResourceGroup(resourceGroupName);
}
代码示例来源:origin: apache/jclouds
@Override
protected void initializeContext() {
super.initializeContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
api = view.unwrapApi(AzureComputeApi.class);
}
代码示例来源:origin: apache/jclouds
@Override
protected void initializeContext() {
super.initializeContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
api = view.unwrapApi(AzureComputeApi.class);
}
代码示例来源:origin: apache/jclouds
@Override
protected void initializeContext() {
super.initializeContext();
resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
api = view.unwrapApi(AzureComputeApi.class);
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
public void testConcurrentUseOfComputeServiceToCreateNodes() throws Exception {
final long timeoutMs = 20 * 60 * 1000;
List<String> groups = Lists.newArrayList();
List<ListenableFuture<NodeMetadata>> futures = Lists.newArrayList();
ListeningExecutorService userExecutor = MoreExecutors.listeningDecorator(context.utils().userExecutor());
try {
for (int i = 0; i < 2; i++) {
final int groupNum = i;
final String group = "twin" + groupNum;
groups.add(group);
ListenableFuture<NodeMetadata> future = userExecutor.submit(new Callable<NodeMetadata>() {
public NodeMetadata call() throws Exception {
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, inboundPorts(22, 8080)
.blockOnPort(22, 300 + groupNum)));
getAnonymousLogger().info("Started node " + node.getId());
return node;
}
});
futures.add(future);
}
ListenableFuture<List<NodeMetadata>> compoundFuture = Futures.allAsList(futures);
compoundFuture.get(timeoutMs, TimeUnit.MILLISECONDS);
} finally {
for (String group : groups) {
client.destroyNodesMatching(inGroup(group));
}
}
}
代码示例来源:origin: jclouds/legacy-jclouds
protected void buildSocketTester() {
SocketOpen socketOpen = view.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpen, 60, 1, SECONDS);
// wait a maximum of 60 seconds for port 8080 to open.
openSocketFinder = context.utils().injector().getInstance(OpenSocketFinder.class);
}
代码示例来源:origin: apache/jclouds
private Resources resourceApi() {
return builder().build().utils().injector().getInstance(Resources.class);
}
}
代码示例来源:origin: apache/jclouds
protected void buildSocketTester() {
SocketOpen socketOpen = view.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpen, 60, 1, SECONDS);
// wait a maximum of 60 seconds for port 8080 to open.
openSocketFinder = context.utils().injector().getInstance(OpenSocketFinder.class);
}
代码示例来源:origin: apache/jclouds
protected void buildSocketTester() {
SocketOpen socketOpen = view.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpen, 60, 1, SECONDS);
// wait a maximum of 60 seconds for port 8080 to open.
openSocketFinder = context.utils().injector().getInstance(OpenSocketFinder.class);
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test(expectedExceptions=UnsupportedOperationException.class)
public void testSocketOpenThrowsUnsupported() {
Context context = ContextBuilder.newBuilder(
AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class,
"dummyurl"))
.modules(ImmutableSet.of(new GoogleAppEngineConfigurationModule()))
.build();
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
socketOpen.apply(HostAndPort.fromParts("localhost", 22));
}
}
代码示例来源:origin: apache/jclouds
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testSocketOpenThrowsUnsupported() {
Context context = ContextBuilder.newBuilder(forApiOnEndpoint(IntegrationTestClient.class, "dummyurl"))
.modules(ImmutableSet.of(new GoogleAppEngineConfigurationModule()))
.build();
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
socketOpen.apply(HostAndPort.fromParts("localhost", 22));
}
}
代码示例来源:origin: apache/jclouds
@BeforeGroups(groups = { "live" })
public void setupContext() {
super.setupContext();
adapter = context.utils().injector().getInstance(
CloudStackComputeServiceAdapter.class);
keyPairName = prefix + "-adapter-test-keypair";
keyPair = SshKeys.generate();
client.getSSHKeyPairApi().deleteSSHKeyPair(keyPairName);
client.getSSHKeyPairApi().registerSSHKeyPair(keyPairName, keyPair.get("public"));
}
代码示例来源:origin: jclouds/legacy-jclouds
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
client = view.utils().injector().getInstance(ElasticStackClient.class);
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);
}
代码示例来源:origin: apache/jclouds
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
client = view.utils().injector().getInstance(ElasticStackApi.class);
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);
}
代码示例来源:origin: jclouds/legacy-jclouds
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
client = view.utils().injector().getInstance(CloudSigmaClient.class);
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
SocketOpen socketOpten = context.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpten, maxDriveImageTime, 1, SECONDS);
if (template == null || template.getImageId() == null) {
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
}
}
代码示例来源:origin: apache/jclouds
@Test(groups = "live")
public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException {
final String containerName = getScratchContainerName();
try {
view.getBlobStore().createContainerInLocation(null, containerName, publicRead());
assertConsistencyAwareContainerExists(containerName);
defaultLocation = Iterables.find(view.getBlobStore().list(), new Predicate<StorageMetadata>() {
@Override
public boolean apply(@Nullable StorageMetadata input) {
return input.getName().equals(containerName);
}
}).getLocation();
view.getBlobStore().putBlob(containerName,
view.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build());
assertConsistencyAwareContainerSize(containerName, 1);
BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, "hello");
assertNotNull(metadata.getPublicUri(), metadata.toString());
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
Predicate<HostAndPort> socketTester = retry(socketOpen, 60, 5, SECONDS);
int port = metadata.getPublicUri().getPort();
HostAndPort hostAndPort = HostAndPort.fromParts(metadata.getPublicUri().getHost(), port != -1 ? port : 80);
assertTrue(socketTester.apply(hostAndPort), metadata.getPublicUri().toString());
assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), TEST_STRING);
} finally {
// this container is now public, so we can't reuse it directly
recycleContainerAndAddToPool(containerName);
}
}
内容来源于网络,如有侵权,请联系作者删除!