use of org.elasticsearch.plugins.Plugin in project elasticsearch by elastic.
the class InternalTestCluster method buildNode.
/**
* builds a new node
*
* @param nodeId the node internal id (see {@link NodeAndClient#nodeAndClientId()}
* @param seed the node's random seed
* @param settings the settings to use
* @param reuseExisting if a node with the same name is already part of {@link #nodes}, no new node will be built and
* the method will return the existing one
* @param defaultMinMasterNodes min_master_nodes value to use if min_master_nodes is auto managed
*/
private NodeAndClient buildNode(int nodeId, long seed, Settings settings, boolean reuseExisting, int defaultMinMasterNodes) {
assert Thread.holdsLock(this);
ensureOpen();
settings = getSettings(nodeId, seed, settings);
Collection<Class<? extends Plugin>> plugins = getPlugins();
String name = buildNodeName(nodeId, settings);
if (reuseExisting && nodes.containsKey(name)) {
return nodes.get(name);
} else {
assert reuseExisting == true || nodes.containsKey(name) == false : "node name [" + name + "] already exists but not allowed to use it";
}
Settings.Builder finalSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), // allow overriding path.home
baseDir).put(settings).put("node.name", name).put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), seed);
if (autoManageMinMasterNodes) {
assert finalSettings.get(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey()) == null : "min master nodes may not be set when auto managed";
finalSettings.put(ZenDiscovery.MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING.getKey(), "5s").put(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), defaultMinMasterNodes);
} else if (finalSettings.get(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey()) == null) {
throw new IllegalArgumentException(DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey() + " must be configured");
}
MockNode node = new MockNode(finalSettings.build(), plugins);
return new NodeAndClient(name, node, nodeId);
}
use of org.elasticsearch.plugins.Plugin in project elasticsearch by elastic.
the class ESSingleNodeTestCase method newNode.
private Node newNode() {
final Path tempDir = createTempDir();
Settings settings = Settings.builder().put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", random().nextLong())).put(Environment.PATH_HOME_SETTING.getKey(), tempDir).put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo")).put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir().getParent()).put("node.name", "node_s_0").put("script.inline", "true").put("script.stored", "true").put(ScriptService.SCRIPT_MAX_COMPILATIONS_PER_MINUTE.getKey(), 1000).put(EsExecutors.PROCESSORS_SETTING.getKey(), // limit the number of threads created
1).put(NetworkModule.HTTP_ENABLED.getKey(), false).put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put(Node.NODE_DATA_SETTING.getKey(), true).put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong()).put(// allow test cases to provide their own settings or override these
nodeSettings()).build();
Collection<Class<? extends Plugin>> plugins = getPlugins();
if (plugins.contains(MockTcpTransportPlugin.class) == false) {
plugins = new ArrayList<>(plugins);
plugins.add(MockTcpTransportPlugin.class);
}
if (plugins.contains(TestZenDiscovery.TestPlugin.class) == false) {
plugins = new ArrayList<>(plugins);
plugins.add(TestZenDiscovery.TestPlugin.class);
}
Node build = new MockNode(settings, plugins);
try {
build.start();
} catch (NodeValidationException e) {
throw new RuntimeException(e);
}
return build;
}
use of org.elasticsearch.plugins.Plugin in project elasticsearch by elastic.
the class TribeUnitTests method createTribes.
@BeforeClass
public static void createTribes() throws NodeValidationException {
Settings baseSettings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2).build();
final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(MockTcpTransportPlugin.class, TestZenDiscovery.TestPlugin.class);
tribe1 = new MockNode(Settings.builder().put(baseSettings).put("cluster.name", "tribe1").put("node.name", "tribe1_node").put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong()).build(), mockPlugins).start();
tribe2 = new MockNode(Settings.builder().put(baseSettings).put("cluster.name", "tribe2").put("node.name", "tribe2_node").put(NodeEnvironment.NODE_ID_SEED_SETTING.getKey(), random().nextLong()).build(), mockPlugins).start();
}
use of org.elasticsearch.plugins.Plugin in project elasticsearch by elastic.
the class ESSmokeClientTestCase method startClient.
private static Client startClient(Path tempDir, TransportAddress... transportAddresses) {
Settings.Builder builder = Settings.builder().put("node.name", "qa_smoke_client_" + counter.getAndIncrement()).put("client.transport.ignore_cluster_name", true).put(Environment.PATH_HOME_SETTING.getKey(), tempDir);
final Collection<Class<? extends Plugin>> plugins;
if (random().nextBoolean()) {
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
plugins = Collections.singleton(MockTcpTransportPlugin.class);
} else {
plugins = Collections.emptyList();
}
TransportClient client = new PreBuiltTransportClient(builder.build(), plugins).addTransportAddresses(transportAddresses);
logger.info("--> Elasticsearch Java TransportClient started");
Exception clientException = null;
try {
ClusterHealthResponse health = client.admin().cluster().prepareHealth().get();
logger.info("--> connected to [{}] cluster which is running [{}] node(s).", health.getClusterName(), health.getNumberOfNodes());
} catch (Exception e) {
clientException = e;
}
assumeNoException("Sounds like your cluster is not running at " + clusterAddresses, clientException);
return client;
}
use of org.elasticsearch.plugins.Plugin in project crate by crate.
the class InternalTestClusterTests method testTwoNodeCluster.
public void testTwoNodeCluster() throws Exception {
String transportClient = getTestTransportType();
NodeConfigurationSource nodeConfigurationSource = new NodeConfigurationSource() {
@Override
public Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()).putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file").putList(SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()).build();
}
@Override
public Path nodeConfigPath(int nodeOrdinal) {
return null;
}
@Override
public Settings transportClientSettings() {
return Settings.builder().put(NetworkModule.TRANSPORT_TYPE_KEY, transportClient).build();
}
};
String nodePrefix = "test";
Path baseDir = createTempDir();
List<Class<? extends Plugin>> plugins = new ArrayList<>(mockPlugins());
plugins.add(NodeAttrCheckPlugin.class);
InternalTestCluster cluster = new InternalTestCluster(randomLong(), baseDir, false, true, 2, 2, "test", nodeConfigurationSource, 0, nodePrefix, plugins);
try {
cluster.beforeTest(random());
switch(randomInt(2)) {
case 0:
cluster.stopRandomDataNode();
cluster.startNode();
break;
case 1:
cluster.rollingRestart(InternalTestCluster.EMPTY_CALLBACK);
break;
case 2:
cluster.fullRestart();
break;
}
} finally {
cluster.close();
}
}
Aggregations