All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.elasticsearch.node.ClusterRunnerNode Maven / Gradle / Ivy

There is a newer version: 7.10.2.0
Show newest version
package org.elasticsearch.node;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;

public class ClusterRunnerNode extends Node {

	private Version version;

	private Collection> plugins;

	public ClusterRunnerNode(Settings settings, Version version, Collection> classpathPlugins) {
		super(settings, version, classpathPlugins);
		this.version = version;
		this.plugins = classpathPlugins;
	}

	public ClusterRunnerNode(final Settings preparedSettings) {
		this(preparedSettings, Version.CURRENT, getDefaultPlugins(preparedSettings));
	}

	public Collection> getPlugins() {
		return plugins;
	}

	public Version getVersion() {
		return version;
	}

	private static Collection> getDefaultPlugins(final Settings preparedSettings) {
		final String pluginTypes = preparedSettings.get("plugin.types");
		if (pluginTypes != null) {
			Collection> pluginList = new ArrayList<>();
			for (String pluginType : pluginTypes.split(",")) {
				Class clazz;
				try {
					clazz = Class.forName(pluginType).asSubclass(Plugin.class);
					pluginList.add(clazz);
				} catch (ClassNotFoundException e) {
					throw new IllegalArgumentException("Failed to load " + pluginType, e);
				}
			}
			return pluginList;
		}
		return Collections.>emptyList();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy