Search in sources :

Example 11 with Tuple

use of org.opensearch.common.collect.Tuple in project OpenSearch by opensearch-project.

the class Netty4HttpPipeliningHandler method close.

@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) {
    List<Tuple<HttpPipelinedResponse, ChannelPromise>> inflightResponses = aggregator.removeAllInflightResponses();
    if (inflightResponses.isEmpty() == false) {
        ClosedChannelException closedChannelException = new ClosedChannelException();
        for (Tuple<HttpPipelinedResponse, ChannelPromise> inflightResponse : inflightResponses) {
            try {
                inflightResponse.v2().setFailure(closedChannelException);
            } catch (RuntimeException e) {
                logger.error("unexpected error while releasing pipelined http responses", e);
            }
        }
    }
    ctx.close(promise);
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) HttpPipelinedResponse(org.opensearch.http.HttpPipelinedResponse) ChannelPromise(io.netty.channel.ChannelPromise) Tuple(org.opensearch.common.collect.Tuple)

Example 12 with Tuple

use of org.opensearch.common.collect.Tuple in project OpenSearch by opensearch-project.

the class AzureStorageCleanupThirdPartyTests method ensureSasTokenPermissions.

private void ensureSasTokenPermissions() {
    final BlobStoreRepository repository = getRepository();
    final PlainActionFuture<Void> future = PlainActionFuture.newFuture();
    repository.threadPool().generic().execute(ActionRunnable.wrap(future, l -> {
        final AzureBlobStore blobStore = (AzureBlobStore) repository.blobStore();
        final String account = "default";
        final Tuple<BlobServiceClient, Supplier<Context>> client = blobStore.getService().client(account);
        final BlobContainerClient blobContainer = client.v1().getBlobContainerClient(blobStore.toString());
        try {
            SocketAccess.doPrivilegedException(() -> blobContainer.existsWithResponse(null, client.v2().get()));
            future.onFailure(new RuntimeException("The SAS token used in this test allowed for checking container existence. This test only supports tokens " + "that grant only the documented permission requirements for the Azure repository plugin."));
        } catch (BlobStorageException e) {
            if (e.getStatusCode() == HttpURLConnection.HTTP_FORBIDDEN) {
                future.onResponse(null);
            } else {
                future.onFailure(e);
            }
        }
    }));
    future.actionGet();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Matchers.blankOrNullString(org.hamcrest.Matchers.blankOrNullString) AfterClass(org.junit.AfterClass) BlobStoreRepository(org.opensearch.repositories.blobstore.BlobStoreRepository) Context(com.azure.core.util.Context) BlobContainerClient(com.azure.storage.blob.BlobContainerClient) BlobStorageException(com.azure.storage.blob.models.BlobStorageException) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) ActionRunnable(org.opensearch.action.ActionRunnable) Collection(java.util.Collection) AbstractThirdPartyRepositoryTestCase(org.opensearch.repositories.AbstractThirdPartyRepositoryTestCase) Matchers.not(org.hamcrest.Matchers.not) Settings(org.opensearch.common.settings.Settings) Supplier(java.util.function.Supplier) Plugin(org.opensearch.plugins.Plugin) Strings(org.opensearch.common.Strings) Tuple(org.opensearch.common.collect.Tuple) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) SecureSettings(org.opensearch.common.settings.SecureSettings) BlobServiceClient(com.azure.storage.blob.BlobServiceClient) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Schedulers(reactor.core.scheduler.Schedulers) Context(com.azure.core.util.Context) BlobContainerClient(com.azure.storage.blob.BlobContainerClient) BlobStoreRepository(org.opensearch.repositories.blobstore.BlobStoreRepository) Matchers.blankOrNullString(org.hamcrest.Matchers.blankOrNullString) BlobStorageException(com.azure.storage.blob.models.BlobStorageException) Tuple(org.opensearch.common.collect.Tuple)

Example 13 with Tuple

use of org.opensearch.common.collect.Tuple in project OpenSearch by opensearch-project.

the class IndexingPressureIT method getPrimaryReplicaNodeNames.

