1.修改参数文件名称,希望解决配置文件无法加载的问题(待验证)
2.修改大量类名、方法名,增加可读性 3.统计参数和节点类型增加“人为中断”,根据配置是否可忽略异常,确定节点统计类型。
This commit is contained in:
parent
361eee8f3f
commit
daf6eab08a
|
|
@ -1,9 +1,10 @@
|
|||
package com.ai.cloud.skywalking.analysis;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.Categorize2ChainMapper;
|
||||
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 java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.conf.Configured;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
|
@ -20,10 +21,11 @@ import org.apache.hadoop.util.ToolRunner;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.Categorize2ChainMapper;
|
||||
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;
|
||||
|
||||
public class AnalysisServerDriver extends Configured implements Tool {
|
||||
|
||||
|
|
@ -37,7 +39,7 @@ public class AnalysisServerDriver extends Configured implements Tool {
|
|||
|
||||
@Override
|
||||
public int run(String[] args) throws Exception {
|
||||
// ConfigInitializer.initialize();
|
||||
ConfigInitializer.initialize();
|
||||
Configuration conf = new Configuration();
|
||||
conf.set("hbase.zookeeper.quorum", Config.HBase.ZK_QUORUM);
|
||||
conf.set("hbase.zookeeper.property.clientPort", Config.HBase.ZK_CLIENT_PORT);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.hadoop.io.IntWritable;
|
||||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hadoop.mapreduce.Reducer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.util.HBaseUtil;
|
||||
|
||||
public class Categorize2ChainReducer extends Reducer<Text, ChainInfo, Text, IntWritable> {
|
||||
private static Logger logger = LoggerFactory.getLogger(Categorize2ChainReducer.class.getName());
|
||||
|
|
@ -24,12 +24,12 @@ public class Categorize2ChainReducer extends Reducer<Text, ChainInfo, Text, IntW
|
|||
public static int reduceAction(String key, Iterator<ChainInfo> chainInfoIterator) throws IOException, InterruptedException {
|
||||
int totalCount = 0;
|
||||
try {
|
||||
ChainRelate chainRelate = HBaseUtil.selectCallChainRelationship(key.toString());
|
||||
ChainRelationship chainRelate = HBaseUtil.selectCallChainRelationship(key.toString());
|
||||
Summary summary = new Summary();
|
||||
while (chainInfoIterator.hasNext()) {
|
||||
ChainInfo chainInfo = chainInfoIterator.next();
|
||||
try {
|
||||
chainRelate.addRelate(chainInfo);
|
||||
chainRelate.categoryChain(chainInfo);
|
||||
summary.summary(chainInfo);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.dao.CallChainInfoDao;
|
||||
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;
|
||||
|
|
@ -40,7 +39,7 @@ public class ChainDetail {
|
|||
entry.getValue().toString().getBytes());
|
||||
}
|
||||
if (isNormal) {
|
||||
CallChainInfoDao.saveChainDetail(this);
|
||||
DBCallChainInfoDao.saveChainDetail(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class ChainNodeSpecificTimeWindowSummary {
|
|||
|
||||
private String traceLevelId;
|
||||
|
||||
private Map<String, ChainNodeSpecificTimeWindowSummaryValue> summerResultMap;
|
||||
private Map<String, ChainNodeSpecificTimeWindowSummaryValue> summerValueMap;
|
||||
|
||||
public static ChainNodeSpecificTimeWindowSummary newInstance(String traceLevelId) {
|
||||
ChainNodeSpecificTimeWindowSummary cns = new ChainNodeSpecificTimeWindowSummary();
|
||||
|
|
@ -23,13 +23,13 @@ public class ChainNodeSpecificTimeWindowSummary {
|
|||
}
|
||||
|
||||
private ChainNodeSpecificTimeWindowSummary() {
|
||||
summerResultMap = new HashMap<String, ChainNodeSpecificTimeWindowSummaryValue>();
|
||||
summerValueMap = new HashMap<String, ChainNodeSpecificTimeWindowSummaryValue>();
|
||||
}
|
||||
|
||||
public ChainNodeSpecificTimeWindowSummary(String value) {
|
||||
JsonObject jsonObject = (JsonObject) new JsonParser().parse(value);
|
||||
traceLevelId = jsonObject.get("traceLevelId").getAsString();
|
||||
summerResultMap = new Gson().fromJson(jsonObject.get("summerResultMap").toString(),
|
||||
summerValueMap = new Gson().fromJson(jsonObject.get("summerValueMap").toString(),
|
||||
new TypeToken<Map<String, ChainNodeSpecificTimeWindowSummaryValue>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
|
@ -40,10 +40,10 @@ public class ChainNodeSpecificTimeWindowSummary {
|
|||
|
||||
public void summary(ChainNode node) {
|
||||
String key = generateKey(node.getStartDate());
|
||||
ChainNodeSpecificTimeWindowSummaryValue summaryResult = summerResultMap.get(key);
|
||||
ChainNodeSpecificTimeWindowSummaryValue summaryResult = summerValueMap.get(key);
|
||||
if (summaryResult == null) {
|
||||
summaryResult = new ChainNodeSpecificTimeWindowSummaryValue();
|
||||
summerResultMap.put(key, summaryResult);
|
||||
summerValueMap.put(key, summaryResult);
|
||||
}
|
||||
summaryResult.summary(node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@ public class ChainNodeSpecificTimeWindowSummaryValue {
|
|||
private long totalCall;
|
||||
private long totalCostTime;
|
||||
private long correctNumber;
|
||||
private long humanInterruptionNumber;
|
||||
|
||||
public ChainNodeSpecificTimeWindowSummaryValue() {
|
||||
totalCall = 0;
|
||||
totalCostTime = 0;
|
||||
correctNumber = 0;
|
||||
humanInterruptionNumber = 0;
|
||||
}
|
||||
|
||||
public long getTotalCall() {
|
||||
|
|
@ -32,6 +34,10 @@ public class ChainNodeSpecificTimeWindowSummaryValue {
|
|||
public long getCorrectNumber() {
|
||||
return correctNumber;
|
||||
}
|
||||
|
||||
public long getHumanInterruptionNumber() {
|
||||
return humanInterruptionNumber;
|
||||
}
|
||||
|
||||
public void setCorrectNumber(long correctNumber) {
|
||||
this.correctNumber = correctNumber;
|
||||
|
|
@ -42,6 +48,9 @@ public class ChainNodeSpecificTimeWindowSummaryValue {
|
|||
if (node.getStatus() == ChainNode.NodeStatus.NORMAL) {
|
||||
correctNumber++;
|
||||
}
|
||||
if (node.getStatus() == ChainNode.NodeStatus.HUMAN_INTERRUPTION) {
|
||||
humanInterruptionNumber++;
|
||||
}
|
||||
totalCostTime += node.getCost();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,21 +13,21 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
public class ChainRelate {
|
||||
private static Logger logger = LoggerFactory.getLogger(ChainRelate.class.getName());
|
||||
public class ChainRelationship {
|
||||
private static Logger logger = LoggerFactory.getLogger(ChainRelationship.class.getName());
|
||||
|
||||
private String key;
|
||||
private Map<String, CategorizedChainInfo> categorizedChainInfoMap = new HashMap<String, CategorizedChainInfo>();
|
||||
private Set<UncategorizeChainInfo> uncategorizeChainInfoList = new HashSet<UncategorizeChainInfo>();
|
||||
private Set<UncategorizeChainInfo> uncategorizeChainInfoSet = new HashSet<UncategorizeChainInfo>();
|
||||
private Map<String, ChainDetail> chainDetailMap = new HashMap<String, ChainDetail>();
|
||||
|
||||
public ChainRelate(String key) {
|
||||
public ChainRelationship(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
private void categoryAllUncategorizedChainInfo(CategorizedChainInfo parentChains) {
|
||||
if (uncategorizeChainInfoList != null && uncategorizeChainInfoList.size() > 0) {
|
||||
Iterator<UncategorizeChainInfo> uncategorizeChainInfoIterator = uncategorizeChainInfoList.iterator();
|
||||
if (uncategorizeChainInfoSet != null && uncategorizeChainInfoSet.size() > 0) {
|
||||
Iterator<UncategorizeChainInfo> uncategorizeChainInfoIterator = uncategorizeChainInfoSet.iterator();
|
||||
while (uncategorizeChainInfoIterator.hasNext()) {
|
||||
UncategorizeChainInfo uncategorizeChainInfo = uncategorizeChainInfoIterator.next();
|
||||
if (parentChains.isContained(uncategorizeChainInfo)) {
|
||||
|
|
@ -51,10 +51,10 @@ public class ChainRelate {
|
|||
}
|
||||
|
||||
if (!isContained) {
|
||||
if (!uncategorizeChainInfoList.contains(child)) {
|
||||
if (!uncategorizeChainInfoSet.contains(child)) {
|
||||
chainDetailMap.put(child.getCID(), new ChainDetail(child.getChainInfo(), false));
|
||||
uncategorizeChainInfoSet.add(child);
|
||||
}
|
||||
uncategorizeChainInfoList.add(child);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public class ChainRelate {
|
|||
return categorizedChainInfoMap.get(chainInfo.getCID());
|
||||
}
|
||||
|
||||
public void addRelate(ChainInfo chainInfo) {
|
||||
public void categoryChain(ChainInfo chainInfo) {
|
||||
if (chainInfo.getChainStatus() == ChainInfo.ChainStatus.NORMAL) {
|
||||
CategorizedChainInfo categorizedChainInfo = addCategorizedChain(chainInfo);
|
||||
categoryAllUncategorizedChainInfo(categorizedChainInfo);
|
||||
|
|
@ -80,7 +80,7 @@ public class ChainRelate {
|
|||
}
|
||||
|
||||
public void save() throws SQLException, IOException, InterruptedException {
|
||||
saveChainRelationShip();
|
||||
saveChainRelationship();
|
||||
saveChainDetail();
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ public class ChainRelate {
|
|||
}
|
||||
}
|
||||
|
||||
private void saveChainRelationShip() throws IOException {
|
||||
private void saveChainRelationship() throws IOException {
|
||||
Put put = new Put(getKey().getBytes());
|
||||
|
||||
put.addColumn(Config.HBase.CHAIN_RELATIONSHIP_COLUMN_FAMILY.getBytes(), Constants.UNCATEGORIZED_QUALIFIER_NAME.getBytes()
|
||||
|
|
@ -116,7 +116,7 @@ public class ChainRelate {
|
|||
}
|
||||
|
||||
try {
|
||||
HBaseUtil.saveChainRelate(put);
|
||||
HBaseUtil.saveChainRelationship(put);
|
||||
} catch (IOException e) {
|
||||
logger.error("Faild to save chain relationship to hbase.", e);
|
||||
throw e;
|
||||
|
|
@ -136,10 +136,10 @@ public class ChainRelate {
|
|||
}
|
||||
|
||||
public Set<UncategorizeChainInfo> getUncategorizeChainInfoList() {
|
||||
return uncategorizeChainInfoList;
|
||||
return uncategorizeChainInfoSet;
|
||||
}
|
||||
|
||||
public void addUncategorizeChain(List<UncategorizeChainInfo> uncategorizeChainInfos) {
|
||||
uncategorizeChainInfoList.addAll(uncategorizeChainInfos);
|
||||
uncategorizeChainInfoSet.addAll(uncategorizeChainInfos);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class DBCallChainInfoDao {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(DBCallChainInfoDao.class.getName());
|
||||
|
||||
private static Connection connection;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName(Config.MySql.DRIVER_CLASS);
|
||||
connection = DriverManager.getConnection(Config.MySql.URL,
|
||||
Config.MySql.USERNAME, Config.MySql.PASSWORD);
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Failed to find jdbc driver class["
|
||||
+ Config.MySql.DRIVER_CLASS + "]", e);
|
||||
System.exit(-1);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Failed to connection database.", e);
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void saveChainDetail(ChainDetail chainDetail)
|
||||
throws SQLException {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
preparedStatement = connection
|
||||
.prepareStatement("INSERT INTO sw_chain_detail(cid,uid,traceLevelId,viewpoint,create_time)"
|
||||
+ " VALUES(?,?,?,?,?)");
|
||||
for (ChainNode chainNode : chainDetail.getChainNodes()) {
|
||||
preparedStatement.setString(1, chainDetail.getChainToken());
|
||||
preparedStatement.setString(2, chainDetail.getUserId());
|
||||
preparedStatement.setString(3, chainNode.getTraceLevelId());
|
||||
preparedStatement.setString(4, chainNode.getViewPoint() + ":"
|
||||
+ chainNode.getBusinessKey());
|
||||
preparedStatement.setTimestamp(5,
|
||||
new Timestamp(System.currentTimeMillis()));
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
int[] result = preparedStatement.executeBatch();
|
||||
for (int i : result) {
|
||||
if (i != 1) {
|
||||
logger.error("Failed to save chain detail ["
|
||||
+ chainDetail.getChainToken() + "]");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (preparedStatement != null)
|
||||
preparedStatement.close();
|
||||
}
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
public synchronized static void updateChainDetail(Map<String, Timestamp> updateChainInfo)
|
||||
throws SQLException {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
preparedStatement = connection
|
||||
.prepareStatement("UPDATE sw_chain_detail SET update_time = ? WHERE cid = ?");
|
||||
for (Map.Entry<String, Timestamp> entry : updateChainInfo
|
||||
.entrySet()) {
|
||||
preparedStatement.setTimestamp(1, entry.getValue());
|
||||
preparedStatement.setString(2, entry.getKey());
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
int[] result = preparedStatement.executeBatch();
|
||||
for (int i : result) {
|
||||
if (i != 1) {
|
||||
logger.error("Failed to update chain detail");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (preparedStatement != null)
|
||||
preparedStatement.close();
|
||||
}
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
|
@ -93,13 +93,21 @@ public class SpanEntry {
|
|||
public ChainNode.NodeStatus getSpanStatus() {
|
||||
if (clientSpan != null) {
|
||||
if (clientSpan.getExceptionStack() != null && clientSpan.getExceptionStack().length() > 0) {
|
||||
return ChainNode.NodeStatus.ABNORMAL;
|
||||
if(clientSpan.getStatusCode() == 1){
|
||||
return ChainNode.NodeStatus.ABNORMAL;
|
||||
}else{
|
||||
return ChainNode.NodeStatus.HUMAN_INTERRUPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (serverSpan != null) {
|
||||
if (serverSpan.getExceptionStack() != null && serverSpan.getExceptionStack().length() > 0) {
|
||||
return ChainNode.NodeStatus.ABNORMAL;
|
||||
if(clientSpan.getStatusCode() == 1){
|
||||
return ChainNode.NodeStatus.ABNORMAL;
|
||||
}else{
|
||||
return ChainNode.NodeStatus.HUMAN_INTERRUPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.dao.CallChainInfoDao;
|
||||
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;
|
||||
|
|
@ -49,7 +48,7 @@ public class Summary {
|
|||
}
|
||||
|
||||
private void batchUpdateChainDetail() throws SQLException {
|
||||
CallChainInfoDao.updateChainDetail(updateChainInfo);
|
||||
DBCallChainInfoDao.updateChainDetail(updateChainInfo);
|
||||
}
|
||||
|
||||
private void batchSaveChainSpecificTimeWindowSummary() throws IOException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
package com.ai.cloud.skywalking.analysis.categorize2chain.dao;
|
||||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.ChainDetail;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainNode;
|
||||
import com.ai.cloud.skywalking.analysis.config.Config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class CallChainInfoDao {
|
||||
private static Logger logger = LoggerFactory.getLogger(CallChainInfoDao.class.getName());
|
||||
|
||||
private static Connection connection;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName(Config.MySql.DRIVER_CLASS);
|
||||
connection = DriverManager.getConnection(Config.MySql.URL, Config.MySql.USERNAME, Config.MySql.PASSWORD);
|
||||
} catch (ClassNotFoundException e) {
|
||||
logger.error("Failed to find jdbc driver class[" + Config.MySql.DRIVER_CLASS + "]", e);
|
||||
System.exit(-1);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Failed to connection database.", e);
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void saveChainDetail(ChainDetail chainDetail) throws SQLException {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO sw_chain_detail(cid,uid,traceLevelId,viewpoint,create_time)" +
|
||||
" VALUES(?,?,?,?,?)");
|
||||
for (ChainNode chainNode : chainDetail.getChainNodes()) {
|
||||
preparedStatement.setString(1, chainDetail.getChainToken());
|
||||
preparedStatement.setString(2, chainDetail.getUserId());
|
||||
preparedStatement.setString(3, chainNode.getTraceLevelId());
|
||||
preparedStatement.setString(4, chainNode.getViewPoint() + ":" + chainNode.getBusinessKey());
|
||||
preparedStatement.setTimestamp(5, new Timestamp(System.currentTimeMillis()));
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
int[] result = preparedStatement.executeBatch();
|
||||
for (int i : result) {
|
||||
if (i != 1) {
|
||||
logger.error("Failed to save chain detail [" + chainDetail.getChainToken() + "]");
|
||||
}
|
||||
}
|
||||
preparedStatement.close();
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
public static void updateChainDetail(Map<String, Timestamp> updateChainInfo) throws SQLException {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE sw_chain_detail SET update_time = ? WHERE cid = ?");
|
||||
for (Map.Entry<String, Timestamp> entry : updateChainInfo.entrySet()) {
|
||||
preparedStatement.setTimestamp(1, entry.getValue());
|
||||
preparedStatement.setString(2, entry.getKey());
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
int[] result = preparedStatement.executeBatch();
|
||||
for (int i : result) {
|
||||
if (i != 1) {
|
||||
logger.error("Failed to update chain detail");
|
||||
}
|
||||
}
|
||||
preparedStatement.close();
|
||||
connection.commit();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,125 +14,129 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class ChainInfo implements Writable {
|
||||
private String cid;
|
||||
private ChainStatus chainStatus = ChainStatus.NORMAL;
|
||||
private List<ChainNode> nodes;
|
||||
private String userId = null;
|
||||
private ChainNode firstChainNode;
|
||||
private long startDate;
|
||||
private String cid;
|
||||
private ChainStatus chainStatus = ChainStatus.NORMAL;
|
||||
private List<ChainNode> nodes;
|
||||
private String userId = null;
|
||||
private ChainNode firstChainNode;
|
||||
private long startDate;
|
||||
|
||||
public ChainInfo(String userId) {
|
||||
super();
|
||||
this.userId = userId;
|
||||
}
|
||||
public ChainInfo(String userId) {
|
||||
super();
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public ChainInfo() {
|
||||
this.nodes = new ArrayList<ChainNode>();
|
||||
}
|
||||
public ChainInfo() {
|
||||
this.nodes = new ArrayList<ChainNode>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutput out) throws IOException {
|
||||
out.write(new Gson().toJson(this).getBytes());
|
||||
}
|
||||
@Override
|
||||
public void write(DataOutput out) throws IOException {
|
||||
out.write(new Gson().toJson(this).getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFields(DataInput in) throws IOException {
|
||||
JsonObject jsonObject = (JsonObject) new JsonParser().parse(in.readLine());
|
||||
cid = jsonObject.get("cid").getAsString();
|
||||
chainStatus = ChainStatus.convert(jsonObject.get("chainStatus").getAsCharacter());
|
||||
nodes = new Gson().fromJson(jsonObject.get("nodes"),
|
||||
new TypeToken<List<ChainNode>>() {
|
||||
}.getType());
|
||||
userId = jsonObject.get("userId").getAsString();
|
||||
}
|
||||
@Override
|
||||
public void readFields(DataInput in) throws IOException {
|
||||
JsonObject jsonObject = (JsonObject) new JsonParser().parse(in
|
||||
.readLine());
|
||||
cid = jsonObject.get("cid").getAsString();
|
||||
chainStatus = ChainStatus.convert(jsonObject.get("chainStatus")
|
||||
.getAsCharacter());
|
||||
nodes = new Gson().fromJson(jsonObject.get("nodes"),
|
||||
new TypeToken<List<ChainNode>>() {
|
||||
}.getType());
|
||||
userId = jsonObject.get("userId").getAsString();
|
||||
}
|
||||
|
||||
public String getCID() {
|
||||
return cid;
|
||||
}
|
||||
public String getCID() {
|
||||
return cid;
|
||||
}
|
||||
|
||||
public String getEntranceNodeToken() {
|
||||
if (firstChainNode == null) {
|
||||
return "";
|
||||
} else {
|
||||
return firstChainNode.getNodeToken();
|
||||
}
|
||||
}
|
||||
public String getEntranceNodeToken() {
|
||||
if (firstChainNode == null) {
|
||||
return "";
|
||||
} else {
|
||||
return firstChainNode.getNodeToken();
|
||||
}
|
||||
}
|
||||
|
||||
public void generateChainToken() {
|
||||
StringBuilder chainTokenDesc = new StringBuilder();
|
||||
for (ChainNode node : nodes) {
|
||||
chainTokenDesc.append(node.getParentLevelId() + "." + node.getLevelId() + "-" + node.getNodeToken() + ";");
|
||||
}
|
||||
this.cid = TokenGenerator.generateCID(chainTokenDesc.toString());
|
||||
}
|
||||
public void generateChainToken() {
|
||||
StringBuilder chainTokenDesc = new StringBuilder();
|
||||
for (ChainNode node : nodes) {
|
||||
chainTokenDesc.append(node.getParentLevelId() + "."
|
||||
+ node.getLevelId() + "-" + node.getNodeToken() + ";");
|
||||
}
|
||||
this.cid = TokenGenerator.generateCID(chainTokenDesc.toString());
|
||||
}
|
||||
|
||||
public ChainStatus getChainStatus() {
|
||||
return chainStatus;
|
||||
}
|
||||
public ChainStatus getChainStatus() {
|
||||
return chainStatus;
|
||||
}
|
||||
|
||||
public void setChainStatus(ChainStatus chainStatus) {
|
||||
this.chainStatus = chainStatus;
|
||||
}
|
||||
public void setChainStatus(ChainStatus chainStatus) {
|
||||
this.chainStatus = chainStatus;
|
||||
}
|
||||
|
||||
public void addNodes(ChainNode chainNode) {
|
||||
this.nodes.add(0, chainNode);
|
||||
if (chainNode.getStatus() == ChainNode.NodeStatus.ABNORMAL) {
|
||||
chainStatus = ChainStatus.ABNORMAL;
|
||||
}
|
||||
if (userId == null) {
|
||||
userId = chainNode.getUserId();
|
||||
}
|
||||
if ((chainNode.getParentLevelId() == null || chainNode.getParentLevelId().length() == 0)
|
||||
&& chainNode.getLevelId() == 0) {
|
||||
firstChainNode = chainNode;
|
||||
startDate = chainNode.getStartDate();
|
||||
}
|
||||
}
|
||||
public void addNodes(ChainNode chainNode) {
|
||||
this.nodes.add(0, chainNode);
|
||||
if (chainNode.getStatus() == ChainNode.NodeStatus.ABNORMAL
|
||||
|| chainNode.getStatus() == ChainNode.NodeStatus.HUMAN_INTERRUPTION) {
|
||||
chainStatus = ChainStatus.ABNORMAL;
|
||||
}
|
||||
if (userId == null) {
|
||||
userId = chainNode.getUserId();
|
||||
}
|
||||
if ((chainNode.getParentLevelId() == null || chainNode
|
||||
.getParentLevelId().length() == 0)
|
||||
&& chainNode.getLevelId() == 0) {
|
||||
firstChainNode = chainNode;
|
||||
startDate = chainNode.getStartDate();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChainNode> getNodes() {
|
||||
return nodes;
|
||||
}
|
||||
public List<ChainNode> getNodes() {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public enum ChainStatus {
|
||||
NORMAL('N'), ABNORMAL('A');
|
||||
private char value;
|
||||
public enum ChainStatus {
|
||||
NORMAL('N'), ABNORMAL('A');
|
||||
private char value;
|
||||
|
||||
ChainStatus(char value) {
|
||||
this.value = value;
|
||||
}
|
||||
ChainStatus(char value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ChainStatus convert(char value) {
|
||||
switch (value) {
|
||||
case 'N':
|
||||
return NORMAL;
|
||||
case 'A':
|
||||
return ABNORMAL;
|
||||
default:
|
||||
throw new IllegalStateException("Failed to convert[" + value + "]");
|
||||
}
|
||||
}
|
||||
public static ChainStatus convert(char value) {
|
||||
switch (value) {
|
||||
case 'N':
|
||||
return NORMAL;
|
||||
case 'A':
|
||||
return ABNORMAL;
|
||||
default:
|
||||
throw new IllegalStateException("Failed to convert[" + value
|
||||
+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value + "";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return value + "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setCID(String cid) {
|
||||
this.cid = cid;
|
||||
}
|
||||
public void setCID(String cid) {
|
||||
this.cid = cid;
|
||||
}
|
||||
|
||||
public long getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
public long getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class ChainNode {
|
|||
}
|
||||
|
||||
public enum NodeStatus {
|
||||
NORMAL('N'), ABNORMAL('A');
|
||||
NORMAL('N'), ABNORMAL('A'), HUMAN_INTERRUPTION('I');
|
||||
private char value;
|
||||
|
||||
NodeStatus(char value) {
|
||||
|
|
@ -125,6 +125,8 @@ public class ChainNode {
|
|||
return NORMAL;
|
||||
case 'A':
|
||||
return ABNORMAL;
|
||||
case 'I':
|
||||
return HUMAN_INTERRUPTION;
|
||||
default:
|
||||
throw new IllegalStateException("Failed to convert[" + value + "]");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class ConfigInitializer {
|
|||
|
||||
public static void initialize() {
|
||||
InputStream inputStream = Thread.currentThread()
|
||||
.getContextClassLoader().getResourceAsStream("/config.properties");
|
||||
.getContextClassLoader().getResourceAsStream("/analysis.conf");
|
||||
//InputStream inputStream = ConfigInitializer.class.getResourceAsStream("/config.properties");
|
||||
if (inputStream == null) {
|
||||
logger.log(Level.ALL, "No provider sky-walking certification documents, sky-walking api auto shutdown.");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ai.cloud.skywalking.analysis.util;
|
|||
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.CategorizedChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.ChainNodeSpecificTimeWindowSummary;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.ChainRelate;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.ChainRelationship;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.ChainSpecificTimeWindowSummary;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.UncategorizeChainInfo;
|
||||
import com.ai.cloud.skywalking.analysis.categorize2chain.model.ChainInfo;
|
||||
|
|
@ -95,8 +95,8 @@ public class HBaseUtil {
|
|||
}
|
||||
|
||||
|
||||
public static ChainRelate selectCallChainRelationship(String key) throws IOException {
|
||||
ChainRelate chainRelate = new ChainRelate(key);
|
||||
public static ChainRelationship selectCallChainRelationship(String key) throws IOException {
|
||||
ChainRelationship chainRelate = new ChainRelationship(key);
|
||||
Table table = connection.getTable(TableName.valueOf(Config.HBase.TABLE_CALL_CHAIN_RELATIONSHIP));
|
||||
Get g = new Get(Bytes.toBytes(key));
|
||||
Result r = table.get(g);
|
||||
|
|
@ -140,7 +140,7 @@ public class HBaseUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void saveChainRelate(Put put) throws IOException {
|
||||
public static void saveChainRelationship(Put put) throws IOException {
|
||||
Table table = connection.getTable(TableName.valueOf(Config.HBase.TABLE_CALL_CHAIN_RELATIONSHIP));
|
||||
|
||||
table.put(put);
|
||||
|
|
|
|||
Loading…
Reference in New Issue