org.elasticsearch.client.tasks.CancelTasksResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-rest-high-level-client Show documentation
Show all versions of elasticsearch-rest-high-level-client Show documentation
Elasticsearch subproject :client:rest-high-level
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.client.tasks;
import org.elasticsearch.xcontent.ConstructingObjectParser;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.XContentParser;
import java.io.IOException;
import java.util.List;
import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg;
/**
* cancel tasks response that contains
* - task failures
* - node failures
* - tasks
*/
public class CancelTasksResponse extends ListTasksResponse {
CancelTasksResponse(List nodesInfoData, List taskFailures, List nodeFailures) {
super(nodesInfoData, taskFailures, nodeFailures);
}
public static CancelTasksResponse fromXContent(final XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}
private static ConstructingObjectParser PARSER;
static {
ConstructingObjectParser parser = new ConstructingObjectParser<>(
"cancel_tasks_response",
true,
constructingObjects -> {
int i = 0;
@SuppressWarnings("unchecked")
List tasksFailures = (List) constructingObjects[i++];
@SuppressWarnings("unchecked")
List nodeFailures = (List) constructingObjects[i++];
@SuppressWarnings("unchecked")
List nodesInfoData = (List) constructingObjects[i];
return new CancelTasksResponse(nodesInfoData, tasksFailures, nodeFailures);
}
);
parser.declareObjectArray(
optionalConstructorArg(),
(p, c) -> TaskOperationFailure.fromXContent(p),
new ParseField("task_failures")
);
parser.declareObjectArray(
optionalConstructorArg(),
(p, c) -> ElasticsearchException.fromXContent(p),
new ParseField("node_failures")
);
parser.declareNamedObjects(optionalConstructorArg(), NodeData.PARSER, new ParseField("nodes"));
PARSER = parser;
}
@Override
public boolean equals(Object o) {
return super.equals(o);
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public String toString() {
return "CancelTasksResponse{"
+ "taskFailures="
+ taskFailures
+ ", nodeFailures="
+ nodeFailures
+ ", nodesInfoData="
+ nodesInfoData
+ ", tasks="
+ tasks
+ ", taskGroups="
+ taskGroups
+ '}';
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy