Message.java
2.38 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.dianping.cat.message;
/**
* <p>
* Message represents data collected during application runtime. It will be sent to back-end system asynchronous for
* further processing.
* </p>
*
* <p>
* Super interface of <code>Event</code>, <code>Heartbeat</code> and <code>Transaction</code>.
* </p>
*
* @see Event, Heartbeat, Transaction
* @author Frankie Wu
*/
public interface Message {
public static final String SUCCESS = "0";
/**
* add one or multiple key-value pairs to the message.
*
* @param keyValuePairs
* key-value pairs like 'a=1&b=2&...'
*/
public void addData(String keyValuePairs);
/**
* add one key-value pair to the message.
*
* @param key
* @param value
*/
public void addData(String key, Object value);
/**
* Complete the message construction.
*/
public void complete();
/**
* @return key value pairs data
*/
public Object getData();
/**
* Message name.
*
* @return message name
*/
public String getName();
/**
* Get the message status.
*
* @return message status. "0" means success, otherwise error code.
*/
public String getStatus();
/**
* The time stamp the message was created.
*
* @return message creation time stamp in milliseconds
*/
public long getTimestamp();
/**
* Message type.
*
* <p>
* Typical message types are:
* <ul>
* <li>URL: maps to one method of an action</li>
* <li>Service: maps to one method of service call</li>
* <li>Search: maps to one method of search call</li>
* <li>SQL: maps to one SQL statement</li>
* <li>Cache: maps to one cache access</li>
* <li>Error: maps to java.lang.Throwable (java.lang.Exception and java.lang.Error)</li>
* </ul>
* </p>
*
* @return message type
*/
public String getType();
/**
* If the complete() method was called or not.
*
* @return true means the complete() method was called, false otherwise.
*/
public boolean isCompleted();
/**
* @return
*/
public boolean isSuccess();
/**
* Set the message status.
*
* @param status
* message status. "0" means success, otherwise error code.
*/
public void setStatus(String status);
/**
* Set the message status with exception class name.
*
* @param e
* exception.
*/
public void setStatus(Throwable e);
}