Search in sources :

Example 1 with TestCustomMetadata

use of org.opensearch.test.TestCustomMetadata in project OpenSearch by opensearch-project.

the class ClusterChangedEventTests method nextState.

private static ClusterState nextState(final ClusterState previousState, List<TestCustomMetadata> customMetadataList) {
    final ClusterState.Builder builder = ClusterState.builder(previousState);
    builder.stateUUID(UUIDs.randomBase64UUID());
    Metadata.Builder metadataBuilder = new Metadata.Builder(previousState.metadata());
    for (ObjectObjectCursor<String, Metadata.Custom> customMetadata : previousState.metadata().customs()) {
        if (customMetadata.value instanceof TestCustomMetadata) {
            metadataBuilder.removeCustom(customMetadata.key);
        }
    }
    for (TestCustomMetadata testCustomMetadata : customMetadataList) {
        metadataBuilder.putCustom(testCustomMetadata.getWriteableName(), testCustomMetadata);
    }
    builder.metadata(metadataBuilder);
    return builder.build();
}
Also used : TestCustomMetadata(org.opensearch.test.TestCustomMetadata) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) TestCustomMetadata(org.opensearch.test.TestCustomMetadata)

Aggregations

IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)1 Metadata (org.opensearch.cluster.metadata.Metadata)1 TestCustomMetadata (org.opensearch.test.TestCustomMetadata)1