http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/pom.xml ---------------------------------------------------------------------- diff --git a/server/base/pom.xml b/server/base/pom.xml index 60762be..c21a168 100644 --- a/server/base/pom.xml +++ b/server/base/pom.xml @@ -76,10 +76,6 @@ <artifactId>accumulo-start</artifactId> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-trace</artifactId> - </dependency> - <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> </dependency>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java index 756d79b..a2ff172 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java +++ b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java @@ -54,6 +54,8 @@ import org.apache.accumulo.core.file.FileSKVIterator; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; +import org.apache.accumulo.core.trace.wrappers.TraceRunnable; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.CachedConfiguration; import org.apache.accumulo.core.util.LoggingRunnable; import org.apache.accumulo.core.util.NamingThreadFactory; @@ -64,8 +66,6 @@ import org.apache.accumulo.server.conf.ServerConfigurationFactory; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.fs.VolumeManagerImpl; import org.apache.accumulo.server.util.FileUtil; -import org.apache.accumulo.trace.instrument.TraceRunnable; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java index 83d02db..d5349ba 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java +++ b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java @@ -54,6 +54,7 @@ import org.apache.accumulo.core.security.NamespacePermission; import org.apache.accumulo.core.security.SystemPermission; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.core.security.thrift.TCredentials; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.server.conf.ServerConfigurationFactory; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.security.AuditedSecurityOperation; @@ -61,7 +62,6 @@ import org.apache.accumulo.server.security.SecurityOperation; import org.apache.accumulo.server.util.TableDiskUsage; import org.apache.accumulo.server.zookeeper.TransactionWatcher; import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.log4j.Logger; import org.apache.thrift.TException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java b/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java index e577153..3388b5b 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java @@ -34,6 +34,7 @@ import org.apache.accumulo.core.data.KeyExtent; import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.core.util.ServerServices; import org.apache.accumulo.core.util.ThriftUtil; @@ -45,7 +46,6 @@ import org.apache.accumulo.server.util.time.SimpleTimer; import org.apache.accumulo.server.zookeeper.ZooCache; import org.apache.accumulo.server.zookeeper.ZooLock; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.hadoop.io.Text; import org.apache.log4j.Logger; import org.apache.thrift.TException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java index 59d3e0b..30a2460 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java @@ -29,13 +29,13 @@ import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client; import org.apache.accumulo.core.tabletserver.thrift.TabletStats; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.ThriftUtil; import org.apache.accumulo.server.conf.ServerConfiguration; import org.apache.accumulo.server.conf.ServerConfigurationFactory; import org.apache.accumulo.server.master.state.TServerInstance; import org.apache.accumulo.server.master.state.TabletMigration; import org.apache.accumulo.server.security.SystemCredentials; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.apache.thrift.transport.TTransportException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java index 23bb021..254b62c 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java @@ -47,11 +47,11 @@ import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.security.SystemPermission; import org.apache.accumulo.core.security.TablePermission; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.server.cli.ClientOpts; import org.apache.accumulo.server.conf.ServerConfigurationFactory; import org.apache.accumulo.server.security.SystemCredentials; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.hadoop.conf.Configuration; import org.apache.log4j.Logger; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/util/RpcWrapper.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RpcWrapper.java b/server/base/src/main/java/org/apache/accumulo/server/util/RpcWrapper.java index 02bd1ef..2464a15 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/RpcWrapper.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/RpcWrapper.java @@ -20,8 +20,8 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; -import org.apache.accumulo.trace.instrument.thrift.RpcServerInvocationHandler; -import org.apache.accumulo.trace.instrument.thrift.TraceWrap; +import org.apache.accumulo.core.trace.wrappers.RpcServerInvocationHandler; +import org.apache.accumulo.core.trace.wrappers.TraceWrap; import org.apache.thrift.TApplicationException; import org.apache.thrift.TException; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java b/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java index 0fbeb6b..50d7014 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java @@ -48,11 +48,11 @@ import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; +import org.apache.accumulo.core.trace.Tracer; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.core.util.ThriftUtil; import org.apache.accumulo.server.cli.ClientOpts; import org.apache.accumulo.server.conf.ServerConfigurationFactory; -import org.apache.accumulo.trace.instrument.Tracer; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.hadoop.io.Text; import org.apache.log4j.Logger; import org.apache.thrift.TException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/gc/pom.xml ---------------------------------------------------------------------- diff --git a/server/gc/pom.xml b/server/gc/pom.xml index 8194121..9602b95 100644 --- a/server/gc/pom.xml +++ b/server/gc/pom.xml @@ -52,10 +52,6 @@ <artifactId>accumulo-server-base</artifactId> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-trace</artifactId> - </dependency> - <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java index 4c0a3a9..e96fee3 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java @@ -54,6 +54,9 @@ import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.tabletserver.log.LogEntry; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.core.util.ThriftUtil; import org.apache.accumulo.core.zookeeper.ZooUtil; @@ -63,9 +66,6 @@ import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.security.SystemCredentials; import org.apache.accumulo.server.util.MetadataTableUtil; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.thrift.TException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java index 0f5cada..56fbefe 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java @@ -40,9 +40,9 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Da import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ScanFileColumnFamily; import org.apache.accumulo.core.replication.StatusUtil; import org.apache.accumulo.core.replication.proto.Replication.Status; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; import org.apache.accumulo.server.ServerConstants; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; import org.apache.hadoop.io.Text; import org.apache.log4j.Logger; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java index 720d18b..d7ff148 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java @@ -69,7 +69,11 @@ import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.security.SecurityUtil; import org.apache.accumulo.core.security.thrift.TCredentials; +import org.apache.accumulo.core.trace.CountSampler; import org.apache.accumulo.core.trace.DistributedTrace; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.core.util.NamingThreadFactory; import org.apache.accumulo.core.util.Pair; import org.apache.accumulo.core.util.ServerServices; @@ -97,10 +101,6 @@ import org.apache.accumulo.server.util.RpcWrapper; import org.apache.accumulo.server.util.TServerUtils; import org.apache.accumulo.server.util.TabletIterator; import org.apache.accumulo.server.zookeeper.ZooLock; -import org.apache.accumulo.trace.instrument.CountSampler; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.Text; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/gc/src/main/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferences.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferences.java b/server/gc/src/main/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferences.java index 1c94253..bfa53ae 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferences.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/replication/CloseWriteAheadLogReferences.java @@ -44,8 +44,8 @@ import org.apache.accumulo.core.replication.proto.Replication.Status; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.tabletserver.log.LogEntry; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.Text; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java ---------------------------------------------------------------------- diff --git a/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java b/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java index a72eb5d..6195f42 100644 --- a/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java +++ b/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java @@ -35,9 +35,9 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.security.Credentials; import org.apache.accumulo.core.security.thrift.TCredentials; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.gc.SimpleGarbageCollector.Opts; import org.apache.accumulo.server.fs.VolumeManager; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.hadoop.fs.Path; import org.easymock.EasyMock; import org.junit.Before; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/pom.xml ---------------------------------------------------------------------- diff --git a/server/master/pom.xml b/server/master/pom.xml index 3b9684c..7e9ab1d 100644 --- a/server/master/pom.xml +++ b/server/master/pom.xml @@ -56,10 +56,6 @@ <artifactId>accumulo-server-base</artifactId> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-trace</artifactId> - </dependency> - <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java index 891f267..bdb5e2f 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java +++ b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java @@ -47,6 +47,7 @@ import org.apache.accumulo.core.iterators.IteratorUtil; import org.apache.accumulo.core.master.thrift.FateOperation; import org.apache.accumulo.core.master.thrift.FateService; import org.apache.accumulo.core.security.thrift.TCredentials; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.core.util.ByteBufferUtil; import org.apache.accumulo.core.util.Validator; import org.apache.accumulo.fate.ReadOnlyTStore.TStatus; @@ -68,7 +69,6 @@ import org.apache.accumulo.master.tableOps.TraceRepo; import org.apache.accumulo.server.client.ClientServiceHandler; import org.apache.accumulo.server.master.state.MergeInfo; import org.apache.accumulo.server.util.TablePropUtil; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.hadoop.io.Text; import org.apache.log4j.Logger; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/Master.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java index bbd2396..93691fb 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/Master.java +++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java @@ -70,6 +70,7 @@ import org.apache.accumulo.core.security.NamespacePermission; import org.apache.accumulo.core.security.SecurityUtil; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.core.trace.DistributedTrace; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.core.util.Daemon; import org.apache.accumulo.core.util.Pair; import org.apache.accumulo.core.util.UtilWaitThread; @@ -129,7 +130,6 @@ import org.apache.accumulo.server.zookeeper.ZooLock; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; import org.apache.accumulo.start.classloader.vfs.ContextManager; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.DataOutputBuffer; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java index a3eb70d..2007b36 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java +++ b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java @@ -59,6 +59,7 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.LogColumnFamily; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.security.thrift.TCredentials; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.core.util.ByteBufferUtil; import org.apache.accumulo.core.util.UtilWaitThread; import org.apache.accumulo.core.zookeeper.ZooUtil; @@ -81,7 +82,6 @@ import org.apache.accumulo.server.util.TableInfoUtil; import org.apache.accumulo.server.util.TablePropUtil; import org.apache.accumulo.server.util.TabletIterator.TabletDeletedException; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; -import org.apache.accumulo.trace.thrift.TInfo; import org.apache.hadoop.io.Text; import org.apache.log4j.Logger; import org.apache.thrift.TException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java b/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java index 1554f52..762b18d 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java +++ b/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java @@ -30,11 +30,11 @@ import org.apache.accumulo.core.master.thrift.MasterClientService; import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; import org.apache.accumulo.core.replication.ReplicationTable; import org.apache.accumulo.core.replication.ReplicationTarget; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.server.client.HdfsZooInstance; import org.apache.accumulo.server.metrics.AbstractMetricsImpl; import org.apache.accumulo.server.replication.ReplicationUtil; import org.apache.accumulo.server.security.SystemCredentials; -import org.apache.accumulo.trace.instrument.Tracer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/replication/ReplicationDriver.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/ReplicationDriver.java b/server/master/src/main/java/org/apache/accumulo/master/replication/ReplicationDriver.java index e3bbafa..ea378f4 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/ReplicationDriver.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/ReplicationDriver.java @@ -21,11 +21,11 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; +import org.apache.accumulo.core.trace.CountSampler; +import org.apache.accumulo.core.trace.Trace; import org.apache.accumulo.core.util.Daemon; import org.apache.accumulo.fate.util.UtilWaitThread; import org.apache.accumulo.master.Master; -import org.apache.accumulo.trace.instrument.CountSampler; -import org.apache.accumulo.trace.instrument.Trace; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java b/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java index 3f831a8..c7f47e4 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java @@ -39,8 +39,8 @@ import org.apache.accumulo.core.replication.ReplicationTable; import org.apache.accumulo.core.replication.ReplicationTableOfflineException; import org.apache.accumulo.core.replication.proto.Replication.Status; import org.apache.accumulo.core.security.Authorizations; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; import org.apache.hadoop.io.Text; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java index f4fd676..e2ac08b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java @@ -37,10 +37,10 @@ import org.apache.accumulo.core.replication.ReplicationTableOfflineException; import org.apache.accumulo.core.replication.ReplicationTarget; import org.apache.accumulo.core.replication.StatusUtil; import org.apache.accumulo.core.replication.proto.Replication.Status; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; import org.apache.accumulo.server.conf.ServerConfigurationFactory; import org.apache.accumulo.server.conf.TableConfiguration; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.io.Text; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java index ce25310..66c3fcc 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java @@ -60,6 +60,8 @@ import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; import org.apache.accumulo.core.security.Authorizations; +import org.apache.accumulo.core.trace.wrappers.TraceExecutorService; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.Pair; import org.apache.accumulo.core.util.SimpleThreadPool; import org.apache.accumulo.core.util.UtilWaitThread; @@ -76,8 +78,6 @@ import org.apache.accumulo.server.tablets.UniqueNameAllocator; import org.apache.accumulo.server.util.MetadataTableUtil; import org.apache.accumulo.server.zookeeper.DistributedWorkQueue; import org.apache.accumulo.server.zookeeper.TransactionWatcher.ZooArbitrator; -import org.apache.accumulo.trace.instrument.TraceExecutorService; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/master/src/main/java/org/apache/accumulo/master/tableOps/TraceRepo.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TraceRepo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/TraceRepo.java index 9b1a735..2571030 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TraceRepo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/TraceRepo.java @@ -16,11 +16,11 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.trace.Span; +import org.apache.accumulo.core.trace.Trace; +import org.apache.accumulo.core.trace.Tracer; +import org.apache.accumulo.core.trace.thrift.TInfo; import org.apache.accumulo.fate.Repo; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.instrument.Trace; -import org.apache.accumulo.trace.instrument.Tracer; -import org.apache.accumulo.trace.thrift.TInfo; /** * http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/pom.xml ---------------------------------------------------------------------- diff --git a/server/monitor/pom.xml b/server/monitor/pom.xml index a847183..ba61aeb 100644 --- a/server/monitor/pom.xml +++ b/server/monitor/pom.xml @@ -69,7 +69,7 @@ </dependency> <dependency> <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-trace</artifactId> + <artifactId>accumulo-tracer</artifactId> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java index 7fe1af7..8bc255d 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java @@ -47,6 +47,8 @@ import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.security.SecurityUtil; import org.apache.accumulo.core.tabletserver.thrift.ActiveScan; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client; +import org.apache.accumulo.core.trace.DistributedTrace; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.Daemon; import org.apache.accumulo.core.util.LoggingRunnable; import org.apache.accumulo.core.util.Pair; @@ -54,7 +56,6 @@ import org.apache.accumulo.core.util.ServerServices; import org.apache.accumulo.core.util.ServerServices.Service; import org.apache.accumulo.core.util.ThriftUtil; import org.apache.accumulo.core.util.UtilWaitThread; -import org.apache.accumulo.core.trace.DistributedTrace; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; @@ -90,7 +91,6 @@ import org.apache.accumulo.server.util.Halt; import org.apache.accumulo.server.util.TableInfoUtil; import org.apache.accumulo.server.zookeeper.ZooLock; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; -import org.apache.accumulo.trace.instrument.Tracer; import org.apache.log4j.Logger; import org.apache.zookeeper.KeeperException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TServersServlet.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TServersServlet.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TServersServlet.java index 452f790..4409dff 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TServersServlet.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/TServersServlet.java @@ -34,6 +34,7 @@ import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.tabletserver.thrift.ActionStats; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; import org.apache.accumulo.core.tabletserver.thrift.TabletStats; +import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.Base64; import org.apache.accumulo.core.util.Duration; import org.apache.accumulo.core.util.ThriftUtil; @@ -52,7 +53,6 @@ import org.apache.accumulo.server.master.state.TabletServerState; import org.apache.accumulo.server.security.SystemCredentials; import org.apache.accumulo.server.util.ActionStatsUpdator; import org.apache.accumulo.server.util.TableInfoUtil; -import org.apache.accumulo.trace.instrument.Tracer; import com.google.common.net.HostAndPort; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Basic.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Basic.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Basic.java index 475cae1..53cb172 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Basic.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Basic.java @@ -34,10 +34,10 @@ import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Prope import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.trace.TraceFormatter; import org.apache.accumulo.monitor.Monitor; import org.apache.accumulo.monitor.servlets.BasicServlet; import org.apache.accumulo.server.client.HdfsZooInstance; +import org.apache.accumulo.tracer.TraceFormatter; abstract class Basic extends BasicServlet { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ListType.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ListType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ListType.java index 1ba0590..5ab3b2a 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ListType.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ListType.java @@ -25,11 +25,11 @@ 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.core.trace.TraceFormatter; import org.apache.accumulo.monitor.util.Table; import org.apache.accumulo.monitor.util.celltypes.DurationType; import org.apache.accumulo.monitor.util.celltypes.StringType; -import org.apache.accumulo.trace.thrift.RemoteSpan; +import org.apache.accumulo.tracer.TraceFormatter; +import org.apache.accumulo.tracer.thrift.RemoteSpan; import org.apache.hadoop.io.Text; public class ListType extends Basic { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java index 8968088..067f184 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTrace.java @@ -31,13 +31,13 @@ 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.core.trace.SpanTree; -import org.apache.accumulo.core.trace.SpanTreeVisitor; -import org.apache.accumulo.core.trace.TraceDump; -import org.apache.accumulo.core.trace.TraceFormatter; import org.apache.accumulo.monitor.servlets.BasicServlet; -import org.apache.accumulo.trace.thrift.Annotation; -import org.apache.accumulo.trace.thrift.RemoteSpan; +import org.apache.accumulo.tracer.SpanTree; +import org.apache.accumulo.tracer.SpanTreeVisitor; +import org.apache.accumulo.tracer.TraceDump; +import org.apache.accumulo.tracer.TraceFormatter; +import org.apache.accumulo.tracer.thrift.Annotation; +import org.apache.accumulo.tracer.thrift.RemoteSpan; import org.apache.hadoop.io.Text; public class ShowTrace extends Basic { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTraceLinkType.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTraceLinkType.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTraceLinkType.java index 98b7d6e..d9de107 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTraceLinkType.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/ShowTraceLinkType.java @@ -18,9 +18,9 @@ package org.apache.accumulo.monitor.servlets.trace; import java.util.Date; -import org.apache.accumulo.core.trace.TraceFormatter; import org.apache.accumulo.monitor.util.celltypes.StringType; -import org.apache.accumulo.trace.thrift.RemoteSpan; +import org.apache.accumulo.tracer.TraceFormatter; +import org.apache.accumulo.tracer.thrift.RemoteSpan; /** * http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Summary.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Summary.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Summary.java index f717af8..8cc451f 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Summary.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/trace/Summary.java @@ -27,13 +27,13 @@ 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.core.trace.TraceFormatter; import org.apache.accumulo.monitor.servlets.BasicServlet; import org.apache.accumulo.monitor.util.Table; import org.apache.accumulo.monitor.util.celltypes.DurationType; import org.apache.accumulo.monitor.util.celltypes.NumberType; import org.apache.accumulo.monitor.util.celltypes.StringType; -import org.apache.accumulo.trace.thrift.RemoteSpan; +import org.apache.accumulo.tracer.TraceFormatter; +import org.apache.accumulo.tracer.thrift.RemoteSpan; import org.apache.hadoop.io.Text; public class Summary extends Basic { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java ---------------------------------------------------------------------- diff --git a/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java b/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java index effb0e6..ef4107b 100644 --- a/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java +++ b/server/monitor/src/test/java/org/apache/accumulo/monitor/ShowTraceLinkTypeTest.java @@ -19,8 +19,8 @@ package org.apache.accumulo.monitor; import java.util.ArrayList; import java.util.Collections; -import org.apache.accumulo.trace.thrift.RemoteSpan; -import org.apache.accumulo.trace.thrift.Annotation; +import org.apache.accumulo.tracer.thrift.RemoteSpan; +import org.apache.accumulo.tracer.thrift.Annotation; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/pom.xml ---------------------------------------------------------------------- diff --git a/server/tracer/pom.xml b/server/tracer/pom.xml index e1f61e6..859a471 100644 --- a/server/tracer/pom.xml +++ b/server/tracer/pom.xml @@ -48,10 +48,6 @@ <artifactId>accumulo-start</artifactId> </dependency> <dependency> - <groupId>org.apache.accumulo</groupId> - <artifactId>accumulo-trace</artifactId> - </dependency> - <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> </dependency> @@ -64,8 +60,16 @@ <artifactId>zookeeper</artifactId> </dependency> <dependency> + <groupId>org.htrace</groupId> + <artifactId>htrace-core</artifactId> + </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> @@ -74,4 +78,42 @@ <scope>test</scope> </dependency> </dependencies> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + <configuration> + <excludeFilterFile>src/main/findbugs/exclude-filter.xml</excludeFilterFile> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <profiles> + <profile> + <id>thrift</id> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-thrift</id> + <goals> + <goal>exec</goal> + </goals> + <phase>generate-sources</phase> + <configuration> + <executable>${basedir}/src/main/scripts/generate-thrift.sh</executable> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/findbugs/exclude-filter.xml ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/findbugs/exclude-filter.xml b/server/tracer/src/main/findbugs/exclude-filter.xml new file mode 100644 index 0000000..593390e --- /dev/null +++ b/server/tracer/src/main/findbugs/exclude-filter.xml @@ -0,0 +1,21 @@ +<!-- + 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. +--> +<FindBugsFilter> + <Match> + <Class name="~org\.apache\.accumulo\.tracer\.thrift\..*" /> + </Match> +</FindBugsFilter> http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java new file mode 100644 index 0000000..7c54b55 --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java @@ -0,0 +1,174 @@ +/* + * 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 org.apache.accumulo.core.trace.DistributedTrace; +import org.apache.accumulo.tracer.thrift.Annotation; +import org.apache.accumulo.tracer.thrift.RemoteSpan; +import org.apache.log4j.Logger; +import org.htrace.HTraceConfiguration; +import org.htrace.Span; +import org.htrace.SpanReceiver; +import org.htrace.TimelineAnnotation; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.nio.ByteBuffer; +import java.util.AbstractQueue; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; + +/** + * Deliver Span information periodically to a destination. + * <ul> + * <li>Send host and service information with the span. + * <li>Cache Destination objects by some key that can be extracted from the span. + * <li>Can be used to queue spans up for delivery over RPC, or for saving into a file. + * </ul> + */ +public abstract class AsyncSpanReceiver<SpanKey,Destination> implements SpanReceiver { + + private static final Logger log = Logger.getLogger(AsyncSpanReceiver.class); + + private final Map<SpanKey,Destination> clients = new HashMap<SpanKey,Destination>(); + + protected String host = null; + protected String service = null; + + protected abstract Destination createDestination(SpanKey key) throws Exception; + + protected abstract void send(Destination resource, RemoteSpan span) throws Exception; + + protected abstract SpanKey getSpanKey(Map<ByteBuffer,ByteBuffer> data); + + Timer timer = new Timer("SpanSender", true); + protected final AbstractQueue<RemoteSpan> sendQueue = new ConcurrentLinkedQueue<RemoteSpan>(); + + public AsyncSpanReceiver() { + this(1000); + } + + public AsyncSpanReceiver(long millis) { + timer.schedule(new TimerTask() { + @Override + public void run() { + try { + sendSpans(); + } catch (Exception ex) { + log.warn("Exception sending spans to destination", ex); + } + } + + }, millis, millis); + } + + protected void sendSpans() { + while (!sendQueue.isEmpty()) { + boolean sent = false; + RemoteSpan s = sendQueue.peek(); + SpanKey dest = getSpanKey(s.data); + Destination client = clients.get(dest); + if (client == null) { + try { + clients.put(dest, createDestination(dest)); + } catch (Exception ex) { + log.warn("Exception creating connection to span receiver", ex); + } + } + if (client != null) { + try { + send(client, s); + synchronized (sendQueue) { + sendQueue.remove(); + sendQueue.notifyAll(); + } + sent = true; + } catch (Exception ex) { + log.warn("Got error sending to " + dest + ", refreshing client", ex); + clients.remove(dest); + } + } + if (!sent) + break; + } + } + + public static Map<ByteBuffer, ByteBuffer> convertToByteBuffers(Map<byte[], byte[]> bytesMap) { + if (bytesMap == null) + return null; + Map<ByteBuffer, ByteBuffer> result = new HashMap<ByteBuffer, ByteBuffer>(); + for (Entry<byte[], byte[]> bytes : bytesMap.entrySet()) { + result.put(ByteBuffer.wrap(bytes.getKey()), ByteBuffer.wrap(bytes.getValue())); + } + return result; + } + + public static List<Annotation> convertToAnnotations(List<TimelineAnnotation> annotations) { + if (annotations == null) + return null; + List<Annotation> result = new ArrayList<Annotation>(); + for (TimelineAnnotation annotation : annotations) { + result.add(new Annotation(annotation.getTime(), annotation.getMessage())); + } + return result; + } + + @Override + public void receiveSpan(Span s) { + Map<ByteBuffer, ByteBuffer> data = convertToByteBuffers(s.getKVAnnotations()); + SpanKey dest = getSpanKey(data); + if (dest != null) { + List<Annotation> annotations = convertToAnnotations(s.getTimelineAnnotations()); + sendQueue.add(new RemoteSpan(host, service==null ? s.getProcessId() : service, s.getTraceId(), s.getSpanId(), s.getParentId(), + s.getStartTimeMillis(), s.getStopTimeMillis(), s.getDescription(), data, annotations)); + } + } + + @Override + public void close() { + synchronized (sendQueue) { + while (!sendQueue.isEmpty()) { + try { + sendQueue.wait(); + } catch (InterruptedException e) { + log.warn("flush interrupted"); + break; + } + } + } + } + + @Override + public void configure(HTraceConfiguration conf) { + host = conf.get(DistributedTrace.TRACE_HOST_PROPERTY, host); + if (host == null) { + try { + host = InetAddress.getLocalHost().getCanonicalHostName().toString(); + } catch (UnknownHostException e) { + host = "unknown"; + } + } + service = conf.get(DistributedTrace.TRACE_SERVICE_PROPERTY, service); + } + +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/SendSpansViaThrift.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/SendSpansViaThrift.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/SendSpansViaThrift.java new file mode 100644 index 0000000..2190570 --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/SendSpansViaThrift.java @@ -0,0 +1,97 @@ +/* + * 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.nio.charset.StandardCharsets.UTF_8; + +import org.apache.accumulo.tracer.thrift.RemoteSpan; +import org.apache.accumulo.tracer.thrift.SpanReceiver.Client; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.transport.TSocket; +import org.apache.thrift.transport.TTransport; + +import java.net.InetSocketAddress; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.util.Map; + +/** + * Send Span data to a destination using thrift. + */ +public class SendSpansViaThrift extends AsyncSpanReceiver<String,Client> { + + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SendSpansViaThrift.class); + + private static final String THRIFT = "thrift://"; + + public SendSpansViaThrift() { + super(); + } + + public SendSpansViaThrift(long millis) { + super(millis); + } + + @Override + protected Client createDestination(String destination) throws Exception { + if (destination == null) + return null; + try { + int portSeparatorIndex = destination.lastIndexOf(':'); + String host = destination.substring(0, portSeparatorIndex); + int port = Integer.parseInt(destination.substring(portSeparatorIndex+1)); + log.debug("Connecting to " + host + ":" + port); + InetSocketAddress addr = new InetSocketAddress(host, port); + Socket sock = new Socket(); + sock.connect(addr); + TTransport transport = new TSocket(sock); + TProtocol prot = new TBinaryProtocol(transport); + return new Client(prot); + } catch (Exception ex) { + log.error(ex, ex); + return null; + } + } + + @Override + protected void send(Client client, RemoteSpan s) throws Exception { + if (client != null) { + try { + client.span(s); + } catch (Exception ex) { + client.getInputProtocol().getTransport().close(); + throw ex; + } + } + } + + private static final ByteBuffer DEST = ByteBuffer.wrap("dest".getBytes(UTF_8)); + + protected String getSpanKey(Map<ByteBuffer,ByteBuffer> data) { + String dest = new String(data.get(DEST).array()); + if (dest != null && dest.startsWith(THRIFT)) { + String hostAddress = dest.substring(THRIFT.length()); + String[] hostAddr = hostAddress.split(":", 2); + if (hostAddr.length == 2) { + return hostAddress; + } + } + return null; + } + +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTree.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTree.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTree.java new file mode 100644 index 0000000..6337ee4 --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTree.java @@ -0,0 +1,76 @@ +/* + * 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 java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.htrace.Span; +import org.apache.accumulo.tracer.thrift.RemoteSpan; + +public class SpanTree { + final Map<Long,List<Long>> parentChildren = new HashMap<Long,List<Long>>(); + public final Map<Long,RemoteSpan> nodes = new HashMap<Long,RemoteSpan>(); + + public SpanTree() {} + + public void addNode(RemoteSpan span) { + nodes.put(span.spanId, span); + if (parentChildren.get(span.parentId) == null) + parentChildren.put(span.parentId, new ArrayList<Long>()); + parentChildren.get(span.parentId).add(span.spanId); + } + + public Set<Long> visit(SpanTreeVisitor visitor) { + Set<Long> visited = new HashSet<Long>(); + List<Long> root = parentChildren.get(Long.valueOf(Span.ROOT_SPAN_ID)); + if (root == null || root.isEmpty()) + return visited; + RemoteSpan rootSpan = nodes.get(root.iterator().next()); + if (rootSpan == null) + return visited; + recurse(0, null, rootSpan, visitor, visited); + return visited; + } + + private void recurse(int level, RemoteSpan parent, RemoteSpan node, SpanTreeVisitor visitor, Set<Long> visited) { + // improbable case: duplicate spanId in a trace tree: prevent + // infinite recursion + if (visited.contains(node.spanId)) + return; + visited.add(node.spanId); + List<RemoteSpan> children = new ArrayList<RemoteSpan>(); + List<Long> childrenIds = parentChildren.get(node.spanId); + if (childrenIds != null) { + for (Long childId : childrenIds) { + RemoteSpan child = nodes.get(childId); + if (child != null) { + children.add(child); + } + } + } + children = TraceDump.sortByStart(children); + visitor.visit(level, parent, node, children); + for (RemoteSpan child : children) { + recurse(level + 1, node, child, visitor, visited); + } + } +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTreeVisitor.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTreeVisitor.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTreeVisitor.java new file mode 100644 index 0000000..2ca1f3b --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/SpanTreeVisitor.java @@ -0,0 +1,25 @@ +/* + * 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 java.util.Collection; + +import org.apache.accumulo.tracer.thrift.RemoteSpan; + +public interface SpanTreeVisitor { + void visit(int level, RemoteSpan parent, RemoteSpan node, Collection<RemoteSpan> children); +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java new file mode 100644 index 0000000..c109fd8 --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java @@ -0,0 +1,162 @@ +/* + * 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.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++; + } + 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/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceFormatter.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceFormatter.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceFormatter.java new file mode 100644 index 0000000..4829eb2 --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceFormatter.java @@ -0,0 +1,126 @@ +/* + * 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.nio.charset.StandardCharsets.UTF_8; + +import java.nio.ByteBuffer; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Iterator; +import java.util.Map.Entry; + +import org.apache.accumulo.tracer.thrift.Annotation; +import org.apache.accumulo.tracer.thrift.RemoteSpan; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.util.format.DefaultFormatter; +import org.apache.accumulo.core.util.format.Formatter; +import org.apache.commons.lang.NotImplementedException; +import org.apache.hadoop.io.Text; +import org.apache.thrift.TException; +import org.apache.thrift.protocol.TCompactProtocol; +import org.apache.thrift.transport.TMemoryInputTransport; + + +/** + * A formatter than can be used in the shell to display trace information. + * + */ +public class TraceFormatter implements Formatter { + public static final String DATE_FORMAT = "yyyy/MM/dd HH:mm:ss.SSS"; + // ugh... SimpleDataFormat is not thread safe + private static final ThreadLocal<SimpleDateFormat> formatter = new ThreadLocal<SimpleDateFormat>() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat(DATE_FORMAT); + } + }; + + public static String formatDate(final Date date) { + return formatter.get().format(date); + } + + private final static Text SPAN_CF = new Text("span"); + + private Iterator<Entry<Key,Value>> scanner; + private boolean printTimeStamps; + + public static RemoteSpan getRemoteSpan(Entry<Key,Value> entry) { + TMemoryInputTransport transport = new TMemoryInputTransport(entry.getValue().get()); + TCompactProtocol protocol = new TCompactProtocol(transport); + RemoteSpan span = new RemoteSpan(); + try { + span.read(protocol); + } catch (TException ex) { + throw new RuntimeException(ex); + } + return span; + } + + @Override + public boolean hasNext() { + return scanner.hasNext(); + } + + @Override + public String next() { + Entry<Key,Value> next = scanner.next(); + if (next.getKey().getColumnFamily().equals(SPAN_CF)) { + StringBuilder result = new StringBuilder(); + SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT); + RemoteSpan span = getRemoteSpan(next); + result.append("----------------------\n"); + result.append(String.format(" %12s:%s%n", "name", span.description)); + result.append(String.format(" %12s:%s%n", "trace", Long.toHexString(span.traceId))); + result.append(String.format(" %12s:%s%n", "loc", span.svc + "@" + span.sender)); + result.append(String.format(" %12s:%s%n", "span", Long.toHexString(span.spanId))); + result.append(String.format(" %12s:%s%n", "parent", Long.toHexString(span.parentId))); + result.append(String.format(" %12s:%s%n", "start", dateFormatter.format(span.start))); + result.append(String.format(" %12s:%s%n", "ms", span.stop - span.start)); + if (span.data != null) { + for (Entry<ByteBuffer, ByteBuffer> entry : span.data.entrySet()) { + String key = new String(entry.getKey().array(), entry.getKey().arrayOffset(), entry.getKey().limit(), UTF_8); + String value = new String(entry.getValue().array(), entry.getValue().arrayOffset(), entry.getValue().limit(), UTF_8); + result.append(String.format(" %12s:%s%n", key, value)); + } + } + if (span.annotations != null) { + for (Annotation annotation : span.annotations) { + result.append(String.format(" %12s:%s:%s%n", "annotation", annotation.getMsg(), dateFormatter.format(annotation.getTime()))); + } + } + + if (printTimeStamps) { + result.append(String.format(" %-12s:%d%n", "timestamp", next.getKey().getTimestamp())); + } + return result.toString(); + } + return DefaultFormatter.formatEntry(next, printTimeStamps); + } + + @Override + public void remove() { + throw new NotImplementedException(); + } + + @Override + public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) { + this.scanner = scanner.iterator(); + this.printTimeStamps = printTimestamps; + } +} http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/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 af1ec56..18fe47a 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 @@ -43,7 +43,6 @@ import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.user.AgeOffFilter; import org.apache.accumulo.core.security.SecurityUtil; import org.apache.accumulo.core.util.UtilWaitThread; -import org.apache.accumulo.core.trace.TraceFormatter; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.server.Accumulo; @@ -55,10 +54,10 @@ import org.apache.accumulo.server.fs.VolumeManagerImpl; import org.apache.accumulo.server.util.time.SimpleTimer; import org.apache.accumulo.server.zookeeper.ZooReaderWriter; import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; -import org.apache.accumulo.trace.instrument.Span; -import org.apache.accumulo.trace.thrift.RemoteSpan; -import org.apache.accumulo.trace.thrift.SpanReceiver.Iface; -import org.apache.accumulo.trace.thrift.SpanReceiver.Processor; +import org.htrace.Span; +import org.apache.accumulo.tracer.thrift.RemoteSpan; +import org.apache.accumulo.tracer.thrift.SpanReceiver.Iface; +import org.apache.accumulo.tracer.thrift.SpanReceiver.Processor; import org.apache.hadoop.io.Text; import org.apache.log4j.Logger; import org.apache.thrift.TByteArrayOutputStream; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6b5f5ef4/server/tracer/src/main/java/org/apache/accumulo/tracer/ZooTraceClient.java ---------------------------------------------------------------------- diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/ZooTraceClient.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/ZooTraceClient.java new file mode 100644 index 0000000..866784d --- /dev/null +++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/ZooTraceClient.java @@ -0,0 +1,124 @@ +/* + * 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.nio.charset.StandardCharsets.UTF_8; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.trace.DistributedTrace; +import org.apache.accumulo.fate.zookeeper.ZooReader; +import org.apache.log4j.Logger; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.htrace.HTraceConfiguration; + +/** + * Find a Span collector via zookeeper and push spans there via Thrift RPC + */ +public class ZooTraceClient extends SendSpansViaThrift implements Watcher { + private static final Logger log = Logger.getLogger(ZooTraceClient.class); + + private static final int DEFAULT_TIMEOUT = 30 * 1000; + + ZooReader zoo = null; + String path; + boolean pathExists = false; + final Random random = new Random(); + final List<String> hosts = new ArrayList<String>(); + + public ZooTraceClient() { + super(); + } + + public ZooTraceClient(long millis) { + super(millis); + } + + @Override + synchronized protected String getSpanKey(Map<ByteBuffer,ByteBuffer> data) { + if (hosts.size() > 0) { + String host = hosts.get(random.nextInt(hosts.size())); + log.debug("sending data to " + host); + return host; + } + return null; + } + + @Override + public void configure(HTraceConfiguration conf) { + super.configure(conf); + String keepers = conf.get(DistributedTrace.TRACER_ZK_HOST); + if (keepers == null) + throw new IllegalArgumentException("Must configure " + DistributedTrace.TRACER_ZK_HOST); + int timeout = conf.getInt(DistributedTrace.TRACER_ZK_TIMEOUT, DEFAULT_TIMEOUT); + zoo = new ZooReader(keepers, timeout); + path = conf.get(DistributedTrace.TRACER_ZK_PATH, Constants.ZTRACERS); + process(null); + } + + @Override + public void process(WatchedEvent event) { + log.debug("Processing event for trace server zk watch"); + try { + if (pathExists || zoo.exists(path)) { + pathExists = true; + updateHosts(path, zoo.getChildren(path, this)); + } else { + zoo.exists(path, this); + } + } catch (Exception ex) { + log.error("unable to get destination hosts in zookeeper", ex); + } + } + + @Override + protected void sendSpans() { + if (hosts.isEmpty()) { + if (!sendQueue.isEmpty()) { + log.error("No hosts to send data to, dropping queued spans"); + synchronized (sendQueue) { + sendQueue.clear(); + sendQueue.notifyAll(); + } + } + } else { + super.sendSpans(); + } + } + + synchronized private void updateHosts(String path, List<String> children) { + log.debug("Scanning trace hosts in zookeeper: " + path); + try { + List<String> hosts = new ArrayList<String>(); + for (String child : children) { + byte[] data = zoo.getData(path + "/" + child, null); + hosts.add(new String(data, UTF_8)); + } + this.hosts.clear(); + this.hosts.addAll(hosts); + log.debug("Trace hosts: " + this.hosts); + } catch (Exception ex) { + log.error("unable to get destination hosts in zookeeper", ex); + } + } +}