private Tuple<String, String> getPrimaryReplicaNodeNames() {
    IndicesStatsResponse response = client().admin().indices().prepareStats(INDEX_NAME).get();
    String primaryId = Stream.of(response.getShards()).map(ShardStats::getShardRouting).filter(ShardRouting::primary).findAny().get().currentNodeId();
    String replicaId = Stream.of(response.getShards()).map(ShardStats::getShardRouting).filter(sr -> sr.primary() == false).findAny().get().currentNodeId();
    DiscoveryNodes nodes = client().admin().cluster().prepareState().get().getState().nodes();
    String primaryName = nodes.get(primaryId).getName();
    String replicaName = nodes.get(replicaId).getName();
    return new Tuple<>(primaryName, replicaName);
}
Also used : ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Arrays(java.util.Arrays) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) IndexResponse(org.opensearch.action.index.IndexResponse) ThreadPool(org.opensearch.threadpool.ThreadPool) BulkRequest(org.opensearch.action.bulk.BulkRequest) Releasable(org.opensearch.common.lease.Releasable) MockTransportService(org.opensearch.test.transport.MockTransportService) InternalTestCluster(org.opensearch.test.InternalTestCluster) ArrayList(java.util.ArrayList) TransportShardBulkAction(org.opensearch.action.bulk.TransportShardBulkAction) InternalSettingsPlugin(org.opensearch.test.InternalSettingsPlugin) UUIDs(org.opensearch.common.UUIDs) OpenSearchAssertions.assertAcked(org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked) Collection(java.util.Collection) Settings(org.opensearch.common.settings.Settings) TransportService(org.opensearch.transport.TransportService) Plugin(org.opensearch.plugins.Plugin) ActionFuture(org.opensearch.action.ActionFuture) Tuple(org.opensearch.common.collect.Tuple) ShardRouting(org.opensearch.cluster.routing.ShardRouting) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) CountDownLatch(java.util.concurrent.CountDownLatch) Stream(java.util.stream.Stream) BulkResponse(org.opensearch.action.bulk.BulkResponse) IndicesStatsResponse(org.opensearch.action.admin.indices.stats.IndicesStatsResponse) ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) IndexRequest(org.opensearch.action.index.IndexRequest) OpenSearchIntegTestCase(org.opensearch.test.OpenSearchIntegTestCase) Collections(java.util.Collections) IndicesStatsResponse(org.opensearch.action.admin.indices.stats.IndicesStatsResponse) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Tuple(org.opensearch.common.collect.Tuple)

Example 14 with Tuple

use of org.opensearch.common.collect.Tuple in project OpenSearch by opensearch-project.

the class ShardIndexingPressureIT method getPrimaryReplicaNodeNames.

private Tuple<String, String> getPrimaryReplicaNodeNames(String indexName) {
    IndicesStatsResponse response = client().admin().indices().prepareStats(indexName).get();
    String primaryId = Stream.of(response.getShards()).map(ShardStats::getShardRouting).filter(ShardRouting::primary).findAny().get().currentNodeId();
    String replicaId = Stream.of(response.getShards()).map(ShardStats::getShardRouting).filter(sr -> sr.primary() == false).findAny().get().currentNodeId();
    DiscoveryNodes nodes = client().admin().cluster().prepareState().get().getState().nodes();
    String primaryName = nodes.get(primaryId).getName();
    String replicaName = nodes.get(replicaId).getName();
    return new Tuple<>(primaryName, replicaName);
}
Also used : ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Arrays(java.util.Arrays) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) ThreadPool(org.opensearch.threadpool.ThreadPool) BulkRequest(org.opensearch.action.bulk.BulkRequest) Releasable(org.opensearch.common.lease.Releasable) MockTransportService(org.opensearch.test.transport.MockTransportService) InternalTestCluster(org.opensearch.test.InternalTestCluster) TransportShardBulkAction(org.opensearch.action.bulk.TransportShardBulkAction) InternalSettingsPlugin(org.opensearch.test.InternalSettingsPlugin) UUIDs(org.opensearch.common.UUIDs) BulkItemRequest(org.opensearch.action.bulk.BulkItemRequest) OpenSearchAssertions.assertAcked(org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked) BulkShardRequest(org.opensearch.action.bulk.BulkShardRequest) Collection(java.util.Collection) IndicesService(org.opensearch.indices.IndicesService) Settings(org.opensearch.common.settings.Settings) TransportService(org.opensearch.transport.TransportService) Plugin(org.opensearch.plugins.Plugin) ActionFuture(org.opensearch.action.ActionFuture) Tuple(org.opensearch.common.collect.Tuple) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardId(org.opensearch.index.shard.ShardId) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) RamUsageEstimator(org.apache.lucene.util.RamUsageEstimator) CountDownLatch(java.util.concurrent.CountDownLatch) Stream(java.util.stream.Stream) BulkResponse(org.opensearch.action.bulk.BulkResponse) Matchers.equalTo(org.hamcrest.Matchers.equalTo) IndicesStatsResponse(org.opensearch.action.admin.indices.stats.IndicesStatsResponse) ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) IndexRequest(org.opensearch.action.index.IndexRequest) OpenSearchIntegTestCase(org.opensearch.test.OpenSearchIntegTestCase) Collections(java.util.Collections) IndicesStatsResponse(org.opensearch.action.admin.indices.stats.IndicesStatsResponse) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Tuple(org.opensearch.common.collect.Tuple)

Example 15 with Tuple

use of org.opensearch.common.collect.Tuple in project OpenSearch by opensearch-project.

the class ShardIndexingPressureSettingsIT method getPrimaryReplicaNodeNames.

private Tuple<String, String> getPrimaryReplicaNodeNames(String indexName) {
    IndicesStatsResponse response = client().admin().indices().prepareStats(indexName).get();
    String primaryId = Stream.of(response.getShards()).map(ShardStats::getShardRouting).filter(ShardRouting::primary).findAny().get().currentNodeId();
    String replicaId = Stream.of(response.getShards()).map(ShardStats::getShardRouting).filter(sr -> sr.primary() == false).findAny().get().currentNodeId();
    DiscoveryNodes nodes = client().admin().cluster().prepareState().get().getState().nodes();
    String primaryName = nodes.get(primaryId).getName();
    String replicaName = nodes.get(replicaId).getName();
    return new Tuple<>(primaryName, replicaName);
}
Also used : ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) OpenSearchRejectedExecutionException(org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Arrays(java.util.Arrays) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) ThreadPool(org.opensearch.threadpool.ThreadPool) BulkRequest(org.opensearch.action.bulk.BulkRequest) ClusterUpdateSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Releasable(org.opensearch.common.lease.Releasable) MockTransportService(org.opensearch.test.transport.MockTransportService) InternalTestCluster(org.opensearch.test.InternalTestCluster) TransportShardBulkAction(org.opensearch.action.bulk.TransportShardBulkAction) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) InternalSettingsPlugin(org.opensearch.test.InternalSettingsPlugin) UUIDs(org.opensearch.common.UUIDs) BulkItemRequest(org.opensearch.action.bulk.BulkItemRequest) OpenSearchAssertions.assertAcked(org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked) BulkShardRequest(org.opensearch.action.bulk.BulkShardRequest) Collection(java.util.Collection) IndicesService(org.opensearch.indices.IndicesService) Settings(org.opensearch.common.settings.Settings) TransportService(org.opensearch.transport.TransportService) Plugin(org.opensearch.plugins.Plugin) ActionFuture(org.opensearch.action.ActionFuture) Tuple(org.opensearch.common.collect.Tuple) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardId(org.opensearch.index.shard.ShardId) RamUsageEstimator(org.apache.lucene.util.RamUsageEstimator) CountDownLatch(java.util.concurrent.CountDownLatch) Stream(java.util.stream.Stream) BulkResponse(org.opensearch.action.bulk.BulkResponse) IndicesStatsResponse(org.opensearch.action.admin.indices.stats.IndicesStatsResponse) ShardStats(org.opensearch.action.admin.indices.stats.ShardStats) IndexRequest(org.opensearch.action.index.IndexRequest) OpenSearchIntegTestCase(org.opensearch.test.OpenSearchIntegTestCase) Collections(java.util.Collections) IndicesStatsResponse(org.opensearch.action.admin.indices.stats.IndicesStatsResponse) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) Tuple(org.opensearch.common.collect.Tuple)

Aggregations

Tuple (org.opensearch.common.collect.Tuple)151 ArrayList (java.util.ArrayList)65 List (java.util.List)49 IOException (java.io.IOException)45 Collections (java.util.Collections)44 HashMap (java.util.HashMap)40 Map (java.util.Map)40 Settings (org.opensearch.common.settings.Settings)38 ClusterState (org.opensearch.cluster.ClusterState)34 HashSet (java.util.HashSet)28 ShardId (org.opensearch.index.shard.ShardId)28 Arrays (java.util.Arrays)27 Collectors (java.util.stream.Collectors)26 Set (java.util.Set)25 Index (org.opensearch.index.Index)25 BytesReference (org.opensearch.common.bytes.BytesReference)24 OpenSearchTestCase (org.opensearch.test.OpenSearchTestCase)24 CountDownLatch (java.util.concurrent.CountDownLatch)22 Version (org.opensearch.Version)21 Strings (org.opensearch.common.Strings)21