use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class AlterTableOperation method executeAlterTableAddColumn.
public CompletableFuture<Long> executeAlterTableAddColumn(final BoundAddColumn analysis) {
FutureActionListener<AcknowledgedResponse, Long> result = new FutureActionListener<>(r -> -1L);
if (analysis.newPrimaryKeys() || analysis.hasNewGeneratedColumns()) {
RelationName ident = analysis.table().ident();
String stmt = String.format(Locale.ENGLISH, "SELECT COUNT(*) FROM \"%s\".\"%s\"", ident.schema(), ident.name());
try {
session().quickExec(stmt, new ResultSetReceiver(analysis, result), Row.EMPTY);
} catch (Throwable t) {
result.completeExceptionally(t);
}
} else {
return addColumnToTable(analysis, result);
}
return result;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportCreateTableAction method masterOperation.
@Override
protected void masterOperation(final CreateTableRequest request, final ClusterState state, final ActionListener<CreateTableResponse> listener) {
final RelationName relationName = request.getTableName();
if (viewsExists(relationName, state)) {
listener.onFailure(new RelationAlreadyExists(relationName));
return;
}
if (request.getCreateIndexRequest() != null) {
CreateIndexRequest createIndexRequest = request.getCreateIndexRequest();
ActionListener<CreateIndexResponse> wrappedListener = ActionListener.wrap(response -> listener.onResponse(new CreateTableResponse(response.isShardsAcknowledged())), listener::onFailure);
transportCreateIndexAction.masterOperation(createIndexRequest, state, wrappedListener);
} else if (request.getPutIndexTemplateRequest() != null) {
PutIndexTemplateRequest putIndexTemplateRequest = request.getPutIndexTemplateRequest();
ActionListener<AcknowledgedResponse> wrappedListener = ActionListener.wrap(response -> listener.onResponse(new CreateTableResponse(response.isAcknowledged())), listener::onFailure);
transportPutIndexTemplateAction.masterOperation(putIndexTemplateRequest, state, wrappedListener);
} else {
throw new IllegalStateException("Unknown table request");
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class ShardingUpsertExecutor method createPartitions.
private CompletableFuture<AcknowledgedResponse> createPartitions(Map<String, List<ShardedRequests.ItemAndRoutingAndSourceInfo<ShardUpsertRequest.Item>>> itemsByMissingIndex) {
FutureActionListener<AcknowledgedResponse, AcknowledgedResponse> listener = FutureActionListener.newInstance();
createPartitionsAction.execute(new CreatePartitionsRequest(itemsByMissingIndex.keySet(), jobId), listener);
return listener;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class InsertFromValues method createIndices.
private static CompletableFuture<AcknowledgedResponse> createIndices(TransportCreatePartitionsAction createPartitionsAction, Set<String> indices, ClusterService clusterService, UUID jobId) {
Metadata metadata = clusterService.state().getMetadata();
List<String> indicesToCreate = new ArrayList<>();
for (var index : indices) {
if (IndexParts.isPartitioned(index) && metadata.hasIndex(index) == false) {
indicesToCreate.add(index);
}
}
if (indicesToCreate.isEmpty()) {
return CompletableFuture.completedFuture(new AcknowledgedResponse(true));
}
FutureActionListener<AcknowledgedResponse, AcknowledgedResponse> listener = new FutureActionListener<>(r -> r);
createPartitionsAction.execute(new CreatePartitionsRequest(indicesToCreate, jobId), listener);
return listener;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class SysRepositoriesServiceTest method createRepository.
private void createRepository(String name) {
AcknowledgedResponse putRepositoryResponse = client().admin().cluster().preparePutRepository(name).setType("fs").setSettings(Settings.builder().put("location", new File(TEMP_FOLDER.getRoot(), "backup").getAbsolutePath()).put("chunk_size", "5k").put("compress", false)).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
repositories.add(name);
}
Aggregations