Fix main class runners

Original commit: elastic/x-pack-elasticsearch@28a90a19b8
This commit is contained in:
Martijn van Groningen 2015-08-31 22:45:40 +02:00
parent 39b7092185
commit 593fc30669
2 changed files with 56 additions and 26 deletions

View File

@ -5,8 +5,14 @@
*/
package org.elasticsearch.marvel;
import org.elasticsearch.bootstrap.Elasticsearch;
import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.node.MockNode;
import org.elasticsearch.node.Node;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
/**
* Main class to easily run Marvel from a IDE.
@ -17,13 +23,24 @@ import org.elasticsearch.license.plugin.LicensePlugin;
public class MarvelLauncher {
public static void main(String[] args) throws Throwable {
System.setProperty("es.script.inline", "on");
System.setProperty("es.security.manager.enabled", "false");
System.setProperty("es.plugins.load_classpath_plugins", "false");
System.setProperty("es.plugin.types", MarvelPlugin.class.getName() + "," + LicensePlugin.class.getName());
System.setProperty("es.cluster.name", MarvelLauncher.class.getSimpleName());
Settings.Builder settings = Settings.builder();
settings.put("script.inline", "on");
settings.put("security.manager.enabled", "false");
settings.put("plugins.load_classpath_plugins", "false");
settings.put("cluster.name", MarvelLauncher.class.getSimpleName());
Elasticsearch.main(new String[]{"start"});
final CountDownLatch latch = new CountDownLatch(1);
final Node node = new MockNode(settings.build(), false, Version.CURRENT, Arrays.asList(MarvelPlugin.class, LicensePlugin.class));
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
node.close();
latch.countDown();
}
});
node.start();
latch.await();
}
}

View File

@ -5,8 +5,14 @@
*/
package org.elasticsearch.watcher;
import org.elasticsearch.bootstrap.Elasticsearch;
import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.node.MockNode;
import org.elasticsearch.node.Node;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
/**
* Main class to easily run Watcher from a IDE.
@ -18,32 +24,39 @@ import org.elasticsearch.license.plugin.LicensePlugin;
public class WatcherF {
public static void main(String[] args) throws Throwable {
System.setProperty("es.http.cors.enabled", "true");
System.setProperty("es.http.cors.allow-origin", "*");
System.setProperty("es.script.inline", "on");
System.setProperty("es.shield.enabled", "false");
System.setProperty("es.security.manager.enabled", "false");
System.setProperty("es.plugins.load_classpath_plugins", "false");
Settings.Builder settings = Settings.builder();
settings.put("http.cors.enabled", "true");
settings.put("http.cors.allow-origin", "*");
settings.put("script.inline", "on");
settings.put("shield.enabled", "false");
settings.put("security.manager.enabled", "false");
settings.put("cluster.name", WatcherF.class.getSimpleName());
// this is for the `test-watcher-integration` group level integration in HipChat
System.setProperty("es.watcher.actions.hipchat.service.account.integration.profile", "integration");
System.setProperty("es.watcher.actions.hipchat.service.account.integration.auth_token", "huuS9v7ccuOy3ZBWWWr1vt8Lqu3sQnLUE81nrLZU");
System.setProperty("es.watcher.actions.hipchat.service.account.integration.room", "test-watcher");
settings.put("watcher.actions.hipchat.service.account.integration.profile", "integration");
settings.put("watcher.actions.hipchat.service.account.integration.auth_token", "huuS9v7ccuOy3ZBWWWr1vt8Lqu3sQnLUE81nrLZU");
settings.put("watcher.actions.hipchat.service.account.integration.room", "test-watcher");
// this is for the Watcher Test account in HipChat
System.setProperty("es.watcher.actions.hipchat.service.account.user.profile", "user");
System.setProperty("es.watcher.actions.hipchat.service.account.user.auth_token", "FYVx16oDH78ZW9r13wtXbcszyoyA7oX5tiMWg9X0");
settings.put("watcher.actions.hipchat.service.account.user.profile", "user");
settings.put("watcher.actions.hipchat.service.account.user.auth_token", "FYVx16oDH78ZW9r13wtXbcszyoyA7oX5tiMWg9X0");
// this is for the `test-watcher-v1` notification token
System.setProperty("es.watcher.actions.hipchat.service.account.v1.profile", "v1");
System.setProperty("es.watcher.actions.hipchat.service.account.v1.auth_token", "a734baf62df618b96dda55b323fc30");
settings.put("watcher.actions.hipchat.service.account.v1.profile", "v1");
settings.put("watcher.actions.hipchat.service.account.v1.auth_token", "a734baf62df618b96dda55b323fc30");
final CountDownLatch latch = new CountDownLatch(1);
final Node node = new MockNode(settings.build(), false, Version.CURRENT, Arrays.asList(WatcherPlugin.class, LicensePlugin.class));
Runtime.getRuntime().addShutdownHook(new Thread() {
System.setProperty("es.plugin.types", WatcherPlugin.class.getName() + "," + LicensePlugin.class.getName());
System.setProperty("es.cluster.name", WatcherF.class.getSimpleName());
Elasticsearch.main(new String[]{"start"});
@Override
public void run() {
node.close();
latch.countDown();
}
});
node.start();
latch.await();
}
}