Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HLRC: Add ILM Status to HLRC (#33283)
Adds support for the Index Lifecycle Management Status to the Java High-Level Rest Client. Relates to #33100
- Loading branch information
1 parent
023e1bf
commit 8b8ff2b
Showing
11 changed files
with
294 additions
and
21 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
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
28 changes: 28 additions & 0 deletions
28
...c/main/java/org/elasticsearch/client/indexlifecycle/LifecycleManagementStatusRequest.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,28 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.indexlifecycle; | ||
|
||
import org.elasticsearch.client.TimedRequest; | ||
|
||
/** | ||
* A {@link TimedRequest} to get the current status of index lifecycle management. | ||
*/ | ||
public class LifecycleManagementStatusRequest extends TimedRequest { | ||
} |
68 changes: 68 additions & 0 deletions
68
.../main/java/org/elasticsearch/client/indexlifecycle/LifecycleManagementStatusResponse.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,68 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.indexlifecycle; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* The current status of index lifecycle management. See {@link OperationMode} for available statuses. | ||
*/ | ||
public class LifecycleManagementStatusResponse { | ||
|
||
private final OperationMode operationMode; | ||
private static final String OPERATION_MODE = "operation_mode"; | ||
@SuppressWarnings("unchecked") | ||
private static final ConstructingObjectParser<LifecycleManagementStatusResponse, Void> PARSER = new ConstructingObjectParser<>( | ||
OPERATION_MODE, a -> new LifecycleManagementStatusResponse((String) a[0])); | ||
|
||
static { | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField(OPERATION_MODE)); | ||
} | ||
|
||
//package private for testing | ||
LifecycleManagementStatusResponse(String operationMode) { | ||
this.operationMode = OperationMode.fromString(operationMode); | ||
} | ||
|
||
public OperationMode getOperationMode() { | ||
return operationMode; | ||
} | ||
|
||
public static LifecycleManagementStatusResponse fromXContent(XContentParser parser) { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
LifecycleManagementStatusResponse that = (LifecycleManagementStatusResponse) o; | ||
return operationMode == that.operationMode; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(operationMode); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
client/rest-high-level/src/test/java/org/elasticsearch/client/TimedRequestTests.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,42 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.test.ESTestCase; | ||
|
||
public class TimedRequestTests extends ESTestCase { | ||
|
||
public void testDefaults() { | ||
TimedRequest timedRequest = new TimedRequest(){}; | ||
assertEquals(timedRequest.timeout(), TimedRequest.DEFAULT_TIMEOUT); | ||
assertEquals(timedRequest.masterNodeTimeout(), TimedRequest.DEFAULT_MASTER_TIMEOUT); | ||
} | ||
|
||
public void testNonDefaults() { | ||
TimedRequest timedRequest = new TimedRequest(){}; | ||
TimeValue timeout = TimeValue.timeValueSeconds(randomIntBetween(0, 1000)); | ||
TimeValue masterTimeout = TimeValue.timeValueSeconds(randomIntBetween(0,1000)); | ||
timedRequest.setTimeout(timeout); | ||
timedRequest.setMasterTimeout(masterTimeout); | ||
assertEquals(timedRequest.timeout(), timeout); | ||
assertEquals(timedRequest.masterNodeTimeout(), masterTimeout); | ||
} | ||
} |
Oops, something went wrong.