mirror of https://github.com/apache/jclouds.git
added toString to common functions so that they are easier to see when debugging
This commit is contained in:
parent
b0f37625ec
commit
f5fa2d983b
|
@ -82,9 +82,9 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
@Inject
|
@Inject
|
||||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async,
|
@Memoized Supplier<Set<? extends Location>> locations, AtmosAsyncClient async, AtmosClient sync,
|
||||||
AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd,
|
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||||
BlobToObject blob2Object, BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||||
DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto,
|
DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions, Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
BlobToHttpGetOptions blob2ObjectGetOptions, Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
|
||||||
super(context, blobUtils, service, defaultLocation, locations);
|
super(context, blobUtils, service, defaultLocation, locations);
|
||||||
|
@ -235,9 +235,12 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
@Override
|
@Override
|
||||||
public String call() throws Exception {
|
public String call() throws Exception {
|
||||||
return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob);
|
return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "putBlob(" + container + "," + blob.getMetadata().getName() + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,10 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore {
|
||||||
return blobUtils.countBlobs(containerName, options);
|
return blobUtils.countBlobs(containerName, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "countBlobs(" + containerName + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +163,10 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "clearContainer(" + containerName + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +185,10 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "deleteDirectory(" + containerName + "," + directory + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +207,10 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore {
|
||||||
return blobUtils.directoryExists(containerName, directory);
|
return blobUtils.directoryExists(containerName, directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "directoryExists(" + containerName + "," + directory + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +231,11 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore {
|
||||||
blobUtils.createDirectory(containerName, directory);
|
blobUtils.createDirectory(containerName, directory);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "createDirectory(" + containerName + "," + directory + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +268,10 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "deleteContainer(" + container + ")";
|
||||||
|
}
|
||||||
}), service);
|
}), service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,8 +155,8 @@ public class FormSigner implements HttpRequestFilter, RequestSigner {
|
||||||
public String sign(String stringToSign) {
|
public String sign(String stringToSign) {
|
||||||
String signature;
|
String signature;
|
||||||
try {
|
try {
|
||||||
signature = CryptoStreams.base64(CryptoStreams.mac(InputSuppliers.of(stringToSign),
|
signature = CryptoStreams.base64(CryptoStreams.mac(InputSuppliers.of(stringToSign), crypto
|
||||||
crypto.hmacSHA256(secretKey.getBytes())));
|
.hmacSHA256(secretKey.getBytes())));
|
||||||
if (signatureWire.enabled())
|
if (signatureWire.enabled())
|
||||||
signatureWire.input(Strings2.toInputStream(signature));
|
signatureWire.input(Strings2.toInputStream(signature));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -184,14 +184,16 @@ public class FormSigner implements HttpRequestFilter, RequestSigner {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
String buildCanonicalizedString(Multimap<String, String> decodedParams) {
|
String buildCanonicalizedString(Multimap<String, String> decodedParams) {
|
||||||
return ModifyRequest.makeQueryLine(decodedParams, new Comparator<Map.Entry<String, String>>() {
|
return ModifyRequest.makeQueryLine(decodedParams, sortAWSFirst);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Comparator<Map.Entry<String, String>> sortAWSFirst = new Comparator<Map.Entry<String, String>>() {
|
||||||
public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
|
public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
|
||||||
if (o1.getKey().startsWith("AWSAccessKeyId"))
|
if (o1.getKey().startsWith("AWSAccessKeyId"))
|
||||||
return -1;
|
return -1;
|
||||||
return o1.getKey().compareTo(o2.getKey());
|
return o1.getKey().compareTo(o2.getKey());
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void addSigningParams(Multimap<String, String> params) {
|
void addSigningParams(Multimap<String, String> params) {
|
||||||
|
|
|
@ -83,6 +83,10 @@ public class VCloudHardwareSupplier implements Supplier<Set<? extends Hardware>>
|
||||||
return sizesInOrg.apply(from);
|
return sizesInOrg.apply(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "sizesInOrg(" + from.getHref() + ")";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,10 @@ public class VCloudImageSupplier implements Supplier<Set<? extends Image>> {
|
||||||
return imagesInOrg.apply(from);
|
return imagesInOrg.apply(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "imagesInOrg(" + from.getHref() + ")";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,12 +133,14 @@ public class BaseComputeService implements ComputeService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected BaseComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
|
protected BaseComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
|
@Memoized Supplier<Set<? extends Image>> images,
|
||||||
|
@Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||||
GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
|
GetNodeMetadataStrategy getNodeMetadataStrategy,
|
||||||
RebootNodeStrategy rebootNodeStrategy, DestroyNodeStrategy destroyNodeStrategy,
|
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
|
||||||
ResumeNodeStrategy resumeNodeStrategy, SuspendNodeStrategy suspendNodeStrategy,
|
DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy resumeNodeStrategy,
|
||||||
Provider<TemplateBuilder> templateBuilderProvider, Provider<TemplateOptions> templateOptionsProvider,
|
SuspendNodeStrategy suspendNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
|
||||||
|
Provider<TemplateOptions> templateOptionsProvider,
|
||||||
@Named("NODE_RUNNING") Predicate<NodeMetadata> nodeRunning,
|
@Named("NODE_RUNNING") Predicate<NodeMetadata> nodeRunning,
|
||||||
@Named("NODE_TERMINATED") Predicate<NodeMetadata> nodeTerminated,
|
@Named("NODE_TERMINATED") Predicate<NodeMetadata> nodeTerminated,
|
||||||
@Named("NODE_SUSPENDED") Predicate<NodeMetadata> nodeSuspended,
|
@Named("NODE_SUSPENDED") Predicate<NodeMetadata> nodeSuspended,
|
||||||
|
@ -287,6 +289,10 @@ public class BaseComputeService implements ComputeService {
|
||||||
return from;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "destroyNode(" + from.getId() + ")";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,8 +490,8 @@ public class BaseComputeService implements ComputeService {
|
||||||
public Map<NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, Payload runScript,
|
public Map<NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, Payload runScript,
|
||||||
RunScriptOptions options) throws RunScriptOnNodesException {
|
RunScriptOptions options) throws RunScriptOnNodesException {
|
||||||
try {
|
try {
|
||||||
return runScriptOnNodesMatching(filter,
|
return runScriptOnNodesMatching(filter, Statements.exec(Strings2.toStringAndClose(checkNotNull(runScript,
|
||||||
Statements.exec(Strings2.toStringAndClose(checkNotNull(runScript, "runScript").getInput())), options);
|
"runScript").getInput())), options);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -552,8 +558,7 @@ public class BaseComputeService implements ComputeService {
|
||||||
private Iterable<? extends RunScriptOnNode> transformNodesIntoInitializedScriptRunners(
|
private Iterable<? extends RunScriptOnNode> transformNodesIntoInitializedScriptRunners(
|
||||||
Iterable<? extends NodeMetadata> nodes, Statement script, RunScriptOptions options,
|
Iterable<? extends NodeMetadata> nodes, Statement script, RunScriptOptions options,
|
||||||
Map<NodeMetadata, Exception> badNodes) {
|
Map<NodeMetadata, Exception> badNodes) {
|
||||||
return filter(
|
return filter(transformParallel(nodes, new TransformNodesIntoInitializedScriptRunners(script, options, badNodes),
|
||||||
transformParallel(nodes, new TransformNodesIntoInitializedScriptRunners(script, options, badNodes),
|
|
||||||
executor, null, logger, "initialize script runners"), notNull());
|
executor, null, logger, "initialize script runners"), notNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
|
||||||
request = filter.filter(request);
|
request = filter.filter(request);
|
||||||
}
|
}
|
||||||
checkRequestHasContentLengthOrChunkedEncoding(request,
|
checkRequestHasContentLengthOrChunkedEncoding(request,
|
||||||
"After filtering, the request has niether chunked encoding nor content length: " + request);
|
"After filtering, the request has neither chunked encoding nor content length: " + request);
|
||||||
logger.debug("Sending request %s: %s", request.hashCode(), request.getRequestLine());
|
logger.debug("Sending request %s: %s", request.hashCode(), request.getRequestLine());
|
||||||
wirePayloadIfEnabled(wire, request);
|
wirePayloadIfEnabled(wire, request);
|
||||||
utils.logRequest(headerLog, request, ">>");
|
utils.logRequest(headerLog, request, ">>");
|
||||||
|
@ -203,6 +203,11 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
|
||||||
return shouldContinue;
|
return shouldContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[command=" + command + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Q convert(HttpRequest request) throws IOException, InterruptedException;
|
protected abstract Q convert(HttpRequest request) throws IOException, InterruptedException;
|
||||||
|
|
|
@ -20,16 +20,12 @@
|
||||||
package org.jclouds.http.utils;
|
package org.jclouds.http.utils;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.collect.Sets.newTreeSet;
|
|
||||||
import static org.jclouds.io.Payloads.newUrlEncodedFormPayload;
|
import static org.jclouds.io.Payloads.newUrlEncodedFormPayload;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
@ -40,6 +36,7 @@ import org.jclouds.util.Strings2;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.LinkedHashMultimap;
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
import com.google.common.collect.LinkedListMultimap;
|
import com.google.common.collect.LinkedListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -51,9 +48,7 @@ import com.google.common.collect.Multimap;
|
||||||
public class ModifyRequest {
|
public class ModifyRequest {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <R extends HttpRequest> R putHeaders(R request, Multimap<String, String> moreHeaders) {
|
public static <R extends HttpRequest> R putHeaders(R request, Multimap<String, String> moreHeaders) {
|
||||||
return (R) request
|
return (R) request.toBuilder().headers(
|
||||||
.toBuilder()
|
|
||||||
.headers(
|
|
||||||
ImmutableMultimap.<String, String> builder().putAll(request.getHeaders()).putAll(moreHeaders).build())
|
ImmutableMultimap.<String, String> builder().putAll(request.getHeaders()).putAll(moreHeaders).build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -168,8 +163,8 @@ public class ModifyRequest {
|
||||||
|
|
||||||
public static String makeQueryLine(Multimap<String, String> params,
|
public static String makeQueryLine(Multimap<String, String> params,
|
||||||
@Nullable Comparator<Map.Entry<String, String>> sorter, char... skips) {
|
@Nullable Comparator<Map.Entry<String, String>> sorter, char... skips) {
|
||||||
Iterator<Map.Entry<String, String>> pairs = ((sorter == null) ? params.entries() : sortEntries(params.entries(),
|
Iterator<Map.Entry<String, String>> pairs = ((sorter == null) ? params.entries() : ImmutableSortedSet.copyOf(
|
||||||
sorter)).iterator();
|
sorter, params.entries())).iterator();
|
||||||
StringBuilder formBuilder = new StringBuilder();
|
StringBuilder formBuilder = new StringBuilder();
|
||||||
while (pairs.hasNext()) {
|
while (pairs.hasNext()) {
|
||||||
Map.Entry<String, String> pair = pairs.next();
|
Map.Entry<String, String> pair = pairs.next();
|
||||||
|
@ -183,12 +178,4 @@ public class ModifyRequest {
|
||||||
}
|
}
|
||||||
return formBuilder.toString();
|
return formBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SortedSet<Entry<String, String>> sortEntries(Collection<Map.Entry<String, String>> in,
|
|
||||||
Comparator<Map.Entry<String, String>> sorter) {
|
|
||||||
SortedSet<Entry<String, String>> entries = newTreeSet(sorter);
|
|
||||||
entries.addAll(in);
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,10 @@ public class FutureExceptionParserTest {
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "throwException(" + exception + ")";
|
||||||
|
}
|
||||||
}), executorService);
|
}), executorService);
|
||||||
|
|
||||||
future = new ExceptionParsingListenableFuture(future, new Function<Exception, String>() {
|
future = new ExceptionParsingListenableFuture(future, new Function<Exception, String>() {
|
||||||
|
|
Loading…
Reference in New Issue