Skip to content

Commit 5a11e23

Browse files
committed
Merge branch '6.x' into ccr-6.x
2 parents 5432cae + 1690178 commit 5a11e23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+343
-235
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/indices.flush/10_basic.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,34 @@
2121
indices.stats: {level: shards}
2222

2323
- is_true: indices.testing.shards.0.0.commit.user_data.sync_id
24+
25+
---
26+
"Flush stats":
27+
- skip:
28+
version: " - 6.2.99"
29+
reason: periodic flush stats is introduced in 6.3.0
30+
- do:
31+
indices.create:
32+
index: test
33+
body:
34+
settings:
35+
number_of_shards: 1
36+
index.translog.flush_threshold_size: 160b
37+
- do:
38+
indices.flush:
39+
index: test
40+
- do:
41+
indices.stats: { index: test }
42+
- match: { indices.test.primaries.flush.periodic: 0 }
43+
- match: { indices.test.primaries.flush.total: 1 }
44+
- do:
45+
index:
46+
index: test
47+
type: doc
48+
id: 1
49+
body: { "message": "a long message to make a periodic flush happen after this index operation" }
50+
- do:
51+
indices.stats: { index: test }
52+
# periodic flush is async
53+
- gte: { indices.test.primaries.flush.periodic: 0 }
54+
- gte: { indices.test.primaries.flush.total: 1 }

rest-api-spec/src/main/resources/rest-api-spec/test/scroll/12_slices.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ setup:
3737

3838
---
3939
"Sliced scroll":
40-
- skip:
41-
version: " - 6.2.99"
42-
reason: Slicing on _uid was deprecated in 6.3.0
43-
4440
- do:
4541
search:
4642
index: test_sliced_scroll

server/cli/src/main/java/org/elasticsearch/cli/Terminal.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ public String readText(String text) {
163163
getWriter().print(text);
164164
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
165165
try {
166-
return reader.readLine();
166+
final String line = reader.readLine();
167+
if (line == null) {
168+
throw new IllegalStateException("unable to read from standard input; is standard input open and a tty attached?");
169+
}
170+
return line;
167171
} catch (IOException ioe) {
168172
throw new RuntimeException(ioe);
169173
}

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public void readFrom(StreamInput in) throws IOException {
201201
indices[i] = in.readString();
202202
}
203203
}
204-
timeout = new TimeValue(in);
204+
timeout = in.readTimeValue();
205205
if (in.readBoolean()) {
206206
waitForStatus = ClusterHealthStatus.fromValue(in.readByte());
207207
}
@@ -227,7 +227,7 @@ public void writeTo(StreamOutput out) throws IOException {
227227
out.writeString(index);
228228
}
229229
}
230-
timeout.writeTo(out);
230+
out.writeTimeValue(timeout);
231231
if (waitForStatus == null) {
232232
out.writeBoolean(false);
233233
} else {

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void readFrom(StreamInput in) throws IOException {
184184
timedOut = in.readBoolean();
185185
numberOfInFlightFetch = in.readInt();
186186
delayedUnassignedShards= in.readInt();
187-
taskMaxWaitingTime = new TimeValue(in);
187+
taskMaxWaitingTime = in.readTimeValue();
188188
}
189189

190190
@Override
@@ -197,7 +197,7 @@ public void writeTo(StreamOutput out) throws IOException {
197197
out.writeBoolean(timedOut);
198198
out.writeInt(numberOfInFlightFetch);
199199
out.writeInt(delayedUnassignedShards);
200-
taskMaxWaitingTime.writeTo(out);
200+
out.writeTimeValue(taskMaxWaitingTime);
201201
}
202202

203203
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void readFrom(StreamInput in) throws IOException {
9999
threads = in.readInt();
100100
ignoreIdleThreads = in.readBoolean();
101101
type = in.readString();
102-
interval = new TimeValue(in);
102+
interval = in.readTimeValue();
103103
snapshots = in.readInt();
104104
}
105105

@@ -109,7 +109,7 @@ public void writeTo(StreamOutput out) throws IOException {
109109
out.writeInt(threads);
110110
out.writeBoolean(ignoreIdleThreads);
111111
out.writeString(type);
112-
interval.writeTo(out);
112+
out.writeTimeValue(interval);
113113
out.writeInt(snapshots);
114114
}
115115
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/get/GetTaskRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public ActionRequestValidationException validate() {
105105
public void readFrom(StreamInput in) throws IOException {
106106
super.readFrom(in);
107107
taskId = TaskId.readFromStream(in);
108-
timeout = in.readOptionalWriteable(TimeValue::new);
108+
timeout = in.readOptionalTimeValue();
109109
waitForCompletion = in.readBoolean();
110110
}
111111

112112
@Override
113113
public void writeTo(StreamOutput out) throws IOException {
114114
super.writeTo(out);
115115
taskId.writeTo(out);
116-
out.writeOptionalWriteable(timeout);
116+
out.writeOptionalTimeValue(timeout);
117117
out.writeBoolean(waitForCompletion);
118118
}
119119
}

server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ public void readFrom(StreamInput in) throws IOException {
593593
requests.add(DocWriteRequest.readDocumentRequest(in));
594594
}
595595
refreshPolicy = RefreshPolicy.readFrom(in);
596-
timeout = new TimeValue(in);
596+
timeout = in.readTimeValue();
597597
}
598598

