HLRC XPack Protocol clean up: Migration; Graph; Watcher (#34639)
Move parts related to XPack for packages Migration; Graph; Watcher from protocol to client Drop protocol module Relates #34451
This commit is contained in:
parent
8d7889d20c
commit
69fe9a1bf1
|
@ -51,7 +51,6 @@ dependencies {
|
||||||
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
|
compile "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}"
|
||||||
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
|
compile "org.elasticsearch.plugin:rank-eval-client:${version}"
|
||||||
compile "org.elasticsearch.plugin:lang-mustache-client:${version}"
|
compile "org.elasticsearch.plugin:lang-mustache-client:${version}"
|
||||||
bundle project(':x-pack:protocol')
|
|
||||||
|
|
||||||
testCompile "org.elasticsearch.client:test:${version}"
|
testCompile "org.elasticsearch.client:test:${version}"
|
||||||
testCompile "org.elasticsearch.test:framework:${version}"
|
testCompile "org.elasticsearch.test:framework:${version}"
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
package org.elasticsearch.client;
|
package org.elasticsearch.client;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
|
import org.elasticsearch.client.graph.GraphExploreRequest;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse;
|
import org.elasticsearch.client.graph.GraphExploreResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.elasticsearch.client;
|
package org.elasticsearch.client;
|
||||||
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
|
import org.elasticsearch.client.graph.GraphExploreRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
package org.elasticsearch.client;
|
package org.elasticsearch.client;
|
||||||
|
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.elasticsearch.client;
|
package org.elasticsearch.client;
|
||||||
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
|
||||||
|
|
||||||
final class MigrationRequestConverters {
|
final class MigrationRequestConverters {
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ final class MigrationRequestConverters {
|
||||||
|
|
||||||
static Request getMigrationAssistance(IndexUpgradeInfoRequest indexUpgradeInfoRequest) {
|
static Request getMigrationAssistance(IndexUpgradeInfoRequest indexUpgradeInfoRequest) {
|
||||||
RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
|
RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack/migration/assistance")
|
.addPathPartAsIs("_xpack", "migration", "assistance")
|
||||||
.addCommaSeparatedPathParts(indexUpgradeInfoRequest.indices());
|
.addCommaSeparatedPathParts(indexUpgradeInfoRequest.indices());
|
||||||
String endpoint = endpointBuilder.build();
|
String endpoint = endpointBuilder.build();
|
||||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||||
|
|
|
@ -28,10 +28,10 @@ import org.elasticsearch.client.watcher.AckWatchRequest;
|
||||||
import org.elasticsearch.client.watcher.AckWatchResponse;
|
import org.elasticsearch.client.watcher.AckWatchResponse;
|
||||||
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
||||||
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
|
import org.elasticsearch.client.watcher.DeleteWatchResponse;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
|
import org.elasticsearch.client.watcher.PutWatchResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ import org.elasticsearch.client.watcher.AckWatchRequest;
|
||||||
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
||||||
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||||
|
|
||||||
final class WatcherRequestConverters {
|
final class WatcherRequestConverters {
|
||||||
|
|
||||||
|
@ -59,9 +59,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request putWatch(PutWatchRequest putWatchRequest) {
|
static Request putWatch(PutWatchRequest putWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_xpack", "watcher", "watch")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("watch")
|
|
||||||
.addPathPart(putWatchRequest.getId())
|
.addPathPart(putWatchRequest.getId())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -89,9 +87,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
|
static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_xpack", "watcher", "watch")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("watch")
|
|
||||||
.addPathPart(deleteWatchRequest.getId())
|
.addPathPart(deleteWatchRequest.getId())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -101,9 +97,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
public static Request ackWatch(AckWatchRequest ackWatchRequest) {
|
public static Request ackWatch(AckWatchRequest ackWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_xpack", "watcher", "watch")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("watch")
|
|
||||||
.addPathPart(ackWatchRequest.getWatchId())
|
.addPathPart(ackWatchRequest.getWatchId())
|
||||||
.addPathPartAsIs("_ack")
|
.addPathPartAsIs("_ack")
|
||||||
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
|
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
|
||||||
|
@ -114,9 +108,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
|
static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_xpack", "watcher", "watch")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("watch")
|
|
||||||
.addPathPart(activateWatchRequest.getWatchId())
|
.addPathPart(activateWatchRequest.getWatchId())
|
||||||
.addPathPartAsIs("_activate")
|
.addPathPartAsIs("_activate")
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -16,22 +16,19 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.ObjectIntHashMap;
|
import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||||
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent.Params;
|
import org.elasticsearch.common.xcontent.ToXContent.Params;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Vertex.VertexId;
|
import org.elasticsearch.client.graph.Vertex.VertexId;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||||
|
@ -55,25 +52,9 @@ public class Connection {
|
||||||
this.docCount = docCount;
|
this.docCount = docCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Connection(StreamInput in, Map<VertexId, Vertex> vertices) throws IOException {
|
|
||||||
from = vertices.get(new VertexId(in.readString(), in.readString()));
|
|
||||||
to = vertices.get(new VertexId(in.readString(), in.readString()));
|
|
||||||
weight = in.readDouble();
|
|
||||||
docCount = in.readVLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
Connection() {
|
Connection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeString(from.getField());
|
|
||||||
out.writeString(from.getTerm());
|
|
||||||
out.writeString(to.getField());
|
|
||||||
out.writeString(to.getTerm());
|
|
||||||
out.writeDouble(weight);
|
|
||||||
out.writeVLong(docCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConnectionId getId() {
|
public ConnectionId getId() {
|
||||||
return new ConnectionId(from.getId(), to.getId());
|
return new ConnectionId(from.getId(), to.getId());
|
||||||
}
|
}
|
|
@ -16,13 +16,12 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
|
||||||
import org.elasticsearch.action.IndicesRequest;
|
import org.elasticsearch.action.IndicesRequest;
|
||||||
import org.elasticsearch.action.ValidateActions;
|
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
|
import org.elasticsearch.client.Validatable;
|
||||||
|
import org.elasticsearch.client.ValidationException;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
|
@ -37,14 +36,14 @@ import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the criteria required to guide the exploration of connected terms which
|
* Holds the criteria required to guide the exploration of connected terms which
|
||||||
* can be returned as a graph.
|
* can be returned as a graph.
|
||||||
*/
|
*/
|
||||||
public class GraphExploreRequest extends ActionRequest implements IndicesRequest.Replaceable, ToXContentObject {
|
public class GraphExploreRequest implements IndicesRequest.Replaceable, ToXContentObject, Validatable {
|
||||||
|
|
||||||
public static final String NO_HOPS_ERROR_MESSAGE = "Graph explore request must have at least one hop";
|
public static final String NO_HOPS_ERROR_MESSAGE = "Graph explore request must have at least one hop";
|
||||||
public static final String NO_VERTICES_ERROR_MESSAGE = "Graph explore hop must have at least one VertexRequest";
|
public static final String NO_VERTICES_ERROR_MESSAGE = "Graph explore hop must have at least one VertexRequest";
|
||||||
|
@ -74,15 +73,15 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionRequestValidationException validate() {
|
public Optional<ValidationException> validate() {
|
||||||
ActionRequestValidationException validationException = null;
|
ValidationException validationException = new ValidationException();
|
||||||
if (hops.size() == 0) {
|
if (hops.size() == 0) {
|
||||||
validationException = ValidateActions.addValidationError(NO_HOPS_ERROR_MESSAGE, validationException);
|
validationException.addValidationError(NO_HOPS_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
for (Hop hop : hops) {
|
for (Hop hop : hops) {
|
||||||
validationException = hop.validate(validationException);
|
hop.validate(validationException);
|
||||||
}
|
}
|
||||||
return validationException;
|
return validationException.validationErrors().isEmpty() ? Optional.empty() : Optional.of(validationException);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -159,55 +158,6 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
|
|
||||||
indices = in.readStringArray();
|
|
||||||
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
||||||
types = in.readStringArray();
|
|
||||||
routing = in.readOptionalString();
|
|
||||||
timeout = in.readOptionalTimeValue();
|
|
||||||
sampleSize = in.readInt();
|
|
||||||
sampleDiversityField = in.readOptionalString();
|
|
||||||
maxDocsPerDiversityValue = in.readInt();
|
|
||||||
|
|
||||||
useSignificance = in.readBoolean();
|
|
||||||
returnDetailedInfo = in.readBoolean();
|
|
||||||
|
|
||||||
int numHops = in.readInt();
|
|
||||||
Hop parentHop = null;
|
|
||||||
for (int i = 0; i < numHops; i++) {
|
|
||||||
Hop hop = new Hop(parentHop);
|
|
||||||
hop.readFrom(in);
|
|
||||||
hops.add(hop);
|
|
||||||
parentHop = hop;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeStringArray(indices);
|
|
||||||
indicesOptions.writeIndicesOptions(out);
|
|
||||||
out.writeStringArray(types);
|
|
||||||
out.writeOptionalString(routing);
|
|
||||||
out.writeOptionalTimeValue(timeout);
|
|
||||||
|
|
||||||
out.writeInt(sampleSize);
|
|
||||||
out.writeOptionalString(sampleDiversityField);
|
|
||||||
out.writeInt(maxDocsPerDiversityValue);
|
|
||||||
|
|
||||||
out.writeBoolean(useSignificance);
|
|
||||||
out.writeBoolean(returnDetailedInfo);
|
|
||||||
out.writeInt(hops.size());
|
|
||||||
for (Iterator<Hop> iterator = hops.iterator(); iterator.hasNext();) {
|
|
||||||
Hop hop = iterator.next();
|
|
||||||
hop.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "graph explore [" + Arrays.toString(indices) + "][" + Arrays.toString(types) + "]";
|
return "graph explore [" + Arrays.toString(indices) + "][" + Arrays.toString(types) + "]";
|
|
@ -16,24 +16,21 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.ObjectIntHashMap;
|
import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
|
||||||
import org.elasticsearch.action.ShardOperationFailedException;
|
import org.elasticsearch.action.ShardOperationFailedException;
|
||||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Connection.ConnectionId;
|
import org.elasticsearch.client.graph.Connection.ConnectionId;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Connection.UnresolvedConnection;
|
import org.elasticsearch.client.graph.Connection.UnresolvedConnection;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Vertex.VertexId;
|
import org.elasticsearch.client.graph.Vertex.VertexId;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -41,7 +38,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.action.search.ShardSearchFailure.readShardSearchFailure;
|
|
||||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
|
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg;
|
||||||
|
|
||||||
|
@ -51,7 +47,7 @@ import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optiona
|
||||||
*
|
*
|
||||||
* @see GraphExploreRequest
|
* @see GraphExploreRequest
|
||||||
*/
|
*/
|
||||||
public class GraphExploreResponse extends ActionResponse implements ToXContentObject {
|
public class GraphExploreResponse implements ToXContentObject {
|
||||||
|
|
||||||
private long tookInMillis;
|
private long tookInMillis;
|
||||||
private boolean timedOut = false;
|
private boolean timedOut = false;
|
||||||
|
@ -94,41 +90,6 @@ public class GraphExploreResponse extends ActionResponse implements ToXContentOb
|
||||||
return shardFailures;
|
return shardFailures;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
tookInMillis = in.readVLong();
|
|
||||||
timedOut = in.readBoolean();
|
|
||||||
|
|
||||||
int size = in.readVInt();
|
|
||||||
if (size == 0) {
|
|
||||||
shardFailures = ShardSearchFailure.EMPTY_ARRAY;
|
|
||||||
} else {
|
|
||||||
shardFailures = new ShardSearchFailure[size];
|
|
||||||
for (int i = 0; i < shardFailures.length; i++) {
|
|
||||||
shardFailures[i] = readShardSearchFailure(in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// read vertices
|
|
||||||
size = in.readVInt();
|
|
||||||
vertices = new HashMap<>();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
Vertex n = Vertex.readFrom(in);
|
|
||||||
vertices.put(n.getId(), n);
|
|
||||||
}
|
|
||||||
|
|
||||||
size = in.readVInt();
|
|
||||||
|
|
||||||
connections = new HashMap<>();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
Connection e = new Connection(in, vertices);
|
|
||||||
connections.put(e.getId(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
returnDetailedInfo = in.readBoolean();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<Connection> getConnections() {
|
public Collection<Connection> getConnections() {
|
||||||
return connections.values();
|
return connections.values();
|
||||||
}
|
}
|
||||||
|
@ -141,31 +102,6 @@ public class GraphExploreResponse extends ActionResponse implements ToXContentOb
|
||||||
return vertices.get(id);
|
return vertices.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeVLong(tookInMillis);
|
|
||||||
out.writeBoolean(timedOut);
|
|
||||||
|
|
||||||
out.writeVInt(shardFailures.length);
|
|
||||||
for (ShardOperationFailedException shardSearchFailure : shardFailures) {
|
|
||||||
shardSearchFailure.writeTo(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
out.writeVInt(vertices.size());
|
|
||||||
for (Vertex vertex : vertices.values()) {
|
|
||||||
vertex.writeTo(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
out.writeVInt(connections.size());
|
|
||||||
for (Connection connection : connections.values()) {
|
|
||||||
connection.writeTo(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
out.writeBoolean(returnDetailedInfo);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final ParseField TOOK = new ParseField("took");
|
private static final ParseField TOOK = new ParseField("took");
|
||||||
private static final ParseField TIMED_OUT = new ParseField("timed_out");
|
private static final ParseField TIMED_OUT = new ParseField("timed_out");
|
||||||
private static final ParseField VERTICES = new ParseField("vertices");
|
private static final ParseField VERTICES = new ParseField("vertices");
|
|
@ -16,12 +16,9 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.client.ValidationException;
|
||||||
import org.elasticsearch.action.ValidateActions;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
@ -56,7 +53,7 @@ import java.util.List;
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Hop implements ToXContentFragment{
|
public class Hop implements ToXContentFragment {
|
||||||
final Hop parentHop;
|
final Hop parentHop;
|
||||||
List<VertexRequest> vertices = null;
|
List<VertexRequest> vertices = null;
|
||||||
QueryBuilder guidingQuery = null;
|
QueryBuilder guidingQuery = null;
|
||||||
|
@ -65,44 +62,16 @@ public class Hop implements ToXContentFragment{
|
||||||
this.parentHop = parent;
|
this.parentHop = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionRequestValidationException validate(ActionRequestValidationException validationException) {
|
public void validate(ValidationException validationException) {
|
||||||
|
|
||||||
if (getEffectiveVertexRequests().size() == 0) {
|
if (getEffectiveVertexRequests().size() == 0) {
|
||||||
validationException = ValidateActions.addValidationError(GraphExploreRequest.NO_VERTICES_ERROR_MESSAGE, validationException);
|
validationException.addValidationError(GraphExploreRequest.NO_VERTICES_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
return validationException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hop getParentHop() {
|
public Hop getParentHop() {
|
||||||
return parentHop;
|
return parentHop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeOptionalNamedWriteable(guidingQuery);
|
|
||||||
if (vertices == null) {
|
|
||||||
out.writeVInt(0);
|
|
||||||
} else {
|
|
||||||
out.writeVInt(vertices.size());
|
|
||||||
for (VertexRequest vr : vertices) {
|
|
||||||
vr.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void readFrom(StreamInput in) throws IOException {
|
|
||||||
guidingQuery = in.readOptionalNamedWriteable(QueryBuilder.class);
|
|
||||||
int size = in.readVInt();
|
|
||||||
if (size > 0) {
|
|
||||||
vertices = new ArrayList<>();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
VertexRequest vr = new VertexRequest();
|
|
||||||
vr.readFrom(in);
|
|
||||||
vertices.add(vr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryBuilder guidingQuery() {
|
public QueryBuilder guidingQuery() {
|
||||||
if (guidingQuery != null) {
|
if (guidingQuery != null) {
|
||||||
return guidingQuery;
|
return guidingQuery;
|
|
@ -16,11 +16,9 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -65,19 +63,6 @@ public class Vertex implements ToXContentFragment {
|
||||||
this.fg = fg;
|
this.fg = fg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vertex readFrom(StreamInput in) throws IOException {
|
|
||||||
return new Vertex(in.readString(), in.readString(), in.readDouble(), in.readVInt(), in.readVLong(), in.readVLong());
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeString(field);
|
|
||||||
out.writeString(term);
|
|
||||||
out.writeDouble(weight);
|
|
||||||
out.writeVInt(depth);
|
|
||||||
out.writeVLong(bg);
|
|
||||||
out.writeVLong(fg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(field, term, weight, depth, bg, fg);
|
return Objects.hash(field, term, weight, depth, bg, fg);
|
|
@ -16,13 +16,11 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest.TermBoost;
|
import org.elasticsearch.client.graph.GraphExploreRequest.TermBoost;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -52,57 +50,6 @@ public class VertexRequest implements ToXContentObject {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void readFrom(StreamInput in) throws IOException {
|
|
||||||
fieldName = in.readString();
|
|
||||||
size = in.readVInt();
|
|
||||||
minDocCount = in.readVInt();
|
|
||||||
shardMinDocCount = in.readVInt();
|
|
||||||
|
|
||||||
int numIncludes = in.readVInt();
|
|
||||||
if (numIncludes > 0) {
|
|
||||||
includes = new HashMap<>();
|
|
||||||
for (int i = 0; i < numIncludes; i++) {
|
|
||||||
TermBoost tb = new TermBoost();
|
|
||||||
tb.readFrom(in);
|
|
||||||
includes.put(tb.term, tb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int numExcludes = in.readVInt();
|
|
||||||
if (numExcludes > 0) {
|
|
||||||
excludes = new HashSet<>();
|
|
||||||
for (int i = 0; i < numExcludes; i++) {
|
|
||||||
excludes.add(in.readString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeString(fieldName);
|
|
||||||
out.writeVInt(size);
|
|
||||||
out.writeVInt(minDocCount);
|
|
||||||
out.writeVInt(shardMinDocCount);
|
|
||||||
|
|
||||||
if (includes != null) {
|
|
||||||
out.writeVInt(includes.size());
|
|
||||||
for (TermBoost tb : includes.values()) {
|
|
||||||
tb.writeTo(out);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.writeVInt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (excludes != null) {
|
|
||||||
out.writeVInt(excludes.size());
|
|
||||||
for (String term : excludes) {
|
|
||||||
out.writeString(term);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.writeVInt(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String fieldName() {
|
public String fieldName() {
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +171,7 @@ public class VertexRequest implements ToXContentObject {
|
||||||
if (shardMinDocCount != DEFAULT_SHARD_MIN_DOC_COUNT) {
|
if (shardMinDocCount != DEFAULT_SHARD_MIN_DOC_COUNT) {
|
||||||
builder.field("shard_min_doc_count", shardMinDocCount);
|
builder.field("shard_min_doc_count", shardMinDocCount);
|
||||||
}
|
}
|
||||||
if(includes!=null) {
|
if (includes != null) {
|
||||||
builder.startArray("include");
|
builder.startArray("include");
|
||||||
for (TermBoost tb : includes.values()) {
|
for (TermBoost tb : includes.values()) {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
@ -234,7 +181,7 @@ public class VertexRequest implements ToXContentObject {
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
}
|
}
|
||||||
if(excludes!=null) {
|
if (excludes != null) {
|
||||||
builder.startArray("exclude");
|
builder.startArray("exclude");
|
||||||
for (String value : excludes) {
|
for (String value : excludes) {
|
||||||
builder.value(value);
|
builder.value(value);
|
|
@ -21,4 +21,4 @@
|
||||||
* Request and Response objects for the default distribution's Graph
|
* Request and Response objects for the default distribution's Graph
|
||||||
* APIs.
|
* APIs.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
|
@ -16,21 +16,17 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.migration;
|
package org.elasticsearch.client.migration;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
|
||||||
import org.elasticsearch.action.IndicesRequest;
|
import org.elasticsearch.action.IndicesRequest;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
import org.elasticsearch.client.TimedRequest;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class IndexUpgradeInfoRequest extends MasterNodeReadRequest<IndexUpgradeInfoRequest> implements IndicesRequest.Replaceable {
|
public class IndexUpgradeInfoRequest extends TimedRequest implements IndicesRequest.Replaceable {
|
||||||
|
|
||||||
private String[] indices = Strings.EMPTY_ARRAY;
|
private String[] indices = Strings.EMPTY_ARRAY;
|
||||||
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
|
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
|
||||||
|
@ -39,19 +35,6 @@ public class IndexUpgradeInfoRequest extends MasterNodeReadRequest<IndexUpgradeI
|
||||||
indices(indices);
|
indices(indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexUpgradeInfoRequest(StreamInput in) throws IOException {
|
|
||||||
super(in);
|
|
||||||
indices = in.readStringArray();
|
|
||||||
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeStringArray(indices);
|
|
||||||
indicesOptions.writeIndicesOptions(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] indices() {
|
public String[] indices() {
|
||||||
return indices;
|
return indices;
|
||||||
|
@ -72,16 +55,6 @@ public class IndexUpgradeInfoRequest extends MasterNodeReadRequest<IndexUpgradeI
|
||||||
this.indicesOptions = indicesOptions;
|
this.indicesOptions = indicesOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionRequestValidationException validate() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
|
@ -16,25 +16,19 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.migration;
|
package org.elasticsearch.client.migration;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||||
|
|
||||||
public class IndexUpgradeInfoResponse extends ActionResponse implements ToXContentObject {
|
public class IndexUpgradeInfoResponse {
|
||||||
|
|
||||||
private static final ParseField INDICES = new ParseField("indices");
|
private static final ParseField INDICES = new ParseField("indices");
|
||||||
private static final ParseField ACTION_REQUIRED = new ParseField("action_required");
|
private static final ParseField ACTION_REQUIRED = new ParseField("action_required");
|
||||||
|
@ -70,50 +64,16 @@ public class IndexUpgradeInfoResponse extends ActionResponse implements ToXConte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, UpgradeActionRequired> actions;
|
private final Map<String, UpgradeActionRequired> actions;
|
||||||
|
|
||||||
public IndexUpgradeInfoResponse() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndexUpgradeInfoResponse(Map<String, UpgradeActionRequired> actions) {
|
public IndexUpgradeInfoResponse(Map<String, UpgradeActionRequired> actions) {
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
actions = in.readMap(StreamInput::readString, UpgradeActionRequired::readFromStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeMap(actions, StreamOutput::writeString, (out1, value) -> value.writeTo(out1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, UpgradeActionRequired> getActions() {
|
public Map<String, UpgradeActionRequired> getActions() {
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
builder.startObject();
|
|
||||||
{
|
|
||||||
builder.startObject(INDICES.getPreferredName());
|
|
||||||
for (Map.Entry<String, UpgradeActionRequired> entry : actions.entrySet()) {
|
|
||||||
builder.startObject(entry.getKey());
|
|
||||||
{
|
|
||||||
builder.field(ACTION_REQUIRED.getPreferredName(), entry.getValue().toString());
|
|
||||||
}
|
|
||||||
builder.endObject();
|
|
||||||
}
|
|
||||||
builder.endObject();
|
|
||||||
}
|
|
||||||
builder.endObject();
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.migration;
|
package org.elasticsearch.client.migration;
|
||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
@ -21,4 +21,4 @@
|
||||||
* Request and Response objects for the default distribution's Migration
|
* Request and Response objects for the default distribution's Migration
|
||||||
* APIs.
|
* APIs.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.migration;
|
package org.elasticsearch.client.migration;
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.client.Validatable;
|
import org.elasticsearch.client.Validatable;
|
||||||
import org.elasticsearch.client.ValidationException;
|
import org.elasticsearch.client.ValidationException;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.elasticsearch.client.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.client.Validatable;
|
import org.elasticsearch.client.Validatable;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.elasticsearch.client.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.client.Validatable;
|
import org.elasticsearch.client.Validatable;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ public class DeactivateWatchRequest implements Validatable {
|
||||||
private final String watchId;
|
private final String watchId;
|
||||||
|
|
||||||
public DeactivateWatchRequest(String watchId) {
|
public DeactivateWatchRequest(String watchId) {
|
||||||
|
|
||||||
Objects.requireNonNull(watchId, "watch id is missing");
|
Objects.requireNonNull(watchId, "watch id is missing");
|
||||||
if (PutWatchRequest.isValidId(watchId) == false) {
|
if (PutWatchRequest.isValidId(watchId) == false) {
|
||||||
throw new IllegalArgumentException("watch id contains whitespace");
|
throw new IllegalArgumentException("watch id contains whitespace");
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Licensed to Elasticsearch under one or more contributor
|
||||||
|
* license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright
|
||||||
|
* ownership. Elasticsearch licenses this file to you under
|
||||||
|
* the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
|
import org.elasticsearch.client.Validatable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A delete watch request to delete an watch by name (id)
|
||||||
|
*/
|
||||||
|
public class DeleteWatchRequest implements Validatable {
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
|
||||||
|
public DeleteWatchRequest(String id) {
|
||||||
|
Objects.requireNonNull(id, "watch id is missing");
|
||||||
|
if (PutWatchRequest.isValidId(id) == false) {
|
||||||
|
throw new IllegalArgumentException("watch id contains whitespace");
|
||||||
|
}
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The name of the watch to be deleted
|
||||||
|
*/
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "delete [" + id + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,12 +16,9 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -30,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DeleteWatchResponse extends ActionResponse implements ToXContentObject {
|
public class DeleteWatchResponse implements ToXContentObject {
|
||||||
|
|
||||||
private static final ObjectParser<DeleteWatchResponse, Void> PARSER
|
private static final ObjectParser<DeleteWatchResponse, Void> PARSER
|
||||||
= new ObjectParser<>("x_pack_delete_watch_response", DeleteWatchResponse::new);
|
= new ObjectParser<>("x_pack_delete_watch_response", DeleteWatchResponse::new);
|
||||||
|
@ -92,22 +89,6 @@ public class DeleteWatchResponse extends ActionResponse implements ToXContentObj
|
||||||
return Objects.hash(id, version, found);
|
return Objects.hash(id, version, found);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
id = in.readString();
|
|
||||||
version = in.readVLong();
|
|
||||||
found = in.readBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeString(id);
|
|
||||||
out.writeVLong(version);
|
|
||||||
out.writeBoolean(found);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
return builder.startObject()
|
return builder.startObject()
|
|
@ -16,67 +16,43 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.client.Validatable;
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
|
||||||
import org.elasticsearch.action.ValidateActions;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.lucene.uid.Versions;
|
import org.elasticsearch.common.lucene.uid.Versions;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.Objects;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This request class contains the data needed to create a watch along with the name of the watch.
|
* This request class contains the data needed to create a watch along with the name of the watch.
|
||||||
* The name of the watch will become the ID of the indexed document.
|
* The name of the watch will become the ID of the indexed document.
|
||||||
*/
|
*/
|
||||||
public final class PutWatchRequest extends ActionRequest {
|
public final class PutWatchRequest implements Validatable {
|
||||||
|
|
||||||
private static final Pattern NO_WS_PATTERN = Pattern.compile("\\S+");
|
private static final Pattern NO_WS_PATTERN = Pattern.compile("\\S+");
|
||||||
|
|
||||||
private String id;
|
private final String id;
|
||||||
private BytesReference source;
|
private final BytesReference source;
|
||||||
private XContentType xContentType = XContentType.JSON;
|
private final XContentType xContentType;
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private long version = Versions.MATCH_ANY;
|
private long version = Versions.MATCH_ANY;
|
||||||
|
|
||||||
public PutWatchRequest() {}
|
|
||||||
|
|
||||||
public PutWatchRequest(StreamInput in) throws IOException {
|
|
||||||
readFrom(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PutWatchRequest(String id, BytesReference source, XContentType xContentType) {
|
public PutWatchRequest(String id, BytesReference source, XContentType xContentType) {
|
||||||
|
Objects.requireNonNull(id, "watch id is missing");
|
||||||
|
if (isValidId(id) == false) {
|
||||||
|
throw new IllegalArgumentException("watch id contains whitespace");
|
||||||
|
}
|
||||||
|
Objects.requireNonNull(source, "watch source is missing");
|
||||||
|
Objects.requireNonNull(xContentType, "request body is missing");
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.xContentType = xContentType;
|
this.xContentType = xContentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
id = in.readString();
|
|
||||||
source = in.readBytesReference();
|
|
||||||
active = in.readBoolean();
|
|
||||||
xContentType = in.readEnum(XContentType.class);
|
|
||||||
version = in.readZLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeString(id);
|
|
||||||
out.writeBytesReference(source);
|
|
||||||
out.writeBoolean(active);
|
|
||||||
out.writeEnum(xContentType);
|
|
||||||
out.writeZLong(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The name that will be the ID of the indexed document
|
* @return The name that will be the ID of the indexed document
|
||||||
*/
|
*/
|
||||||
|
@ -84,13 +60,6 @@ public final class PutWatchRequest extends ActionRequest {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the watch name
|
|
||||||
*/
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The source of the watch
|
* @return The source of the watch
|
||||||
*/
|
*/
|
||||||
|
@ -98,14 +67,6 @@ public final class PutWatchRequest extends ActionRequest {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the source of the watch
|
|
||||||
*/
|
|
||||||
public void setSource(BytesReference source, XContentType xContentType) {
|
|
||||||
this.source = source;
|
|
||||||
this.xContentType = xContentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The initial active state of the watch (defaults to {@code true}, e.g. "active")
|
* @return The initial active state of the watch (defaults to {@code true}, e.g. "active")
|
||||||
*/
|
*/
|
||||||
|
@ -135,23 +96,6 @@ public final class PutWatchRequest extends ActionRequest {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionRequestValidationException validate() {
|
|
||||||
ActionRequestValidationException validationException = null;
|
|
||||||
if (id == null) {
|
|
||||||
validationException = ValidateActions.addValidationError("watch id is missing", validationException);
|
|
||||||
} else if (isValidId(id) == false) {
|
|
||||||
validationException = ValidateActions.addValidationError("watch id contains whitespace", validationException);
|
|
||||||
}
|
|
||||||
if (source == null) {
|
|
||||||
validationException = ValidateActions.addValidationError("watch source is missing", validationException);
|
|
||||||
}
|
|
||||||
if (xContentType == null) {
|
|
||||||
validationException = ValidateActions.addValidationError("request body is missing", validationException);
|
|
||||||
}
|
|
||||||
return validationException;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isValidId(String id) {
|
public static boolean isValidId(String id) {
|
||||||
return Strings.isEmpty(id) == false && NO_WS_PATTERN.matcher(id).matches();
|
return Strings.isEmpty(id) == false && NO_WS_PATTERN.matcher(id).matches();
|
||||||
}
|
}
|
|
@ -16,12 +16,9 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -30,10 +27,11 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class PutWatchResponse extends ActionResponse implements ToXContentObject {
|
public class PutWatchResponse implements ToXContentObject {
|
||||||
|
|
||||||
private static final ObjectParser<PutWatchResponse, Void> PARSER
|
private static final ObjectParser<PutWatchResponse, Void> PARSER
|
||||||
= new ObjectParser<>("x_pack_put_watch_response", PutWatchResponse::new);
|
= new ObjectParser<>("x_pack_put_watch_response", PutWatchResponse::new);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PARSER.declareString(PutWatchResponse::setId, new ParseField("_id"));
|
PARSER.declareString(PutWatchResponse::setId, new ParseField("_id"));
|
||||||
PARSER.declareLong(PutWatchResponse::setVersion, new ParseField("_version"));
|
PARSER.declareLong(PutWatchResponse::setVersion, new ParseField("_version"));
|
||||||
|
@ -92,22 +90,6 @@ public class PutWatchResponse extends ActionResponse implements ToXContentObject
|
||||||
return Objects.hash(id, version, created);
|
return Objects.hash(id, version, created);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeString(id);
|
|
||||||
out.writeVLong(version);
|
|
||||||
out.writeBoolean(created);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
id = in.readString();
|
|
||||||
version = in.readVLong();
|
|
||||||
created = in.readBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
return builder.startObject()
|
return builder.startObject()
|
|
@ -21,4 +21,4 @@
|
||||||
* Request and Response objects for the default distribution's Watcher
|
* Request and Response objects for the default distribution's Watcher
|
||||||
* APIs.
|
* APIs.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
package org.elasticsearch.client.watcher;
|
|
@ -24,17 +24,16 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
|
import org.elasticsearch.client.graph.GraphExploreRequest;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Hop;
|
import org.elasticsearch.client.graph.Hop;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.junit.Assert;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class GrapRequestConvertersTests extends ESTestCase{
|
public class GrapRequestConvertersTests extends ESTestCase {
|
||||||
|
|
||||||
public void testGraphExplore() throws Exception {
|
public void testGraphExplore() throws Exception {
|
||||||
Map<String, String> expectedParams = new HashMap<>();
|
Map<String, String> expectedParams = new HashMap<>();
|
||||||
|
@ -43,14 +42,14 @@ public class GrapRequestConvertersTests extends ESTestCase{
|
||||||
graphExploreRequest.sampleDiversityField("diversity");
|
graphExploreRequest.sampleDiversityField("diversity");
|
||||||
graphExploreRequest.indices("index1", "index2");
|
graphExploreRequest.indices("index1", "index2");
|
||||||
graphExploreRequest.types("type1", "type2");
|
graphExploreRequest.types("type1", "type2");
|
||||||
int timeout = ESTestCase.randomIntBetween(10000, 20000);
|
int timeout = randomIntBetween(10000, 20000);
|
||||||
graphExploreRequest.timeout(TimeValue.timeValueMillis(timeout));
|
graphExploreRequest.timeout(TimeValue.timeValueMillis(timeout));
|
||||||
graphExploreRequest.useSignificance(ESTestCase.randomBoolean());
|
graphExploreRequest.useSignificance(randomBoolean());
|
||||||
int numHops = ESTestCase.randomIntBetween(1, 5);
|
int numHops = randomIntBetween(1, 5);
|
||||||
for (int i = 0; i < numHops; i++) {
|
for (int i = 0; i < numHops; i++) {
|
||||||
int hopNumber = i + 1;
|
int hopNumber = i + 1;
|
||||||
QueryBuilder guidingQuery = null;
|
QueryBuilder guidingQuery = null;
|
||||||
if (ESTestCase.randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
guidingQuery = new TermQueryBuilder("field" + hopNumber, "value" + hopNumber);
|
guidingQuery = new TermQueryBuilder("field" + hopNumber, "value" + hopNumber);
|
||||||
}
|
}
|
||||||
Hop hop = graphExploreRequest.createNextHop(guidingQuery);
|
Hop hop = graphExploreRequest.createNextHop(guidingQuery);
|
||||||
|
@ -58,10 +57,10 @@ public class GrapRequestConvertersTests extends ESTestCase{
|
||||||
hop.getVertexRequest(0).addInclude("value" + hopNumber, hopNumber);
|
hop.getVertexRequest(0).addInclude("value" + hopNumber, hopNumber);
|
||||||
}
|
}
|
||||||
Request request = GraphRequestConverters.explore(graphExploreRequest);
|
Request request = GraphRequestConverters.explore(graphExploreRequest);
|
||||||
Assert.assertEquals(HttpGet.METHOD_NAME, request.getMethod());
|
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
|
||||||
Assert.assertEquals("/index1,index2/type1,type2/_xpack/graph/_explore", request.getEndpoint());
|
assertEquals("/index1,index2/type1,type2/_xpack/graph/_explore", request.getEndpoint());
|
||||||
Assert.assertEquals(expectedParams, request.getParameters());
|
assertEquals(expectedParams, request.getParameters());
|
||||||
Assert.assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
|
assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
|
||||||
RequestConvertersTests.assertToXContentBody(graphExploreRequest, request.getEntity());
|
RequestConvertersTests.assertToXContentBody(graphExploreRequest, request.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ import org.apache.http.client.methods.HttpPut;
|
||||||
import org.elasticsearch.action.ShardOperationFailedException;
|
import org.elasticsearch.action.ShardOperationFailedException;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
|
import org.elasticsearch.client.graph.GraphExploreRequest;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse;
|
import org.elasticsearch.client.graph.GraphExploreResponse;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Hop;
|
import org.elasticsearch.client.graph.Hop;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Vertex;
|
import org.elasticsearch.client.graph.Vertex;
|
||||||
import org.elasticsearch.protocol.xpack.graph.VertexRequest;
|
import org.elasticsearch.client.graph.VertexRequest;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
package org.elasticsearch.client;
|
package org.elasticsearch.client;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.elasticsearch.client;
|
package org.elasticsearch.client;
|
||||||
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public class MigrationRequestConvertersTests extends ESTestCase {
|
public class MigrationRequestConvertersTests extends ESTestCase {
|
||||||
|
|
||||||
public static void testGetMigrationAssistance() {
|
public void testGetMigrationAssistance() {
|
||||||
IndexUpgradeInfoRequest upgradeInfoRequest = new IndexUpgradeInfoRequest();
|
IndexUpgradeInfoRequest upgradeInfoRequest = new IndexUpgradeInfoRequest();
|
||||||
String expectedEndpoint = "/_xpack/migration/assistance";
|
String expectedEndpoint = "/_xpack/migration/assistance";
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
|
|
|
@ -35,10 +35,10 @@ import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
|
import org.elasticsearch.client.watcher.DeleteWatchResponse;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
|
import org.elasticsearch.client.watcher.PutWatchResponse;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.elasticsearch.client.watcher.StartWatchServiceRequest;
|
||||||
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
import org.elasticsearch.client.watcher.StopWatchServiceRequest;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -56,11 +56,9 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWatch() throws Exception {
|
public void testPutWatch() throws Exception {
|
||||||
PutWatchRequest putWatchRequest = new PutWatchRequest();
|
|
||||||
String watchId = randomAlphaOfLength(10);
|
String watchId = randomAlphaOfLength(10);
|
||||||
putWatchRequest.setId(watchId);
|
|
||||||
String body = randomAlphaOfLength(20);
|
String body = randomAlphaOfLength(20);
|
||||||
putWatchRequest.setSource(new BytesArray(body), XContentType.JSON);
|
PutWatchRequest putWatchRequest = new PutWatchRequest(watchId, new BytesArray(body), XContentType.JSON);
|
||||||
|
|
||||||
Map<String, String> expectedParams = new HashMap<>();
|
Map<String, String> expectedParams = new HashMap<>();
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
|
@ -94,9 +92,8 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteWatch() {
|
public void testDeleteWatch() {
|
||||||
DeleteWatchRequest deleteWatchRequest = new DeleteWatchRequest();
|
|
||||||
String watchId = randomAlphaOfLength(10);
|
String watchId = randomAlphaOfLength(10);
|
||||||
deleteWatchRequest.setId(watchId);
|
DeleteWatchRequest deleteWatchRequest = new DeleteWatchRequest(watchId);
|
||||||
|
|
||||||
Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest);
|
Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest);
|
||||||
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
|
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.elasticsearch.common.SuppressForbidden;
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Connection;
|
import org.elasticsearch.client.graph.Connection;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
|
import org.elasticsearch.client.graph.GraphExploreRequest;
|
||||||
import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse;
|
import org.elasticsearch.client.graph.GraphExploreResponse;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Hop;
|
import org.elasticsearch.client.graph.Hop;
|
||||||
import org.elasticsearch.protocol.xpack.graph.Vertex;
|
import org.elasticsearch.client.graph.Vertex;
|
||||||
import org.elasticsearch.protocol.xpack.graph.VertexRequest;
|
import org.elasticsearch.client.graph.VertexRequest;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -24,9 +24,9 @@ import org.elasticsearch.client.ESRestHighLevelClientTestCase;
|
||||||
import org.elasticsearch.client.RequestOptions;
|
import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
|
||||||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
|
import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
|
||||||
import org.elasticsearch.protocol.xpack.migration.UpgradeActionRequired;
|
import org.elasticsearch.client.migration.UpgradeActionRequired;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -40,10 +40,10 @@ import org.elasticsearch.client.watcher.WatchStatus;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
import org.elasticsearch.client.watcher.DeleteWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
|
import org.elasticsearch.client.watcher.DeleteWatchResponse;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
import org.elasticsearch.client.watcher.PutWatchRequest;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
|
import org.elasticsearch.client.watcher.PutWatchResponse;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.graph;
|
package org.elasticsearch.client.graph;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.ShardOperationFailedException;
|
import org.elasticsearch.action.ShardOperationFailedException;
|
||||||
|
@ -35,7 +35,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class GraphExploreResponseTests extends AbstractXContentTestCase< GraphExploreResponse> {
|
public class GraphExploreResponseTests extends AbstractXContentTestCase<GraphExploreResponse> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GraphExploreResponse createTestInstance() {
|
protected GraphExploreResponse createTestInstance() {
|
|
@ -17,13 +17,16 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
apply plugin: 'elasticsearch.build'
|
package org.elasticsearch.client.migration;
|
||||||
|
|
||||||
description = 'Request and Response objects for x-pack that are used by the' +
|
import org.elasticsearch.test.ESTestCase;
|
||||||
' high level rest client and x-pack itself'
|
|
||||||
|
|
||||||
dependencies {
|
public class IndexUpgradeInfoRequestTests extends ESTestCase {
|
||||||
compileOnly "org.elasticsearch:elasticsearch:${version}"
|
|
||||||
|
|
||||||
testCompile "org.elasticsearch.test:framework:${version}"
|
// TODO: add to cross XPack-HLRC serialization test
|
||||||
|
|
||||||
|
public void testNullIndices() {
|
||||||
|
expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest((String[])null));
|
||||||
|
expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest().indices((String[])null));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -17,7 +17,10 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
package org.elasticsearch.client.migration;
|
||||||
* Request and Response objects for miscellaneous X-Pack APIs.
|
|
||||||
*/
|
import org.elasticsearch.test.ESTestCase;
|
||||||
package org.elasticsearch.protocol.xpack;
|
|
||||||
|
public class IndexUpgradeInfoResponseTests extends ESTestCase {
|
||||||
|
// TODO: add to cross XPack-HLRC serialization test
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.test.AbstractXContentTestCase;
|
import org.elasticsearch.test.AbstractXContentTestCase;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.test.AbstractXContentTestCase;
|
import org.elasticsearch.test.AbstractXContentTestCase;
|
|
@ -19,19 +19,15 @@
|
||||||
|
|
||||||
package org.elasticsearch.client.watcher;
|
package org.elasticsearch.client.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
|
||||||
import org.elasticsearch.client.ValidationException;
|
import org.elasticsearch.client.ValidationException;
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
|
||||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.hasItem;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
|
||||||
|
|
||||||
public class WatchRequestValidationTests extends ESTestCase {
|
public class WatchRequestValidationTests extends ESTestCase {
|
||||||
|
|
||||||
|
@ -61,38 +57,38 @@ public class WatchRequestValidationTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteWatchInvalidWatchId() {
|
public void testDeleteWatchInvalidWatchId() {
|
||||||
ActionRequestValidationException e = new DeleteWatchRequest("id with whitespaces").validate();
|
final IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||||
assertThat(e, is(notNullValue()));
|
() -> new DeleteWatchRequest("id with whitespaces"));
|
||||||
assertThat(e.validationErrors(), hasItem("watch id contains whitespace"));
|
assertThat(exception.getMessage(), is("watch id contains whitespace"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteWatchNullId() {
|
public void testDeleteWatchNullId() {
|
||||||
ActionRequestValidationException e = new DeleteWatchRequest(null).validate();
|
final NullPointerException exception = expectThrows(NullPointerException.class,
|
||||||
assertThat(e, is(notNullValue()));
|
() -> new DeleteWatchRequest(null));
|
||||||
assertThat(e.validationErrors(), hasItem("watch id is missing"));
|
assertThat(exception.getMessage(), is("watch id is missing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWatchInvalidWatchId() {
|
public void testPutWatchInvalidWatchId() {
|
||||||
ActionRequestValidationException e = new PutWatchRequest("id with whitespaces", BytesArray.EMPTY, XContentType.JSON).validate();
|
final IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
|
||||||
assertThat(e, is(notNullValue()));
|
() -> new PutWatchRequest("id with whitespaces", BytesArray.EMPTY, XContentType.JSON));
|
||||||
assertThat(e.validationErrors(), hasItem("watch id contains whitespace"));
|
assertThat(exception.getMessage(), is("watch id contains whitespace"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWatchNullId() {
|
public void testPutWatchNullId() {
|
||||||
ActionRequestValidationException e = new PutWatchRequest(null, BytesArray.EMPTY, XContentType.JSON).validate();
|
final NullPointerException exception = expectThrows(NullPointerException.class,
|
||||||
assertThat(e, is(notNullValue()));
|
() -> new PutWatchRequest(null, BytesArray.EMPTY, XContentType.JSON));
|
||||||
assertThat(e.validationErrors(), hasItem("watch id is missing"));
|
assertThat(exception.getMessage(), is("watch id is missing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWatchSourceNull() {
|
public void testPutWatchSourceNull() {
|
||||||
ActionRequestValidationException e = new PutWatchRequest("foo", null, XContentType.JSON).validate();
|
final NullPointerException exception = expectThrows(NullPointerException.class,
|
||||||
assertThat(e, is(notNullValue()));
|
() -> new PutWatchRequest("foo", null, XContentType.JSON));
|
||||||
assertThat(e.validationErrors(), hasItem("watch source is missing"));
|
assertThat(exception.getMessage(), is("watch source is missing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWatchContentNull() {
|
public void testPutWatchContentNull() {
|
||||||
ActionRequestValidationException e = new PutWatchRequest("foo", BytesArray.EMPTY, null).validate();
|
final NullPointerException exception = expectThrows(NullPointerException.class,
|
||||||
assertThat(e, is(notNullValue()));
|
() -> new PutWatchRequest("foo", BytesArray.EMPTY, null));
|
||||||
assertThat(e.validationErrors(), hasItem("request body is missing"));
|
assertThat(exception.getMessage(), is("request body is missing"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ subprojects {
|
||||||
project.esplugin.noticeFile = xpackRootProject.file('NOTICE.txt')
|
project.esplugin.noticeFile = xpackRootProject.file('NOTICE.txt')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.name != 'protocol') {
|
|
||||||
tasks.withType(LicenseHeadersTask.class) {
|
tasks.withType(LicenseHeadersTask.class) {
|
||||||
approvedLicenses = ['Elastic License', 'Generated']
|
approvedLicenses = ['Elastic License', 'Generated']
|
||||||
additionalLicense 'ELAST', 'Elastic License', 'Licensed under the Elastic License'
|
additionalLicense 'ELAST', 'Elastic License', 'Licensed under the Elastic License'
|
||||||
|
@ -28,7 +27,6 @@ subprojects {
|
||||||
|
|
||||||
project.ext.licenseFile = rootProject.file('licenses/ELASTIC-LICENSE.txt')
|
project.ext.licenseFile = rootProject.file('licenses/ELASTIC-LICENSE.txt')
|
||||||
project.ext.noticeFile = xpackRootProject.file('NOTICE.txt')
|
project.ext.noticeFile = xpackRootProject.file('NOTICE.txt')
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
|
|
@ -1,202 +0,0 @@
|
||||||
|
|
||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.elasticsearch.protocol.xpack.watcher;
|
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
|
||||||
import org.elasticsearch.action.ValidateActions;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
import org.elasticsearch.common.lucene.uid.Versions;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A delete watch request to delete an watch by name (id)
|
|
||||||
*/
|
|
||||||
public class DeleteWatchRequest extends ActionRequest {
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private long version = Versions.MATCH_ANY;
|
|
||||||
|
|
||||||
public DeleteWatchRequest() {
|
|
||||||
this(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeleteWatchRequest(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The name of the watch to be deleted
|
|
||||||
*/
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of the watch to be deleted
|
|
||||||
*/
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionRequestValidationException validate() {
|
|
||||||
ActionRequestValidationException validationException = null;
|
|
||||||
if (id == null){
|
|
||||||
validationException = ValidateActions.addValidationError("watch id is missing", validationException);
|
|
||||||
} else if (PutWatchRequest.isValidId(id) == false) {
|
|
||||||
validationException = ValidateActions.addValidationError("watch id contains whitespace", validationException);
|
|
||||||
}
|
|
||||||
return validationException;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
id = in.readString();
|
|
||||||
version = in.readLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
out.writeString(id);
|
|
||||||
out.writeLong(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "delete [" + id + "]";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.protocol.xpack.migration;
|
|
||||||
|
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
|
||||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
|
||||||
|
|
||||||
public class IndexUpgradeInfoRequestTests extends AbstractWireSerializingTestCase<IndexUpgradeInfoRequest> {
|
|
||||||
@Override
|
|
||||||
protected IndexUpgradeInfoRequest createTestInstance() {
|
|
||||||
int indexCount = randomInt(4);
|
|
||||||
String[] indices = new String[indexCount];
|
|
||||||
for (int i = 0; i < indexCount; i++) {
|
|
||||||
indices[i] = randomAlphaOfLength(10);
|
|
||||||
}
|
|
||||||
IndexUpgradeInfoRequest request = new IndexUpgradeInfoRequest(indices);
|
|
||||||
if (randomBoolean()) {
|
|
||||||
request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
|
|
||||||
}
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Writeable.Reader<IndexUpgradeInfoRequest> instanceReader() {
|
|
||||||
return IndexUpgradeInfoRequest::new;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNullIndices() {
|
|
||||||
expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest((String[])null));
|
|
||||||
expectThrows(NullPointerException.class, () -> new IndexUpgradeInfoRequest().indices((String[])null));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.protocol.xpack.migration;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
|
||||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class IndexUpgradeInfoResponseTests extends AbstractStreamableXContentTestCase<IndexUpgradeInfoResponse> {
|
|
||||||
@Override
|
|
||||||
protected IndexUpgradeInfoResponse doParseInstance(XContentParser parser) {
|
|
||||||
return IndexUpgradeInfoResponse.fromXContent(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IndexUpgradeInfoResponse createBlankInstance() {
|
|
||||||
return new IndexUpgradeInfoResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IndexUpgradeInfoResponse createTestInstance() {
|
|
||||||
return randomIndexUpgradeInfoResponse(randomIntBetween(0, 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IndexUpgradeInfoResponse randomIndexUpgradeInfoResponse(int numIndices) {
|
|
||||||
Map<String, UpgradeActionRequired> actions = new HashMap<>();
|
|
||||||
for (int i = 0; i < numIndices; i++) {
|
|
||||||
actions.put(randomAlphaOfLength(5), randomFrom(UpgradeActionRequired.values()));
|
|
||||||
}
|
|
||||||
return new IndexUpgradeInfoResponse(actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IndexUpgradeInfoResponse mutateInstance(IndexUpgradeInfoResponse instance) {
|
|
||||||
if (instance.getActions().size() == 0) {
|
|
||||||
return randomIndexUpgradeInfoResponse(1);
|
|
||||||
}
|
|
||||||
Map<String, UpgradeActionRequired> actions = new HashMap<>(instance.getActions());
|
|
||||||
if (randomBoolean()) {
|
|
||||||
Iterator<Map.Entry<String, UpgradeActionRequired>> iterator = actions.entrySet().iterator();
|
|
||||||
iterator.next();
|
|
||||||
iterator.remove();
|
|
||||||
} else {
|
|
||||||
actions.put(randomAlphaOfLength(5), randomFrom(UpgradeActionRequired.values()));
|
|
||||||
}
|
|
||||||
return new IndexUpgradeInfoResponse(actions);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue