This is an automated email from the ASF dual-hosted git repository.

domgarguilo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 3e6c5be1b8f2c3ea03d2d1cf73ecebe8001b6893
Merge: fc4bc695fd 41fd482771
Author: Dom Garguilo <domgargu...@apache.org>
AuthorDate: Fri Aug 2 14:27:14 2024 -0400

    Merge remote-tracking branch 'upstream/2.1'

 .../accumulo/core/clientImpl/ClientContext.java    |  17 +--
 .../core/clientImpl/NamespaceOperationsImpl.java   |  18 +--
 .../core/clientImpl/RootTabletLocator.java         |  10 +-
 .../core/clientImpl/TableOperationsImpl.java       |  24 ++-
 .../core/clientImpl/TabletLocatorImpl.java         |  24 ++-
 .../TabletServerBatchReaderIterator.java           |  15 +-
 .../accumulo/core/clientImpl/ThriftScanner.java    |  28 ++--
 .../core/metadata/MetadataLocationObtainer.java    |  12 +-
 .../org/apache/accumulo/core/util/OpTimer.java     | 131 ----------------
 .../java/org/apache/accumulo/core/util/Timer.java  |  91 +++++++++++
 .../org/apache/accumulo/core/util/OpTimerTest.java | 168 ---------------------
 .../org/apache/accumulo/core/util/TimerTest.java   | 109 +++++++++++++
 12 files changed, 268 insertions(+), 379 deletions(-)

diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
index 62efab71f5,b6c30891b6..cdb5e53214
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
@@@ -508,30 -508,30 +507,30 @@@ public class ClientContext implements A
     */
    public List<String> getManagerLocations() {
      ensureOpen();
 -    return getManagerLocations(zooCache, getInstanceID().canonical());
 -  }
 -
 -  // available only for sharing code with old ZooKeeperInstance
 -  public static List<String> getManagerLocations(ZooCache zooCache, String 
instanceId) {
      var zLockManagerPath =
 -        ServiceLock.path(Constants.ZROOT + "/" + instanceId + 
Constants.ZMANAGER_LOCK);
 +        ServiceLock.path(Constants.ZROOT + "/" + getInstanceID() + 
Constants.ZMANAGER_LOCK);
  
-     OpTimer timer = null;
+     Timer timer = null;
  
      if (log.isTraceEnabled()) {
 -      log.trace("tid={} Looking up manager location in zookeeper.", 
Thread.currentThread().getId());
 +      log.trace("tid={} Looking up manager location in zookeeper at {}.",
 +          Thread.currentThread().getId(), zLockManagerPath);
-       timer = new OpTimer().start();
+       timer = Timer.startNew();
      }
  
 -    byte[] loc = zooCache.getLockData(zLockManagerPath);
 +    Optional<ServiceLockData> sld = zooCache.getLockData(zLockManagerPath);
 +    String location = null;
 +    if (sld.isPresent()) {
 +      location = sld.orElseThrow().getAddressString(ThriftService.MANAGER);
 +    }
  
      if (timer != null) {
-       timer.stop();
        log.trace("tid={} Found manager at {} in {}", 
Thread.currentThread().getId(),
-           (location == null ? "null" : location), String.format("%.3f secs", 
timer.scale(SECONDS)));
 -          (loc == null ? "null" : new String(loc, UTF_8)),
++          (location == null ? "null" : location),
+           String.format("%.3f secs", timer.elapsed(MILLISECONDS) / 1000.0));
      }
  
 -    if (loc == null) {
 +    if (location == null) {
        return Collections.emptyList();
      }
  
diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java
index 3c92fa5fc7,adcd02e4f4..4b4de4adfb
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java
@@@ -20,7 -20,9 +20,7 @@@ package org.apache.accumulo.core.client
  
  import static com.google.common.base.Preconditions.checkArgument;
  import static java.nio.charset.StandardCharsets.UTF_8;
- import static java.util.concurrent.TimeUnit.SECONDS;
+ import static java.util.concurrent.TimeUnit.MILLISECONDS;
 -import static java.util.concurrent.TimeUnit.MINUTES;
 -import static java.util.concurrent.TimeUnit.SECONDS;
  import static 
org.apache.accumulo.core.util.Validators.EXISTING_NAMESPACE_NAME;
  import static org.apache.accumulo.core.util.Validators.NEW_NAMESPACE_NAME;
  
diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java
index a24a236998,7fa49e5794..a86a3355c8
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java
@@@ -18,10 -18,9 +18,9 @@@
   */
  package org.apache.accumulo.core.clientImpl;
  
 +import static 
com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
  import static java.util.concurrent.TimeUnit.MILLISECONDS;
- import static java.util.concurrent.TimeUnit.SECONDS;
  import static 
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
 -import static 
org.apache.accumulo.core.util.UtilWaitThread.sleepUninterruptibly;
  
  import java.util.Collection;
  import java.util.Collections;
diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
index 91a1248c97,0d69699164..2ebd5636f8
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
@@@ -561,30 -561,30 +559,30 @@@ public class TableOperationsImpl extend
            continue;
          }
  
 -        HostAndPort address = HostAndPort.fromString(tl.tablet_location);
 +        HostAndPort address = HostAndPort.fromString(tl.getTserverLocation());
  
          try {
 -          TabletClientService.Client client =
 -              ThriftUtil.getClient(ThriftClientTypes.TABLET_SERVER, address, 
context);
 +          TabletManagementClientService.Client client =
 +              ThriftUtil.getClient(ThriftClientTypes.TABLET_MGMT, address, 
context);
            try {
  
-             OpTimer timer = null;
+             Timer timer = null;
  
              if (log.isTraceEnabled()) {
                log.trace("tid={} Splitting tablet {} on {} at {}", 
Thread.currentThread().getId(),
 -                  tl.tablet_extent, address, split);
 +                  tl.getExtent(), address, split);
-               timer = new OpTimer().start();
+               timer = Timer.startNew();
              }
  
 -            client.splitTablet(TraceUtil.traceInfo(), context.rpcCreds(),
 -                tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split));
 +            client.splitTablet(TraceUtil.traceInfo(), context.rpcCreds(), 
tl.getExtent().toThrift(),
 +                TextUtil.getByteBuffer(split));
  
              // just split it, might as well invalidate it in the cache
 -            tabLocator.invalidateCache(tl.tablet_extent);
 +            tabLocator.invalidateCache(tl.getExtent());
  
              if (timer != null) {
-               timer.stop();
-               log.trace("Split tablet in {}", String.format("%.3f secs", 
timer.scale(SECONDS)));
+               log.trace("Split tablet in {}",
+                   String.format("%.3f secs", timer.elapsed(MILLISECONDS) / 
1000.0));
              }
  
            } finally {
diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
index dafada9132,d1e935577b..6e6ccbb023
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
@@@ -18,9 -18,8 +18,8 @@@
   */
  package org.apache.accumulo.core.clientImpl;
  
 +import static 
com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
  import static java.util.concurrent.TimeUnit.MILLISECONDS;
- import static java.util.concurrent.TimeUnit.SECONDS;
 -import static 
org.apache.accumulo.core.util.UtilWaitThread.sleepUninterruptibly;
  
  import java.util.ArrayList;
  import java.util.Collection;
@@@ -515,10 -511,9 +512,9 @@@ public class TabletLocatorImpl extends 
        }
  
        if (timer != null) {
-         timer.stop();
          log.trace("tid={} Located tablet {} at {} in {}", 
Thread.currentThread().getId(),
 -            (tl == null ? "null" : tl.tablet_extent), (tl == null ? "null" : 
tl.tablet_location),
 +            (tl == null ? "null" : tl.getExtent()), (tl == null ? "null" : 
tl.getTserverLocation()),
-             String.format("%.3f secs", timer.scale(SECONDS)));
+             String.format("%.3f secs", timer.elapsed(MILLISECONDS) / 1000.0));
        }
  
        return tl;
diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java
index b39240fb4e,79fd934861..ff8df386b3
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java
@@@ -18,6 -18,8 +18,7 @@@
   */
  package org.apache.accumulo.core.clientImpl;
  
+ import static java.util.concurrent.TimeUnit.MILLISECONDS;
 -import static java.util.concurrent.TimeUnit.MINUTES;
  import static java.util.concurrent.TimeUnit.SECONDS;
  
  import java.io.IOException;
@@@ -71,14 -73,15 +72,14 @@@ import org.apache.accumulo.core.securit
  import org.apache.accumulo.core.spi.scan.ScanServerAttempt;
  import org.apache.accumulo.core.spi.scan.ScanServerSelections;
  import org.apache.accumulo.core.spi.scan.ScanServerSelector;
 +import org.apache.accumulo.core.tabletscan.thrift.ScanServerBusyException;
 +import org.apache.accumulo.core.tabletscan.thrift.TSampleNotPresentException;
 +import org.apache.accumulo.core.tabletscan.thrift.TabletScanClientService;
  import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
 -import org.apache.accumulo.core.tabletserver.thrift.ScanServerBusyException;
 -import 
org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
 -import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
  import org.apache.accumulo.core.trace.TraceUtil;
  import org.apache.accumulo.core.util.ByteBufferUtil;
- import org.apache.accumulo.core.util.OpTimer;
 -import org.apache.accumulo.core.util.HostAndPort;
  import org.apache.accumulo.core.util.Retry;
+ import org.apache.accumulo.core.util.Timer;
  import org.apache.thrift.TApplicationException;
  import org.apache.thrift.TException;
  import org.apache.thrift.transport.TTransportException;
diff --cc 
core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java
index 14027327d1,fc49f486f7..4ff9907460
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java
@@@ -18,10 -18,11 +18,10 @@@
   */
  package org.apache.accumulo.core.clientImpl;
  
