本文整理了Java中org.jclouds.rest.HttpClient.get()
方法的一些代码示例,展示了HttpClient.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.get()
方法的具体详情如下:
包路径:org.jclouds.rest.HttpClient
类名称:HttpClient
方法名:get
暂无
代码示例来源:origin: jclouds/legacy-jclouds
public static void checkHttpGet(HttpClient client, NodeMetadata node, int port) {
for (int i = 0; i < 5; i++)
try {
assert client.get(URI.create(String.format("http://%s:%d", get(node.getPublicAddresses(), 0), port))) != null;
break;
} catch (UndeclaredThrowableException e) {
assertEquals(e.getCause().getClass(), TimeoutException.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
}
}
}
代码示例来源:origin: apache/jclouds
public static void checkHttpGet(HttpClient client, NodeMetadata node, int port) {
for (int i = 0; i < 5; i++)
try {
assert client.get(URI.create(String.format("http://%s:%d", get(node.getPublicAddresses(), 0), port))) != null;
break;
} catch (UndeclaredThrowableException e) {
assertEquals(e.getCause().getClass(), TimeoutException.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
}
}
}
代码示例来源:origin: jclouds/legacy-jclouds-chef
@Test(dependsOnMethods = "testCanUpdateRunList")
public void testRunNodesWithBootstrap() throws IOException {
Statement bootstrap = view.getChefService().createBootstrapScriptForGroup(group);
try {
nodes = computeContext.getComputeService().createNodesInGroup(group, 1, runScript(bootstrap));
} catch (RunNodesException e) {
nodes = concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet());
}
for (NodeMetadata node : nodes) {
URI uri = URI.create("http://" + getLast(node.getPublicAddresses()));
InputStream content = computeContext.utils().http().get(uri);
String string = Strings2.toStringAndClose(content);
assert string.indexOf("It works!") >= 0 : string;
}
}
代码示例来源: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);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
private void runCreateContainerInLocation(String payload, Location nonDefault) throws InterruptedException,
IOException {
String blobName = "hello";
BlobStore blobStore = view.getBlobStore();
final String containerName = getScratchContainerName();
try {
Logger.getAnonymousLogger().info(
String.format("creating public container %s in location %s", containerName, nonDefault.getId()));
blobStore.createContainerInLocation(nonDefault, containerName, publicRead());
assertConsistencyAwareContainerExists(containerName);
assertConsistencyAwareContainerInLocation(containerName, nonDefault);
blobStore.putBlob(containerName, blobStore.blobBuilder(blobName).payload(payload).build());
assertConsistencyAwareContainerSize(containerName, 1);
BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, blobName);
assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), payload);
assertConsistencyAwareBlobInLocation(containerName, blobName, nonDefault);
} finally {
// this container is now public, so we can't reuse it directly
recycleContainer(containerName);
}
}
代码示例来源:origin: apache/jclouds
private void runCreateContainerInLocation(String payload, Location nonDefault) throws InterruptedException,
IOException {
String blobName = "hello";
BlobStore blobStore = view.getBlobStore();
final String containerName = getScratchContainerName();
try {
Logger.getAnonymousLogger().info(
String.format("creating public container %s in location %s", containerName, nonDefault.getId()));
blobStore.createContainerInLocation(nonDefault, containerName, publicRead());
assertConsistencyAwareContainerExists(containerName);
assertConsistencyAwareContainerInLocation(containerName, nonDefault);
blobStore.putBlob(containerName, blobStore.blobBuilder(blobName).payload(payload).build());
assertConsistencyAwareContainerSize(containerName, 1);
BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, blobName);
assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), payload);
assertConsistencyAwareBlobInLocation(containerName, blobName, nonDefault);
} finally {
// this container is now public, so we can't reuse it directly
recycleContainerAndAddToPool(containerName);
}
}
}
代码示例来源:origin: jclouds/legacy-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");
assert metadata.getPublicUri() != null : metadata;
assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), TEST_STRING);
} finally {
// this container is now public, so we can't reuse it directly
recycleContainer(containerName);
}
}
内容来源于网络,如有侵权,请联系作者删除!