5656import org.opensearch.plugins.IdentityAwarePlugin;
5757import org.opensearch.plugins.Plugin;
5858import org.opensearch.plugins.SystemIndexPlugin;
59- import org.opensearch.remote.metadata.client.SdkClient;
60- import org.opensearch.remote.metadata.client.impl.SdkClientFactory;
6159import org.opensearch.repositories.RepositoriesService;
6260import org.opensearch.rest.RestController;
6361import org.opensearch.script.ScriptService;
7270import java.util.Map;
7371import java.util.Set;
7472import java.util.Collection;
75- import java.util.Collections;
7673import java.util.List;
7774import java.util.ArrayList;
7875import java.util.function.Supplier;
7976
80- import static org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_ENDPOINT_KEY;
81- import static org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_REGION_KEY;
82- import static org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_SERVICE_NAME_KEY;
83- import static org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_TYPE_KEY;
84- import static org.opensearch.remote.metadata.common.CommonValue.TENANT_AWARE_KEY;
85- import static org.opensearch.remote.metadata.common.CommonValue.TENANT_ID_FIELD_KEY;
86-
8777public class JobSchedulerPlugin extends Plugin implements ActionPlugin, ExtensiblePlugin, SystemIndexPlugin, IdentityAwarePlugin {
8878
8979 public static final String OPEN_DISTRO_JOB_SCHEDULER_THREAD_POOL_NAME = "open_distro_job_scheduler";
9080 public static final String JS_BASE_URI = "/_plugins/_job_scheduler";
91- public static final String TENANT_ID_FIELD = "tenant_id";
9281
9382 private static final Logger log = LogManager.getLogger(JobSchedulerPlugin.class);
9483 private JobSweeper sweeper;
@@ -98,7 +87,6 @@ public class JobSchedulerPlugin extends Plugin implements ActionPlugin, Extensib
9887 private Map<String, ScheduledJobProvider> indexToJobProviders;
9988 private Set<String> indicesToListen;
10089 private PluginClient pluginClient;
101- private SdkClient sdkClient;
10290
10391 private JobDetailsService jobDetailsService;
10492
@@ -142,36 +130,10 @@ public Collection<Object> createComponents(
142130 IndexNameExpressionResolver indexNameExpressionResolver,
143131 Supplier<RepositoriesService> repositoriesServiceSupplier
144132 ) {
145- Settings settings = environment.settings();
146- Boolean isMultiTenancyEnabled = JobSchedulerSettings.JOB_SCHEDULER_MULTI_TENANCY_ENABLED.get(settings);
147- this.pluginClient = new PluginClient(client);
148-
149- // Initialize SDK client for remote metadata storage
150- this.sdkClient = SdkClientFactory.createSdkClient(
151- pluginClient,
152- xContentRegistry,
153- isMultiTenancyEnabled
154- ? Map.ofEntries(
155- Map.entry(REMOTE_METADATA_TYPE_KEY, JobSchedulerSettings.REMOTE_METADATA_TYPE.get(settings)),
156- Map.entry(REMOTE_METADATA_ENDPOINT_KEY, JobSchedulerSettings.REMOTE_METADATA_ENDPOINT.get(settings)),
157- Map.entry(REMOTE_METADATA_REGION_KEY, JobSchedulerSettings.REMOTE_METADATA_REGION.get(settings)),
158- Map.entry(REMOTE_METADATA_SERVICE_NAME_KEY, JobSchedulerSettings.REMOTE_METADATA_SERVICE_NAME.get(settings)),
159- Map.entry(TENANT_AWARE_KEY, "true"),
160- Map.entry(TENANT_ID_FIELD_KEY, TENANT_ID_FIELD)
161- )
162- : Collections.emptyMap()
163- );
164-
165133 Supplier<Boolean> statusHistoryEnabled = () -> JobSchedulerSettings.STATUS_HISTORY.get(environment.settings());
134+ this.pluginClient = new PluginClient(client);
166135 this.historyService = new JobHistoryService(pluginClient, clusterService);
167- this.lockService = new LockServiceImpl(
168- pluginClient,
169- clusterService,
170- historyService,
171- statusHistoryEnabled,
172- this.sdkClient,
173- isMultiTenancyEnabled
174- );
136+ this.lockService = new LockServiceImpl(pluginClient, clusterService, historyService, statusHistoryEnabled);
175137 this.jobDetailsService = new JobDetailsService(client, clusterService, this.indicesToListen, this.indexToJobProviders);
176138 this.scheduler = new JobScheduler(threadPool, this.lockService);
177139 this.sweeper = initSweeper(
@@ -187,7 +149,7 @@ public Collection<Object> createComponents(
187149 clusterService.addListener(this.sweeper);
188150 clusterService.addLifecycleListener(this.sweeper);
189151
190- return List.of(this.lockService, this.scheduler, this.jobDetailsService, this.pluginClient, this.sdkClient );
152+ return List.of(this.lockService, this.scheduler, this.jobDetailsService, this.pluginClient);
191153 }
192154
193155 @Override
@@ -206,11 +168,6 @@ public List<Setting<?>> getSettings() {
206168 settingList.add(JobSchedulerSettings.SWEEP_PERIOD);
207169 settingList.add(JobSchedulerSettings.JITTER_LIMIT);
208170 settingList.add(JobSchedulerSettings.STATUS_HISTORY);
209- settingList.add(JobSchedulerSettings.REMOTE_METADATA_TYPE);
210- settingList.add(JobSchedulerSettings.REMOTE_METADATA_ENDPOINT);
211- settingList.add(JobSchedulerSettings.REMOTE_METADATA_REGION);
212- settingList.add(JobSchedulerSettings.REMOTE_METADATA_SERVICE_NAME);
213- settingList.add(JobSchedulerSettings.JOB_SCHEDULER_MULTI_TENANCY_ENABLED);
214171 return settingList;
215172 }
216173
0 commit comments