- import static java.util.concurrent.TimeUnit.SECONDS;
+ import static java.util.concurrent.TimeUnit.MILLISECONDS;
 -import static java.util.concurrent.TimeUnit.SECONDS;
 +import static org.apache.accumulo.core.util.LazySingletons.RANDOM;
  
  import java.io.IOException;
 -import java.security.SecureRandom;
  import java.time.Duration;
  import java.util.ArrayList;
  import java.util.Collection;
@@@ -69,15 -70,17 +69,15 @@@ import org.apache.accumulo.core.securit
  import org.apache.accumulo.core.spi.scan.ScanServerAttempt;
  import org.apache.accumulo.core.spi.scan.ScanServerSelections;
  import org.apache.accumulo.core.spi.scan.ScanServerSelector;
 +import org.apache.accumulo.core.tabletscan.thrift.ScanServerBusyException;
 +import org.apache.accumulo.core.tabletscan.thrift.TSampleNotPresentException;
 +import org.apache.accumulo.core.tabletscan.thrift.TabletScanClientService;
 +import org.apache.accumulo.core.tabletscan.thrift.TooManyFilesException;
  import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
  import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
 -import org.apache.accumulo.core.tabletserver.thrift.ScanServerBusyException;
 -import 
org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException;
 -import org.apache.accumulo.core.tabletserver.thrift.TabletScanClientService;
 -import org.apache.accumulo.core.tabletserver.thrift.TooManyFilesException;
  import org.apache.accumulo.core.trace.TraceUtil;
- import org.apache.accumulo.core.util.OpTimer;
 -import org.apache.accumulo.core.trace.thrift.TInfo;
 -import org.apache.accumulo.core.util.HostAndPort;
  import org.apache.accumulo.core.util.Retry;
+ import org.apache.accumulo.core.util.Timer;
  import org.apache.hadoop.io.Text;
  import org.apache.thrift.TApplicationException;
  import org.apache.thrift.TException;
@@@ -688,15 -691,14 +688,15 @@@ public class ThriftScanner 
                + scanState.serverSideIteratorList + " ssio=" + 
scanState.serverSideIteratorOptions
                + " context=" + scanState.classLoaderContext;
            log.trace("tid={} {}", Thread.currentThread().getId(), msg);
-           timer = new OpTimer().start();
+           timer = Timer.startNew();
          }
  
 -        TabletType ttype = TabletType.type(loc.tablet_extent);
 -        boolean waitForWrites = 
!serversWaitedForWrites.get(ttype).contains(loc.tablet_location);
 +        TabletType ttype = TabletType.type(loc.getExtent());
 +        boolean waitForWrites =
 +            
!serversWaitedForWrites.get(ttype).contains(loc.getTserverLocation());
  
          InitialScan is = client.startScan(tinfo, scanState.context.rpcCreds(),
 -            loc.tablet_extent.toThrift(), scanState.range.toThrift(),
 +            loc.getExtent().toThrift(), scanState.range.toThrift(),
              
scanState.columns.stream().map(Column::toThrift).collect(Collectors.toList()),
              scanState.size, scanState.serverSideIteratorList, 
scanState.serverSideIteratorOptions,
              scanState.authorizations.getAuthorizationsBB(), waitForWrites, 
scanState.isolated,
diff --cc 
core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java
index 80126d125d,e81ec2b485..9b380b296a
--- 
a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java
@@@ -18,10 -18,9 +18,10 @@@
   */
  package org.apache.accumulo.core.metadata;
  
- import static java.util.concurrent.TimeUnit.SECONDS;
+ import static java.util.concurrent.TimeUnit.MILLISECONDS;
  
  import java.io.IOException;
 +import java.io.UncheckedIOException;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
@@@ -89,9 -88,9 +89,9 @@@ public class MetadataLocationObtainer i
  
        if (log.isTraceEnabled()) {
          log.trace("tid={} Looking up in {} row={} extent={} tserver={}",
 -            Thread.currentThread().getId(), src.tablet_extent.tableId(), 
TextUtil.truncate(row),
 -            src.tablet_extent, src.tablet_location);
 +            Thread.currentThread().getId(), src.getExtent().tableId(), 
TextUtil.truncate(row),
 +            src.getExtent(), src.getTserverLocation());
-         timer = new OpTimer().start();
+         timer = Timer.startNew();
        }
  
        Range range = new Range(row, true, stopRow, true);
@@@ -124,9 -123,9 +124,9 @@@
        }
  
        if (timer != null) {
-         timer.stop();
          log.trace("tid={} Got {} results from {} in {}", 
Thread.currentThread().getId(),
-             results.size(), src.getExtent(), String.format("%.3f secs", 
timer.scale(SECONDS)));
 -            results.size(), src.tablet_extent,
++            results.size(), src.getExtent(),
+             String.format("%.3f secs", timer.elapsed(MILLISECONDS) / 1000.0));
        }
  
        // if (log.isTraceEnabled()) log.trace("results "+results);

Reply via email to