19
19
20
20
package org .elasticsearch .index .refresh ;
21
21
22
+ import org .elasticsearch .Version ;
22
23
import org .elasticsearch .common .io .stream .StreamInput ;
23
24
import org .elasticsearch .common .io .stream .StreamOutput ;
24
25
import org .elasticsearch .common .io .stream .Streamable ;
@@ -36,6 +37,10 @@ public class RefreshStats implements Streamable, Writeable, ToXContentFragment {
36
37
37
38
private long totalTimeInMillis ;
38
39
40
+ private long externalTotal ;
41
+
42
+ private long externalTotalTimeInMillis ;
43
+
39
44
/**
40
45
* Number of waiting refresh listeners.
41
46
*/
@@ -47,12 +52,29 @@ public RefreshStats() {
47
52
public RefreshStats (StreamInput in ) throws IOException {
48
53
total = in .readVLong ();
49
54
totalTimeInMillis = in .readVLong ();
55
+ if (in .getVersion ().onOrAfter (Version .V_7_1_0 )) {
56
+ externalTotal = in .readVLong ();
57
+ externalTotalTimeInMillis = in .readVLong ();
58
+ }
50
59
listeners = in .readVInt ();
51
60
}
52
61
53
- public RefreshStats (long total , long totalTimeInMillis , int listeners ) {
62
+ @ Override
63
+ public void writeTo (StreamOutput out ) throws IOException {
64
+ out .writeVLong (total );
65
+ out .writeVLong (totalTimeInMillis );
66
+ if (out .getVersion ().onOrAfter (Version .V_7_1_0 )) {
67
+ out .writeVLong (externalTotal );
68
+ out .writeVLong (externalTotalTimeInMillis );
69
+ }
70
+ out .writeVInt (listeners );
71
+ }
72
+
73
+ public RefreshStats (long total , long totalTimeInMillis , long externalTotal , long externalTotalTimeInMillis , int listeners ) {
54
74
this .total = total ;
55
75
this .totalTimeInMillis = totalTimeInMillis ;
76
+ this .externalTotal = externalTotal ;
77
+ this .externalTotalTimeInMillis = externalTotalTimeInMillis ;
56
78
this .listeners = listeners ;
57
79
}
58
80
@@ -66,6 +88,8 @@ public void addTotals(RefreshStats refreshStats) {
66
88
}
67
89
this .total += refreshStats .total ;
68
90
this .totalTimeInMillis += refreshStats .totalTimeInMillis ;
91
+ this .externalTotal += refreshStats .externalTotal ;
92
+ this .externalTotalTimeInMillis += refreshStats .externalTotalTimeInMillis ;
69
93
this .listeners += refreshStats .listeners ;
70
94
}
71
95
@@ -76,20 +100,38 @@ public long getTotal() {
76
100
return this .total ;
77
101
}
78
102
103
+ /*
104
+ * The total number of external refresh executed.
105
+ */
106
+ public long getExternalTotal () { return this .externalTotal ; }
107
+
79
108
/**
80
- * The total time merges have been executed (in milliseconds).
109
+ * The total time spent executing refreshes (in milliseconds).
81
110
*/
82
111
public long getTotalTimeInMillis () {
83
112
return this .totalTimeInMillis ;
84
113
}
85
114
86
115
/**
87
- * The total time merges have been executed.
116
+ * The total time spent executing external refreshes (in milliseconds).
117
+ */
118
+ public long getExternalTotalTimeInMillis () {
119
+ return this .externalTotalTimeInMillis ;
120
+ }
121
+
122
+ /**
123
+ * The total time refreshes have been executed.
88
124
*/
89
125
public TimeValue getTotalTime () {
90
126
return new TimeValue (totalTimeInMillis );
91
127
}
92
128
129
+ /**
130
+ * The total time external refreshes have been executed.
131
+ */
132
+ public TimeValue getExternalTotalTime () {
133
+ return new TimeValue (externalTotalTimeInMillis );
134
+ }
93
135
/**
94
136
* The number of waiting refresh listeners.
95
137
*/
@@ -102,6 +144,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
102
144
builder .startObject ("refresh" );
103
145
builder .field ("total" , total );
104
146
builder .humanReadableField ("total_time_in_millis" , "total_time" , getTotalTime ());
147
+ builder .field ("external_total" , externalTotal );
148
+ builder .humanReadableField ("external_total_time_in_millis" , "external_total_time" , getExternalTotalTime ());
105
149
builder .field ("listeners" , listeners );
106
150
builder .endObject ();
107
151
return builder ;
@@ -112,13 +156,6 @@ public void readFrom(StreamInput in) throws IOException {
112
156
throw new UnsupportedOperationException ("usage of Streamable is to be replaced by Writeable" );
113
157
}
114
158
115
- @ Override
116
- public void writeTo (StreamOutput out ) throws IOException {
117
- out .writeVLong (total );
118
- out .writeVLong (totalTimeInMillis );
119
- out .writeVInt (listeners );
120
- }
121
-
122
159
@ Override
123
160
public boolean equals (Object obj ) {
124
161
if (obj == null || obj .getClass () != RefreshStats .class ) {
@@ -127,11 +164,13 @@ public boolean equals(Object obj) {
127
164
RefreshStats rhs = (RefreshStats ) obj ;
128
165
return total == rhs .total
129
166
&& totalTimeInMillis == rhs .totalTimeInMillis
167
+ && externalTotal == rhs .externalTotal
168
+ && externalTotalTimeInMillis == rhs .externalTotalTimeInMillis
130
169
&& listeners == rhs .listeners ;
131
170
}
132
171
133
172
@ Override
134
173
public int hashCode () {
135
- return Objects .hash (total , totalTimeInMillis , listeners );
174
+ return Objects .hash (total , totalTimeInMillis , externalTotal , externalTotalTimeInMillis , listeners );
136
175
}
137
176
}
0 commit comments