599599
@Override
@@ -605,7 +605,7 @@ public void writeTo(StreamOutput out) throws IOException {
605605
DocWriteRequest.writeDocumentRequest(out, request);
606606
}
607607
refreshPolicy.writeTo(out);
608-
timeout.writeTo(out);
608+
out.writeTimeValue(timeout);
609609
}
610610

611611
@Override

server/src/main/java/org/elasticsearch/action/index/IndexRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public void readFrom(StreamInput in) throws IOException {
532532
parent = in.readOptionalString();
533533
if (in.getVersion().before(Version.V_6_0_0_alpha1)) {
534534
in.readOptionalString(); // timestamp
535-
in.readOptionalWriteable(TimeValue::new); // ttl
535+
in.readOptionalTimeValue(); // ttl
536536
}
537537
source = in.readBytesReference();
538538
opType = OpType.fromId(in.readByte());

server/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ public TimeValue ackTimeout() {
7878
@Override
7979
public void readFrom(StreamInput in) throws IOException {
8080
super.readFrom(in);
81-
timeout = new TimeValue(in);
81+
timeout = in.readTimeValue();
8282
}
8383

8484
@Override
8585
public void writeTo(StreamOutput out) throws IOException {
8686
super.writeTo(out);
87-
timeout.writeTo(out);
87+
out.writeTimeValue(timeout);
8888
}
8989
}

server/src/main/java/org/elasticsearch/action/support/master/MasterNodeRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ public final TimeValue masterNodeTimeout() {
6161
@Override
6262
public void readFrom(StreamInput in) throws IOException {
6363
super.readFrom(in);
64-
masterNodeTimeout = new TimeValue(in);
64+
masterNodeTimeout = in.readTimeValue();
6565
}
6666

6767
@Override
6868
public void writeTo(StreamOutput out) throws IOException {
6969
super.writeTo(out);
70-
masterNodeTimeout.writeTo(out);
70+
out.writeTimeValue(masterNodeTimeout);
7171
}
7272
}

server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ public void readFrom(StreamInput in) throws IOException {
107107
super.readFrom(in);
108108
nodesIds = in.readStringArray();
109109
concreteNodes = in.readOptionalArray(DiscoveryNode::new, DiscoveryNode[]::new);
110-
timeout = in.readOptionalWriteable(TimeValue::new);
110+
timeout = in.readOptionalTimeValue();
111111
}
112112

113113
@Override
114114
public void writeTo(StreamOutput out) throws IOException {
115115
super.writeTo(out);
116116
out.writeStringArrayNullable(nodesIds);
117117
out.writeOptionalArray(concreteNodes);
118-
out.writeOptionalWriteable(timeout);
118+
out.writeOptionalTimeValue(timeout);
119119
}
120120
}

server/src/main/java/org/elasticsearch/action/support/replication/ReplicationRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void readFrom(StreamInput in) throws IOException {
187187
shardId = null;
188188
}
189189
waitForActiveShards = ActiveShardCount.readFrom(in);
190-
timeout = new TimeValue(in);
190+
timeout = in.readTimeValue();
191191
index = in.readString();
192192
routedBasedOnClusterVersion = in.readVLong();
193193
}
@@ -202,7 +202,7 @@ public void writeTo(StreamOutput out) throws IOException {
202202
out.writeBoolean(false);
203203
}
204204
waitForActiveShards.writeTo(out);
205-
timeout.writeTo(out);
205+
out.writeTimeValue(timeout);
206206
out.writeString(index);
207207
out.writeVLong(routedBasedOnClusterVersion);
208208
}

server/src/main/java/org/elasticsearch/action/support/single/instance/InstanceShardOperationRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void readFrom(StreamInput in) throws IOException {
118118
} else {
119119
shardId = null;
120120
}
121-
timeout = new TimeValue(in);
121+
timeout = in.readTimeValue();
122122
concreteIndex = in.readOptionalString();
123123
}
124124

@@ -127,7 +127,7 @@ public void writeTo(StreamOutput out) throws IOException {
127127
super.writeTo(out);
128128
out.writeString(index);
129129
out.writeOptionalStreamable(shardId);
130-
timeout.writeTo(out);
130+
out.writeTimeValue(timeout);
131131
out.writeOptionalString(concreteIndex);
132132
}
133133

server/src/main/java/org/elasticsearch/action/support/tasks/BaseTasksRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void readFrom(StreamInput in) throws IOException {
144144
parentTaskId = TaskId.readFromStream(in);
145145
nodes = in.readStringArray();
146146
actions = in.readStringArray();
147-
timeout = in.readOptionalWriteable(TimeValue::new);
147+
timeout = in.readOptionalTimeValue();
148148
}
149149

