-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HLRC: Add Lifecycle delete to the HLRC #33142
Changes from 3 commits
2085d31
b3cd4c3
60eb043
3f02774
7b14f1b
4c6a5c6
24c2f6a
5f8e8d0
6681ccc
b65b83b
95dce78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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; | ||
|
||
// TODO: This class exists as a stopgap to allow progress in the new HLRC structure. | ||
// It should be replaced with a version of MasterNodeRequest that will likely be | ||
// created when everything is moved from o.e.xpack.protocol to o.e.client. | ||
public abstract class MasterTimeoutRequest<Request> implements Validatable { | ||
|
||
public static final TimeValue DEFAULT_MASTER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30); | ||
|
||
protected TimeValue timeout = DEFAULT_MASTER_NODE_TIMEOUT; | ||
|
||
@SuppressWarnings("unchecked") | ||
public Request masterNodeTimeout(TimeValue timeout) { | ||
this.timeout = timeout; | ||
return (Request) this; | ||
} | ||
|
||
/** | ||
* A timeout value in case the master has not been discovered yet or disconnected. | ||
*/ | ||
public final Request masterNodeTimeout(String timeout) { | ||
return masterNodeTimeout(TimeValue.parseTimeValue(timeout, null, getClass().getSimpleName() + ".masterNodeTimeout")); | ||
} | ||
|
||
public TimeValue masterNodeTimeout() { | ||
return timeout; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.MasterTimeoutRequest; | ||
|
||
import java.util.Objects; | ||
|
||
public class DeleteLifecycleRequest extends MasterTimeoutRequest<DeleteLifecycleRequest> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The transport based APIs extend (this does not) Curious if is this is intentional ? The javadoc for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I based So, to answer your question: It was intentional, but it's possible I intended the wrong thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I talked to @hub-cap on Slack and his answer was that these timeouts should be based on the parameters that the requests can take. To determine this, there should be a (Just waiting on some more feedback to make this change) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gwbrown Thanks for following up. I am working a similar issue and will follow your lead here. |
||
|
||
private final String lifecycle; | ||
|
||
public DeleteLifecycleRequest(String lifecycle) { | ||
this.lifecycle = Objects.requireNonNull(lifecycle, "lifecycle cannot be null"); | ||
} | ||
|
||
public String getLifecycle() { | ||
return lifecycle; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
DeleteLifecycleRequest that = (DeleteLifecycleRequest) o; | ||
return Objects.equals(getLifecycle(), that.getLifecycle()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getLifecycle()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.test.ESTestCase; | ||
|
||
public class DeleteLifecycleRequestTests extends ESTestCase { | ||
|
||
private DeleteLifecycleRequest createTestInstance() { | ||
return new DeleteLifecycleRequest(randomAlphaOfLengthBetween(2, 20)); | ||
} | ||
|
||
public void testValidate() { | ||
DeleteLifecycleRequest req = createTestInstance(); | ||
assertTrue(req.validate() == null || req.validate().validationErrors().size() == 0); | ||
|
||
} | ||
|
||
public void testValidationFailure() { | ||
try { | ||
DeleteLifecycleRequest req = new DeleteLifecycleRequest(null); | ||
fail("should not be able to create a DeleteLifecycleRequest with null lifecycle name"); | ||
} catch (NullPointerException exception) { | ||
// ok | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Delete
Index
LifecycleRequest ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I saw, the classes with names including
IndexLifecycle
seem to relate to index<->lifecycle policy relationships (i.e. lifecycleA
applies to indexB
), but ones with justLifecycle
relate to the management of lifecycles. If that's correct, this class is named correctly.@dakrone, can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
DeleteLifecyclePolicyRequest
to indicate that the policy is going to be removed, and thenDeleteIndexLifecycleRequest
is for when we are removing a lifecycle from an index