7
7
8
8
import org .elasticsearch .common .io .stream .StreamInput ;
9
9
import org .elasticsearch .common .io .stream .StreamOutput ;
10
- import org .elasticsearch .common .io .stream .Streamable ;
10
+ import org .elasticsearch .common .io .stream .Writeable ;
11
11
import org .elasticsearch .common .xcontent .ToXContentObject ;
12
12
import org .elasticsearch .common .xcontent .XContentBuilder ;
13
13
import org .elasticsearch .xpack .core .watcher .actions .ActionWrapperResult ;
18
18
import java .time .ZonedDateTime ;
19
19
import java .util .Map ;
20
20
21
- public class WatchExecutionSnapshot implements Streamable , ToXContentObject {
21
+ public class WatchExecutionSnapshot implements Writeable , ToXContentObject {
22
22
23
- private String watchId ;
24
- private String watchRecordId ;
25
- private ZonedDateTime triggeredTime ;
26
- private ZonedDateTime executionTime ;
27
- private ExecutionPhase phase ;
23
+ private final String watchId ;
24
+ private final String watchRecordId ;
25
+ private final ZonedDateTime triggeredTime ;
26
+ private final ZonedDateTime executionTime ;
27
+ private final ExecutionPhase phase ;
28
+ private final StackTraceElement [] executionStackTrace ;
28
29
private String [] executedActions ;
29
- private StackTraceElement [] executionStackTrace ;
30
-
31
- public WatchExecutionSnapshot () {
32
- }
33
30
34
31
public WatchExecutionSnapshot (WatchExecutionContext context , StackTraceElement [] executionStackTrace ) {
35
32
watchId = context .id ().watchId ();
@@ -48,6 +45,23 @@ public WatchExecutionSnapshot(WatchExecutionContext context, StackTraceElement[]
48
45
this .executionStackTrace = executionStackTrace ;
49
46
}
50
47
48
+ public WatchExecutionSnapshot (StreamInput in ) throws IOException {
49
+ watchId = in .readString ();
50
+ watchRecordId = in .readString ();
51
+ triggeredTime = Instant .ofEpochMilli (in .readVLong ()).atZone (ZoneOffset .UTC );
52
+ executionTime = Instant .ofEpochMilli (in .readVLong ()).atZone (ZoneOffset .UTC );
53
+ phase = ExecutionPhase .resolve (in .readString ());
54
+ int size = in .readVInt ();
55
+ executionStackTrace = new StackTraceElement [size ];
56
+ for (int i = 0 ; i < size ; i ++) {
57
+ String declaringClass = in .readString ();
58
+ String methodName = in .readString ();
59
+ String fileName = in .readOptionalString ();
60
+ int lineNumber = in .readInt ();
61
+ executionStackTrace [i ] = new StackTraceElement (declaringClass , methodName , fileName , lineNumber );
62
+ }
63
+ }
64
+
51
65
public String watchId () {
52
66
return watchId ;
53
67
}
@@ -72,24 +86,6 @@ public StackTraceElement[] executionStackTrace() {
72
86
return executionStackTrace ;
73
87
}
74
88
75
- @ Override
76
- public void readFrom (StreamInput in ) throws IOException {
77
- watchId = in .readString ();
78
- watchRecordId = in .readString ();
79
- triggeredTime = Instant .ofEpochMilli (in .readVLong ()).atZone (ZoneOffset .UTC );
80
- executionTime = Instant .ofEpochMilli (in .readVLong ()).atZone (ZoneOffset .UTC );
81
- phase = ExecutionPhase .resolve (in .readString ());
82
- int size = in .readVInt ();
83
- executionStackTrace = new StackTraceElement [size ];
84
- for (int i = 0 ; i < size ; i ++) {
85
- String declaringClass = in .readString ();
86
- String methodName = in .readString ();
87
- String fileName = in .readOptionalString ();
88
- int lineNumber = in .readInt ();
89
- executionStackTrace [i ] = new StackTraceElement (declaringClass , methodName , fileName , lineNumber );
90
- }
91
- }
92
-
93
89
@ Override
94
90
public void writeTo (StreamOutput out ) throws IOException {
95
91
out .writeString (watchId );
0 commit comments