mirror of https://github.com/apache/jclouds.git
Address miscellaneous Guava deprecations
References JCLOUDS-415.
This commit is contained in:
parent
fcca1fd525
commit
f9e98681b6
|
@ -22,7 +22,7 @@ import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.sqs.domain.Message;
|
import org.jclouds.sqs.domain.Message;
|
||||||
|
|
||||||
import com.google.common.hash.HashCodes;
|
import com.google.common.hash.HashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
|
@ -55,7 +55,7 @@ public class MessageHandler extends ParseSax.HandlerForGeneratedRequestWithResul
|
||||||
} else if (qName.equals("ReceiptHandle")) {
|
} else if (qName.equals("ReceiptHandle")) {
|
||||||
builder.receiptHandle(currentOrNull(currentText));
|
builder.receiptHandle(currentOrNull(currentText));
|
||||||
} else if (qName.equals("MD5OfBody")) {
|
} else if (qName.equals("MD5OfBody")) {
|
||||||
builder.md5(HashCodes.fromBytes(base16().lowerCase().decode(currentOrNull(currentText))));
|
builder.md5(HashCode.fromBytes(base16().lowerCase().decode(currentOrNull(currentText))));
|
||||||
} else if (qName.equals("Body")) {
|
} else if (qName.equals("Body")) {
|
||||||
builder.body(currentOrNull(currentText));
|
builder.body(currentOrNull(currentText));
|
||||||
} else if (qName.equals("Name")) {
|
} else if (qName.equals("Name")) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.jclouds.http.functions.ReturnStringIf2xx;
|
||||||
import org.jclouds.sqs.domain.MessageIdAndMD5;
|
import org.jclouds.sqs.domain.MessageIdAndMD5;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.hash.HashCodes;
|
import com.google.common.hash.HashCode;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ public class RegexMessageIdAndMD5Handler implements Function<HttpResponse, Messa
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
return MessageIdAndMD5.builder()
|
return MessageIdAndMD5.builder()
|
||||||
.id(matcher.group(1))
|
.id(matcher.group(1))
|
||||||
.md5(HashCodes.fromBytes(base16().lowerCase().decode(matcher.group(2))))
|
.md5(HashCode.fromBytes(base16().lowerCase().decode(matcher.group(2))))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.jclouds.sqs.domain.MessageIdAndMD5;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.hash.HashCodes;
|
import com.google.common.hash.HashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
|
@ -59,7 +59,7 @@ public class SendMessageBatchResultEntryHandler extends
|
||||||
} else if (qName.equals("MessageId")) {
|
} else if (qName.equals("MessageId")) {
|
||||||
builder.id(currentOrNull(currentText));
|
builder.id(currentOrNull(currentText));
|
||||||
} else if (qName.equals("MD5OfMessageBody")) {
|
} else if (qName.equals("MD5OfMessageBody")) {
|
||||||
builder.md5(HashCodes.fromBytes(base16().lowerCase().decode(currentOrNull(currentText))));
|
builder.md5(HashCode.fromBytes(base16().lowerCase().decode(currentOrNull(currentText))));
|
||||||
}
|
}
|
||||||
currentText = new StringBuilder();
|
currentText = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SQSErrorRetryHandlerTest {
|
||||||
assertTrue(retry.shouldRetryRequestOnError(command, response, error));
|
assertTrue(retry.shouldRetryRequestOnError(command, response, error));
|
||||||
assertEquals(command.getFailureCount(), 60);
|
assertEquals(command.getFailureCount(), 60);
|
||||||
// allow for slightly inaccurate system timers
|
// allow for slightly inaccurate system timers
|
||||||
assertTrue(watch.stop().elapsedTime(TimeUnit.MILLISECONDS) >= 98);
|
assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) >= 98);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class SQSErrorRetryHandlerTest {
|
||||||
Stopwatch watch = new Stopwatch().start();
|
Stopwatch watch = new Stopwatch().start();
|
||||||
assertFalse(retry.shouldRetryRequestOnError(command, response, error));
|
assertFalse(retry.shouldRetryRequestOnError(command, response, error));
|
||||||
assertEquals(command.getFailureCount(), 61);
|
assertEquals(command.getFailureCount(), 61);
|
||||||
assertTrue(watch.stop().elapsedTime(TimeUnit.MILLISECONDS) < 100);
|
assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpCommand createHttpCommandForFailureCount(final int failureCount) {
|
HttpCommand createHttpCommandForFailureCount(final int failureCount) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.hash.HashCodes;
|
import com.google.common.hash.HashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -56,7 +56,7 @@ public class ReceiveMessageResponseTest extends BaseHandlerTest {
|
||||||
.id("5fea7756-0ea4-451a-a703-a558b933e274")
|
.id("5fea7756-0ea4-451a-a703-a558b933e274")
|
||||||
.receiptHandle(
|
.receiptHandle(
|
||||||
"+eXJYhj5rDr9cAe/9BuheT5fysi9BoqtEZSkO7IazVbNHg60eCCINxLqaSVv2pFHrWeWNpZwbleSkWRbCtZaQGgpOx/3cWJZiNSG1KKlJX4IOwISFvb3FwByMx4w0lnINeXzcw2VcKQXNrCatO9gdIiVPvJC3SCKatYM/7YTidtjqc8igrtYW2E2mHlCy3NXPCeXxP4tSvyEwIxpDAmMT7IF0mWvTHS6+JBUtFUsrmi61oIHlESNrD1OjdB1QQw+kdvJ6VbsntbJNNYKw+YqdqWNpZkiGQ8y1z9OdHsr1+4=")
|
"+eXJYhj5rDr9cAe/9BuheT5fysi9BoqtEZSkO7IazVbNHg60eCCINxLqaSVv2pFHrWeWNpZwbleSkWRbCtZaQGgpOx/3cWJZiNSG1KKlJX4IOwISFvb3FwByMx4w0lnINeXzcw2VcKQXNrCatO9gdIiVPvJC3SCKatYM/7YTidtjqc8igrtYW2E2mHlCy3NXPCeXxP4tSvyEwIxpDAmMT7IF0mWvTHS6+JBUtFUsrmi61oIHlESNrD1OjdB1QQw+kdvJ6VbsntbJNNYKw+YqdqWNpZkiGQ8y1z9OdHsr1+4=")
|
||||||
.md5(HashCodes.fromBytes(base16().lowerCase().decode("fafb00f5732ab283681e124bf8747ed1")))
|
.md5(HashCode.fromBytes(base16().lowerCase().decode("fafb00f5732ab283681e124bf8747ed1")))
|
||||||
.body("This is a test message")
|
.body("This is a test message")
|
||||||
.addAttribute("SenderId", "195004372649")
|
.addAttribute("SenderId", "195004372649")
|
||||||
.addAttribute("SentTimestamp", "1238099229000")
|
.addAttribute("SentTimestamp", "1238099229000")
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.jclouds.sqs.domain.MessageIdAndMD5;
|
||||||
import org.jclouds.sqs.xml.SendMessageBatchResponseHandler;
|
import org.jclouds.sqs.xml.SendMessageBatchResponseHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.hash.HashCodes;
|
import com.google.common.hash.HashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -54,10 +54,10 @@ public class SendMessageBatchResponseTest extends BaseHandlerTest {
|
||||||
.<MessageIdAndMD5> builder()
|
.<MessageIdAndMD5> builder()
|
||||||
.put("test_msg_001",
|
.put("test_msg_001",
|
||||||
MessageIdAndMD5.builder().id("0a5231c7-8bff-4955-be2e-8dc7c50a25fa")
|
MessageIdAndMD5.builder().id("0a5231c7-8bff-4955-be2e-8dc7c50a25fa")
|
||||||
.md5(HashCodes.fromBytes(base16().lowerCase().decode("0e024d309850c78cba5eabbeff7cae71"))).build())
|
.md5(HashCode.fromBytes(base16().lowerCase().decode("0e024d309850c78cba5eabbeff7cae71"))).build())
|
||||||
.put("test_msg_002",
|
.put("test_msg_002",
|
||||||
MessageIdAndMD5.builder().id("15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9")
|
MessageIdAndMD5.builder().id("15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9")
|
||||||
.md5(HashCodes.fromBytes(base16().lowerCase().decode("7fb8146a82f95e0af155278f406862c2"))).build())
|
.md5(HashCode.fromBytes(base16().lowerCase().decode("7fb8146a82f95e0af155278f406862c2"))).build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.jclouds.sqs.domain.MessageIdAndMD5;
|
||||||
import org.jclouds.sqs.xml.RegexMessageIdAndMD5Handler;
|
import org.jclouds.sqs.xml.RegexMessageIdAndMD5Handler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.hash.HashCodes;
|
import com.google.common.hash.HashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -51,6 +51,6 @@ public class SendMessageResponseTest {
|
||||||
|
|
||||||
public MessageIdAndMD5 expected() {
|
public MessageIdAndMD5 expected() {
|
||||||
return MessageIdAndMD5.builder().id("c332b2b0-b61f-42d3-8832-d03ebd89f68d")
|
return MessageIdAndMD5.builder().id("c332b2b0-b61f-42d3-8832-d03ebd89f68d")
|
||||||
.md5(HashCodes.fromBytes(base16().lowerCase().decode("e32aedf2b2b25355d04b1507055532e6"))).build();
|
.md5(HashCode.fromBytes(base16().lowerCase().decode("e32aedf2b2b25355d04b1507055532e6"))).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_R
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.formatStatus;
|
import static org.jclouds.compute.util.ComputeServiceUtils.formatStatus;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
@ -63,7 +64,7 @@ public class PollNodeRunning implements Function<AtomicReference<NodeMetadata>,
|
||||||
try {
|
try {
|
||||||
Stopwatch stopwatch = new Stopwatch().start();
|
Stopwatch stopwatch = new Stopwatch().start();
|
||||||
if (!nodeRunning.apply(node)) {
|
if (!nodeRunning.apply(node)) {
|
||||||
long timeWaited = stopwatch.elapsedMillis();
|
long timeWaited = stopwatch.elapsed(TimeUnit.MILLISECONDS);
|
||||||
if (node.get() == null) {
|
if (node.get() == null) {
|
||||||
node.set(originalNode);
|
node.set(originalNode);
|
||||||
throw new IllegalStateException(format("api response for node(%s) was null", originalId));
|
throw new IllegalStateException(format("api response for node(%s) was null", originalId));
|
||||||
|
|
|
@ -660,7 +660,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
ServiceStats stats = new ServiceStats();
|
ServiceStats stats = new ServiceStats();
|
||||||
Stopwatch watch = new Stopwatch().start();
|
Stopwatch watch = new Stopwatch().start();
|
||||||
ExecResponse exec = client.runScriptOnNode(node.getId(), process, runAsRoot(false).wrapInInitScript(false));
|
ExecResponse exec = client.runScriptOnNode(node.getId(), process, runAsRoot(false).wrapInInitScript(false));
|
||||||
stats.backgroundProcessMilliseconds = watch.elapsedTime(TimeUnit.MILLISECONDS);
|
stats.backgroundProcessMilliseconds = watch.elapsed(TimeUnit.MILLISECONDS);
|
||||||
watch.reset().start();
|
watch.reset().start();
|
||||||
|
|
||||||
HostAndPort socket = null;
|
HostAndPort socket = null;
|
||||||
|
@ -670,7 +670,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
throw new NoSuchElementException(format("%s%n%s%s", e.getMessage(), exec.getOutput(), exec.getError()));
|
throw new NoSuchElementException(format("%s%n%s%s", e.getMessage(), exec.getOutput(), exec.getError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.socketOpenMilliseconds = watch.elapsedTime(TimeUnit.MILLISECONDS);
|
stats.socketOpenMilliseconds = watch.elapsed(TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
getAnonymousLogger().info(format("<< %s on node(%s)[%s] %s", processName, node.getId(), socket, stats));
|
getAnonymousLogger().info(format("<< %s on node(%s)[%s] %s", processName, node.getId(), socket, stats));
|
||||||
return stats;
|
return stats;
|
||||||
|
@ -702,7 +702,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
Stopwatch watch = new Stopwatch().start();
|
Stopwatch watch = new Stopwatch().start();
|
||||||
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1,
|
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1,
|
||||||
inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags)));
|
inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags)));
|
||||||
long createSeconds = watch.elapsedTime(TimeUnit.SECONDS);
|
long createSeconds = watch.elapsed(TimeUnit.SECONDS);
|
||||||
|
|
||||||
final String nodeId = node.getId();
|
final String nodeId = node.getId();
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
|
|
||||||
client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty"));
|
client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty"));
|
||||||
|
|
||||||
long configureSeconds = watch.elapsedTime(TimeUnit.SECONDS);
|
long configureSeconds = watch.elapsed(TimeUnit.SECONDS);
|
||||||
|
|
||||||
getAnonymousLogger().info(
|
getAnonymousLogger().info(
|
||||||
format(
|
format(
|
||||||
|
|
|
@ -93,9 +93,9 @@ public abstract class Wire {
|
||||||
long bytesRead = ByteStreams.copy(instream, out);
|
long bytesRead = ByteStreams.copy(instream, out);
|
||||||
if (bytesRead >= limit)
|
if (bytesRead >= limit)
|
||||||
logger.debug("over limit %d/%d: wrote temp file", bytesRead, limit);
|
logger.debug("over limit %d/%d: wrote temp file", bytesRead, limit);
|
||||||
wire(header, out.getSupplier().getInput());
|
wire(header, out.asByteSource().getInput());
|
||||||
// we must call FileBackedOutputStream.reset to remove temporary file
|
// we must call FileBackedOutputStream.reset to remove temporary file
|
||||||
return new FilterInputStream(out.getSupplier().getInput()) {
|
return new FilterInputStream(out.asByteSource().getInput()) {
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
super.close();
|
super.close();
|
||||||
|
|
|
@ -42,6 +42,6 @@ public class BindAsHostPrefix implements Binder {
|
||||||
checkNotNull(payload, "hostprefix");
|
checkNotNull(payload, "hostprefix");
|
||||||
checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request);
|
checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request);
|
||||||
InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString());
|
InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString());
|
||||||
return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.name()).build()).build();
|
return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.toString()).build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue