mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-27 21:56:38 +10:00
[유치수] [NOBTS] change data type of traceid
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@727 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nhn.hippo.web.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.nhn.hippo.web.calltree.RPCCallTree;
|
||||
import com.nhn.hippo.web.service.FlowChartService;
|
||||
import com.nhn.hippo.web.vo.TraceId;
|
||||
|
||||
/**
|
||||
* retrieve data for drawing call tree.
|
||||
@@ -38,13 +40,24 @@ public class FlowChartController {
|
||||
@RequestMapping(value = "/flow", method = RequestMethod.GET)
|
||||
public String arcus(Model model, @RequestParam("host") String[] hosts, @RequestParam("from") long from, @RequestParam("to") long to) {
|
||||
String[] agentIds = flow.selectAgentIds(hosts);
|
||||
List<byte[]> traceIds = flow.selectTraceIdsFromTraceIndex(agentIds, from, to);
|
||||
System.out.println("");
|
||||
System.out.println("--------------------------------------");
|
||||
System.out.println("agentIds=" + Arrays.toString(agentIds));
|
||||
|
||||
Set<TraceId> traceIds = flow.selectTraceIdsFromTraceIndex(agentIds, from, to);
|
||||
for(TraceId tid : traceIds) {
|
||||
System.out.println("traceIds=" + tid);
|
||||
}
|
||||
System.out.println("--------------------------------------");
|
||||
System.out.println("");
|
||||
|
||||
RPCCallTree callTree = flow.selectRPCCallTree(traceIds);
|
||||
|
||||
model.addAttribute("nodes", callTree.getNodes());
|
||||
model.addAttribute("links", callTree.getLinks());
|
||||
model.addAttribute("value", "hello world");
|
||||
|
||||
System.out.println("");
|
||||
System.out.println("--------------------------------------");
|
||||
System.out.println(callTree.toString());
|
||||
|
||||
return "flow";
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.nhn.hippo.web.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.nhn.hippo.web.calltree.RPCCallTree;
|
||||
import com.nhn.hippo.web.calltree.ServerCallTree;
|
||||
import com.nhn.hippo.web.vo.TraceId;
|
||||
import com.profiler.common.dto.thrift.Span;
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ public interface FlowChartService {
|
||||
* @param to
|
||||
* @return
|
||||
*/
|
||||
public List<byte[]> selectTraceIdsFromTraceIndex(String[] agentIds, long from, long to);
|
||||
public Set<TraceId> selectTraceIdsFromTraceIndex(String[] agentIds, long from, long to);
|
||||
|
||||
/**
|
||||
* select Traces from Trace table
|
||||
@@ -46,8 +48,8 @@ public interface FlowChartService {
|
||||
* @param traceIds
|
||||
* @return
|
||||
*/
|
||||
public RPCCallTree selectRPCCallTree(List<byte[]> traceIds);
|
||||
|
||||
public RPCCallTree selectRPCCallTree(Set<TraceId> traceIds);
|
||||
|
||||
/**
|
||||
* select call tree
|
||||
*
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.nhn.hippo.web.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.nhn.hippo.web.calltree.RPCCallTree;
|
||||
import com.nhn.hippo.web.calltree.ServerCallTree;
|
||||
import com.nhn.hippo.web.service.TracesProcessor.SpanHandler;
|
||||
import com.nhn.hippo.web.vo.TraceId;
|
||||
import com.profiler.common.dto.thrift.Span;
|
||||
import com.profiler.common.hbase.HBaseClient;
|
||||
import com.profiler.common.hbase.HBaseQuery;
|
||||
@@ -55,11 +58,11 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> selectTraceIdsFromTraceIndex(String[] agentIds, long from, long to) {
|
||||
public Set<TraceId> selectTraceIdsFromTraceIndex(String[] agentIds, long from, long to) {
|
||||
List<HbaseColumn> column = new ArrayList<HBaseQuery.HbaseColumn>();
|
||||
column.add(new HbaseColumn("Trace", "ID"));
|
||||
|
||||
List<byte[]> list = new ArrayList<byte[]>();
|
||||
Set<TraceId> set = new HashSet<TraceId>();
|
||||
|
||||
for (String agentId : agentIds) {
|
||||
byte[] s = ArrayUtils.addAll(Bytes.toBytes(agentId), Bytes.toBytes(from));
|
||||
@@ -69,11 +72,11 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
Iterator<Map<String, byte[]>> result = client.getHBaseData(query);
|
||||
|
||||
while (result.hasNext()) {
|
||||
list.add(result.next().get("ID"));
|
||||
set.add(new TraceId(result.next().get("ID")));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,10 +108,10 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RPCCallTree selectRPCCallTree(List<byte[]> traceIds) {
|
||||
public RPCCallTree selectRPCCallTree(Set<TraceId> traceIds) {
|
||||
List<Get> gets = new ArrayList<Get>(traceIds.size());
|
||||
for (byte[] traceId : traceIds) {
|
||||
gets.add(new Get(traceId));
|
||||
for (TraceId traceId : traceIds) {
|
||||
gets.add(new Get(traceId.getBytes()));
|
||||
}
|
||||
|
||||
Result[] results = client.get(HBaseTables.TRACES, gets);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.nhn.hippo.web.vo;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TraceId {
|
||||
|
||||
private final byte[] id;
|
||||
private final int hashcode;
|
||||
|
||||
public TraceId(byte[] traceId) {
|
||||
this.id = traceId;
|
||||
this.hashcode = new String(id).hashCode();
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object traceId) {
|
||||
if (traceId instanceof TraceId) {
|
||||
return Arrays.equals(id, ((TraceId) traceId).id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashcode;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return Arrays.toString(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user