mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-15 07:46:19 +10:00
[유치수] [NOBTS] change ApplicationTraceIndex, TraceIndex, RootTraceIndex column qualifier format, from "ID" to byte arrays of traceId
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@1071 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
*
|
||||
*/
|
||||
public interface ApplicationTraceIndexDao {
|
||||
List<byte[]> scanTraceIndex(String applicationName, long start, long end);
|
||||
List<List<byte[]>> scanTraceIndex(String applicationName, long start, long end);
|
||||
|
||||
List<List<byte[]>> multiScanTraceIndex(String[] applicationNames, long start, long end);
|
||||
List<List<List<byte[]>>> multiScanTraceIndex(String[] applicationNames, long start, long end);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.util.List;
|
||||
*
|
||||
*/
|
||||
public interface RootTraceIndexDao {
|
||||
List<byte[]> scanTraceIndex(String agent, long start, long end);
|
||||
List<List<byte[]>> scanTraceIndex(String agent, long start, long end);
|
||||
|
||||
List<List<byte[]>> multiScanTraceIndex(String[] agents, long start, long end);
|
||||
List<List<List<byte[]>>> multiScanTraceIndex(String[] agents, long start, long end);
|
||||
|
||||
List parallelScanTraceIndex(String[] agents, long start, long end);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
*
|
||||
*/
|
||||
public interface TraceIndexDao {
|
||||
List<byte[]> scanTraceIndex(String agent, long start, long end);
|
||||
List<List<byte[]>> scanTraceIndex(String agent, long start, long end);
|
||||
|
||||
List<List<byte[]>> multiScanTraceIndex(String[] agents, long start, long end);
|
||||
List<List<List<byte[]>>> multiScanTraceIndex(String[] agents, long start, long end);
|
||||
}
|
||||
|
||||
@@ -26,14 +26,13 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final byte[] COLFAM_TRACE = HBaseTables.APPLICATION_TRACE_INDEX_CF_TRACE;
|
||||
private final byte[] COLNAME_ID = HBaseTables.APPLICATION_TRACE_INDEX_CN_ID;
|
||||
|
||||
@Autowired
|
||||
private HbaseOperations2 hbaseOperations2;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("traceIndexMapper")
|
||||
private RowMapper<byte[]> traceIndexMapper;
|
||||
private RowMapper<List<byte[]>> traceIndexMapper;
|
||||
|
||||
private int scanCacheSize = 40;
|
||||
|
||||
@@ -42,13 +41,13 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> scanTraceIndex(String applicationName, long start, long end) {
|
||||
public List<List<byte[]>> scanTraceIndex(String applicationName, long start, long end) {
|
||||
Scan scan = createScan(applicationName, start, end);
|
||||
return hbaseOperations2.find(HBaseTables.APPLICATION_TRACE_INDEX, scan, traceIndexMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<byte[]>> multiScanTraceIndex(String[] applicationNames, long start, long end) {
|
||||
public List<List<List<byte[]>>> multiScanTraceIndex(String[] applicationNames, long start, long end) {
|
||||
final List<Scan> multiScan = new ArrayList<Scan>(applicationNames.length);
|
||||
for (String agent : applicationNames) {
|
||||
Scan scan = createScan(agent, start, end);
|
||||
@@ -71,7 +70,7 @@ public class HbaseApplicationTraceIndexDao implements ApplicationTraceIndexDao {
|
||||
|
||||
byte[] traceIndexEndKey = SpanUtils.getTraceIndexRowKey(bAgent, end);
|
||||
scan.setStopRow(traceIndexEndKey);
|
||||
scan.addColumn(COLFAM_TRACE, COLNAME_ID);
|
||||
scan.addFamily(COLFAM_TRACE);
|
||||
scan.setId("traceIndexScan");
|
||||
|
||||
// json으로 변화해서 로그를 찍어서. 최초 변환 속도가 느림.
|
||||
|
||||
@@ -25,15 +25,12 @@ public class HbaseRootTraceIndexDao implements RootTraceIndexDao {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final byte[] COLFAM_TRACE = Bytes.toBytes("Trace");
|
||||
private final byte[] COLNAME_ID = Bytes.toBytes("ID");
|
||||
|
||||
@Autowired
|
||||
private HbaseOperations2 hbaseOperations2;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("traceIndexMapper")
|
||||
private RowMapper<byte[]> traceIndexMapper;
|
||||
private RowMapper<List<byte[]>> traceIndexMapper;
|
||||
|
||||
private int scanCacheSize = 40;
|
||||
|
||||
@@ -42,13 +39,13 @@ public class HbaseRootTraceIndexDao implements RootTraceIndexDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> scanTraceIndex(String agent, long start, long end) {
|
||||
public List<List<byte[]>> scanTraceIndex(String agent, long start, long end) {
|
||||
Scan scan = createScan(agent, start, end);
|
||||
return hbaseOperations2.find(HBaseTables.ROOT_TRACE_INDEX, scan, traceIndexMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<byte[]>> multiScanTraceIndex(String[] agents, long start, long end) {
|
||||
public List<List<List<byte[]>>> multiScanTraceIndex(String[] agents, long start, long end) {
|
||||
final List<Scan> multiScan = new ArrayList<Scan>(agents.length);
|
||||
for (String agent : agents) {
|
||||
Scan scan = createScan(agent, start, end);
|
||||
@@ -68,8 +65,7 @@ public class HbaseRootTraceIndexDao implements RootTraceIndexDao {
|
||||
|
||||
byte[] traceIndexEndKey = SpanUtils.getTraceIndexRowKey(bAgent, end);
|
||||
scan.setStopRow(traceIndexEndKey);
|
||||
|
||||
scan.addColumn(COLFAM_TRACE, COLNAME_ID);
|
||||
scan.addFamily(HBaseTables.ROOT_TRACE_INDEX_CF_TRACE);
|
||||
scan.setId("rootTraceIndexScan");
|
||||
|
||||
// json으로 변화해서 로그를 찍어서. 최초 변환 속도가 느림.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.nhn.hippo.web.dao.hbase;
|
||||
|
||||
import com.nhn.hippo.web.dao.TraceIndexDao;
|
||||
import com.profiler.common.hbase.HBaseTables;
|
||||
import com.profiler.common.hbase.HbaseOperations2;
|
||||
import com.profiler.common.util.SpanUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.hbase.client.Scan;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.slf4j.Logger;
|
||||
@@ -13,8 +12,10 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.nhn.hippo.web.dao.TraceIndexDao;
|
||||
import com.profiler.common.hbase.HBaseTables;
|
||||
import com.profiler.common.hbase.HbaseOperations2;
|
||||
import com.profiler.common.util.SpanUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -24,15 +25,12 @@ public class HbaseTraceIndexDao implements TraceIndexDao {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final byte[] COLFAM_TRACE = Bytes.toBytes("Trace");
|
||||
private final byte[] COLNAME_ID = Bytes.toBytes("ID");
|
||||
|
||||
@Autowired
|
||||
private HbaseOperations2 hbaseOperations2;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("traceIndexMapper")
|
||||
private RowMapper<byte[]> traceIndexMapper;
|
||||
private RowMapper<List<byte[]>> traceIndexMapper;
|
||||
|
||||
private int scanCacheSize = 40;
|
||||
|
||||
@@ -41,13 +39,13 @@ public class HbaseTraceIndexDao implements TraceIndexDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> scanTraceIndex(String agent, long start, long end) {
|
||||
public List<List<byte[]>> scanTraceIndex(String agent, long start, long end) {
|
||||
Scan scan = createScan(agent, start, end);
|
||||
return hbaseOperations2.find(HBaseTables.TRACE_INDEX, scan, traceIndexMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<byte[]>> multiScanTraceIndex(String[] agents, long start, long end) {
|
||||
public List<List<List<byte[]>>> multiScanTraceIndex(String[] agents, long start, long end) {
|
||||
final List<Scan> multiScan = new ArrayList<Scan>(agents.length);
|
||||
for (String agent : agents) {
|
||||
Scan scan = createScan(agent, start, end);
|
||||
@@ -71,7 +69,7 @@ public class HbaseTraceIndexDao implements TraceIndexDao {
|
||||
|
||||
byte[] traceIndexEndKey = SpanUtils.getTraceIndexRowKey(bAgent, end);
|
||||
scan.setStopRow(traceIndexEndKey);
|
||||
scan.addColumn(COLFAM_TRACE, COLNAME_ID);
|
||||
scan.addFamily(HBaseTables.TRACE_INDEX_CF_TRACE);
|
||||
scan.setId("traceIndexScan");
|
||||
|
||||
// json으로 변화해서 로그를 찍어서. 최초 변환 속도가 느림.
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.*;
|
||||
@Component
|
||||
public class SpanMapper implements RowMapper<List<SpanBo>> {
|
||||
|
||||
private final byte[] COLFAM_SPAN = Bytes.toBytes("Span");
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private AnnotationMapper annotationMapper;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.nhn.hippo.web.mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.springframework.data.hadoop.hbase.RowMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -9,15 +13,21 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class TraceIndexMapper implements RowMapper<byte[]> {
|
||||
public class TraceIndexMapper implements RowMapper<List<byte[]>> {
|
||||
@Override
|
||||
public List<byte[]> mapRow(Result result, int rowNum) throws Exception {
|
||||
if (result == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private final byte[] COLFAM_TRACE = Bytes.toBytes("Trace");
|
||||
private final byte[] COLNAME_ID = Bytes.toBytes("ID");
|
||||
KeyValue[] raw = result.raw();
|
||||
|
||||
@Override
|
||||
public byte[] mapRow(Result result, int rowNum) throws Exception {
|
||||
List<byte[]> list = new ArrayList<byte[]>(raw.length);
|
||||
|
||||
// TODO null처리 해야 될듯.
|
||||
return result.getValue(COLFAM_TRACE, COLNAME_ID);
|
||||
}
|
||||
for (KeyValue kv : raw) {
|
||||
list.add(kv.getQualifier());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,21 +85,25 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("scan {}, {}, {}", new Object[] { agentIds[0], from, to });
|
||||
}
|
||||
List<byte[]> bytes = this.traceIndexDao.scanTraceIndex(agentIds[0], from, to);
|
||||
List<List<byte[]>> bytes = this.traceIndexDao.scanTraceIndex(agentIds[0], from, to);
|
||||
Set<TraceId> result = new HashSet<TraceId>();
|
||||
for (byte[] traceId : bytes) {
|
||||
TraceId tid = new TraceId(traceId);
|
||||
result.add(tid);
|
||||
logger.trace("traceid:{}", tid);
|
||||
for (List<byte[]> list : bytes) {
|
||||
for (byte[] traceId : list) {
|
||||
TraceId tid = new TraceId(traceId);
|
||||
result.add(tid);
|
||||
logger.trace("traceid:{}", tid);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
// multi scan 가능한 동일 open htable 에서 액세스함.
|
||||
List<List<byte[]>> multiScan = this.traceIndexDao.multiScanTraceIndex(agentIds, from, to);
|
||||
List<List<List<byte[]>>> multiScan = this.traceIndexDao.multiScanTraceIndex(agentIds, from, to);
|
||||
Set<TraceId> result = new HashSet<TraceId>();
|
||||
for (List<byte[]> scan : multiScan) {
|
||||
for (byte[] traceId : scan) {
|
||||
result.add(new TraceId(traceId));
|
||||
for (List<List<byte[]>> list : multiScan) {
|
||||
for (List<byte[]> scan : list) {
|
||||
for (byte[] traceId : scan) {
|
||||
result.add(new TraceId(traceId));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -299,12 +303,14 @@ public class FlowChartServiceImpl implements FlowChartService {
|
||||
logger.trace("scan {}, {}, {}", new Object[] { applicationName, from, to });
|
||||
}
|
||||
|
||||
List<byte[]> bytes = this.applicationTraceIndexDao.scanTraceIndex(applicationName, from, to);
|
||||
List<List<byte[]>> bytes = this.applicationTraceIndexDao.scanTraceIndex(applicationName, from, to);
|
||||
Set<TraceId> result = new HashSet<TraceId>();
|
||||
for (byte[] traceId : bytes) {
|
||||
TraceId tid = new TraceId(traceId);
|
||||
result.add(tid);
|
||||
logger.trace("traceid:{}", tid);
|
||||
for (List<byte[]> list : bytes) {
|
||||
for (byte[] traceId : list) {
|
||||
TraceId tid = new TraceId(traceId);
|
||||
result.add(tid);
|
||||
logger.trace("traceid:{}", tid);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user