diff options
author | Jacques Nadeau <jacques@apache.org> | 2015-09-14 13:01:57 -0700 |
---|---|---|
committer | Jacques Nadeau <jacques@apache.org> | 2016-02-05 06:59:39 -0800 |
commit | 422c5a83b8e69e4169d3ebc946401248073c8bf8 (patch) | |
tree | 5b7d06065ab69e3271123e2bcfa9f55125b90a17 /exec/java-exec/src | |
parent | dea0d8bcdaaa148e9ead0e01cb4520d75471866d (diff) |
DRILL-3581: Upgrade to Guava 18.0
- Replace Stopwatch constructors with .createStarted() or .createUnstarted()
- Stop using InputSupplier and Closeables.closeQuietly
- Clean up quiet closes to log or (preferably) propagate.
- Add log4j to enforcer exclusions.
- Update HBaseTestSuite to add patching of Closeables.closeQuietly() and Stopwatch legacy methods. Only needed when running HBaseMiniCluster.
- Remove log4j from HBase's pom to provide exception logging.
- Remove log4j from Hive's shaded pom.
- Update Catastrophic failures to use the same pattern to ensure reporting.
- Update test framework to avoid trying IPv6 resolution. (This removes 90s pause from HBase startup in my tests)
This closes #361.
This closes #157.
Diffstat (limited to 'exec/java-exec/src')
42 files changed, 80 insertions, 118 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java b/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java index 6bc8593c7..bdd2fab12 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/PrintingResultsListener.java @@ -44,7 +44,7 @@ public class PrintingResultsListener implements UserResultsListener { private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PrintingResultsListener.class); private final AtomicInteger count = new AtomicInteger(); - private final Stopwatch w = new Stopwatch(); + private final Stopwatch w = Stopwatch.createUnstarted(); private final RecordBatchLoader loader; private final Format format; private final int columnWidth; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java index 76a0a31dc..c285fb7c6 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/QuerySubmitter.java @@ -186,7 +186,7 @@ public class QuerySubmitter { System.out.println("Invalid format type: " + format); return -1; } - Stopwatch watch = new Stopwatch(); + Stopwatch watch = Stopwatch.createUnstarted(); for (String query : queries) { AwaitableUserResultsListener listener = new AwaitableUserResultsListener(new PrintingResultsListener(client.getConfig(), outputFormat, width)); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java index 6be615d8e..a57f11636 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionImplementationRegistry.java @@ -51,7 +51,7 @@ public class FunctionImplementationRegistry implements FunctionLookupContext { } public FunctionImplementationRegistry(DrillConfig config, ScanResult classpathScan){ - Stopwatch w = new Stopwatch().start(); + Stopwatch w = Stopwatch.createStarted(); logger.debug("Generating function registry."); drillFuncRegistry = new DrillFunctionRegistry(classpathScan); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java index 55d5d9282..1007afcdb 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java @@ -33,7 +33,6 @@ import org.codehaus.janino.Scanner; import org.mortbay.util.IO; import com.google.common.collect.Maps; -import com.google.common.io.InputSupplier; import com.google.common.io.Resources; /** @@ -125,8 +124,7 @@ public class FunctionInitializer { } URL u = Resources.getResource(c, path); - InputSupplier<InputStream> supplier = Resources.newInputStreamSupplier(u); - try (InputStream is = supplier.getInput()) { + try (InputStream is = Resources.asByteSource(u).openStream()) { if (is == null) { throw new IOException(String.format( "Failure trying to located source code for Class %s, tried to read on classpath location %s", c.getName(), diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ImplCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ImplCreator.java index 81030302b..6fd6ce2e8 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ImplCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ImplCreator.java @@ -72,8 +72,7 @@ public class ImplCreator { root = IteratorValidatorInjector.rewritePlanWithIteratorValidator(context, root); } final ImplCreator creator = new ImplCreator(); - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); try { final RootExec rootExec = creator.getRootExec(root, context); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/PriorityQueueTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/PriorityQueueTemplate.java index 2b1830eac..7f77ec50d 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/PriorityQueueTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/PriorityQueueTemplate.java @@ -88,8 +88,7 @@ public abstract class PriorityQueueTemplate implements PriorityQueue { @Override public void add(FragmentContext context, RecordBatchData batch) throws SchemaChangeException{ - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); if (hyperBatch == null) { hyperBatch = new ExpandableHyperContainer(batch.getContainer()); } else { @@ -124,8 +123,7 @@ public abstract class PriorityQueueTemplate implements PriorityQueue { @Override public void generate() throws SchemaChangeException { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); final DrillBuf drillBuf = allocator.buffer(4 * queueSize); finalSv4 = new SelectionVector4(drillBuf, queueSize, 4000); for (int i = queueSize - 1; i >= 0; i--) { diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java index a6c3269df..c0d8e9889 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/TopN/TopNBatch.java @@ -180,8 +180,7 @@ public class TopNBatch extends AbstractRecordBatch<TopN> { try{ outer: while (true) { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); IterOutcome upstream; if (first) { upstream = IterOutcome.OK_NEW_SCHEMA; @@ -284,8 +283,7 @@ public class TopNBatch extends AbstractRecordBatch<TopN> { } private void purge() throws SchemaChangeException { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); VectorContainer c = priorityQueue.getHyperBatch(); VectorContainer newContainer = new VectorContainer(oContext); SelectionVector4 selectionVector4 = priorityQueue.getHeapSv4(); @@ -380,8 +378,7 @@ public class TopNBatch extends AbstractRecordBatch<TopN> { * @throws SchemaChangeException */ public void purgeAndResetPriorityQueue() throws SchemaChangeException, ClassTransformationException, IOException { - final Stopwatch watch = new Stopwatch(); - watch.start(); + final Stopwatch watch = Stopwatch.createStarted(); final VectorContainer c = priorityQueue.getHyperBatch(); final VectorContainer newContainer = new VectorContainer(oContext); final SelectionVector4 selectionVector4 = priorityQueue.getHeapSv4(); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/SortTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/SortTemplate.java index 593db0dee..edb704f2c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/SortTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/SortTemplate.java @@ -47,8 +47,7 @@ public abstract class SortTemplate implements Sorter, IndexedSortable{ @Override public void sort(SelectionVector4 vector4, VectorContainer container){ - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); QuickSort qs = new QuickSort(); qs.sort(this, 0, vector4.getTotalCount()); logger.debug("Took {} us to sort {} records", watch.elapsed(TimeUnit.MICROSECONDS), vector4.getTotalCount()); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/BatchGroup.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/BatchGroup.java index e22830557..5a3b30544 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/BatchGroup.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/BatchGroup.java @@ -92,8 +92,7 @@ public class BatchGroup implements VectorAccessible, AutoCloseable { int recordCount = newContainer.getRecordCount(); WritableBatch batch = WritableBatch.getBatchNoHVWrap(recordCount, newContainer, false); VectorAccessibleSerializable outputBatch = new VectorAccessibleSerializable(batch, allocator); - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); outputBatch.writeToStream(outputStream); newContainer.zeroVectors(); logger.debug("Took {} us to spill {} records", watch.elapsed(TimeUnit.MICROSECONDS), recordCount); @@ -107,8 +106,7 @@ public class BatchGroup implements VectorAccessible, AutoCloseable { inputStream = fs.open(path); } VectorAccessibleSerializable vas = new VectorAccessibleSerializable(allocator); - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); vas.readFromStream(inputStream); VectorContainer c = vas.get(); if (schema != null) { diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java index 3dc20dcbb..b2aa305df 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java @@ -267,8 +267,7 @@ public class ExternalSortBatch extends AbstractRecordBatch<ExternalSort> { if (spillCount == 0) { return (getSelectionVector4().next()) ? IterOutcome.OK : IterOutcome.NONE; } else { - Stopwatch w = new Stopwatch(); - w.start(); + Stopwatch w = Stopwatch.createStarted(); int count = copier.next(targetRecordCount); if (count > 0) { long t = w.elapsed(TimeUnit.MICROSECONDS); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java index 6e37a6828..3ed9cd062 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java @@ -124,8 +124,7 @@ public abstract class MSortTemplate implements MSorter, IndexedSortable { @Override public void sort(final VectorContainer container) { - final Stopwatch watch = new Stopwatch(); - watch.start(); + final Stopwatch watch = Stopwatch.createStarted(); while (runStarts.size() > 1) { // check if we're cancelled/failed frequently diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java index fb123af25..9a6bc8cb1 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java @@ -50,8 +50,7 @@ public abstract class SingleBatchSorterTemplate implements SingleBatchSorter, In @Override public void sort(SelectionVector2 vector2){ QuickSort qs = new QuickSort(); - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); if (vector2.getCount() > 0) { qs.sort(this, 0, vector2.getCount()); } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java index aefd247d5..5ef35d35b 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/partition/PruneScanRule.java @@ -154,9 +154,7 @@ public abstract class PruneScanRule extends StoragePluginOptimizerRule { protected void doOnMatch(RelOptRuleCall call, Filter filterRel, Project projectRel, TableScan scanRel) { final String pruningClassName = getClass().getName(); logger.info("Beginning partition pruning, pruning class: {}", pruningClassName); - Stopwatch totalPruningTime = new Stopwatch(); - totalPruningTime.start(); - + Stopwatch totalPruningTime = Stopwatch.createStarted(); final PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner()); PartitionDescriptor descriptor = getPartitionDescriptor(settings, scanRel); @@ -196,7 +194,7 @@ public abstract class PruneScanRule extends StoragePluginOptimizerRule { } // stop watch to track how long we spend in different phases of pruning - Stopwatch miscTimer = new Stopwatch(); + Stopwatch miscTimer = Stopwatch.createUnstarted(); // track how long we spend building the filter tree miscTimer.start(); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnection.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnection.java index 49f0f01de..179a2f4e9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnection.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnection.java @@ -29,7 +29,6 @@ import org.apache.drill.exec.rpc.RemoteConnection; import org.apache.drill.exec.rpc.RpcBus; import org.apache.drill.exec.rpc.RpcOutcomeListener; -import com.google.common.io.Closeables; import com.google.protobuf.MessageLite; public class ControlConnection extends RemoteConnection { @@ -108,12 +107,6 @@ public class ControlConnection extends RemoteConnection { return true; } - public void shutdownIfClient() { - if (bus.isClient()) { - Closeables.closeQuietly(bus); - } - } - @Override public BufferAllocator getAllocator() { return allocator; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/Controller.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/Controller.java index 94df73943..d6b288c45 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/Controller.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/Controller.java @@ -20,8 +20,6 @@ package org.apache.drill.exec.rpc.control; import io.netty.buffer.ByteBuf; import io.netty.buffer.DrillBuf; -import java.io.Closeable; - import org.apache.drill.exec.exception.DrillbitStartupException; import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; import org.apache.drill.exec.rpc.UserRpcException; @@ -35,7 +33,7 @@ import com.google.protobuf.Parser; * making a connection. TODO: Controller should automatically straight route local BitCommunication rather than connecting to its * self. */ -public interface Controller extends Closeable { +public interface Controller extends AutoCloseable { /** * Get a Bit to Bit communication tunnel. If the BitCom doesn't have a tunnel attached to the node already, it will diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControllerImpl.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControllerImpl.java index a22d20758..ddc77783a 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControllerImpl.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControllerImpl.java @@ -17,6 +17,9 @@ */ package org.apache.drill.exec.rpc.control; +import java.util.List; + +import org.apache.drill.common.AutoCloseables; import org.apache.drill.exec.ExecConstants; import org.apache.drill.exec.exception.DrillbitStartupException; import org.apache.drill.exec.memory.BufferAllocator; @@ -24,7 +27,7 @@ import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; import org.apache.drill.exec.server.BootStrapContext; import org.apache.drill.exec.work.batch.ControlMessageHandler; -import com.google.common.io.Closeables; +import com.google.common.collect.Lists; import com.google.protobuf.MessageLite; import com.google.protobuf.Parser; @@ -74,11 +77,15 @@ public class ControllerImpl implements Controller { handlerRegistry.registerCustomHandler(messageTypeId, handler, parser); } - public void close() { - Closeables.closeQuietly(server); + public void close() throws Exception { + List<AutoCloseable> closeables = Lists.newArrayList(); + closeables.add(server); + for (ControlConnectionManager bt : connectionRegistry) { - bt.close(); + closeables.add(bt); } + + AutoCloseables.close(closeables); } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClientConnection.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClientConnection.java index eb5778de8..d6d83e5d3 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClientConnection.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataClientConnection.java @@ -27,7 +27,6 @@ import org.apache.drill.exec.proto.BitData.RpcType; import org.apache.drill.exec.rpc.RemoteConnection; import org.apache.drill.exec.rpc.RpcOutcomeListener; -import com.google.common.io.Closeables; import com.google.protobuf.MessageLite; public class DataClientConnection extends RemoteConnection{ @@ -84,8 +83,5 @@ public class DataClientConnection extends RemoteConnection{ return true; } - public void shutdownIfClient() { - Closeables.closeQuietly(client); - } } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataConnectionCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataConnectionCreator.java index d1ba92b9d..a90d35644 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataConnectionCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/data/DataConnectionCreator.java @@ -17,9 +17,9 @@ */ package org.apache.drill.exec.rpc.data; -import java.io.Closeable; import java.util.concurrent.ConcurrentMap; +import org.apache.drill.common.AutoCloseables; import org.apache.drill.exec.exception.DrillbitStartupException; import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; @@ -28,12 +28,11 @@ import org.apache.drill.exec.server.BootStrapContext; import org.apache.drill.exec.work.WorkManager.WorkerBee; import com.google.common.collect.Maps; -import com.google.common.io.Closeables; /** * Manages a connection for each endpoint. */ -public class DataConnectionCreator implements Closeable { +public class DataConnectionCreator implements AutoCloseable { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DataConnectionCreator.class); private volatile DataServer server; @@ -75,9 +74,8 @@ public class DataConnectionCreator implements Closeable { } @Override - public void close() { - Closeables.closeQuietly(server); - dataAllocator.close(); + public void close() throws Exception { + AutoCloseables.close(server, dataAllocator); } } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java index 049ae0c65..306db141e 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java @@ -57,7 +57,6 @@ import org.apache.drill.exec.rpc.user.security.UserAuthenticator; import org.apache.drill.exec.rpc.user.security.UserAuthenticatorFactory; import org.apache.drill.exec.work.user.UserWorker; -import com.google.common.io.Closeables; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.MessageLite; @@ -284,7 +283,11 @@ public class UserServer extends BasicServer<RpcType, UserServer.UserClientConnec @Override public void close() throws IOException { - Closeables.closeQuietly(authenticator); + try { + authenticator.close(); + } catch (Exception e) { + logger.warn("Failure closing authenticator.", e); + } super.close(); } } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java index 9734a3849..c781493eb 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java @@ -81,7 +81,7 @@ public class Drillbit implements AutoCloseable { final DrillConfig config, final RemoteServiceSet serviceSet, final ScanResult classpathScan) throws Exception { - final Stopwatch w = new Stopwatch().start(); + final Stopwatch w = Stopwatch.createStarted(); logger.debug("Construction started."); final boolean allowPortHunting = serviceSet != null; context = new BootStrapContext(config, classpathScan); @@ -102,7 +102,7 @@ public class Drillbit implements AutoCloseable { } public void run() throws Exception { - final Stopwatch w = new Stopwatch().start(); + final Stopwatch w = Stopwatch.createStarted(); logger.debug("Startup begun."); coord.start(10000); storeProvider.start(); @@ -126,7 +126,7 @@ public class Drillbit implements AutoCloseable { if (isClosed) { return; } - final Stopwatch w = new Stopwatch().start(); + final Stopwatch w = Stopwatch.createStarted(); logger.debug("Shutdown begun."); // wait for anything that is running to complete diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/service/ServiceEngine.java b/exec/java-exec/src/main/java/org/apache/drill/exec/service/ServiceEngine.java index 6444cb82b..169e26e20 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/service/ServiceEngine.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/service/ServiceEngine.java @@ -21,7 +21,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import io.netty.buffer.PooledByteBufAllocatorL; import io.netty.channel.EventLoopGroup; -import java.io.Closeable; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.concurrent.Executor; @@ -50,7 +49,6 @@ import org.apache.drill.exec.work.user.UserWorker; import com.codahale.metrics.Gauge; import com.codahale.metrics.MetricRegistry; import com.google.common.base.Stopwatch; -import com.google.common.io.Closeables; public class ServiceEngine implements AutoCloseable { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ServiceEngine.class); @@ -161,12 +159,16 @@ public class ServiceEngine implements AutoCloseable { return controller; } - private void submit(Executor p, final String name, final Closeable c) { + private void submit(Executor p, final String name, final AutoCloseable c) { p.execute(new Runnable() { @Override public void run() { - Stopwatch watch = new Stopwatch().start(); - Closeables.closeQuietly(c); + Stopwatch watch = Stopwatch.createStarted(); + try { + c.close(); + } catch (Exception e) { + logger.warn("Failure while closing {}.", name, e); + } long elapsed = watch.elapsed(MILLISECONDS); if (elapsed > 500) { logger.info("closed " + name + " in " + elapsed + " ms"); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java index aa9bf48fe..fefa18349 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java @@ -379,8 +379,7 @@ public class StoragePluginRegistryImpl implements StoragePluginRegistry { @Override public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); try { Set<String> currentPluginNames = Sets.newHashSet(plugins.names()); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/TimedRunnable.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/TimedRunnable.java index c562f0506..abb3a0409 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/TimedRunnable.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/TimedRunnable.java @@ -115,7 +115,7 @@ public abstract class TimedRunnable<V> implements Runnable { * @throws IOException All exceptions are coerced to IOException since this was build for storage system tasks initially. */ public static <V> List<V> run(final String activity, final Logger logger, final List<TimedRunnable<V>> runnables, int parallelism) throws IOException { - Stopwatch watch = new Stopwatch().start(); + Stopwatch watch = Stopwatch.createStarted(); long timedRunnableStart=System.nanoTime(); if(runnables.size() == 1){ parallelism = 1; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java index 1405aa5c5..42de8b09b 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/avro/AvroRecordReader.java @@ -130,7 +130,7 @@ public class AvroRecordReader extends AbstractRecordReader { @Override public int next() { - final Stopwatch watch = new Stopwatch().start(); + final Stopwatch watch = Stopwatch.createStarted(); if (reader == null) { throw new IllegalStateException("Avro reader is not open."); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java index 24eed8a40..2a131ba6d 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/sequencefile/SequenceFileRecordReader.java @@ -124,8 +124,7 @@ public class SequenceFileRecordReader extends AbstractRecordReader { @Override public int next() { - final Stopwatch watch = new Stopwatch(); - watch.start(); + final Stopwatch watch = Stopwatch.createStarted(); if (keyVector != null) { keyVector.clear(); keyVector.allocateNew(); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java index 90507fa03..590c612fb 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/Metadata.java @@ -198,8 +198,7 @@ public class Metadata { private ParquetTableMetadata_v2 getParquetTableMetadata(String path) throws IOException { Path p = new Path(path); FileStatus fileStatus = fs.getFileStatus(p); - Stopwatch watch = new Stopwatch(); - watch.start(); + final Stopwatch watch = Stopwatch.createStarted(); List<FileStatus> fileStatuses = getFileStatuses(fileStatus); logger.info("Took {} ms to get file statuses", watch.elapsed(TimeUnit.MILLISECONDS)); watch.reset(); @@ -425,8 +424,7 @@ public class Metadata { * @throws IOException */ private ParquetTableMetadataBase readBlockMeta(String path) throws IOException { - Stopwatch timer = new Stopwatch(); - timer.start(); + Stopwatch timer = Stopwatch.createStarted(); Path p = new Path(path); ObjectMapper mapper = new ObjectMapper(); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java index 1677f8b45..dfe90845f 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetGroupScan.java @@ -108,7 +108,7 @@ public class ParquetGroupScan extends AbstractFileGroupScan { private final List<ReadEntryWithPath> entries; - private final Stopwatch watch = new Stopwatch(); + private final Stopwatch watch = Stopwatch.createUnstarted(); private final ParquetFormatPlugin formatPlugin; private final ParquetFormatConfig formatConfig; private final DrillFileSystem fs; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetScanBatchCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetScanBatchCreator.java index afa4fa041..485f84a6f 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetScanBatchCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetScanBatchCreator.java @@ -120,7 +120,7 @@ public class ParquetScanBatchCreator implements BatchCreator<ParquetRowGroupScan These fields will be added to the constructor below */ try { - Stopwatch timer = new Stopwatch(); + Stopwatch timer = Stopwatch.createUnstarted(); if ( ! footers.containsKey(e.getPath())){ timer.start(); ParquetMetadata footer = ParquetFileReader.readFooter(conf, new Path(e.getPath())); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java index bcc7b33c0..77a216138 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/columnreaders/PageReader.java @@ -131,7 +131,7 @@ final class PageReader { private void loadDictionaryIfExists(final ColumnReader<?> parentStatus, final ColumnChunkMetaData columnChunkMetaData, final FSDataInputStream f) throws IOException { - Stopwatch timer = new Stopwatch(); + Stopwatch timer = Stopwatch.createUnstarted(); if (columnChunkMetaData.getDictionaryPageOffset() > 0) { f.seek(columnChunkMetaData.getDictionaryPageOffset()); long start=f.getPos(); @@ -163,7 +163,7 @@ final class PageReader { } public void readPage(PageHeader pageHeader, int compressedSize, int uncompressedSize, DrillBuf dest) throws IOException { - Stopwatch timer = new Stopwatch(); + Stopwatch timer = Stopwatch.createUnstarted(); long timeToRead; long start=inputStream.getPos(); if (parentColumnReader.columnChunkMetaData.getCodec() == CompressionCodecName.UNCOMPRESSED) { @@ -203,7 +203,7 @@ final class PageReader { * @throws java.io.IOException */ public boolean next() throws IOException { - Stopwatch timer = new Stopwatch(); + Stopwatch timer = Stopwatch.createUnstarted(); currentPageCount = -1; valuesRead = 0; valuesReadyToRead = 0; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AffinityCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AffinityCreator.java index cf3daecd8..b6114fde2 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AffinityCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AffinityCreator.java @@ -33,7 +33,7 @@ public class AffinityCreator { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AffinityCreator.class); public static <T extends CompleteWork> List<EndpointAffinity> getAffinityMap(List<T> work){ - Stopwatch watch = new Stopwatch(); + Stopwatch watch = Stopwatch.createStarted(); long totalBytes = 0; for (CompleteWork entry : work) { diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AssignmentCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AssignmentCreator.java index e76826d60..9efcf4acc 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AssignmentCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/AssignmentCreator.java @@ -106,8 +106,7 @@ public class AssignmentCreator<T extends CompleteWork> { * @return the minor fragment id to work units mapping */ private ListMultimap<Integer, T> getMappings() { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); maxWork = (int) Math.ceil(units.size() / ((float) incomingEndpoints.size())); LinkedList<WorkEndpointListPair<T>> workList = getWorkList(); LinkedList<WorkEndpointListPair<T>> unassignedWorkList; @@ -179,8 +178,7 @@ public class AssignmentCreator<T extends CompleteWork> { * @return the list of WorkEndpointListPairs */ private LinkedList<WorkEndpointListPair<T>> getWorkList() { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); LinkedList<WorkEndpointListPair<T>> workList = Lists.newLinkedList(); for (T work : units) { List<Map.Entry<DrillbitEndpoint,Long>> entries = Lists.newArrayList(); @@ -236,8 +234,7 @@ public class AssignmentCreator<T extends CompleteWork> { * @return */ private Map<DrillbitEndpoint,FragIteratorWrapper> getEndpointIterators() { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); Map<DrillbitEndpoint,FragIteratorWrapper> map = Maps.newLinkedHashMap(); Map<DrillbitEndpoint,List<Integer>> mmap = Maps.newLinkedHashMap(); for (int i = 0; i < incomingEndpoints.size(); i++) { diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/BlockMapBuilder.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/BlockMapBuilder.java index c5c351e95..7a6825f14 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/BlockMapBuilder.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/BlockMapBuilder.java @@ -216,8 +216,7 @@ public class BlockMapBuilder { * @throws IOException */ public EndpointByteMap getEndpointByteMap(FileWork work) throws IOException { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); Path fileName = new Path(work.getPath()); @@ -267,8 +266,7 @@ public class BlockMapBuilder { * Builds a mapping of Drillbit endpoints to hostnames */ private static ImmutableMap<String, DrillbitEndpoint> buildEndpointMap(Collection<DrillbitEndpoint> endpoints) { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); HashMap<String, DrillbitEndpoint> endpointMap = Maps.newHashMap(); for (DrillbitEndpoint d : endpoints) { String hostName = d.getAddress(); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/OldAssignmentCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/OldAssignmentCreator.java index 858cfef09..48bb5f343 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/OldAssignmentCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/schedule/OldAssignmentCreator.java @@ -63,7 +63,7 @@ public class OldAssignmentCreator<T extends CompleteWork> { OldAssignmentCreator(List<DrillbitEndpoint> incomingEndpoints, List<T> units) { logger.debug("Assigning {} units to {} endpoints", units.size(), incomingEndpoints.size()); - Stopwatch watch = new Stopwatch(); + Stopwatch watch = Stopwatch.createUnstarted(); Preconditions.checkArgument(incomingEndpoints.size() <= units.size(), String.format("Incoming endpoints %d " + "is greater than number of row groups %d", incomingEndpoints.size(), units.size())); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/VersionIterator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/VersionIterator.java index 7a94e222b..5620eceab 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/VersionIterator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/sys/VersionIterator.java @@ -46,7 +46,7 @@ public class VersionIterator implements Iterator<Object>{ URL u = Resources.getResource("git.properties"); if(u != null){ Properties p = new Properties(); - p.load(Resources.newInputStreamSupplier(u).getInput()); + p.load(Resources.asByteSource(u).openStream()); commit_id = p.getProperty("git.commit.id"); build_email = p.getProperty("git.build.user.email"); commit_time = p.getProperty("git.commit.time"); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/SpoolingRawBatchBuffer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/SpoolingRawBatchBuffer.java index 9915b7ea7..74762a418 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/SpoolingRawBatchBuffer.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/SpoolingRawBatchBuffer.java @@ -374,8 +374,7 @@ public class SpoolingRawBatchBuffer extends BaseRawBatchBuffer<SpoolingRawBatchB } public void writeToStream(FSDataOutputStream stream) throws IOException { - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); available = false; check = ThreadLocalRandom.current().nextLong(); start = stream.getPos(); @@ -421,8 +420,7 @@ public class SpoolingRawBatchBuffer extends BaseRawBatchBuffer<SpoolingRawBatchB final long check = stream.readLong(); pos = stream.getPos(); assert check == this.check : String.format("Check values don't match: %d %d, Position %d", this.check, check, currentPos); - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); BitData.FragmentRecordBatch header = BitData.FragmentRecordBatch.parseDelimitedFrom(stream); pos = stream.getPos(); assert header != null : "header null after parsing from stream"; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java index cdbdfa4f0..bfc9dfff5 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.apache.drill.common.CatastrophicFailure; import org.apache.drill.common.EventProcessor; import org.apache.drill.common.concurrent.ExtendedLatch; import org.apache.drill.common.config.DrillConfig; @@ -272,10 +273,7 @@ public class Foreman implements Runnable { * die here, they should get notified about that, and cancel themselves; we don't have to attempt to notify * them, which might not work under these conditions. */ - System.out.println("Node ran out of Heap memory, exiting."); - e.printStackTrace(); - System.out.flush(); - System.exit(-1); + CatastrophicFailure.exit(e, "Unable to handle out of memory condition in Foreman.", -1); } } finally { diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java index 9101c1371..9df128fa7 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java @@ -24,6 +24,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import org.apache.drill.common.CatastrophicFailure; import org.apache.drill.common.DeferredException; import org.apache.drill.common.SerializedExecutor; import org.apache.drill.common.concurrent.ExtendedLatch; @@ -266,11 +267,7 @@ public class FragmentExecutor implements Runnable { fail(UserException.memoryError(e).build(logger)); } else { // we have a heap out of memory error. The JVM in unstable, exit. - System.err.println("Node ran out of Heap memory, exiting."); - e.printStackTrace(System.err); - System.err.flush(); - System.exit(-2); - + CatastrophicFailure.exit(e, "Unable to handle out of memory condition in FragmentExecutor.", -2); } } catch (AssertionError | Exception e) { fail(e); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/RunRootExec.java b/exec/java-exec/src/test/java/org/apache/drill/exec/RunRootExec.java index 5928dce96..8d6cc0cb8 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/RunRootExec.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/RunRootExec.java @@ -55,7 +55,7 @@ public class RunRootExec { FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), null, registry); SimpleRootExec exec; for (int i = 0; i < iterations; i ++) { - Stopwatch w= new Stopwatch().start(); + Stopwatch w = Stopwatch.createStarted(); System.out.println("STARTITER:" + i); exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java b/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java index 73ed65e90..155706e9e 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java @@ -151,7 +151,7 @@ public class TestBitRpc extends ExecTest { private class TimingOutcome implements RpcOutcomeListener<Ack> { private AtomicLong max; - private Stopwatch watch = new Stopwatch().start(); + private Stopwatch watch = Stopwatch.createStarted(); public TimingOutcome(AtomicLong max) { super(); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/ParquetRecordReaderTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/ParquetRecordReaderTest.java index fdfcf42a1..26ba31661 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/ParquetRecordReaderTest.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/ParquetRecordReaderTest.java @@ -291,7 +291,7 @@ public class ParquetRecordReaderTest extends BaseTestQuery { TestFileGenerator.populateFieldInfoMap(props); final ParquetResultListener resultListener = new ParquetResultListener(getAllocator(), props, numberOfTimesRead, testValues); - final Stopwatch watch = new Stopwatch().start(); + final Stopwatch watch = Stopwatch.createStarted(); testWithListener(type, planText, resultListener); resultListener.getResults(); // batchLoader.clear(); @@ -642,8 +642,7 @@ public class ParquetRecordReaderTest extends BaseTestQuery { f.getParquetMetadata(), columns); final TestOutputMutator mutator = new TestOutputMutator(allocator); rr.setup(null, mutator); - final Stopwatch watch = new Stopwatch(); - watch.start(); + final Stopwatch watch = Stopwatch.createStarted(); int rowCount = 0; while ((rowCount = rr.next()) > 0) { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java index 7afc05d8c..9282a4556 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetPhysicalPlan.java @@ -127,8 +127,7 @@ public class TestParquetPhysicalPlan extends ExecTest { try(DrillClient client = new DrillClient(config);) { client.connect(); ParquetResultsListener listener = new ParquetResultsListener(); - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Resources.toString(Resources.getResource(fileName),Charsets.UTF_8), listener); System.out.println(String.format("Got %d total records in %d seconds", listener.await(), watch.elapsed(TimeUnit.SECONDS))); client.close(); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java index b98317f19..4f8d86394 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java @@ -58,8 +58,7 @@ public class FileTest { out = fs.create(new Path("/tmp/file")); for (int i = 0; i < 100; i++) { bytes = new byte[256*1024]; - Stopwatch watch = new Stopwatch(); - watch.start(); + Stopwatch watch = Stopwatch.createStarted(); out.write(bytes); out.sync(); long t = watch.elapsed(TimeUnit.MILLISECONDS); |