Skip to content

Commit 1be3dd5

Browse files
authored
HLRC: create base timed request class (#33216)
There are many requests that allow the user to set a few timeouts on. This class will allow requests impl'd in HLRC to extend from, and allow users to set those values without significant work to add them to every request.
1 parent 1cbde72 commit 1be3dd5

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.client;
20+
21+
import org.elasticsearch.common.unit.TimeValue;
22+
23+
/**
24+
* A base request for any requests that supply timeouts.
25+
*
26+
* Please note, any requests that use a ackTimeout should set timeout as they
27+
* represent the same backing field on the server.
28+
*/
29+
public class TimedRequest implements Validatable {
30+
31+
private TimeValue timeout;
32+
private TimeValue masterTimeout;
33+
34+
public void setTimeout(TimeValue timeout) {
35+
this.timeout = timeout;
36+
37+
}
38+
39+
public void setMasterTimeout(TimeValue masterTimeout) {
40+
this.masterTimeout = masterTimeout;
41+
}
42+
43+
/**
44+
* Returns the request timeout
45+
*/
46+
public TimeValue timeout() {
47+
return timeout;
48+
}
49+
50+
/**
51+
* Returns the timeout for the request to be completed on the master node
52+
*/
53+
public TimeValue masterNodeTimeout() {
54+
return masterTimeout;
55+
}
56+
}

0 commit comments

Comments
 (0)