本文整理汇总了Java中org.elasticsearch.node.NodeValidationException类的典型用法代码示例。如果您正苦于以下问题:Java NodeValidationException类的具体用法?Java NodeValidationException怎么用?Java NodeValidationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeValidationException类属于org.elasticsearch.node包,在下文中一共展示了NodeValidationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTribes
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@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();
}
示例2: execute
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@Override
protected void execute(Terminal terminal, OptionSet options, Environment env) throws UserException {
if (options.nonOptionArguments().isEmpty() == false) {
throw new UserException(ExitCodes.USAGE, "Positional arguments not allowed, found " + options.nonOptionArguments());
}
if (options.has(versionOption)) {
if (options.has(daemonizeOption) || options.has(pidfileOption)) {
throw new UserException(ExitCodes.USAGE, "Elasticsearch version option is mutually exclusive with any other option");
}
terminal.println("Version: " + org.elasticsearch.Version.CURRENT
+ ", Build: " + Build.CURRENT.shortHash() + "/" + Build.CURRENT.date()
+ ", JVM: " + JvmInfo.jvmInfo().version());
return;
}
final boolean daemonize = options.has(daemonizeOption);
final Path pidFile = pidfileOption.value(options);
final boolean quiet = options.has(quietOption);
try {
init(daemonize, pidFile, quiet, env);
} catch (NodeValidationException e) {
throw new UserException(ExitCodes.CONFIG, e.getMessage());
}
}
示例3: testMaxNumberOfThreadsCheck
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
public void testMaxNumberOfThreadsCheck() throws NodeValidationException {
final int limit = 1 << 11;
final AtomicLong maxNumberOfThreads = new AtomicLong(randomIntBetween(1, limit - 1));
final BootstrapChecks.MaxNumberOfThreadsCheck check = new BootstrapChecks.MaxNumberOfThreadsCheck() {
@Override
long getMaxNumberOfThreads() {
return maxNumberOfThreads.get();
}
};
final NodeValidationException e = expectThrows(
NodeValidationException.class,
() -> BootstrapChecks.check(true, Collections.singletonList(check), "testMaxNumberOfThreadsCheck"));
assertThat(e.getMessage(), containsString("max number of threads"));
maxNumberOfThreads.set(randomIntBetween(limit + 1, Integer.MAX_VALUE));
BootstrapChecks.check(true, Collections.singletonList(check), "testMaxNumberOfThreadsCheck");
// nothing should happen if current max number of threads is
// not available
maxNumberOfThreads.set(-1);
BootstrapChecks.check(true, Collections.singletonList(check), "testMaxNumberOfThreadsCheck");
}
示例4: testMaxMapCountCheck
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
public void testMaxMapCountCheck() throws NodeValidationException {
final int limit = 1 << 18;
final AtomicLong maxMapCount = new AtomicLong(randomIntBetween(1, limit - 1));
final BootstrapChecks.MaxMapCountCheck check = new BootstrapChecks.MaxMapCountCheck() {
@Override
long getMaxMapCount() {
return maxMapCount.get();
}
};
final NodeValidationException e = expectThrows(
NodeValidationException.class,
() -> BootstrapChecks.check(true, Collections.singletonList(check), "testMaxMapCountCheck"));
assertThat(e.getMessage(), containsString("max virtual memory areas vm.max_map_count"));
maxMapCount.set(randomIntBetween(limit + 1, Integer.MAX_VALUE));
BootstrapChecks.check(true, Collections.singletonList(check), "testMaxMapCountCheck");
// nothing should happen if current vm.max_map_count is not
// available
maxMapCount.set(-1);
BootstrapChecks.check(true, Collections.singletonList(check), "testMaxMapCountCheck");
}
示例5: testClientJvmCheck
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
public void testClientJvmCheck() throws NodeValidationException {
final AtomicReference<String> vmName = new AtomicReference<>("Java HotSpot(TM) 32-Bit Client VM");
final BootstrapCheck check = new BootstrapChecks.ClientJvmCheck() {
@Override
String getVmName() {
return vmName.get();
}
};
final NodeValidationException e = expectThrows(
NodeValidationException.class,
() -> BootstrapChecks.check(true, Collections.singletonList(check), "testClientJvmCheck"));
assertThat(
e.getMessage(),
containsString("JVM is using the client VM [Java HotSpot(TM) 32-Bit Client VM] " +
"but should be using a server VM for the best performance"));
vmName.set("Java HotSpot(TM) 32-Bit Server VM");
BootstrapChecks.check(true, Collections.singletonList(check), "testClientJvmCheck");
}
示例6: testUseSerialGCCheck
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
public void testUseSerialGCCheck() throws NodeValidationException {
final AtomicReference<String> useSerialGC = new AtomicReference<>("true");
final BootstrapCheck check = new BootstrapChecks.UseSerialGCCheck() {
@Override
String getUseSerialGC() {
return useSerialGC.get();
}
};
final NodeValidationException e = expectThrows(
NodeValidationException.class,
() -> BootstrapChecks.check(true, Collections.singletonList(check), "testUseSerialGCCheck"));
assertThat(
e.getMessage(),
containsString("JVM is using the serial collector but should not be for the best performance; " + "" +
"either it's the default for the VM [" + JvmInfo.jvmInfo().getVmName() +"] or -XX:+UseSerialGC was explicitly specified"));
useSerialGC.set("false");
BootstrapChecks.check(true, Collections.singletonList(check), "testUseSerialGCCheck");
}
示例7: testAlwaysEnforcedChecks
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
public void testAlwaysEnforcedChecks() {
final BootstrapCheck check = new BootstrapCheck() {
@Override
public boolean check() {
return true;
}
@Override
public String errorMessage() {
return "error";
}
@Override
public boolean alwaysEnforce() {
return true;
}
};
final NodeValidationException alwaysEnforced = expectThrows(
NodeValidationException.class,
() -> BootstrapChecks.check(randomBoolean(), Collections.singletonList(check), "testAlwaysEnforcedChecks"));
assertThat(alwaysEnforced, hasToString(containsString("error")));
}
示例8: getTestClient
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
private Client getTestClient() {
final Settings nodeSettings = Settings.builder()
.put(TRANSPORT_TYPE_SETTING_KEY, CLUSTER_NAME_SETTING_VALUE)
.put(TRANSPORT_TCP_PORT_SETTING_KEY, port)
.put(PATH_HOME_SETTING_KEY, homePath)
.put(HTTP_ENABLED_SETTING_KEY, false)
.build();
try {
final Environment environment = InternalSettingsPreparer.prepareEnvironment(nodeSettings, null);
addPlugins(environment);
return new StandAloneNode(environment, plugins).start().client();
} catch (final NodeValidationException e) {
LOGGER.error("Error occurs while initializing elastic search node at {}:{} - {}", host, port, e);
throw new EsCoreRuntimeException("Error occurs while initializing elastic search node at " + host + ":" + port, e);
}
}
示例9: elasticSearchTestNode
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
private static Node elasticSearchTestNode(Path path) throws NodeValidationException {
return new MyNode(
Settings.builder()
.put("http.enabled", "true")
.put("path.home", path.toString())
.put("cluster.name", "test-search-api-5-local_junit")
.put("http.port", 9211)
.put("transport.tcp.port", 9311)
.put("http.publish_port", 9211)
.put("http.publish_host", "127.0.0.1")
.put("transport.bind_host", "127.0.0.1")
.put("transport.publish_port", 9311)
.put("transport.publish_host", "127.0.0.1")
.build(),
Lists.newArrayList(Netty4Plugin.class)
).start();
}
示例10: setup
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@BeforeClass
public static void setup() throws NodeValidationException, IOException {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
ServiceConfig serviceConfig = ServiceConfig
.defaults(ServiceDefinitionUtil.simple(Resource.class))
.addon(ElasticsearchAddonMockImpl.defaults)
// .addon(ElasticsearchAddonImpl.defaults
// .coordinatorPort(9300)
// .coordinatorUrl("127.0.0.1")
// .clustername("test-search-api-5-local_jonas")
// .clientname("banan")
// .unitTest(true)
// )
.addon(ExceptionMapperAddon.defaults)
.addon(ServerLogAddon.defaults)
.addon(ElasticsearchIndexAddon.defaults("oneIndex", TestService.Payload.class)
.doIndexing(true)
)
.bind(ResourceImpl.class, Resource.class);
testServiceRunner = TestServiceRunner.defaults(serviceConfig);
TestServiceRunner.defaults(serviceConfig);
}
示例11: setup
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@BeforeClass
public static void setup() throws NodeValidationException, UnknownHostException {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
ServiceConfig serviceConfig = ServiceConfig
.defaults(ServiceDefinitionUtil.simple(Resource.class))
.addon(ExceptionMapperAddon.defaults)
.addon(ServerLogAddon.defaults)
.addon(ElasticsearchAddonMockImpl.defaults)
.addon(ElasticsearchIndexAddon.defaults("oneIndex", TestService.Payload.class))
.addon(ElasticsearchIndexAddon.defaults("anotherIndex", String.class))
.bind(ResourceImpl.class, Resource.class);
testServiceRunner = TestServiceRunner.defaults(serviceConfig);
TestServiceRunner.defaults(serviceConfig);
}
示例12: newNode
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@Bean(destroyMethod="close")
Node newNode() throws NodeValidationException {
final Path tempDir = createTempDir().toPath();
final Settings settings = Settings.builder()
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), new ClusterName("single-node-cluster" + System.nanoTime()))
.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", "single-node")
.put("script.inline", "true")
.put("script.stored", "true")
.put(ScriptService.SCRIPT_MAX_COMPILATIONS_PER_MINUTE.getKey(), 1000)
.put(EsExecutors.PROCESSORS_SETTING.getKey(), 1)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put("discovery.type", "zen")
.put("transport.type", "local")
.put(Node.NODE_DATA_SETTING.getKey(), true)
.put(NODE_ID_SEED_SETTING.getKey(), System.nanoTime())
.build();
return new Node(settings).start(); // NOSONAR
}
示例13: startEmbeddedNode
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@Override
public void startEmbeddedNode() throws NodeValidationException {
if (this.embeddedNode != null) {
log.info("Embedded Elasticsearch cluster already running");
return;
}
log.info("Launching an embedded Elasticsearch cluster: {}", properties.getClusterName());
Collection<Class<? extends Plugin>> plugins = Arrays.asList(Netty4Plugin.class);
embeddedNode = new PluginConfigurableNode(Settings.builder()
.put("path.home", properties.getEmbeddedStoragePath())
.put("cluster.name", properties.getClusterName())
.put("node.name", properties.getNodeName())
.put("transport.type", "netty4")
.put("node.data", true)
.put("node.master", true)
.put("network.host", "0.0.0.0")
.put("http.type", "netty4")
.put("http.enabled", true)
.put("http.cors.enabled", true)
.put("http.cors.allow-origin", "/.*/")
.build(), plugins);
embeddedNode.start();
}
示例14: startElasticEmbeddedServer
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
public static void startElasticEmbeddedServer()
throws NodeValidationException, InterruptedException {
Settings settings = Settings.builder()
.put("node.data", TRUE)
.put("network.host", ELASTIC_IN_MEM_HOSTNAME)
.put("http.port", elasticInMemPort)
.put("path.data", elasticTempFolder.getRoot().getPath())
.put("path.home", elasticTempFolder.getRoot().getPath())
.put("transport.type", "local")
.put("http.enabled", TRUE)
.put("node.ingest", TRUE).build();
node = new PluginNode(settings);
node.start();
LOG.info("Elastic in memory server started.");
prepareElasticIndex();
LOG.info("Prepared index " + ELASTIC_INDEX_NAME
+ "and populated data on elastic in memory server.");
}
示例15: createClient
import org.elasticsearch.node.NodeValidationException; //导入依赖的package包/类
@Override
protected Client createClient() {
StopWatch watch = new StopWatch();
try {
Settings.Builder settings = Settings.builder();
settings.put(Environment.PATH_HOME_SETTING.getKey(), dataPath)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.getKey(), "_local_")
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "single-node");
MockNode node = new MockNode(settings.build());
node.start();
return node.client();
} catch (NodeValidationException e) {
throw new Error(e);
} finally {
logger.info("create local elasticsearch node, dataPath={}, elapsedTime={}", dataPath, watch.elapsedTime());
}
}