|
@@ -6,9 +6,11 @@
|
|
|
|
|
|
package org.elasticsearch.xpack.ccr;
|
|
|
|
|
|
+import org.apache.lucene.util.SetOnce;
|
|
|
import org.elasticsearch.action.ActionRequest;
|
|
|
import org.elasticsearch.action.ActionResponse;
|
|
|
import org.elasticsearch.client.Client;
|
|
|
+import org.elasticsearch.client.node.NodeClient;
|
|
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|
|
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|
|
import org.elasticsearch.cluster.service.ClusterService;
|
|
@@ -32,6 +34,8 @@ import org.elasticsearch.plugins.ActionPlugin;
|
|
|
import org.elasticsearch.plugins.EnginePlugin;
|
|
|
import org.elasticsearch.plugins.PersistentTaskPlugin;
|
|
|
import org.elasticsearch.plugins.Plugin;
|
|
|
+import org.elasticsearch.plugins.RepositoryPlugin;
|
|
|
+import org.elasticsearch.repositories.Repository;
|
|
|
import org.elasticsearch.rest.RestController;
|
|
|
import org.elasticsearch.rest.RestHandler;
|
|
|
import org.elasticsearch.script.ScriptService;
|
|
@@ -41,46 +45,50 @@ import org.elasticsearch.threadpool.FixedExecutorBuilder;
|
|
|
import org.elasticsearch.threadpool.ThreadPool;
|
|
|
import org.elasticsearch.watcher.ResourceWatcherService;
|
|
|
import org.elasticsearch.xpack.ccr.action.AutoFollowCoordinator;
|
|
|
-import org.elasticsearch.xpack.ccr.action.TransportGetAutoFollowPatternAction;
|
|
|
-import org.elasticsearch.xpack.ccr.action.TransportUnfollowAction;
|
|
|
-import org.elasticsearch.xpack.ccr.rest.RestGetAutoFollowPatternAction;
|
|
|
-import org.elasticsearch.xpack.ccr.action.TransportCcrStatsAction;
|
|
|
-import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction;
|
|
|
-import org.elasticsearch.xpack.ccr.rest.RestUnfollowAction;
|
|
|
-import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
|
|
|
-import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction;
|
|
|
-import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction;
|
|
|
-import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.ShardChangesAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.ShardFollowTask;
|
|
|
import org.elasticsearch.xpack.ccr.action.ShardFollowTasksExecutor;
|
|
|
+import org.elasticsearch.xpack.ccr.action.TransportCcrStatsAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.TransportDeleteAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.TransportFollowStatsAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.TransportGetAutoFollowPatternAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.TransportPauseFollowAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.TransportPutAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.TransportPutFollowAction;
|
|
|
-import org.elasticsearch.xpack.ccr.action.TransportDeleteAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.TransportResumeFollowAction;
|
|
|
-import org.elasticsearch.xpack.ccr.action.TransportPutAutoFollowPatternAction;
|
|
|
-import org.elasticsearch.xpack.ccr.action.TransportPauseFollowAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.TransportUnfollowAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.bulk.BulkShardOperationsAction;
|
|
|
import org.elasticsearch.xpack.ccr.action.bulk.TransportBulkShardOperationsAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.repositories.DeleteInternalCcrRepositoryAction;
|
|
|
+import org.elasticsearch.xpack.ccr.action.repositories.PutInternalCcrRepositoryAction;
|
|
|
import org.elasticsearch.xpack.ccr.index.engine.FollowingEngineFactory;
|
|
|
+import org.elasticsearch.xpack.ccr.repository.CcrRepository;
|
|
|
+import org.elasticsearch.xpack.ccr.rest.RestCcrStatsAction;
|
|
|
+import org.elasticsearch.xpack.ccr.rest.RestDeleteAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.rest.RestFollowStatsAction;
|
|
|
+import org.elasticsearch.xpack.ccr.rest.RestGetAutoFollowPatternAction;
|
|
|
+import org.elasticsearch.xpack.ccr.rest.RestPauseFollowAction;
|
|
|
+import org.elasticsearch.xpack.ccr.rest.RestPutAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.rest.RestPutFollowAction;
|
|
|
-import org.elasticsearch.xpack.ccr.rest.RestDeleteAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.ccr.rest.RestResumeFollowAction;
|
|
|
-import org.elasticsearch.xpack.ccr.rest.RestPutAutoFollowPatternAction;
|
|
|
-import org.elasticsearch.xpack.ccr.rest.RestPauseFollowAction;
|
|
|
+import org.elasticsearch.xpack.ccr.rest.RestUnfollowAction;
|
|
|
import org.elasticsearch.xpack.core.XPackPlugin;
|
|
|
import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus;
|
|
|
+import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
|
|
|
+import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
|
|
|
+import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction;
|
|
|
+import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction;
|
|
|
+import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction;
|
|
|
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
|
|
|
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
|
|
|
-import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction;
|
|
|
import org.elasticsearch.xpack.core.ccr.action.UnfollowAction;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
import java.util.function.Supplier;
|
|
@@ -92,7 +100,7 @@ import static org.elasticsearch.xpack.core.XPackSettings.CCR_ENABLED_SETTING;
|
|
|
/**
|
|
|
* Container class for CCR functionality.
|
|
|
*/
|
|
|
-public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, EnginePlugin {
|
|
|
+public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, EnginePlugin, RepositoryPlugin {
|
|
|
|
|
|
public static final String CCR_THREAD_POOL_NAME = "ccr";
|
|
|
public static final String CCR_CUSTOM_METADATA_KEY = "ccr";
|
|
@@ -104,6 +112,7 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
|
|
|
private final boolean enabled;
|
|
|
private final Settings settings;
|
|
|
private final CcrLicenseChecker ccrLicenseChecker;
|
|
|
+ private final SetOnce<CcrRepositoryManager> repositoryManager = new SetOnce<>();
|
|
|
|
|
|
/**
|
|
|
* Construct an instance of the CCR container with the specified settings.
|
|
@@ -142,6 +151,8 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
|
|
|
return emptyList();
|
|
|
}
|
|
|
|
|
|
+ this.repositoryManager.set(new CcrRepositoryManager(settings, clusterService, (NodeClient) client));
|
|
|
+
|
|
|
return Arrays.asList(
|
|
|
ccrLicenseChecker,
|
|
|
new AutoFollowCoordinator(settings, client, threadPool, clusterService, ccrLicenseChecker)
|
|
@@ -166,6 +177,10 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
|
|
|
// internal actions
|
|
|
new ActionHandler<>(BulkShardOperationsAction.INSTANCE, TransportBulkShardOperationsAction.class),
|
|
|
new ActionHandler<>(ShardChangesAction.INSTANCE, ShardChangesAction.TransportAction.class),
|
|
|
+ new ActionHandler<>(PutInternalCcrRepositoryAction.INSTANCE,
|
|
|
+ PutInternalCcrRepositoryAction.TransportPutInternalRepositoryAction.class),
|
|
|
+ new ActionHandler<>(DeleteInternalCcrRepositoryAction.INSTANCE,
|
|
|
+ DeleteInternalCcrRepositoryAction.TransportDeleteInternalRepositoryAction.class),
|
|
|
// stats action
|
|
|
new ActionHandler<>(FollowStatsAction.INSTANCE, TransportFollowStatsAction.class),
|
|
|
new ActionHandler<>(CcrStatsAction.INSTANCE, TransportCcrStatsAction.class),
|
|
@@ -259,6 +274,12 @@ public class Ccr extends Plugin implements ActionPlugin, PersistentTaskPlugin, E
|
|
|
return Collections.singletonList(new FixedExecutorBuilder(settings, CCR_THREAD_POOL_NAME, 32, 100, "xpack.ccr.ccr_thread_pool"));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Repository.Factory> getInternalRepositories(Environment env, NamedXContentRegistry namedXContentRegistry) {
|
|
|
+ Repository.Factory repositoryFactory = (metadata) -> new CcrRepository(metadata, settings);
|
|
|
+ return Collections.singletonMap(CcrRepository.TYPE, repositoryFactory);
|
|
|
+ }
|
|
|
+
|
|
|
protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); }
|
|
|
|
|
|
}
|