-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for index create block in OpenSearch
Signed-off-by: Rishav Sagar <[email protected]>
- Loading branch information
Rishav Sagar
committed
Sep 27, 2022
1 parent
bb47419
commit 6dee99c
Showing
11 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
server/src/internalClusterTest/java/org/opensearch/blocks/CreateIndexBlockIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.blocks; | ||
|
||
import org.opensearch.cluster.metadata.Metadata; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import static org.opensearch.test.OpenSearchIntegTestCase.client; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertBlocked; | ||
|
||
public class CreateIndexBlockIT extends OpenSearchIntegTestCase { | ||
|
||
public void testBlockCreateIndex() { | ||
try { | ||
setCreateIndexBlock("true"); | ||
assertBlocked(client().admin().indices().prepareCreate("diskguardrails1"), Metadata.CLUSTER_CREATE_INDEX_BLOCK); | ||
} finally { | ||
setCreateIndexBlock("false"); | ||
assertAcked(client().admin().indices().prepareCreate("diskguardrails2").execute().actionGet()); | ||
} | ||
|
||
} | ||
|
||
private void setCreateIndexBlock(String value) { | ||
Settings settings = Settings.builder().put(Metadata.SETTING_CREATE_INDEX_BLOCK.getKey(), value).build(); | ||
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings).get()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
server/src/main/java/org/opensearch/cluster/block/IndexCreateBlockException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster.block; | ||
|
||
import org.opensearch.common.io.stream.StreamInput; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
/** | ||
* Internal exception on obtaining an index create block | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class IndexCreateBlockException extends ClusterBlockException { | ||
|
||
public IndexCreateBlockException(Set<ClusterBlock> globalLevelBlocks) { | ||
super(globalLevelBlocks); | ||
} | ||
|
||
public IndexCreateBlockException(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters