-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Feature usage actions for archive #83931
Merged
+331
−77
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
121fbaf
Feature usage actions for archive
ywelsch 9f74e7a
no snapshot build condition anymore
ywelsch 4c1bb9e
bla
ywelsch c50323c
asdasf
ywelsch ce74045
allowlist
ywelsch 82aada8
Merge remote-tracking branch 'elastic/master' into archive-feature-usage
ywelsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
73 changes: 73 additions & 0 deletions
73
...lugin/core/src/main/java/org/elasticsearch/xpack/core/archive/ArchiveFeatureSetUsage.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,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.archive; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.xcontent.ToXContent; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
import org.elasticsearch.xpack.core.XPackFeatureSet; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class ArchiveFeatureSetUsage extends XPackFeatureSet.Usage { | ||
|
||
private final int numberOfArchiveIndices; | ||
|
||
public ArchiveFeatureSetUsage(StreamInput input) throws IOException { | ||
super(input); | ||
numberOfArchiveIndices = input.readVInt(); | ||
} | ||
|
||
@Override | ||
public Version getMinimalSupportedVersion() { | ||
return Version.V_8_2_0; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeVInt(numberOfArchiveIndices); | ||
} | ||
|
||
public ArchiveFeatureSetUsage(boolean available, int numberOfArchiveIndices) { | ||
super(XPackField.ARCHIVE, available, true); | ||
this.numberOfArchiveIndices = numberOfArchiveIndices; | ||
} | ||
|
||
public int getNumberOfArchiveIndices() { | ||
return numberOfArchiveIndices; | ||
} | ||
|
||
@Override | ||
protected void innerXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
super.innerXContent(builder, params); | ||
builder.field("indices_count", numberOfArchiveIndices); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(available, enabled, numberOfArchiveIndices); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
ArchiveFeatureSetUsage other = (ArchiveFeatureSetUsage) obj; | ||
return available == other.available && enabled == other.enabled && numberOfArchiveIndices == other.numberOfArchiveIndices; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
.../core/src/test/java/org/elasticsearch/xpack/core/archive/ArchiveFeatureSetUsageTests.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,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.core.archive; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class ArchiveFeatureSetUsageTests extends AbstractWireSerializingTestCase<ArchiveFeatureSetUsage> { | ||
|
||
@Override | ||
protected ArchiveFeatureSetUsage createTestInstance() { | ||
boolean available = randomBoolean(); | ||
return new ArchiveFeatureSetUsage(available, randomIntBetween(0, 100000)); | ||
} | ||
|
||
@Override | ||
protected ArchiveFeatureSetUsage mutateInstance(ArchiveFeatureSetUsage instance) throws IOException { | ||
boolean available = instance.available(); | ||
int numArchiveIndices = instance.getNumberOfArchiveIndices(); | ||
switch (between(0, 1)) { | ||
case 0 -> available = available == false; | ||
case 1 -> numArchiveIndices = randomValueOtherThan(numArchiveIndices, () -> randomIntBetween(0, 100000)); | ||
default -> throw new AssertionError("Illegal randomisation branch"); | ||
} | ||
return new ArchiveFeatureSetUsage(available, numArchiveIndices); | ||
} | ||
|
||
@Override | ||
protected Writeable.Reader<ArchiveFeatureSetUsage> instanceReader() { | ||
return ArchiveFeatureSetUsage::new; | ||
} | ||
|
||
} |
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
44 changes: 44 additions & 0 deletions
44
...versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/ArchiveInfoTransportAction.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,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.lucene.bwc; | ||
|
||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.license.XPackLicenseState; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; | ||
|
||
import static org.elasticsearch.xpack.lucene.bwc.OldLuceneVersions.ARCHIVE_FEATURE; | ||
|
||
public class ArchiveInfoTransportAction extends XPackInfoFeatureTransportAction { | ||
|
||
private final XPackLicenseState licenseState; | ||
|
||
@Inject | ||
public ArchiveInfoTransportAction(TransportService transportService, ActionFilters actionFilters, XPackLicenseState licenseState) { | ||
super(XPackInfoFeatureAction.ARCHIVE.name(), transportService, actionFilters); | ||
this.licenseState = licenseState; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return XPackField.ARCHIVE; | ||
} | ||
|
||
@Override | ||
public boolean available() { | ||
return ARCHIVE_FEATURE.checkWithoutTracking(licenseState); | ||
} | ||
|
||
@Override | ||
public boolean enabled() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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've removed this condition as part of this PR. As we're going to release the feature in 8.2.0, no need to keep this condition.