|
@@ -14,6 +14,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.core.TimeValue;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* A based request for master based operation.
|
|
@@ -22,10 +23,18 @@ public abstract class MasterNodeRequest<Request extends MasterNodeRequest<Reques
|
|
|
|
|
|
public static final TimeValue DEFAULT_MASTER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30);
|
|
|
|
|
|
- protected TimeValue masterNodeTimeout = DEFAULT_MASTER_NODE_TIMEOUT;
|
|
|
+ private TimeValue masterNodeTimeout = DEFAULT_MASTER_NODE_TIMEOUT;
|
|
|
|
|
|
protected MasterNodeRequest() {}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param masterNodeTimeout Specifies how long to wait when the master has not been discovered yet, or is disconnected, or is busy
|
|
|
+ * processing other tasks. The value {@link TimeValue#MINUS_ONE} means to wait forever.
|
|
|
+ */
|
|
|
+ protected MasterNodeRequest(TimeValue masterNodeTimeout) {
|
|
|
+ this.masterNodeTimeout = Objects.requireNonNull(masterNodeTimeout);
|
|
|
+ }
|
|
|
+
|
|
|
protected MasterNodeRequest(StreamInput in) throws IOException {
|
|
|
super(in);
|
|
|
masterNodeTimeout = in.readTimeValue();
|
|
@@ -44,7 +53,7 @@ public abstract class MasterNodeRequest<Request extends MasterNodeRequest<Reques
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public final Request masterNodeTimeout(TimeValue timeout) {
|
|
|
- this.masterNodeTimeout = timeout;
|
|
|
+ this.masterNodeTimeout = Objects.requireNonNull(timeout);
|
|
|
return (Request) this;
|
|
|
}
|
|
|
|