1.重构并重命名Constants,修改部分类名,修改包的部分结构。提高代码的可读性。
This commit is contained in:
parent
121ea2f039
commit
40d514ed1c
|
|
@ -38,7 +38,7 @@ public class AlarmProcessServer {
|
|||
processThreads.add(tmpThread);
|
||||
}
|
||||
logger.info("Successfully launched {} processing threads.", Config.Server.PROCESS_THREAD_SIZE);
|
||||
new NumberOfUsersChangeDetectionThread().start();
|
||||
new UsersChangedDetectionThread().start();
|
||||
logger.info("Successfully launched the thread that inspect the number of user");
|
||||
logger.info("Alarm process server successfully started.");
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ import org.apache.logging.log4j.Logger;
|
|||
import java.sql.SQLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class NumberOfUsersChangeDetectionThread extends Thread {
|
||||
public class UsersChangedDetectionThread extends Thread {
|
||||
|
||||
private boolean isInspector = false;
|
||||
private InterProcessMutex inspectorLock = new InterProcessMutex(ZKUtil.getZkClient(),
|
||||
Config.ZKPath.INSPECTOR_LOCK_PATH);
|
||||
private String userIdsEncryptedStr;
|
||||
private Logger logger = LogManager.getLogger(NumberOfUsersChangeDetectionThread.class);
|
||||
private Logger logger = LogManager.getLogger(UsersChangedDetectionThread.class);
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
|
|
@ -5,7 +5,7 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.config.Constants;
|
||||
import com.ai.cloud.skywalking.analysis.config.HBaseTableMetaData;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.conf.Configured;
|
||||
import org.apache.hadoop.hbase.client.Scan;
|
||||
|
|
@ -51,7 +51,7 @@ public class AnalysisServerDriver extends Configured implements Tool {
|
|||
job.setJarByClass(AnalysisServerDriver.class);
|
||||
Scan scan = buildHBaseScan(args);
|
||||
|
||||
TableMapReduceUtil.initTableMapperJob(Constants.TABLE_CALL_CHAIN, scan, Categorize2ChainMapper.class,
|
||||
TableMapReduceUtil.initTableMapperJob(HBaseTableMetaData.TABLE_CALL_CHAIN.TABLE_NAME, scan, Categorize2ChainMapper.class,
|
||||
Text.class, ChainInfo.class, job);
|
||||
|
||||
job.setReducerClass(Categorize2ChainReducer.class);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@ import com.ai.cloud.skywalking.analysis.categorize2chain.filter.SpanNodeProcessC
|
|||
import com.ai.cloud.skywalking.analysis.categorize2chain.filter.SpanNodeProcessFilter;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.analysis.config.ConfigInitializer;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.protocol.Span;
|
||||
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
||||
|
|
@ -63,7 +64,7 @@ public class Categorize2ChainMapper extends TableMapper<Text, ChainInfo> {
|
|||
}
|
||||
|
||||
chainInfo.generateChainToken();
|
||||
HBaseUtil.saveData(key, chainInfo);
|
||||
HBaseUtil.saveCidTidMapping(key, chainInfo);
|
||||
return chainInfo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.util.Iterator;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.config.ConfigInitializer;
|
||||
|
||||
import org.apache.hadoop.io.IntWritable;
|
||||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hadoop.mapreduce.Reducer;
|
||||
|
|
@ -11,7 +12,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.HBaseUtil;
|
||||
|
||||
public class Categorize2ChainReducer extends Reducer<Text, ChainInfo, Text, IntWritable> {
|
||||
private static Logger logger = LoggerFactory.getLogger(Categorize2ChainReducer.class.getName());
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.ai.cloud.skywalking.analysis.categorize2chain;
|
|||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
import com.ai.cloud.skywalking.analysis.config.Constants;
|
||||
import com.ai.cloud.skywalking.analysis.config.HBaseTableMetaData;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
|
|
@ -36,7 +36,7 @@ public class ChainDetail {
|
|||
|
||||
public void save(Put put) throws SQLException {
|
||||
for (Map.Entry<String, ChainNode> entry : chainNodeMap.entrySet()){
|
||||
put.addColumn(Constants.COLUMN_FAMILY_NAME_TRACE_DETAIL.getBytes(),entry.getKey().getBytes(),
|
||||
put.addColumn(HBaseTableMetaData.TABLE_CHAIN_DETAIL.COLUMN_FAMILY_NAME.getBytes(),entry.getKey().getBytes(),
|
||||
entry.getValue().toString().getBytes());
|
||||
}
|
||||
if (isNormal) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChainNodeSpecificTimeWindowSummary {
|
||||
public static final long INTERVAL = 1L;
|
||||
|
||||
private String traceLevelId;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ public class ChainNodeSpecificTimeWindowSummary {
|
|||
|
||||
private String generateKey(long startTime) {
|
||||
long minutes = (startTime % (1000 * 60 * 60)) / (1000 * 60);
|
||||
return String.valueOf(minutes / Config.ChainNodeSummary.INTERVAL);
|
||||
return String.valueOf(minutes / INTERVAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
import com.ai.cloud.skywalking.analysis.config.Constants;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
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.hadoop.hbase.client.Put;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.analysis.config.HBaseTableMetaData;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
public class ChainRelationship {
|
||||
private static Logger logger = LoggerFactory.getLogger(ChainRelationship.class.getName());
|
||||
|
|
@ -107,11 +113,11 @@ public class ChainRelationship {
|
|||
private void saveChainRelationship() throws IOException {
|
||||
Put put = new Put(getKey().getBytes());
|
||||
|
||||
put.addColumn(Constants.COLUMN_FAMILY_CHAIN_RELATIONSHIP.getBytes(), Constants.UNCATEGORIZE_COLUMN_FAMILY.getBytes()
|
||||
put.addColumn(HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.COLUMN_FAMILY_NAME.getBytes(), HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.UNCATEGORIZE_COLUMN_NAME.getBytes()
|
||||
, new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(getUncategorizeChainInfoList()).getBytes());
|
||||
|
||||
for (Map.Entry<String, CategorizedChainInfo> entry : getCategorizedChainInfoMap().entrySet()) {
|
||||
put.addColumn(Constants.COLUMN_FAMILY_CHAIN_RELATIONSHIP.getBytes(), entry.getKey().getBytes()
|
||||
put.addColumn(HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.COLUMN_FAMILY_NAME.getBytes(), entry.getKey().getBytes()
|
||||
, entry.getValue().toString().getBytes());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
import com.ai.cloud.skywalking.analysis.config.Constants;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.analysis.config.HBaseTableMetaData;
|
||||
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ public class ChainSpecificTimeWindowSummary {
|
|||
|
||||
public void save(Put put) {
|
||||
for (Map.Entry<String, ChainNodeSpecificTimeWindowSummary> entry : chainNodeSummaryResultMap.entrySet()) {
|
||||
put.addColumn(Constants.COLUMN_FAMILY_NAME_CHAIN_SUMMARY.getBytes(), entry.getKey().getBytes(), entry.getValue().toString().getBytes());
|
||||
put.addColumn(HBaseTableMetaData.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP.COLUMN_FAMILY_NAME.getBytes(), entry.getKey().getBytes(), entry.getValue().toString().getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ai.cloud.skywalking.analysis.categorize2chain;
|
|||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.HBaseUtil;
|
||||
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.ai.cloud.skywalking.analysis.categorize2chain.SubLevelSpanCostCounter
|
|||
import com.ai.cloud.skywalking.analysis.categorize2chain.SpanEntry;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.filter.SpanNodeProcessFilter;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.util.TokenGenerator;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.TokenGenerator;
|
||||
|
||||
public class TokenGenerateFilter extends SpanNodeProcessFilter {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain.model;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.util.TokenGenerator;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.util.TokenGenerator;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.apache.hadoop.io.Writable;
|
||||
|
||||
import java.io.DataInput;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.ai.cloud.skywalking.analysis.util;
|
||||
package com.ai.cloud.skywalking.analysis.categorize2chain.util;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.*;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
import com.ai.cloud.skywalking.analysis.config.Constants;
|
||||
import com.ai.cloud.skywalking.analysis.config.HBaseTableMetaData;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
|
@ -22,44 +22,17 @@ public class HBaseUtil {
|
|||
private static Configuration configuration = null;
|
||||
private static Connection connection;
|
||||
|
||||
public static boolean saveData(String traceId, ChainInfo chainInfo) {
|
||||
Table table = null;
|
||||
|
||||
try {
|
||||
table = connection.getTable(TableName.valueOf(Constants.TABLE_CID_TID_MAPPING));
|
||||
} catch (IOException e) {
|
||||
logger.error("Cannot found table[" + Constants.TABLE_CID_TID_MAPPING + "]", e);
|
||||
}
|
||||
|
||||
Put put = new Put(Bytes.toBytes(traceId));
|
||||
|
||||
put.addColumn(Bytes.toBytes(Constants.COLUMN_FAMILY_NAME_TRACE_INFO),
|
||||
Bytes.toBytes(Constants.COLUMN_FAMILY_NAME_CID),
|
||||
Bytes.toBytes(chainInfo.getCID()));
|
||||
try {
|
||||
table.put(put);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Insert data[RowKey:{}] success.", put.getId());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("Insert data [Rowkey:{}] failed.", put.getId(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
initHBaseClient();
|
||||
//
|
||||
createTableIfNeed(Constants.TABLE_CID_TID_MAPPING, Constants.COLUMN_FAMILY_NAME_TRACE_INFO);
|
||||
//
|
||||
createTableIfNeed(Constants.TABLE_CALL_CHAIN_RELATIONSHIP, Constants.COLUMN_FAMILY_CHAIN_RELATIONSHIP);
|
||||
|
||||
createTableIfNeed(Constants.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP, Constants.COLUMN_FAMILY_NAME_CHAIN_SUMMARY);
|
||||
createTableIfNeed(HBaseTableMetaData.TABLE_CID_TID_MAPPING.TABLE_NAME, HBaseTableMetaData.TABLE_CID_TID_MAPPING.COLUMN_FAMILY_NAME);
|
||||
|
||||
createTableIfNeed(Constants.TABLE_CHAIN_DETAIL, Constants.COLUMN_FAMILY_NAME_TRACE_DETAIL);
|
||||
createTableIfNeed(HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.TABLE_NAME, HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.COLUMN_FAMILY_NAME);
|
||||
|
||||
createTableIfNeed(HBaseTableMetaData.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP.TABLE_NAME, HBaseTableMetaData.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP.COLUMN_FAMILY_NAME);
|
||||
|
||||
createTableIfNeed(HBaseTableMetaData.TABLE_CHAIN_DETAIL.TABLE_NAME, HBaseTableMetaData.TABLE_CHAIN_DETAIL.COLUMN_FAMILY_NAME);
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error("Create tables failed", e);
|
||||
|
|
@ -88,11 +61,38 @@ public class HBaseUtil {
|
|||
connection = ConnectionFactory.createConnection(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean saveCidTidMapping(String traceId, ChainInfo chainInfo) {
|
||||
Table table = null;
|
||||
|
||||
try {
|
||||
table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CID_TID_MAPPING.TABLE_NAME));
|
||||
} catch (IOException e) {
|
||||
logger.error("Cannot found table[" + HBaseTableMetaData.TABLE_CID_TID_MAPPING.TABLE_NAME + "]", e);
|
||||
}
|
||||
|
||||
Put put = new Put(Bytes.toBytes(traceId));
|
||||
|
||||
put.addColumn(Bytes.toBytes(HBaseTableMetaData.TABLE_CID_TID_MAPPING.COLUMN_FAMILY_NAME),
|
||||
Bytes.toBytes(HBaseTableMetaData.TABLE_CID_TID_MAPPING.CID_COLUMN_NAME),
|
||||
Bytes.toBytes(chainInfo.getCID()));
|
||||
try {
|
||||
table.put(put);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Insert data[RowKey:{}] success.", put.getId());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("Insert data [Rowkey:{}] failed.", put.getId(), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static ChainRelationship selectCallChainRelationship(String key) throws IOException {
|
||||
ChainRelationship chainRelate = new ChainRelationship(key);
|
||||
Table table = connection.getTable(TableName.valueOf(Constants.TABLE_CALL_CHAIN_RELATIONSHIP));
|
||||
Table table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.TABLE_NAME));
|
||||
Get g = new Get(Bytes.toBytes(key));
|
||||
Result r = table.get(g);
|
||||
for (Cell cell : r.rawCells()) {
|
||||
|
|
@ -100,7 +100,7 @@ public class HBaseUtil {
|
|||
|
||||
String qualifierName = Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
|
||||
cell.getQualifierLength());
|
||||
if (Constants.UNCATEGORIZE_COLUMN_FAMILY.equals(qualifierName)) {
|
||||
if (HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.UNCATEGORIZE_COLUMN_NAME.equals(qualifierName)) {
|
||||
List<UncategorizeChainInfo> uncategorizeChainInfoList = new Gson().fromJson(Bytes.toString(cell.getValueArray(),
|
||||
cell.getValueOffset(), cell.getValueLength()),
|
||||
new TypeToken<List<UncategorizeChainInfo>>() {
|
||||
|
|
@ -118,7 +118,7 @@ public class HBaseUtil {
|
|||
|
||||
public static ChainSpecificTimeWindowSummary selectChainSummaryResult(String key) throws IOException {
|
||||
ChainSpecificTimeWindowSummary result = null;
|
||||
Table table = connection.getTable(TableName.valueOf(Constants.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP));
|
||||
Table table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP.TABLE_NAME));
|
||||
Get g = new Get(Bytes.toBytes(key));
|
||||
Result r = table.get(g);
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ public class HBaseUtil {
|
|||
}
|
||||
|
||||
public static void saveChainRelationship(Put put) throws IOException {
|
||||
Table table = connection.getTable(TableName.valueOf(Constants.TABLE_CALL_CHAIN_RELATIONSHIP));
|
||||
Table table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CALL_CHAIN_RELATIONSHIP.TABLE_NAME));
|
||||
|
||||
table.put(put);
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
@ -145,7 +145,7 @@ public class HBaseUtil {
|
|||
}
|
||||
|
||||
public static void batchSaveChainSpecificTimeWindowSummary(List<Put> puts) throws IOException, InterruptedException {
|
||||
Table table = connection.getTable(TableName.valueOf(Constants.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP));
|
||||
Table table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP.TABLE_NAME));
|
||||
Object[] resultArrays = new Object[puts.size()];
|
||||
table.batch(puts, resultArrays);
|
||||
for (Object result : resultArrays) {
|
||||
|
|
@ -156,7 +156,7 @@ public class HBaseUtil {
|
|||
}
|
||||
|
||||
public static void saveChainDetails(List<Put> puts) throws IOException, InterruptedException {
|
||||
Table table = connection.getTable(TableName.valueOf(Constants.TABLE_CHAIN_DETAIL));
|
||||
Table table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CHAIN_DETAIL.TABLE_NAME));
|
||||
if (puts != null && puts.size() > 0) {
|
||||
Object[] resultArrays = new Object[puts.size()];
|
||||
table.batch(puts, resultArrays);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ai.cloud.skywalking.analysis.util;
|
||||
package com.ai.cloud.skywalking.analysis.categorize2chain.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -25,8 +25,4 @@ public class Config {
|
|||
public static class Filter {
|
||||
public static String FILTER_PACKAGE_NAME;
|
||||
}
|
||||
|
||||
public static class ChainNodeSummary {
|
||||
public static long INTERVAL = 1L;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
package com.ai.cloud.skywalking.analysis.config;
|
||||
|
||||
public class Constants {
|
||||
public static final String UNCATEGORIZE_COLUMN_FAMILY = "UNCATEGORIZED_CALL_CHAIN";
|
||||
|
||||
// HBase 表:用于存放CID,TID的映射关系表
|
||||
public static String TABLE_CID_TID_MAPPING = "sw-cid-tid-mapping";
|
||||
|
||||
//HBase 表:用于存放调用链一分钟的汇总,汇总结果不包含关系汇总
|
||||
public static String TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP = "sw-chain-1min-summary-ex-rela";
|
||||
|
||||
public static String TABLE_CHAIN_DETAIL = "sw-chain-detail";
|
||||
|
||||
public static String TABLE_CALL_CHAIN = "sw-call-chain";
|
||||
|
||||
public static String TABLE_CALL_CHAIN_RELATIONSHIP = "sw-chain-relationship";
|
||||
|
||||
public static String COLUMN_FAMILY_CHAIN_RELATIONSHIP = "chain-relationship";
|
||||
|
||||
public static String COLUMN_FAMILY_NAME_TRACE_DETAIL = "chain_detail";
|
||||
|
||||
public static String COLUMN_FAMILY_NAME_CHAIN_SUMMARY = "chain_summary";
|
||||
|
||||
public static String COLUMN_FAMILY_NAME_TRACE_INFO = "trace_info";
|
||||
|
||||
public static String COLUMN_FAMILY_NAME_CID = "cid";
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.ai.cloud.skywalking.analysis.config;
|
||||
|
||||
public class HBaseTableMetaData {
|
||||
/**
|
||||
* 调用链明细表,前端收集程序入库数据
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public final static class TABLE_CALL_CHAIN {
|
||||
public static final String TABLE_NAME = "sw-call-chain";
|
||||
}
|
||||
|
||||
/**
|
||||
* HBase 表:用于存放CID,TID的映射关系表
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public final static class TABLE_CID_TID_MAPPING {
|
||||
public static final String TABLE_NAME = "sw-cid-tid-mapping";
|
||||
|
||||
public static final String COLUMN_FAMILY_NAME = "trace_info";
|
||||
|
||||
public static final String CID_COLUMN_NAME = "cid";
|
||||
}
|
||||
|
||||
/**
|
||||
* CID明细信息表
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public final static class TABLE_CHAIN_DETAIL {
|
||||
public static final String TABLE_NAME = "sw-chain-detail";
|
||||
|
||||
public static final String COLUMN_FAMILY_NAME = "chain_detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* CID间关系表,记录异常CID和正常CID间的归属关系
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public final static class TABLE_CALL_CHAIN_RELATIONSHIP {
|
||||
public static final String TABLE_NAME = "sw-chain-relationship";
|
||||
|
||||
public static final String COLUMN_FAMILY_NAME = "chain-relationship";
|
||||
|
||||
public static final String UNCATEGORIZE_COLUMN_NAME = "UNCATEGORIZED_CALL_CHAIN";
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于存放每个CID在一分钟内的汇总,汇总结果不包含关系汇总
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public final static class TABLE_CHAIN_ONE_MINUTE_SUMMARY_EXCLUDE_RELATIONSHIP{
|
||||
public static final String TABLE_NAME = "sw-chain-1min-summary-ex-rela";
|
||||
|
||||
public static final String COLUMN_FAMILY_NAME = "chain_summary";
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import com.ai.cloud.skywalking.analysis.categorize2chain.Categorize2ChainReducer
|
|||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
import com.ai.cloud.skywalking.analysis.config.ConfigInitializer;
|
||||
import com.ai.cloud.skywalking.analysis.config.Constants;
|
||||
import com.ai.cloud.skywalking.analysis.config.HBaseTableMetaData;
|
||||
import com.ai.cloud.skywalking.protocol.Span;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
|
@ -49,7 +49,7 @@ public class CallChainMapperTest {
|
|||
|
||||
public static List<Span> selectByTraceId(String traceId) throws IOException {
|
||||
List<Span> entries = new ArrayList<Span>();
|
||||
Table table = connection.getTable(TableName.valueOf(Constants.TABLE_CALL_CHAIN));
|
||||
Table table = connection.getTable(TableName.valueOf(HBaseTableMetaData.TABLE_CALL_CHAIN.TABLE_NAME));
|
||||
Get g = new Get(Bytes.toBytes(traceId));
|
||||
Result r = table.get(g);
|
||||
for (Cell cell : r.rawCells()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue