Address miscellaneous Guava deprecations

References JCLOUDS-415.
This commit is contained in:
Andrew Gaul 2013-12-20 13:42:29 -08:00
parent fcca1fd525
commit f9e98681b6
11 changed files with 24 additions and 23 deletions

View File

@ -22,7 +22,7 @@ import static org.jclouds.util.SaxUtils.currentOrNull;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.sqs.domain.Message;
import com.google.common.hash.HashCodes;
import com.google.common.hash.HashCode;
/**
* @see <a href=
@ -55,7 +55,7 @@ public class MessageHandler extends ParseSax.HandlerForGeneratedRequestWithResul
} else if (qName.equals("ReceiptHandle")) {
builder.receiptHandle(currentOrNull(currentText));
} 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")) {
builder.body(currentOrNull(currentText));
} else if (qName.equals("Name")) {

View File

@ -28,7 +28,7 @@ import org.jclouds.http.functions.ReturnStringIf2xx;
import org.jclouds.sqs.domain.MessageIdAndMD5;
import com.google.common.base.Function;
import com.google.common.hash.HashCodes;
import com.google.common.hash.HashCode;
import com.google.inject.Singleton;
/**
@ -55,7 +55,7 @@ public class RegexMessageIdAndMD5Handler implements Function<HttpResponse, Messa
if (matcher.find()) {
return MessageIdAndMD5.builder()
.id(matcher.group(1))
.md5(HashCodes.fromBytes(base16().lowerCase().decode(matcher.group(2))))
.md5(HashCode.fromBytes(base16().lowerCase().decode(matcher.group(2))))
.build();
}
}

View File

@ -27,7 +27,7 @@ import org.jclouds.sqs.domain.MessageIdAndMD5;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.hash.HashCodes;
import com.google.common.hash.HashCode;
/**
* @see <a href=
@ -59,7 +59,7 @@ public class SendMessageBatchResultEntryHandler extends
} else if (qName.equals("MessageId")) {
builder.id(currentOrNull(currentText));
} 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();
}

View File

@ -63,7 +63,7 @@ public class SQSErrorRetryHandlerTest {
assertTrue(retry.shouldRetryRequestOnError(command, response, error));
assertEquals(command.getFailureCount(), 60);
// 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();
assertFalse(retry.shouldRetryRequestOnError(command, response, error));
assertEquals(command.getFailureCount(), 61);
assertTrue(watch.stop().elapsedTime(TimeUnit.MILLISECONDS) < 100);
assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100);
}
HttpCommand createHttpCommandForFailureCount(final int failureCount) {

View File

@ -28,7 +28,7 @@ import org.testng.annotations.Test;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.hash.HashCodes;
import com.google.common.hash.HashCode;
/**
* @author Adrian Cole
@ -56,7 +56,7 @@ public class ReceiveMessageResponseTest extends BaseHandlerTest {
.id("5fea7756-0ea4-451a-a703-a558b933e274")
.receiptHandle(
"+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")
.addAttribute("SenderId", "195004372649")
.addAttribute("SentTimestamp", "1238099229000")

View File

@ -27,7 +27,7 @@ import org.jclouds.sqs.domain.MessageIdAndMD5;
import org.jclouds.sqs.xml.SendMessageBatchResponseHandler;
import org.testng.annotations.Test;
import com.google.common.hash.HashCodes;
import com.google.common.hash.HashCode;
/**
* @author Adrian Cole
@ -54,10 +54,10 @@ public class SendMessageBatchResponseTest extends BaseHandlerTest {
.<MessageIdAndMD5> builder()
.put("test_msg_001",
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",
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();
}
}

View File

@ -27,7 +27,7 @@ import org.jclouds.sqs.domain.MessageIdAndMD5;
import org.jclouds.sqs.xml.RegexMessageIdAndMD5Handler;
import org.testng.annotations.Test;
import com.google.common.hash.HashCodes;
import com.google.common.hash.HashCode;
/**
* @author Adrian Cole
@ -51,6 +51,6 @@ public class SendMessageResponseTest {
public MessageIdAndMD5 expected() {
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();
}
}

View File

@ -23,6 +23,7 @@ import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_R
import static org.jclouds.compute.util.ComputeServiceUtils.formatStatus;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Named;
@ -63,7 +64,7 @@ public class PollNodeRunning implements Function<AtomicReference<NodeMetadata>,
try {
Stopwatch stopwatch = new Stopwatch().start();
if (!nodeRunning.apply(node)) {
long timeWaited = stopwatch.elapsedMillis();
long timeWaited = stopwatch.elapsed(TimeUnit.MILLISECONDS);
if (node.get() == null) {
node.set(originalNode);
throw new IllegalStateException(format("api response for node(%s) was null", originalId));

View File

@ -660,7 +660,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
ServiceStats stats = new ServiceStats();
Stopwatch watch = new Stopwatch().start();
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();
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()));
}
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));
return stats;
@ -702,7 +702,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
Stopwatch watch = new Stopwatch().start();
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1,
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();
@ -716,7 +716,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
client.runScriptOnNode(nodeId, JettyStatements.install(), nameTask("configure-jetty"));
long configureSeconds = watch.elapsedTime(TimeUnit.SECONDS);
long configureSeconds = watch.elapsed(TimeUnit.SECONDS);
getAnonymousLogger().info(
format(

View File

@ -93,9 +93,9 @@ public abstract class Wire {
long bytesRead = ByteStreams.copy(instream, out);
if (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
return new FilterInputStream(out.getSupplier().getInput()) {
return new FilterInputStream(out.asByteSource().getInput()) {
@Override
public void close() throws IOException {
super.close();

View File

@ -42,6 +42,6 @@ public class BindAsHostPrefix implements Binder {
checkNotNull(payload, "hostprefix");
checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request);
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();
}
}