HBASE-14963 Remove use of Guava Stopwatch from HBase client code (Devaraj Das)
This commit is contained in:
parent
463374ecfa
commit
8151503fa0
|
@ -54,7 +54,6 @@ import org.apache.hadoop.hbase.util.Pair;
|
||||||
import org.apache.hadoop.ipc.RemoteException;
|
import org.apache.hadoop.ipc.RemoteException;
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,11 +227,11 @@ public class MetaTableLocator {
|
||||||
* @throws InterruptedException if interrupted while waiting
|
* @throws InterruptedException if interrupted while waiting
|
||||||
*/
|
*/
|
||||||
public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException {
|
public void waitMetaRegionLocation(ZooKeeperWatcher zkw) throws InterruptedException {
|
||||||
Stopwatch stopwatch = new Stopwatch().start();
|
long startTime = System.currentTimeMillis();
|
||||||
while (!stopped) {
|
while (!stopped) {
|
||||||
try {
|
try {
|
||||||
if (waitMetaRegionLocation(zkw, 100) != null) break;
|
if (waitMetaRegionLocation(zkw, 100) != null) break;
|
||||||
long sleepTime = stopwatch.elapsedMillis();
|
long sleepTime = System.currentTimeMillis() - startTime;
|
||||||
// +1 in case sleepTime=0
|
// +1 in case sleepTime=0
|
||||||
if ((sleepTime + 1) % 10000 == 0) {
|
if ((sleepTime + 1) % 10000 == 0) {
|
||||||
LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
|
LOG.warn("Have been waiting for meta to be assigned for " + sleepTime + "ms");
|
||||||
|
@ -590,19 +589,15 @@ public class MetaTableLocator {
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
if (timeout < 0) throw new IllegalArgumentException();
|
if (timeout < 0) throw new IllegalArgumentException();
|
||||||
if (zkw == null) throw new IllegalArgumentException();
|
if (zkw == null) throw new IllegalArgumentException();
|
||||||
Stopwatch sw = new Stopwatch().start();
|
long startTime = System.currentTimeMillis();
|
||||||
ServerName sn = null;
|
ServerName sn = null;
|
||||||
try {
|
while (true) {
|
||||||
while (true) {
|
sn = getMetaRegionLocation(zkw, replicaId);
|
||||||
sn = getMetaRegionLocation(zkw, replicaId);
|
if (sn != null || (System.currentTimeMillis() - startTime)
|
||||||
if (sn != null || sw.elapsedMillis()
|
> timeout - HConstants.SOCKET_RETRY_WAIT_MS) {
|
||||||
> timeout - HConstants.SOCKET_RETRY_WAIT_MS) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS);
|
|
||||||
}
|
}
|
||||||
} finally {
|
Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS);
|
||||||
sw.stop();
|
|
||||||
}
|
}
|
||||||
return sn;
|
return sn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue