Skip to content

Commit

Permalink
Random binary string as prefix to index uuid
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Oct 11, 2023
1 parent c0852f8 commit 35e6efe
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.Nullable;
import org.opensearch.common.Priority;
import org.opensearch.common.Randomness;
import org.opensearch.common.UUIDs;
import org.opensearch.common.ValidationException;
import org.opensearch.common.compress.CompressedXContent;
Expand Down Expand Up @@ -111,6 +112,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -164,6 +166,7 @@ public class MetadataCreateIndexService {
private final Set<IndexSettingProvider> indexSettingProviders = new HashSet<>();
private final ClusterManagerTaskThrottler.ThrottlingKey createIndexTaskKey;
private AwarenessReplicaBalance awarenessReplicaBalance;
private static final Random RANDOM_INT_GENERATOR = Randomness.get();

public MetadataCreateIndexService(
final Settings settings,
Expand Down Expand Up @@ -889,7 +892,7 @@ static Settings aggregateIndexSettings(
indexSettingsBuilder.put(SETTING_CREATION_DATE, Instant.now().toEpochMilli());
}
indexSettingsBuilder.put(IndexMetadata.SETTING_INDEX_PROVIDED_NAME, request.getProvidedName());
indexSettingsBuilder.put(SETTING_INDEX_UUID, UUIDs.randomBase64UUID());
indexSettingsBuilder.put(SETTING_INDEX_UUID, Integer.toBinaryString(RANDOM_INT_GENERATOR.nextInt(256)) + UUIDs.randomBase64UUID());

updateReplicationStrategy(indexSettingsBuilder, request.settings(), settings);
updateRemoteStoreSettings(indexSettingsBuilder, settings);
Expand Down

0 comments on commit 35e6efe

Please sign in to comment.