150150
@Override
@@ -154,7 +154,7 @@ public void writeTo(StreamOutput out) throws IOException {
154154
parentTaskId.writeTo(out);
155155
out.writeStringArrayNullable(nodes);
156156
out.writeStringArrayNullable(actions);
157-
out.writeOptionalWriteable(timeout);
157+
out.writeOptionalTimeValue(timeout);
158158
}
159159

160160
public boolean match(Task task) {

server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public DiskThresholdMonitor(Settings settings, Supplier<ClusterState> clusterSta
6666
private void warnAboutDiskIfNeeded(DiskUsage usage) {
6767
// Check absolute disk values
6868
if (usage.getFreeBytes() < diskThresholdSettings.getFreeBytesThresholdFloodStage().getBytes()) {
69-
logger.warn("flood stage disk watermark [{}] exceeded on {}, all indices on this node will marked read-only",
69+
logger.warn("flood stage disk watermark [{}] exceeded on {}, all indices on this node will be marked read-only",
7070
diskThresholdSettings.getFreeBytesThresholdFloodStage(), usage);
7171
} else if (usage.getFreeBytes() < diskThresholdSettings.getFreeBytesThresholdHigh().getBytes()) {
7272
logger.warn("high disk watermark [{}] exceeded on {}, shards will be relocated away from this node",
@@ -78,7 +78,7 @@ private void warnAboutDiskIfNeeded(DiskUsage usage) {
7878

7979
// Check percentage disk values
8080
if (usage.getFreeDiskAsPercentage() < diskThresholdSettings.getFreeDiskThresholdFloodStage()) {
81-
logger.warn("flood stage disk watermark [{}] exceeded on {}, all indices on this node will marked read-only",
81+
logger.warn("flood stage disk watermark [{}] exceeded on {}, all indices on this node will be marked read-only",
8282
Strings.format1Decimals(100.0 - diskThresholdSettings.getFreeDiskThresholdFloodStage(), "%"), usage);
8383
} else if (usage.getFreeDiskAsPercentage() < diskThresholdSettings.getFreeDiskThresholdHigh()) {
8484
logger.warn("high disk watermark [{}] exceeded on {}, shards will be relocated away from this node",

server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.elasticsearch.common.bytes.BytesReference;
3737
import org.elasticsearch.common.geo.GeoPoint;
3838
import org.elasticsearch.common.text.Text;
39+
import org.elasticsearch.common.unit.TimeValue;
3940
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
4041
import org.joda.time.DateTime;
4142
import org.joda.time.DateTimeZone;
@@ -65,6 +66,7 @@
6566
import java.util.List;
6667
import java.util.Locale;
6768
import java.util.Map;
69+
import java.util.concurrent.TimeUnit;
6870
import java.util.function.IntFunction;
6971
import java.util.function.Supplier;
7072

@@ -82,6 +84,26 @@
8284
* on {@link StreamInput}.
8385
*/
8486
public abstract class StreamInput extends InputStream {
87+
88+
private static final Map<Byte, TimeUnit> BYTE_TIME_UNIT_MAP;
89+
90+
static {
91+
final Map<Byte, TimeUnit> byteTimeUnitMap = new HashMap<>();
92+
byteTimeUnitMap.put((byte)0, TimeUnit.NANOSECONDS);
93+
byteTimeUnitMap.put((byte)1, TimeUnit.MICROSECONDS);
94+
byteTimeUnitMap.put((byte)2, TimeUnit.MILLISECONDS);
95+
byteTimeUnitMap.put((byte)3, TimeUnit.SECONDS);
96+
byteTimeUnitMap.put((byte)4, TimeUnit.MINUTES);
97+
byteTimeUnitMap.put((byte)5, TimeUnit.HOURS);
98+
byteTimeUnitMap.put((byte)6, TimeUnit.DAYS);
99+
100+
for (TimeUnit value : TimeUnit.values()) {
101+
assert byteTimeUnitMap.containsValue(value) : value;
102+
}
103+
104+
BYTE_TIME_UNIT_MAP = Collections.unmodifiableMap(byteTimeUnitMap);
105+
}
106+
85107
private Version version = Version.CURRENT;
86108

87109
/**
@@ -976,4 +998,24 @@ private int readArraySize() throws IOException {
976998
* be a no-op depending on the underlying implementation if the information of the remaining bytes is not present.
977999
*/
9781000
protected abstract void ensureCanReadBytes(int length) throws EOFException;
1001+
1002+
/**
1003+
* Read a {@link TimeValue} from the stream
1004+
*/
1005+
public TimeValue readTimeValue() throws IOException {
1006+
long duration = readZLong();
1007+
TimeUnit timeUnit = BYTE_TIME_UNIT_MAP.get(readByte());
1008+
return new TimeValue(duration, timeUnit);
1009+
}
1010+
1011+
/**
1012+
* Read an optional {@link TimeValue} from the stream, returning null if no TimeValue was written.
1013+
*/
1014+
public @Nullable TimeValue readOptionalTimeValue() throws IOException {
1015+
if (readBoolean()) {
1016+
return readTimeValue();
1017+
} else {
1018+
return null;
1019+
}
1020+
}
9791021
}

0 commit comments

Comments
 (0)