-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Transform] Encapsulate plugin-level settings into a `TransformExtens…
…ion` interface (#98978)
- Loading branch information
1 parent
d3f799c
commit f9e4fa9
Showing
13 changed files
with
182 additions
and
29 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.../transform/src/main/java/org/elasticsearch/xpack/transform/DefaultTransformExtension.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,36 @@ | ||
/* | ||
* 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.transform; | ||
|
||
import org.elasticsearch.cluster.metadata.IndexMetadata; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
||
public class DefaultTransformExtension implements TransformExtension { | ||
|
||
@Override | ||
public boolean includeNodeInfo() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Settings getTransformInternalIndexAdditionalSettings() { | ||
return Settings.EMPTY; | ||
} | ||
|
||
/** | ||
* Provides destination index settings, hardcoded at the moment. In future this might be customizable or generation could be based on | ||
* source settings. | ||
*/ | ||
@Override | ||
public Settings getTransformDestinationIndexSettings() { | ||
return Settings.builder() | ||
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) | ||
.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1") | ||
.build(); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
.../plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtension.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,23 @@ | ||
/* | ||
* 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.transform; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
|
||
public interface TransformExtension { | ||
|
||
boolean includeNodeInfo(); | ||
|
||
Settings getTransformInternalIndexAdditionalSettings(); | ||
|
||
/** | ||
* Provides destination index settings, hardcoded at the moment. In future this might be customizable or generation could be based on | ||
* source settings. | ||
*/ | ||
Settings getTransformDestinationIndexSettings(); | ||
} |
41 changes: 41 additions & 0 deletions
41
...n/transform/src/main/java/org/elasticsearch/xpack/transform/TransformExtensionHolder.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,41 @@ | ||
/* | ||
* 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.transform; | ||
|
||
import org.elasticsearch.node.Node; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Wrapper for the {@link TransformExtension} interface that allows it to be used | ||
* given the way {@link Node} does Guice bindings for plugin components. | ||
* TODO: remove this class entirely once Guice is removed entirely. | ||
*/ | ||
public class TransformExtensionHolder { | ||
|
||
private final TransformExtension transformExtension; | ||
|
||
/** | ||
* Used by Guice. | ||
*/ | ||
public TransformExtensionHolder() { | ||
this.transformExtension = null; | ||
} | ||
|
||
public TransformExtensionHolder(TransformExtension transformExtension) { | ||
this.transformExtension = Objects.requireNonNull(transformExtension); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return transformExtension == null; | ||
} | ||
|
||
public TransformExtension getTransformExtension() { | ||
return transformExtension; | ||
} | ||
} |
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
Oops, something went wrong.