use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class SysRepositoriesServiceTest method deleteRepository.
private void deleteRepository(String name) {
AcknowledgedResponse deleteRepositoryResponse = client().admin().cluster().prepareDeleteRepository(name).get();
assertThat(deleteRepositoryResponse.isAcknowledged(), equalTo(true));
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class CreateFunctionPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
UserDefinedFunctionMetadata metadata = new UserDefinedFunctionMetadata(createFunction.schema(), createFunction.name(), createFunction.arguments(), createFunction.returnType(), StringType.INSTANCE.sanitizeValue(eval.apply(createFunction.language())), StringType.INSTANCE.sanitizeValue(eval.apply(createFunction.definition())));
CreateUserDefinedFunctionRequest request = new CreateUserDefinedFunctionRequest(metadata, createFunction.replace());
OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> new Row1(1L));
dependencies.createFunctionAction().execute(request, listener);
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class DropTablePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
TableInfo table = dropTable.table();
DropTableRequest request;
if (table == null) {
if (dropTable.maybeCorrupt()) {
// setting isPartitioned=true should be safe.
// It will delete a template if it exists, and if there is no template it shouldn't do any harm
request = new DropTableRequest(dropTable.tableName(), true);
} else {
// no-op, table is already gone
assert dropTable.dropIfExists() : "If table is null, IF EXISTS flag must have been present";
consumer.accept(InMemoryBatchIterator.of(ROW_ZERO, SENTINEL), null);
return;
}
} else {
boolean isPartitioned = table instanceof DocTableInfo && ((DocTableInfo) table).isPartitioned();
request = new DropTableRequest(table.ident(), isPartitioned);
}
dependencies.transportDropTableAction().execute(request, new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse response) {
if (!response.isAcknowledged() && LOGGER.isWarnEnabled()) {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Dropping table {} was not acknowledged. This could lead to inconsistent state.", dropTable.tableName());
}
}
consumer.accept(InMemoryBatchIterator.of(ROW_ONE, SENTINEL), null);
}
@Override
public void onFailure(Exception e) {
if (dropTable.dropIfExists() && e instanceof IndexNotFoundException) {
consumer.accept(InMemoryBatchIterator.of(ROW_ZERO, SENTINEL), null);
} else {
consumer.accept(null, e);
}
}
});
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class GCDangingArtifactsPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
dependencies.transportActionProvider().transportDeleteIndexAction().execute(new DeleteIndexRequest(IndexParts.DANGLING_INDICES_PREFIX_PATTERNS.toArray(new String[0])), listener);
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportDeleteIndexAction method masterOperation.
@Override
protected void masterOperation(final DeleteIndexRequest request, final ClusterState state, final ActionListener<AcknowledgedResponse> listener) {
final Set<Index> concreteIndices = new HashSet<>(Arrays.asList(indexNameExpressionResolver.concreteIndices(state, request)));
if (concreteIndices.isEmpty()) {
listener.onResponse(new AcknowledgedResponse(true));
return;
}
DeleteIndexClusterStateUpdateRequest deleteRequest = new DeleteIndexClusterStateUpdateRequest().ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout()).indices(concreteIndices.toArray(new Index[concreteIndices.size()]));
deleteIndexService.deleteIndices(deleteRequest, new ActionListener<ClusterStateUpdateResponse>() {
@Override
public void onResponse(ClusterStateUpdateResponse response) {
listener.onResponse(new AcknowledgedResponse(response.isAcknowledged()));
}
@Override
public void onFailure(Exception t) {
logger.debug(() -> new ParameterizedMessage("failed to delete indices [{}]", concreteIndices), t);
listener.onFailure(t);
}
});
}
Aggregations