DatabaseAccessEvent.java
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.yoho.error.event;
/**
* 数据库操作的事件
* Created by chunhua.zhang@yoho.cn on 2016/2/19.
*/
public class DatabaseAccessEvent extends CommonEvent {
/**
* @Fields serialVersionUID
*/
private static final long serialVersionUID = -2863457811659066198L;
private final Throwable throwable;
private final long cost;
private final String datasource;
private final String statement;
//服务的名称
private String serviceName= "UNKNOWN";
//最原始的服务名称,来自gateway
private String srcServiceName = "UNKNOWN";
/**
* Create a new ApplicationEvent.
*
* @param name : dao name : 例如: com.yoho.IProductDAO
* @param statement: 接口名称,例如 getAll
* @param throwable: 数据库操作的异常, 可能为null
* @param cost: 数据库操作的延迟
* @param datasource: 数据库名称
*
*/
public DatabaseAccessEvent(String name, String statement, Throwable throwable, long cost, String datasource) {
super(name);
this.statement = statement;
this.throwable = throwable;
this.cost = cost;
this.datasource = datasource;
}
/**
* 兼容之前的方法。
* @return args
*/
@Deprecated
public String getArgs(){
return this.datasource;
}
public Throwable getThrowable() {
return throwable;
}
public long getCost() {
return cost;
}
public String getDatasource() {
return datasource;
}
public String getStatement() {
return statement;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getSrcServiceName() {
return srcServiceName;
}
public void setSrcServiceName(String srcServiceName) {
this.srcServiceName = srcServiceName;
}
}