You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/11/21 05:04:17 UTC
[1/5] accumulo git commit: ACCUMULO-3351 Try to reset the writer if
we don't have one but the table exists.
Repository: accumulo
Updated Branches:
refs/heads/1.6 d470f056b -> 0934298e0
refs/heads/master 4062b3436 -> 9e2867d46
ACCUMULO-3351 Try to reset the writer if we don't have one but the table exists.
We have to avoid the case where we spin indefinitely trying to process
traces (but cannot because we don't have a writer). If we don't have
a writer, but the trace table exists, try to get a new writer.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/32c18d59
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/32c18d59
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/32c18d59
Branch: refs/heads/1.6
Commit: 32c18d59ffe3581134d6a0e6e83494fb979ee931
Parents: d470f05
Author: Josh Elser <el...@apache.org>
Authored: Thu Nov 20 15:57:59 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Nov 20 15:57:59 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/tracer/TraceServer.java | 5 +
.../test/TracerRecoversAfterOfflineTableIT.java | 128 +++++++++++++++++++
2 files changed, 133 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/32c18d59/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
index 6094911..70e8d7d 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
@@ -243,6 +243,11 @@ public class TraceServer implements Watcher {
final BatchWriter writer = this.writer.get();
if (null != writer) {
writer.flush();
+ } else {
+ // We don't have a writer. If the table exists, try to make a new writer.
+ if (connector.tableOperations().exists(table)) {
+ resetWriter();
+ }
}
} catch (MutationsRejectedException exception) {
log.warn("Problem flushing traces, resetting writer. Set log level to DEBUG to see stacktrace. cause: " + exception);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/32c18d59/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
new file mode 100644
index 0000000..3b32150
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.trace.DistributedTrace;
+import org.apache.accumulo.core.trace.TraceDump;
+import org.apache.accumulo.core.trace.TraceDump.Printer;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.fate.zookeeper.ZooReader;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.test.functional.ConfigurableMacIT;
+import org.apache.accumulo.trace.instrument.Span;
+import org.apache.accumulo.trace.instrument.Trace;
+import org.apache.accumulo.tracer.TraceServer;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacIT {
+
+ @Override
+ public void configure(MiniAccumuloConfigImpl cfg, Configuration coreSite) {
+ cfg.setNumTservers(1);
+ }
+
+ @Override
+ public int defaultTimeoutSeconds() {
+ return 60;
+ }
+
+ @Test
+ public void test() throws Exception {
+ Process tracer = null;
+ Connector conn = getConnector();
+ if (!conn.tableOperations().exists("trace")) {
+ MiniAccumuloClusterImpl mac = cluster;
+ tracer = mac.exec(TraceServer.class);
+ while (!conn.tableOperations().exists("trace")) {
+ UtilWaitThread.sleep(1000);
+ }
+ }
+
+ log.info("Deleting trace table records and taking table offline");
+ conn.tableOperations().deleteRows("trace", null, null);
+ conn.tableOperations().offline("trace", true);
+
+ String tableName = getUniqueNames(1)[0];
+ conn.tableOperations().create(tableName);
+
+ log.info("Start a distributed trace span");
+
+ DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(), 30 * 1000), "testTrace", "localhost");
+ Span root = Trace.on("traceTest");
+ BatchWriter bw = conn.createBatchWriter(tableName, null);
+ Mutation m = new Mutation("m");
+ m.put("a", "b", "c");
+ bw.addMutation(m);
+ bw.close();
+ root.stop();
+
+ log.info("Bringing trace table back online");
+ conn.tableOperations().online("trace", true);
+
+ log.info("Trace table is online, should be able to find trace");
+
+ final Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY);
+ scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
+ while (true) {
+ final StringBuffer finalBuffer = new StringBuffer();
+ int traceCount = TraceDump.printTrace(scanner, new Printer() {
+ @Override
+ public void print(final String line) {
+ try {
+ finalBuffer.append(line).append("\n");
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+ String traceOutput = finalBuffer.toString();
+ log.info("Trace output:" + traceOutput);
+ if (traceCount > 0) {
+ int lastPos = 0;
+ for (String part : "traceTest,close,binMutations".split(",")) {
+ log.info("Looking in trace output for '" + part + "'");
+ int pos = traceOutput.indexOf(part);
+ assertTrue("Did not find '" + part + "' in output", pos > 0);
+ assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
+ lastPos = pos;
+ }
+ break;
+ } else {
+ log.info("Ignoring trace output as traceCount not greater than zero: " + traceCount);
+ Thread.sleep(1000);
+ }
+ }
+ if (tracer != null) {
+ tracer.destroy();
+ }
+ }
+
+}
[2/5] accumulo git commit: ACCUMULO-3351 Try to reset the writer if
we don't have one but the table exists.
Posted by el...@apache.org.
ACCUMULO-3351 Try to reset the writer if we don't have one but the table exists.
We have to avoid the case where we spin indefinitely trying to process
traces (but cannot because we don't have a writer). If we don't have
a writer, but the trace table exists, try to get a new writer.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/32c18d59
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/32c18d59
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/32c18d59
Branch: refs/heads/master
Commit: 32c18d59ffe3581134d6a0e6e83494fb979ee931
Parents: d470f05
Author: Josh Elser <el...@apache.org>
Authored: Thu Nov 20 15:57:59 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Nov 20 15:57:59 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/tracer/TraceServer.java | 5 +
.../test/TracerRecoversAfterOfflineTableIT.java | 128 +++++++++++++++++++
2 files changed, 133 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/32c18d59/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
index 6094911..70e8d7d 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
@@ -243,6 +243,11 @@ public class TraceServer implements Watcher {
final BatchWriter writer = this.writer.get();
if (null != writer) {
writer.flush();
+ } else {
+ // We don't have a writer. If the table exists, try to make a new writer.
+ if (connector.tableOperations().exists(table)) {
+ resetWriter();
+ }
}
} catch (MutationsRejectedException exception) {
log.warn("Problem flushing traces, resetting writer. Set log level to DEBUG to see stacktrace. cause: " + exception);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/32c18d59/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
new file mode 100644
index 0000000..3b32150
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.trace.DistributedTrace;
+import org.apache.accumulo.core.trace.TraceDump;
+import org.apache.accumulo.core.trace.TraceDump.Printer;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.fate.zookeeper.ZooReader;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.test.functional.ConfigurableMacIT;
+import org.apache.accumulo.trace.instrument.Span;
+import org.apache.accumulo.trace.instrument.Trace;
+import org.apache.accumulo.tracer.TraceServer;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacIT {
+
+ @Override
+ public void configure(MiniAccumuloConfigImpl cfg, Configuration coreSite) {
+ cfg.setNumTservers(1);
+ }
+
+ @Override
+ public int defaultTimeoutSeconds() {
+ return 60;
+ }
+
+ @Test
+ public void test() throws Exception {
+ Process tracer = null;
+ Connector conn = getConnector();
+ if (!conn.tableOperations().exists("trace")) {
+ MiniAccumuloClusterImpl mac = cluster;
+ tracer = mac.exec(TraceServer.class);
+ while (!conn.tableOperations().exists("trace")) {
+ UtilWaitThread.sleep(1000);
+ }
+ }
+
+ log.info("Deleting trace table records and taking table offline");
+ conn.tableOperations().deleteRows("trace", null, null);
+ conn.tableOperations().offline("trace", true);
+
+ String tableName = getUniqueNames(1)[0];
+ conn.tableOperations().create(tableName);
+
+ log.info("Start a distributed trace span");
+
+ DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(), 30 * 1000), "testTrace", "localhost");
+ Span root = Trace.on("traceTest");
+ BatchWriter bw = conn.createBatchWriter(tableName, null);
+ Mutation m = new Mutation("m");
+ m.put("a", "b", "c");
+ bw.addMutation(m);
+ bw.close();
+ root.stop();
+
+ log.info("Bringing trace table back online");
+ conn.tableOperations().online("trace", true);
+
+ log.info("Trace table is online, should be able to find trace");
+
+ final Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY);
+ scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
+ while (true) {
+ final StringBuffer finalBuffer = new StringBuffer();
+ int traceCount = TraceDump.printTrace(scanner, new Printer() {
+ @Override
+ public void print(final String line) {
+ try {
+ finalBuffer.append(line).append("\n");
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+ String traceOutput = finalBuffer.toString();
+ log.info("Trace output:" + traceOutput);
+ if (traceCount > 0) {
+ int lastPos = 0;
+ for (String part : "traceTest,close,binMutations".split(",")) {
+ log.info("Looking in trace output for '" + part + "'");
+ int pos = traceOutput.indexOf(part);
+ assertTrue("Did not find '" + part + "' in output", pos > 0);
+ assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
+ lastPos = pos;
+ }
+ break;
+ } else {
+ log.info("Ignoring trace output as traceCount not greater than zero: " + traceCount);
+ Thread.sleep(1000);
+ }
+ }
+ if (tracer != null) {
+ tracer.destroy();
+ }
+ }
+
+}
[5/5] accumulo git commit: Merge branch '1.6'
Posted by el...@apache.org.
Merge branch '1.6'
Conflicts:
server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/9e2867d4
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/9e2867d4
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/9e2867d4
Branch: refs/heads/master
Commit: 9e2867d46969c595dbafff2f59165159da551fcb
Parents: 4062b34 0934298
Author: Josh Elser <el...@apache.org>
Authored: Thu Nov 20 23:04:05 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Nov 20 23:04:05 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/tracer/TraceDump.java | 24 ++--
.../org/apache/accumulo/tracer/TraceServer.java | 5 +
.../accumulo/test/ConditionalWriterIT.java | 1 -
.../test/TracerRecoversAfterOfflineTableIT.java | 127 +++++++++++++++++++
4 files changed, 146 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/9e2867d4/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
----------------------------------------------------------------------
diff --cc server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
index c109fd8,0000000..4468866
mode 100644,000000..100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
@@@ -1,162 -1,0 +1,166 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.tracer;
+
+import static java.lang.Math.min;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+
- import org.apache.accumulo.tracer.thrift.RemoteSpan;
+import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ScannerOpts;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
++import org.apache.accumulo.tracer.thrift.RemoteSpan;
+import org.apache.hadoop.io.Text;
+import org.htrace.Span;
+
+import com.beust.jcommander.Parameter;
+
+
+public class TraceDump {
+ static final long DEFAULT_TIME_IN_MILLIS = 10 * 60 * 1000l;
-
++
+ static class Opts extends ClientOnDefaultTable {
+ @Parameter(names={"-l", "--list"}, description="List recent traces")
+ boolean list = false;
+ @Parameter(names={"-s", "--start"}, description="The start time of traces to display")
+ String start;
+ @Parameter(names={"-e", "--end"}, description="The end time of traces to display")
+ String end;
+ @Parameter(names={"-d", "--dump"}, description="Dump the traces")
+ boolean dump = false;
+ @Parameter(names={"-i", "--instance"}, description="URL to point to accumulo.")
+ String instance;
+ @Parameter(description=" <trace id> { <trace id> ... }")
+ List<String> traceIds = new ArrayList<String>();
+ Opts() { super("trace");}
+ }
-
++
+ public static void main(String[] args) throws Exception {
+ Opts opts = new Opts();
+ ScannerOpts scanOpts = new ScannerOpts();
+ opts.parseArgs(TraceDump.class.getName(), args, scanOpts);
+ int code = 0;
+ if (opts.list) {
+ code = listSpans(opts, scanOpts);
+ }
+ if (code == 0 && opts.dump) {
+ code = dumpTrace(opts, scanOpts);
+ }
+ System.exit(code);
+ }
-
++
+ public static List<RemoteSpan> sortByStart(Collection<RemoteSpan> spans) {
+ List<RemoteSpan> spanList = new ArrayList<RemoteSpan>(spans);
+ Collections.sort(spanList, new Comparator<RemoteSpan>() {
+ @Override
+ public int compare(RemoteSpan o1, RemoteSpan o2) {
+ return (int) (o1.start - o2.start);
+ }
+ });
+ return spanList;
+ }
-
++
+ private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
+ PrintStream out = System.out;
+ long endTime = System.currentTimeMillis();
+ long startTime = endTime - DEFAULT_TIME_IN_MILLIS;
+ Connector conn = opts.getConnector();
+ Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
+ scanner.setBatchSize(scanOpts.scanBatchSize);
+ Range range = new Range(new Text("start:" + Long.toHexString(startTime)), new Text("start:" + Long.toHexString(endTime)));
+ scanner.setRange(range);
+ out.println("Trace Day/Time (ms) Start");
+ for (Entry<Key,Value> entry : scanner) {
+ RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
+ out.println(String.format("%016x %s %5d %s", span.traceId, TraceFormatter.formatDate(new Date(span.getStart())), span.stop - span.start, span.description));
+ }
+ return 0;
+ }
-
++
+ public interface Printer {
+ void print(String line);
+ }
-
++
+ private static int dumpTrace(Opts opts, ScannerOpts scanOpts) throws Exception {
+ final PrintStream out = System.out;
+ Connector conn = opts.getConnector();
-
++
+ int count = 0;
+ for (String traceId : opts.traceIds) {
+ Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
+ scanner.setBatchSize(scanOpts.scanBatchSize);
+ Range range = new Range(new Text(traceId.toString()));
+ scanner.setRange(range);
+ count = printTrace(scanner, new Printer() {
+ @Override
+ public void print(String line) {
+ out.println(line);
+ }
+ });
+ }
+ return count > 0 ? 0 : 1;
+ }
-
++
+ public static int printTrace(Scanner scanner, final Printer out) {
+ int count = 0;
+ SpanTree tree = new SpanTree();
+ long start = Long.MAX_VALUE;
+ for (Entry<Key,Value> entry : scanner) {
+ RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
+ tree.addNode(span);
+ start = min(start, span.start);
+ if (span.parentId == Span.ROOT_SPAN_ID)
+ count++;
+ }
++ if (Long.MAX_VALUE == start) {
++ out.print("Did not find any traces!");
++ return 0;
++ }
+ out.print(String.format("Trace started at %s", TraceFormatter.formatDate(new Date(start))));
+ out.print("Time Start Service@Location Name");
-
++
+ final long finalStart = start;
+ Set<Long> visited = tree.visit(new SpanTreeVisitor() {
+ @Override
+ public void visit(int level, RemoteSpan parent, RemoteSpan node, Collection<RemoteSpan> children) {
+ String fmt = "%5d+%-5d %" + (level * 2 + 1) + "s%s@%s %s";
+ out.print(String.format(fmt, node.stop - node.start, node.start - finalStart, "", node.svc, node.sender, node.description));
+ }
+ });
+ tree.nodes.keySet().removeAll(visited);
+ if (!tree.nodes.isEmpty()) {
+ out.print("Warning: the following spans are not rooted!");
+ for (RemoteSpan span : sortByStart(tree.nodes.values())) {
+ out.print(String.format("%s %s %s", Long.toHexString(span.spanId), Long.toHexString(span.parentId), span.description));
+ }
+ return -1;
+ }
+ return count;
+ }
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/9e2867d4/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/9e2867d4/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
----------------------------------------------------------------------
diff --cc test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
index 72db704,8406570..0810fb2
--- a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@@ -1231,9 -1232,8 +1231,8 @@@ public class ConditionalWriterIT extend
String tableName = getUniqueNames(1)[0];
conn.tableOperations().create(tableName);
- conn.tableOperations().deleteRows("trace", null, null);
- DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(), 30*1000), "testTrace", "localhost");
+ DistributedTrace.enable("localhost", "testTrace", getClientConfig());
Span root = Trace.on("traceTest");
ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/9e2867d4/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
----------------------------------------------------------------------
diff --cc test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
index 0000000,bd186a9..e32ec16
mode 000000,100644..100644
--- a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@@ -1,0 -1,127 +1,127 @@@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.accumulo.test;
+
+ import static org.junit.Assert.assertTrue;
+
+ import org.apache.accumulo.core.client.BatchWriter;
+ import org.apache.accumulo.core.client.Connector;
+ import org.apache.accumulo.core.client.Scanner;
+ import org.apache.accumulo.core.data.Mutation;
+ import org.apache.accumulo.core.data.Range;
+ import org.apache.accumulo.core.security.Authorizations;
+ import org.apache.accumulo.core.trace.DistributedTrace;
-import org.apache.accumulo.core.trace.TraceDump;
-import org.apache.accumulo.core.trace.TraceDump.Printer;
+ import org.apache.accumulo.core.util.UtilWaitThread;
+ import org.apache.accumulo.fate.zookeeper.ZooReader;
+ import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+ import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+ import org.apache.accumulo.test.functional.ConfigurableMacIT;
+ import org.apache.accumulo.trace.instrument.Span;
+ import org.apache.accumulo.trace.instrument.Trace;
++import org.apache.accumulo.tracer.TraceDump;
++import org.apache.accumulo.tracer.TraceDump.Printer;
+ import org.apache.accumulo.tracer.TraceServer;
+ import org.apache.hadoop.conf.Configuration;
+ import org.apache.hadoop.io.Text;
+ import org.junit.Test;
+
+ /**
+ *
+ */
+ public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacIT {
+
+ @Override
+ public void configure(MiniAccumuloConfigImpl cfg, Configuration coreSite) {
+ cfg.setNumTservers(1);
+ }
+
+ @Override
+ public int defaultTimeoutSeconds() {
+ return 60;
+ }
+
+ @Test
+ public void test() throws Exception {
+ Process tracer = null;
+ Connector conn = getConnector();
+ if (!conn.tableOperations().exists("trace")) {
+ MiniAccumuloClusterImpl mac = cluster;
+ tracer = mac.exec(TraceServer.class);
+ while (!conn.tableOperations().exists("trace")) {
+ UtilWaitThread.sleep(1000);
+ }
+ }
+
+ log.info("Taking table offline");
+ conn.tableOperations().offline("trace", true);
+
+ String tableName = getUniqueNames(1)[0];
+ conn.tableOperations().create(tableName);
+
+ log.info("Start a distributed trace span");
+
+ DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(), 30 * 1000), "testTrace", "localhost");
+ Span root = Trace.on("traceTest");
+ BatchWriter bw = conn.createBatchWriter(tableName, null);
+ Mutation m = new Mutation("m");
+ m.put("a", "b", "c");
+ bw.addMutation(m);
+ bw.close();
+ root.stop();
+
+ log.info("Bringing trace table back online");
+ conn.tableOperations().online("trace", true);
+
+ log.info("Trace table is online, should be able to find trace");
+
+ final Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY);
+ scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
+ while (true) {
+ final StringBuffer finalBuffer = new StringBuffer();
+ int traceCount = TraceDump.printTrace(scanner, new Printer() {
+ @Override
+ public void print(final String line) {
+ try {
+ finalBuffer.append(line).append("\n");
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+ String traceOutput = finalBuffer.toString();
+ log.info("Trace output:" + traceOutput);
+ if (traceCount > 0) {
+ int lastPos = 0;
+ for (String part : "traceTest,close,binMutations".split(",")) {
+ log.info("Looking in trace output for '" + part + "'");
+ int pos = traceOutput.indexOf(part);
+ assertTrue("Did not find '" + part + "' in output", pos > 0);
+ assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
+ lastPos = pos;
+ }
+ break;
+ } else {
+ log.info("Ignoring trace output as traceCount not greater than zero: " + traceCount);
+ Thread.sleep(1000);
+ }
+ }
+ if (tracer != null) {
+ tracer.destroy();
+ }
+ }
+
+ }
[4/5] accumulo git commit: ACCUMULO-3355 Catch the case when we find
no traces and quit early.
Posted by el...@apache.org.
ACCUMULO-3355 Catch the case when we find no traces and quit early.
If we don't quit early, we end up creating this absurd date and sending
it back to the user. Also fixed two tests that were unnecessarily
nuking the entire trace table. The Scanner they create is bounded for
their trace session; there is no reason to delete the rest of the records.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0934298e
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0934298e
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0934298e
Branch: refs/heads/1.6
Commit: 0934298e09a2d311e7d9a9cd86b611f285f791b4
Parents: 32c18d5
Author: Josh Elser <el...@apache.org>
Authored: Thu Nov 20 16:30:03 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Nov 20 16:30:03 2014 -0500
----------------------------------------------------------------------
.../apache/accumulo/core/trace/TraceDump.java | 24 ++++++++++++--------
.../accumulo/test/ConditionalWriterIT.java | 1 -
.../test/TracerRecoversAfterOfflineTableIT.java | 3 +--
3 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java b/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
index b44cc3e..4e9ea8c 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
-import org.apache.accumulo.trace.thrift.RemoteSpan;
import org.apache.accumulo.core.cli.ClientOnDefaultTable;
import org.apache.accumulo.core.cli.ScannerOpts;
import org.apache.accumulo.core.client.Connector;
@@ -36,6 +35,7 @@ import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.trace.thrift.RemoteSpan;
import org.apache.hadoop.io.Text;
import com.beust.jcommander.Parameter;
@@ -43,7 +43,7 @@ import com.beust.jcommander.Parameter;
public class TraceDump {
static final long DEFAULT_TIME_IN_MILLIS = 10 * 60 * 1000l;
-
+
static class Opts extends ClientOnDefaultTable {
@Parameter(names={"-l", "--list"}, description="List recent traces")
boolean list = false;
@@ -59,7 +59,7 @@ public class TraceDump {
List<String> traceIds = new ArrayList<String>();
Opts() { super("trace");}
}
-
+
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
ScannerOpts scanOpts = new ScannerOpts();
@@ -73,7 +73,7 @@ public class TraceDump {
}
System.exit(code);
}
-
+
public static List<RemoteSpan> sortByStart(Collection<RemoteSpan> spans) {
List<RemoteSpan> spanList = new ArrayList<RemoteSpan>(spans);
Collections.sort(spanList, new Comparator<RemoteSpan>() {
@@ -84,7 +84,7 @@ public class TraceDump {
});
return spanList;
}
-
+
private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
PrintStream out = System.out;
long endTime = System.currentTimeMillis();
@@ -101,15 +101,15 @@ public class TraceDump {
}
return 0;
}
-
+
public interface Printer {
void print(String line);
}
-
+
private static int dumpTrace(Opts opts, ScannerOpts scanOpts) throws Exception {
final PrintStream out = System.out;
Connector conn = opts.getConnector();
-
+
int count = 0;
for (String traceId : opts.traceIds) {
Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
@@ -125,7 +125,7 @@ public class TraceDump {
}
return count > 0 ? 0 : 1;
}
-
+
public static int printTrace(Scanner scanner, final Printer out) {
int count = 0;
SpanTree tree = new SpanTree();
@@ -137,9 +137,13 @@ public class TraceDump {
if (span.parentId <= 0)
count++;
}
+ if (Long.MAX_VALUE == start) {
+ out.print("Did not find any traces!");
+ return 0;
+ }
out.print(String.format("Trace started at %s", TraceFormatter.formatDate(new Date(start))));
out.print("Time Start Service@Location Name");
-
+
final long finalStart = start;
Set<Long> visited = tree.visit(new SpanTreeVisitor() {
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
index 516cd46..8406570 100644
--- a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@ -1232,7 +1232,6 @@ public class ConditionalWriterIT extends SimpleMacIT {
String tableName = getUniqueNames(1)[0];
conn.tableOperations().create(tableName);
- conn.tableOperations().deleteRows("trace", null, null);
DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(), 30*1000), "testTrace", "localhost");
Span root = Trace.on("traceTest");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
index 3b32150..bd186a9 100644
--- a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -66,8 +66,7 @@ public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacIT {
}
}
- log.info("Deleting trace table records and taking table offline");
- conn.tableOperations().deleteRows("trace", null, null);
+ log.info("Taking table offline");
conn.tableOperations().offline("trace", true);
String tableName = getUniqueNames(1)[0];
[3/5] accumulo git commit: ACCUMULO-3355 Catch the case when we find
no traces and quit early.
Posted by el...@apache.org.
ACCUMULO-3355 Catch the case when we find no traces and quit early.
If we don't quit early, we end up creating this absurd date and sending
it back to the user. Also fixed two tests that were unnecessarily
nuking the entire trace table. The Scanner they create is bounded for
their trace session; there is no reason to delete the rest of the records.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0934298e
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0934298e
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0934298e
Branch: refs/heads/master
Commit: 0934298e09a2d311e7d9a9cd86b611f285f791b4
Parents: 32c18d5
Author: Josh Elser <el...@apache.org>
Authored: Thu Nov 20 16:30:03 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Thu Nov 20 16:30:03 2014 -0500
----------------------------------------------------------------------
.../apache/accumulo/core/trace/TraceDump.java | 24 ++++++++++++--------
.../accumulo/test/ConditionalWriterIT.java | 1 -
.../test/TracerRecoversAfterOfflineTableIT.java | 3 +--
3 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java b/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
index b44cc3e..4e9ea8c 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/TraceDump.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
-import org.apache.accumulo.trace.thrift.RemoteSpan;
import org.apache.accumulo.core.cli.ClientOnDefaultTable;
import org.apache.accumulo.core.cli.ScannerOpts;
import org.apache.accumulo.core.client.Connector;
@@ -36,6 +35,7 @@ import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.trace.thrift.RemoteSpan;
import org.apache.hadoop.io.Text;
import com.beust.jcommander.Parameter;
@@ -43,7 +43,7 @@ import com.beust.jcommander.Parameter;
public class TraceDump {
static final long DEFAULT_TIME_IN_MILLIS = 10 * 60 * 1000l;
-
+
static class Opts extends ClientOnDefaultTable {
@Parameter(names={"-l", "--list"}, description="List recent traces")
boolean list = false;
@@ -59,7 +59,7 @@ public class TraceDump {
List<String> traceIds = new ArrayList<String>();
Opts() { super("trace");}
}
-
+
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
ScannerOpts scanOpts = new ScannerOpts();
@@ -73,7 +73,7 @@ public class TraceDump {
}
System.exit(code);
}
-
+
public static List<RemoteSpan> sortByStart(Collection<RemoteSpan> spans) {
List<RemoteSpan> spanList = new ArrayList<RemoteSpan>(spans);
Collections.sort(spanList, new Comparator<RemoteSpan>() {
@@ -84,7 +84,7 @@ public class TraceDump {
});
return spanList;
}
-
+
private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception {
PrintStream out = System.out;
long endTime = System.currentTimeMillis();
@@ -101,15 +101,15 @@ public class TraceDump {
}
return 0;
}
-
+
public interface Printer {
void print(String line);
}
-
+
private static int dumpTrace(Opts opts, ScannerOpts scanOpts) throws Exception {
final PrintStream out = System.out;
Connector conn = opts.getConnector();
-
+
int count = 0;
for (String traceId : opts.traceIds) {
Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
@@ -125,7 +125,7 @@ public class TraceDump {
}
return count > 0 ? 0 : 1;
}
-
+
public static int printTrace(Scanner scanner, final Printer out) {
int count = 0;
SpanTree tree = new SpanTree();
@@ -137,9 +137,13 @@ public class TraceDump {
if (span.parentId <= 0)
count++;
}
+ if (Long.MAX_VALUE == start) {
+ out.print("Did not find any traces!");
+ return 0;
+ }
out.print(String.format("Trace started at %s", TraceFormatter.formatDate(new Date(start))));
out.print("Time Start Service@Location Name");
-
+
final long finalStart = start;
Set<Long> visited = tree.visit(new SpanTreeVisitor() {
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
index 516cd46..8406570 100644
--- a/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@ -1232,7 +1232,6 @@ public class ConditionalWriterIT extends SimpleMacIT {
String tableName = getUniqueNames(1)[0];
conn.tableOperations().create(tableName);
- conn.tableOperations().deleteRows("trace", null, null);
DistributedTrace.enable(conn.getInstance(), new ZooReader(conn.getInstance().getZooKeepers(), 30*1000), "testTrace", "localhost");
Span root = Trace.on("traceTest");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/0934298e/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
index 3b32150..bd186a9 100644
--- a/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -66,8 +66,7 @@ public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacIT {
}
}
- log.info("Deleting trace table records and taking table offline");
- conn.tableOperations().deleteRows("trace", null, null);
+ log.info("Taking table offline");
conn.tableOperations().offline("trace", true);
String tableName = getUniqueNames(1)[0];