accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [47/50] [abbrv] git commit: Merge branch '1.4.4-SNAPSHOT' into 1.5.1-SNAPSHOT-1.4.4-SNAPSHOT-merged
Date Wed, 31 Jul 2013 15:14:24 GMT
Merge branch '1.4.4-SNAPSHOT' into 1.5.1-SNAPSHOT-1.4.4-SNAPSHOT-merged

Conflicts:
	trace/src/main/java/org/apache/accumulo/trace/instrument/impl/MilliSpan.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8e1e2a57
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8e1e2a57
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8e1e2a57

Branch: refs/heads/master
Commit: 8e1e2a57d150923574ace0e92945fdca14de4fc8
Parents: cb5a543 3e97167
Author: Josh Elser <elserj@apache.org>
Authored: Tue Jul 30 20:03:26 2013 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Tue Jul 30 20:03:26 2013 -0400

----------------------------------------------------------------------
 .../apache/accumulo/trace/instrument/impl/MilliSpan.java  | 10 +++++-----
 .../accumulo/trace/instrument/impl/RootMilliSpan.java     |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8e1e2a57/trace/src/main/java/org/apache/accumulo/trace/instrument/impl/MilliSpan.java
----------------------------------------------------------------------
diff --cc trace/src/main/java/org/apache/accumulo/trace/instrument/impl/MilliSpan.java
index 8f020f0,0000000..b641a2c
mode 100644,000000..100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/impl/MilliSpan.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/impl/MilliSpan.java
@@@ -1,141 -1,0 +1,141 @@@
 +/*
 + * 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.trace.instrument.impl;
 +
 +import java.security.SecureRandom;
 +import java.util.Collections;
 +import java.util.HashMap;
 +import java.util.Map;
 +import java.util.Random;
 +
 +import org.apache.accumulo.trace.instrument.Span;
 +import org.apache.accumulo.trace.instrument.Tracer;
 +
 +
 +/**
 + * A Span implementation that stores its information in milliseconds since the epoch.
 + */
 +public class MilliSpan implements Span {
 +  
 +  private static final Random next = new SecureRandom();
 +  private long start;
 +  private long stop;
 +  final private Span parent;
 +  final private String description;
 +  final private long spanId;
++  final private long traceId;
 +  private Map<String,String> traceInfo = null;
 +  
 +  public Span child(String description) {
-     return new MilliSpan(description, next.nextLong(), this);
++    return new MilliSpan(description, next.nextLong(), traceId, this);
 +  }
 +  
-   public MilliSpan(String description, long id, Span parent) {
++  public MilliSpan(String description, long id, long traceId, Span parent) {
 +    this.description = description;
 +    this.spanId = id;
++    this.traceId = traceId;
 +    this.parent = parent;
 +    this.start = 0;
 +    this.stop = 0;
 +  }
 +  
 +  public synchronized void start() {
 +    if (start > 0)
 +      throw new IllegalStateException("Span for " + description + " has already been started");
 +    start = System.currentTimeMillis();
 +  }
 +  
 +  public synchronized void stop() {
 +    if (start == 0)
 +      throw new IllegalStateException("Span for " + description + " has not been started");
 +    stop = System.currentTimeMillis();
 +    Tracer.getInstance().pop(this);
 +  }
 +  
 +  protected long currentTimeMillis() {
 +    return System.currentTimeMillis();
 +  }
 +  
 +  public synchronized boolean running() {
 +    return start != 0 && stop == 0;
 +  }
 +  
 +  public synchronized long accumulatedMillis() {
 +    if (start == 0)
 +      return 0;
 +    if (stop > 0)
 +      return stop - start;
 +    return currentTimeMillis() - start;
 +  }
 +  
 +  public String toString() {
 +    long parentId = parentId();
 +    return ("\"" + description() + "\" trace:" + Long.toHexString(traceId()) + " span:"
+ spanId + (parentId > 0 ? " parent:" + parentId : "") + " start:"
 +        + start + " ms: " + Long.toString(accumulatedMillis()) + (running() ? "..." : ""));
 +    
 +  }
 +  
 +  public String description() {
 +    return description;
 +  }
 +  
 +  @Override
 +  public long spanId() {
 +    return spanId;
 +  }
 +  
 +  @Override
 +  public Span parent() {
 +    return parent;
 +  }
 +  
 +  @Override
 +  public long parentId() {
 +    if (parent == null)
 +      return -1;
 +    return parent.spanId();
 +  }
 +  
 +  @Override
 +  public long traceId() {
-     if (parent == this)
-       throw new RuntimeException("loop found in trace!");
-     return parent.traceId();
++    return traceId;
 +  }
 +  
 +  @Override
 +  public long getStartTimeMillis() {
 +    return start;
 +  }
 +  
 +  @Override
 +  public long getStopTimeMillis() {
 +    return stop;
 +  }
 +  
 +  @Override
 +  public void data(String key, String value) {
 +    if (traceInfo == null)
 +      traceInfo = new HashMap<String,String>();
 +    traceInfo.put(key, value);
 +  }
 +  
 +  @Override
 +  public Map<String,String> getData() {
 +    if (traceInfo == null)
 +      return Collections.emptyMap();
 +    return Collections.unmodifiableMap(traceInfo);
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8e1e2a57/trace/src/main/java/org/apache/accumulo/trace/instrument/impl/RootMilliSpan.java
----------------------------------------------------------------------
diff --cc trace/src/main/java/org/apache/accumulo/trace/instrument/impl/RootMilliSpan.java
index eb31dcc,0000000..c25e644
mode 100644,000000..100644
--- a/trace/src/main/java/org/apache/accumulo/trace/instrument/impl/RootMilliSpan.java
+++ b/trace/src/main/java/org/apache/accumulo/trace/instrument/impl/RootMilliSpan.java
@@@ -1,43 -1,0 +1,43 @@@
 +/*
 + * 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.trace.instrument.impl;
 +
 +/**
 + * Span that roots the span tree in a process, but perhaps not the whole trace.
 + * 
 + */
 +public class RootMilliSpan extends MilliSpan {
 +  
 +  final long traceId;
 +  final long parentId;
 +  
 +  @Override
 +  public long traceId() {
 +    return traceId;
 +  }
 +  
 +  public RootMilliSpan(String description, long traceId, long spanId, long parentId) {
-     super(description, spanId, null);
++    super(description, spanId, traceId, null);
 +    this.traceId = traceId;
 +    this.parentId = parentId;
 +  }
 +  
 +  public long parentId() {
 +    return parentId;
 +  }
 +  
 +}


Mime
View raw message