Merge branch 'master' into feature/query-refactoring
This commit is contained in:
commit
097511601c
|
@ -19,17 +19,13 @@
|
|||
|
||||
package org.elasticsearch.cache.recycler;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import static org.elasticsearch.common.inject.Modules.createModule;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PageCacheRecyclerModule extends AbstractModule implements SpawnModules {
|
||||
public class PageCacheRecyclerModule extends AbstractModule {
|
||||
|
||||
public static final String CACHE_IMPL = "cache.recycler.page_cache_impl";
|
||||
|
||||
|
@ -41,10 +37,12 @@ public class PageCacheRecyclerModule extends AbstractModule implements SpawnModu
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
return ImmutableList.of(createModule(settings.getAsClass(CACHE_IMPL, DefaultPageCacheRecyclerModule.class), settings));
|
||||
String impl = settings.get(CACHE_IMPL);
|
||||
if (impl == null) {
|
||||
bind(PageCacheRecycler.class).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends PageCacheRecycler> implClass = Classes.loadClass(getClass().getClassLoader(), impl);
|
||||
bind(PageCacheRecycler.class).to(implClass).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.cluster.routing.RoutingService;
|
|||
import org.elasticsearch.cluster.routing.allocation.AllocationModule;
|
||||
import org.elasticsearch.cluster.service.InternalClusterService;
|
||||
import org.elasticsearch.cluster.settings.ClusterDynamicSettingsModule;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
|
@ -88,7 +89,12 @@ public class ClusterModule extends AbstractModule implements SpawnModules {
|
|||
bind(NodeMappingRefreshAction.class).asEagerSingleton();
|
||||
bind(MappingUpdatedAction.class).asEagerSingleton();
|
||||
|
||||
bind(ClusterInfoService.class).to(settings.getAsClass(CLUSTER_SERVICE_IMPL, InternalClusterInfoService.class)).asEagerSingleton();
|
||||
String impl = settings.get(CLUSTER_SERVICE_IMPL);
|
||||
Class<? extends ClusterInfoService> implClass = InternalClusterInfoService.class;
|
||||
if (impl != null) {
|
||||
implClass = Classes.loadClass(getClass().getClassLoader(), impl);
|
||||
}
|
||||
bind(ClusterInfoService.class).to(implClass).asEagerSingleton();
|
||||
|
||||
Multibinder<IndexTemplateFilter> mbinder = Multibinder.newSetBinder(binder(), IndexTemplateFilter.class);
|
||||
for (Class<? extends IndexTemplateFilter> indexTemplateFilter : indexTemplateFilters) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
|||
import org.elasticsearch.cluster.node.DiscoveryNodeFilters;
|
||||
import org.elasticsearch.cluster.routing.HashFunction;
|
||||
import org.elasticsearch.cluster.routing.Murmur3HashFunction;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseFieldMatcher;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
|
@ -245,10 +246,11 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
|
|||
} else {
|
||||
this.minimumCompatibleLuceneVersion = null;
|
||||
}
|
||||
final Class<? extends HashFunction> hashFunctionClass = settings.getAsClass(SETTING_LEGACY_ROUTING_HASH_FUNCTION, null);
|
||||
if (hashFunctionClass == null) {
|
||||
final String hashFunction = settings.get(SETTING_LEGACY_ROUTING_HASH_FUNCTION);
|
||||
if (hashFunction == null) {
|
||||
routingHashFunction = MURMUR3_HASH_FUNCTION;
|
||||
} else {
|
||||
final Class<? extends HashFunction> hashFunctionClass = Classes.loadClass(getClass().getClassLoader(), hashFunction);
|
||||
try {
|
||||
routingHashFunction = hashFunctionClass.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.routing.DjbHashFunction;
|
|||
import org.elasticsearch.cluster.routing.HashFunction;
|
||||
import org.elasticsearch.cluster.routing.SimpleHashFunction;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -66,14 +67,18 @@ public class MetaDataIndexUpgradeService extends AbstractComponent {
|
|||
// the hash function package has changed we replace the two hash functions if their fully qualified name is used.
|
||||
if (hasCustomPre20HashFunction) {
|
||||
switch (pre20HashFunctionName) {
|
||||
case "Simple":
|
||||
case "simple":
|
||||
case "org.elasticsearch.cluster.routing.operation.hash.simple.SimpleHashFunction":
|
||||
pre20HashFunction = SimpleHashFunction.class;
|
||||
break;
|
||||
case "Djb":
|
||||
case "djb":
|
||||
case "org.elasticsearch.cluster.routing.operation.hash.djb.DjbHashFunction":
|
||||
pre20HashFunction = DjbHashFunction.class;
|
||||
break;
|
||||
default:
|
||||
pre20HashFunction = settings.getAsClass(DEPRECATED_SETTING_ROUTING_HASH_FUNCTION, DjbHashFunction.class, "org.elasticsearch.cluster.routing.", "HashFunction");
|
||||
pre20HashFunction = Classes.loadClass(getClass().getClassLoader(), pre20HashFunctionName);
|
||||
}
|
||||
} else {
|
||||
pre20HashFunction = DjbHashFunction.class;
|
||||
|
|
|
@ -608,7 +608,12 @@ public final class ShardRouting implements Streamable, ToXContent {
|
|||
return false;
|
||||
}
|
||||
ShardRouting that = (ShardRouting) o;
|
||||
// TODO: add version + unassigned info check. see #12387
|
||||
if (version != that.version) {
|
||||
return false;
|
||||
}
|
||||
if (unassignedInfo != null ? !unassignedInfo.equals(that.unassignedInfo) : that.unassignedInfo != null) {
|
||||
return false;
|
||||
}
|
||||
return equalsIgnoringMetaData(that);
|
||||
}
|
||||
|
||||
|
@ -626,8 +631,10 @@ public final class ShardRouting implements Streamable, ToXContent {
|
|||
result = 31 * result + (relocatingNodeId != null ? relocatingNodeId.hashCode() : 0);
|
||||
result = 31 * result + (primary ? 1 : 0);
|
||||
result = 31 * result + (state != null ? state.hashCode() : 0);
|
||||
result = 31 * result + (int) (version ^ (version >>> 32));
|
||||
result = 31 * result + (restoreSource != null ? restoreSource.hashCode() : 0);
|
||||
result = 31 * result + (allocationId != null ? allocationId.hashCode() : 0);
|
||||
result = 31 * result + (unassignedInfo != null ? unassignedInfo.hashCode() : 0);
|
||||
return hashCode = result;
|
||||
}
|
||||
|
||||
|
|
|
@ -293,4 +293,27 @@ public class UnassignedInfo implements ToXContent, Writeable<UnassignedInfo> {
|
|||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
UnassignedInfo that = (UnassignedInfo) o;
|
||||
|
||||
if (timestamp != that.timestamp) return false;
|
||||
if (reason != that.reason) return false;
|
||||
if (message != null ? !message.equals(that.message) : that.message != null) return false;
|
||||
return !(failure != null ? !failure.equals(that.failure) : that.failure != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = reason != null ? reason.hashCode() : 0;
|
||||
result = 31 * result + (int) (timestamp ^ (timestamp >>> 32));
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
result = 31 * result + (failure != null ? failure.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.cluster.routing.allocation.allocator;
|
||||
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
|
@ -64,8 +65,7 @@ public class ShardsAllocatorModule extends AbstractModule {
|
|||
logger.warn("{} allocator has been removed in 2.0 using {} instead", EVEN_SHARD_COUNT_ALLOCATOR_KEY, BALANCED_ALLOCATOR_KEY);
|
||||
shardsAllocator = BalancedShardsAllocator.class;
|
||||
} else {
|
||||
shardsAllocator = settings.getAsClass(TYPE_KEY, BalancedShardsAllocator.class,
|
||||
"org.elasticsearch.cluster.routing.allocation.allocator.", "Allocator");
|
||||
throw new IllegalArgumentException("Unknown ShardsAllocator type [" + type + "]");
|
||||
}
|
||||
return shardsAllocator;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.common;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.bootstrap.Elasticsearch;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.NoClassSettingsException;
|
||||
|
||||
|
@ -81,14 +83,6 @@ public class Classes {
|
|||
return (lastDotIndex != -1 ? className.substring(0, lastDotIndex) : "");
|
||||
}
|
||||
|
||||
public static String getPackageNameNoDomain(Class<?> clazz) {
|
||||
String fullPackage = getPackageName(clazz);
|
||||
if (fullPackage.startsWith("org.") || fullPackage.startsWith("com.") || fullPackage.startsWith("net.")) {
|
||||
return fullPackage.substring(4);
|
||||
}
|
||||
return fullPackage;
|
||||
}
|
||||
|
||||
public static boolean isInnerClass(Class<?> clazz) {
|
||||
return !Modifier.isStatic(clazz.getModifiers())
|
||||
&& clazz.getEnclosingClass() != null;
|
||||
|
@ -99,47 +93,13 @@ public class Classes {
|
|||
return !clazz.isInterface() && !Modifier.isAbstract(modifiers);
|
||||
}
|
||||
|
||||
public static <T> Class<? extends T> loadClass(ClassLoader classLoader, String className, String prefixPackage, String suffixClassName) {
|
||||
return loadClass(classLoader, className, prefixPackage, suffixClassName, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static <T> Class<? extends T> loadClass(ClassLoader classLoader, String className, String prefixPackage, String suffixClassName, String errorPrefix) {
|
||||
Throwable t = null;
|
||||
String[] classNames = classNames(className, prefixPackage, suffixClassName);
|
||||
for (String fullClassName : classNames) {
|
||||
try {
|
||||
return (Class<? extends T>) classLoader.loadClass(fullClassName);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
t = ex;
|
||||
} catch (NoClassDefFoundError er) {
|
||||
t = er;
|
||||
}
|
||||
public static <T> Class<? extends T> loadClass(ClassLoader classLoader, String className) {
|
||||
try {
|
||||
return (Class<? extends T>) classLoader.loadClass(className);
|
||||
} catch (ClassNotFoundException|NoClassDefFoundError e) {
|
||||
throw new ElasticsearchException("failed to load class [" + className + "]", e);
|
||||
}
|
||||
if (errorPrefix == null) {
|
||||
errorPrefix = "failed to load class";
|
||||
}
|
||||
throw new NoClassSettingsException(errorPrefix + " with value [" + className + "]; tried " + Arrays.toString(classNames), t);
|
||||
}
|
||||
|
||||
private static String[] classNames(String className, String prefixPackage, String suffixClassName) {
|
||||
String prefixValue = prefixPackage;
|
||||
int packageSeparator = className.lastIndexOf('.');
|
||||
String classNameValue = className;
|
||||
// If class name contains package use it as package prefix instead of specified default one
|
||||
if (packageSeparator > 0) {
|
||||
prefixValue = className.substring(0, packageSeparator + 1);
|
||||
classNameValue = className.substring(packageSeparator + 1);
|
||||
}
|
||||
return new String[]{
|
||||
className,
|
||||
prefixValue + Strings.capitalize(toCamelCase(classNameValue)) + suffixClassName,
|
||||
prefixValue + toCamelCase(classNameValue) + "." + Strings.capitalize(toCamelCase(classNameValue)) + suffixClassName,
|
||||
prefixValue + toCamelCase(classNameValue).toLowerCase(Locale.ROOT) + "." + Strings.capitalize(toCamelCase(classNameValue)) + suffixClassName,
|
||||
};
|
||||
}
|
||||
|
||||
private Classes() {
|
||||
|
||||
}
|
||||
private Classes() {}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,15 @@
|
|||
package org.elasticsearch.common.inject;
|
||||
|
||||
/**
|
||||
* This interface can be added to a Module to spawn sub modules. DO NOT USE.
|
||||
*
|
||||
* This is fundamentally broken.
|
||||
* <ul>
|
||||
* <li>If you have a plugin with multiple modules, return all the modules at once.</li>
|
||||
* <li>If you are trying to make the implementation of a module "pluggable", don't do it.
|
||||
* This is not extendable because custom implementations (using onModule) cannot be
|
||||
* registered before spawnModules() is called.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public interface SpawnModules {
|
||||
|
||||
|
|
|
@ -533,78 +533,6 @@ public final class Settings implements ToXContent {
|
|||
return parseSizeValue(get(settings), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the setting value (as a class) associated with the setting key. If it does not exists,
|
||||
* returns the default class provided.
|
||||
*
|
||||
* @param setting The setting key
|
||||
* @param defaultClazz The class to return if no value is associated with the setting
|
||||
* @param <T> The type of the class
|
||||
* @return The class setting value, or the default class provided is no value exists
|
||||
* @throws org.elasticsearch.common.settings.NoClassSettingsException Failure to load a class
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T> Class<? extends T> getAsClass(String setting, Class<? extends T> defaultClazz) throws NoClassSettingsException {
|
||||
String sValue = get(setting);
|
||||
if (sValue == null) {
|
||||
return defaultClazz;
|
||||
}
|
||||
try {
|
||||
return (Class<? extends T>) getClassLoader().loadClass(sValue);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassSettingsException("Failed to load class setting [" + setting + "] with value [" + sValue + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the setting value (as a class) associated with the setting key. If the value itself fails to
|
||||
* represent a loadable class, the value will be appended to the <tt>prefixPackage</tt> and suffixed with the
|
||||
* <tt>suffixClassName</tt> and it will try to be loaded with it.
|
||||
*
|
||||
* @param setting The setting key
|
||||
* @param defaultClazz The class to return if no value is associated with the setting
|
||||
* @param prefixPackage The prefix package to prefix the value with if failing to load the class as is
|
||||
* @param suffixClassName The suffix class name to prefix the value with if failing to load the class as is
|
||||
* @param <T> The type of the class
|
||||
* @return The class represented by the setting value, or the default class provided if no value exists
|
||||
* @throws org.elasticsearch.common.settings.NoClassSettingsException Failure to load the class
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T> Class<? extends T> getAsClass(String setting, Class<? extends T> defaultClazz, String prefixPackage, String suffixClassName) throws NoClassSettingsException {
|
||||
String sValue = get(setting);
|
||||
if (sValue == null) {
|
||||
return defaultClazz;
|
||||
}
|
||||
String fullClassName = sValue;
|
||||
try {
|
||||
return (Class<? extends T>) getClassLoader().loadClass(fullClassName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
String prefixValue = prefixPackage;
|
||||
int packageSeparator = sValue.lastIndexOf('.');
|
||||
if (packageSeparator > 0) {
|
||||
prefixValue = sValue.substring(0, packageSeparator + 1);
|
||||
sValue = sValue.substring(packageSeparator + 1);
|
||||
}
|
||||
fullClassName = prefixValue + Strings.capitalize(toCamelCase(sValue)) + suffixClassName;
|
||||
try {
|
||||
return (Class<? extends T>) getClassLoader().loadClass(fullClassName);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
return loadClass(prefixValue, sValue, suffixClassName, setting);
|
||||
} catch (NoClassDefFoundError e1) {
|
||||
return loadClass(prefixValue, sValue, suffixClassName, setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private <T> Class<? extends T> loadClass(String prefixValue, String sValue, String suffixClassName, String setting) {
|
||||
String fullClassName = prefixValue + toCamelCase(sValue).toLowerCase(Locale.ROOT) + "." + Strings.capitalize(toCamelCase(sValue)) + suffixClassName;
|
||||
try {
|
||||
return (Class<? extends T>) getClassLoader().loadClass(fullClassName);
|
||||
} catch (ClassNotFoundException e2) {
|
||||
throw new NoClassSettingsException("Failed to load class setting [" + setting + "] with value [" + get(setting) + "]", e2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The values associated with a setting prefix as an array. The settings array is in the format of:
|
||||
* <tt>settingPrefix.[index]</tt>.
|
||||
|
@ -1028,6 +956,26 @@ public final class Settings implements ToXContent {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the setting as an array of values, but keeps existing elements for the key.
|
||||
*/
|
||||
public Builder extendArray(String setting, String... values) {
|
||||
// check for a singular (non array) value
|
||||
String oldSingle = remove(setting);
|
||||
// find the highest array index
|
||||
int counter = 0;
|
||||
while (map.containsKey(setting + '.' + counter)) {
|
||||
++counter;
|
||||
}
|
||||
if (oldSingle != null) {
|
||||
put(setting + '.' + counter++, oldSingle);
|
||||
}
|
||||
for (String value : values) {
|
||||
put(setting + '.' + counter++, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the setting group.
|
||||
*/
|
||||
|
|
|
@ -19,17 +19,15 @@
|
|||
|
||||
package org.elasticsearch.common.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import static org.elasticsearch.common.inject.Modules.createModule;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BigArraysModule extends AbstractModule implements SpawnModules {
|
||||
public class BigArraysModule extends AbstractModule {
|
||||
|
||||
public static final String IMPL = "common.util.big_arrays_impl";
|
||||
|
||||
|
@ -41,10 +39,12 @@ public class BigArraysModule extends AbstractModule implements SpawnModules {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
return ImmutableList.of(createModule(settings.getAsClass(IMPL, DefaultBigArraysModule.class), settings));
|
||||
String impl = settings.get(IMPL);
|
||||
if (impl == null) {
|
||||
bind(BigArrays.class).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends BigArrays> implClass = Classes.loadClass(getClass().getClassLoader(), impl);
|
||||
bind(BigArrays.class).to(implClass).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.util;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DefaultBigArraysModule extends AbstractModule {
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
public DefaultBigArraysModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(BigArrays.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -19,42 +19,71 @@
|
|||
|
||||
package org.elasticsearch.discovery;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.Modules;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.local.LocalDiscoveryModule;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
|
||||
import org.elasticsearch.discovery.local.LocalDiscovery;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* A module for loading classes for node discovery.
|
||||
*/
|
||||
public class DiscoveryModule extends AbstractModule implements SpawnModules {
|
||||
|
||||
private final Settings settings;
|
||||
public class DiscoveryModule extends AbstractModule {
|
||||
|
||||
public static final String DISCOVERY_TYPE_KEY = "discovery.type";
|
||||
|
||||
private final Settings settings;
|
||||
private final List<Class<? extends UnicastHostsProvider>> unicastHostProviders = Lists.newArrayList();
|
||||
private final Map<String, Class<? extends Discovery>> discoveryTypes = new HashMap<>();
|
||||
|
||||
public DiscoveryModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
addDiscoveryType("local", LocalDiscovery.class);
|
||||
addDiscoveryType("zen", ZenDiscovery.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
Class<? extends Module> defaultDiscoveryModule;
|
||||
if (DiscoveryNode.localNode(settings)) {
|
||||
defaultDiscoveryModule = LocalDiscoveryModule.class;
|
||||
} else {
|
||||
defaultDiscoveryModule = ZenDiscoveryModule.class;
|
||||
}
|
||||
return ImmutableList.of(Modules.createModule(settings.getAsClass(DISCOVERY_TYPE_KEY, defaultDiscoveryModule, "org.elasticsearch.discovery.", "DiscoveryModule"), settings));
|
||||
/**
|
||||
* Adds a custom unicast hosts provider to build a dynamic list of unicast hosts list when doing unicast discovery.
|
||||
*/
|
||||
public void addUnicastHostProvider(Class<? extends UnicastHostsProvider> unicastHostProvider) {
|
||||
unicastHostProviders.add(unicastHostProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom Discovery type.
|
||||
*/
|
||||
public void addDiscoveryType(String type, Class<? extends Discovery> clazz) {
|
||||
discoveryTypes.put(type, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
String defaultType = DiscoveryNode.localNode(settings) ? "local" : "zen";
|
||||
String discoveryType = settings.get(DISCOVERY_TYPE_KEY, defaultType);
|
||||
Class<? extends Discovery> discoveryClass = discoveryTypes.get(discoveryType);
|
||||
if (discoveryClass == null) {
|
||||
throw new IllegalArgumentException("Unknown Discovery type [" + discoveryType + "]");
|
||||
}
|
||||
|
||||
if (discoveryType.equals("local") == false) {
|
||||
bind(ElectMasterService.class).asEagerSingleton();
|
||||
bind(ZenPingService.class).asEagerSingleton();
|
||||
Multibinder<UnicastHostsProvider> unicastHostsProviderMultibinder = Multibinder.newSetBinder(binder(), UnicastHostsProvider.class);
|
||||
for (Class<? extends UnicastHostsProvider> unicastHostProvider : unicastHostProviders) {
|
||||
unicastHostsProviderMultibinder.addBinding().to(unicastHostProvider);
|
||||
}
|
||||
}
|
||||
bind(Discovery.class).to(discoveryClass).asEagerSingleton();
|
||||
bind(DiscoveryService.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.local;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class LocalDiscoveryModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(Discovery.class).to(LocalDiscovery.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.zen;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
|
||||
import org.elasticsearch.discovery.zen.ping.ZenPingService;
|
||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ZenDiscoveryModule extends AbstractModule {
|
||||
|
||||
private final List<Class<? extends UnicastHostsProvider>> unicastHostProviders = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Adds a custom unicast hosts provider to build a dynamic list of unicast hosts list when doing unicast discovery.
|
||||
*/
|
||||
public ZenDiscoveryModule addUnicastHostProvider(Class<? extends UnicastHostsProvider> unicastHostProvider) {
|
||||
unicastHostProviders.add(unicastHostProvider);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ElectMasterService.class).asEagerSingleton();
|
||||
bind(ZenPingService.class).asEagerSingleton();
|
||||
Multibinder<UnicastHostsProvider> unicastHostsProviderMultibinder = Multibinder.newSetBinder(binder(), UnicastHostsProvider.class);
|
||||
for (Class<? extends UnicastHostsProvider> unicastHostProvider : unicastHostProviders) {
|
||||
unicastHostsProviderMultibinder.addBinding().to(unicastHostProvider);
|
||||
}
|
||||
bindDiscovery();
|
||||
}
|
||||
|
||||
protected void bindDiscovery() {
|
||||
bind(Discovery.class).to(ZenDiscovery.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -34,33 +34,25 @@ public class HttpServerModule extends AbstractModule {
|
|||
private final Settings settings;
|
||||
private final ESLogger logger;
|
||||
|
||||
private Class<? extends HttpServerTransport> configuredHttpServerTransport;
|
||||
private String configuredHttpServerTransportSource;
|
||||
private Class<? extends HttpServerTransport> httpServerTransportClass;
|
||||
|
||||
public HttpServerModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
this.httpServerTransportClass = NettyHttpServerTransport.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@Override
|
||||
protected void configure() {
|
||||
if (configuredHttpServerTransport != null) {
|
||||
logger.info("Using [{}] as http transport, overridden by [{}]", configuredHttpServerTransport.getName(), configuredHttpServerTransportSource);
|
||||
bind(HttpServerTransport.class).to(configuredHttpServerTransport).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends HttpServerTransport> defaultHttpServerTransport = NettyHttpServerTransport.class;
|
||||
Class<? extends HttpServerTransport> httpServerTransport = settings.getAsClass("http.type", defaultHttpServerTransport, "org.elasticsearch.http.", "HttpServerTransport");
|
||||
bind(HttpServerTransport.class).to(httpServerTransport).asEagerSingleton();
|
||||
}
|
||||
|
||||
bind(HttpServerTransport.class).to(httpServerTransportClass).asEagerSingleton();
|
||||
bind(HttpServer.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
public void setHttpServerTransport(Class<? extends HttpServerTransport> httpServerTransport, String source) {
|
||||
Preconditions.checkNotNull(httpServerTransport, "Configured http server transport may not be null");
|
||||
Preconditions.checkNotNull(source, "Plugin, that changes transport may not be null");
|
||||
this.configuredHttpServerTransport = httpServerTransport;
|
||||
this.configuredHttpServerTransportSource = source;
|
||||
logger.info("Using [{}] as http transport, overridden by [{}]", httpServerTransportClass.getName(), source);
|
||||
this.httpServerTransportClass = httpServerTransport;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
|
|||
injector.getInstance(IndicesQueryCache.class).onClose(shardId);
|
||||
}
|
||||
}), path));
|
||||
modules.add(new DeletionPolicyModule(indexSettings));
|
||||
modules.add(new DeletionPolicyModule());
|
||||
try {
|
||||
shardInjector = modules.createChildInjector(injector);
|
||||
} catch (CreationException e) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -114,12 +115,8 @@ public class AnalysisModule extends AbstractModule {
|
|||
private final Map<String, Class<? extends TokenizerFactory>> tokenizers = Maps.newHashMap();
|
||||
private final Map<String, Class<? extends AnalyzerProvider>> analyzers = Maps.newHashMap();
|
||||
|
||||
|
||||
public AnalysisModule(Settings settings) {
|
||||
this(settings, null);
|
||||
}
|
||||
|
||||
public AnalysisModule(Settings settings, IndicesAnalysisService indicesAnalysisService) {
|
||||
Objects.requireNonNull(indicesAnalysisService);
|
||||
this.settings = settings;
|
||||
this.indicesAnalysisService = indicesAnalysisService;
|
||||
processors.add(new DefaultProcessor());
|
||||
|
@ -173,24 +170,13 @@ public class AnalysisModule extends AbstractModule {
|
|||
String charFilterName = entry.getKey();
|
||||
Settings charFilterSettings = entry.getValue();
|
||||
|
||||
Class<? extends CharFilterFactory> type = null;
|
||||
try {
|
||||
type = charFilterSettings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "CharFilterFactory");
|
||||
} catch (NoClassSettingsException e) {
|
||||
// nothing found, see if its in bindings as a binding name
|
||||
if (charFilterSettings.get("type") != null) {
|
||||
type = charFiltersBindings.charFilters.get(Strings.toUnderscoreCase(charFilterSettings.get("type")));
|
||||
if (type == null) {
|
||||
type = charFiltersBindings.charFilters.get(Strings.toCamelCase(charFilterSettings.get("type")));
|
||||
}
|
||||
}
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("failed to find char filter type [" + charFilterSettings.get("type") + "] for [" + charFilterName + "]", e);
|
||||
}
|
||||
String typeName = charFilterSettings.get("type");
|
||||
if (typeName == null) {
|
||||
throw new IllegalArgumentException("CharFilter [" + charFilterName + "] must have a type associated with it");
|
||||
}
|
||||
Class<? extends CharFilterFactory> type = charFiltersBindings.charFilters.get(typeName);
|
||||
if (type == null) {
|
||||
// nothing found, see if its in bindings as a binding name
|
||||
throw new IllegalArgumentException("Char Filter [" + charFilterName + "] must have a type associated with it");
|
||||
throw new IllegalArgumentException("Unknown CharFilter type [" + typeName + "] for [" + charFilterName + "]");
|
||||
}
|
||||
charFilterBinder.addBinding(charFilterName).toProvider(FactoryProvider.newFactory(CharFilterFactoryFactory.class, type)).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
@ -206,11 +192,8 @@ public class AnalysisModule extends AbstractModule {
|
|||
if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) {
|
||||
continue;
|
||||
}
|
||||
// register it as default under the name
|
||||
if (indicesAnalysisService != null && indicesAnalysisService.hasCharFilter(charFilterName)) {
|
||||
// don't register it here, we will use explicitly register it in the AnalysisService
|
||||
//charFilterBinder.addBinding(charFilterName).toInstance(indicesAnalysisService.charFilterFactoryFactory(charFilterName));
|
||||
} else {
|
||||
// register if it's not builtin
|
||||
if (indicesAnalysisService.hasCharFilter(charFilterName) == false) {
|
||||
charFilterBinder.addBinding(charFilterName).toProvider(FactoryProvider.newFactory(CharFilterFactoryFactory.class, clazz)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
|
@ -233,23 +216,13 @@ public class AnalysisModule extends AbstractModule {
|
|||
String tokenFilterName = entry.getKey();
|
||||
Settings tokenFilterSettings = entry.getValue();
|
||||
|
||||
Class<? extends TokenFilterFactory> type = null;
|
||||
try {
|
||||
type = tokenFilterSettings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "TokenFilterFactory");
|
||||
} catch (NoClassSettingsException e) {
|
||||
// nothing found, see if its in bindings as a binding name
|
||||
if (tokenFilterSettings.get("type") != null) {
|
||||
type = tokenFiltersBindings.tokenFilters.get(Strings.toUnderscoreCase(tokenFilterSettings.get("type")));
|
||||
if (type == null) {
|
||||
type = tokenFiltersBindings.tokenFilters.get(Strings.toCamelCase(tokenFilterSettings.get("type")));
|
||||
}
|
||||
}
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("failed to find token filter type [" + tokenFilterSettings.get("type") + "] for [" + tokenFilterName + "]", e);
|
||||
}
|
||||
String typeName = tokenFilterSettings.get("type");
|
||||
if (typeName == null) {
|
||||
throw new IllegalArgumentException("TokenFilter [" + tokenFilterName + "] must have a type associated with it");
|
||||
}
|
||||
Class<? extends TokenFilterFactory> type = tokenFiltersBindings.tokenFilters.get(typeName);
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("token filter [" + tokenFilterName + "] must have a type associated with it");
|
||||
throw new IllegalArgumentException("Unknown TokenFilter type [" + typeName + "] for [" + tokenFilterName + "]");
|
||||
}
|
||||
tokenFilterBinder.addBinding(tokenFilterName).toProvider(FactoryProvider.newFactory(TokenFilterFactoryFactory.class, type)).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
@ -265,11 +238,8 @@ public class AnalysisModule extends AbstractModule {
|
|||
if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) {
|
||||
continue;
|
||||
}
|
||||
// register it as default under the name
|
||||
if (indicesAnalysisService != null && indicesAnalysisService.hasTokenFilter(tokenFilterName)) {
|
||||
// don't register it here, we will use explicitly register it in the AnalysisService
|
||||
// tokenFilterBinder.addBinding(tokenFilterName).toInstance(indicesAnalysisService.tokenFilterFactoryFactory(tokenFilterName));
|
||||
} else {
|
||||
// register if it's not builtin
|
||||
if (indicesAnalysisService.hasTokenFilter(tokenFilterName) == false) {
|
||||
tokenFilterBinder.addBinding(tokenFilterName).toProvider(FactoryProvider.newFactory(TokenFilterFactoryFactory.class, clazz)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
|
@ -291,24 +261,13 @@ public class AnalysisModule extends AbstractModule {
|
|||
String tokenizerName = entry.getKey();
|
||||
Settings tokenizerSettings = entry.getValue();
|
||||
|
||||
|
||||
Class<? extends TokenizerFactory> type = null;
|
||||
try {
|
||||
type = tokenizerSettings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "TokenizerFactory");
|
||||
} catch (NoClassSettingsException e) {
|
||||
// nothing found, see if its in bindings as a binding name
|
||||
if (tokenizerSettings.get("type") != null) {
|
||||
type = tokenizersBindings.tokenizers.get(Strings.toUnderscoreCase(tokenizerSettings.get("type")));
|
||||
if (type == null) {
|
||||
type = tokenizersBindings.tokenizers.get(Strings.toCamelCase(tokenizerSettings.get("type")));
|
||||
}
|
||||
}
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("failed to find tokenizer type [" + tokenizerSettings.get("type") + "] for [" + tokenizerName + "]", e);
|
||||
}
|
||||
String typeName = tokenizerSettings.get("type");
|
||||
if (typeName == null) {
|
||||
throw new IllegalArgumentException("Tokenizer [" + tokenizerName + "] must have a type associated with it");
|
||||
}
|
||||
Class<? extends TokenizerFactory> type = tokenizersBindings.tokenizers.get(typeName);
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("token filter [" + tokenizerName + "] must have a type associated with it");
|
||||
throw new IllegalArgumentException("Unknown Tokenizer type [" + typeName + "] for [" + tokenizerName + "]");
|
||||
}
|
||||
tokenizerBinder.addBinding(tokenizerName).toProvider(FactoryProvider.newFactory(TokenizerFactoryFactory.class, type)).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
@ -324,11 +283,8 @@ public class AnalysisModule extends AbstractModule {
|
|||
if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) {
|
||||
continue;
|
||||
}
|
||||
// register it as default under the name
|
||||
if (indicesAnalysisService != null && indicesAnalysisService.hasTokenizer(tokenizerName)) {
|
||||
// don't register it here, we will use explicitly register it in the AnalysisService
|
||||
// tokenizerBinder.addBinding(tokenizerName).toProvider(FactoryProvider.newFactory(TokenizerFactoryFactory.class, clazz)).in(Scopes.SINGLETON);
|
||||
} else {
|
||||
// register if it's not builtin
|
||||
if (indicesAnalysisService.hasTokenizer(tokenizerName) == false) {
|
||||
tokenizerBinder.addBinding(tokenizerName).toProvider(FactoryProvider.newFactory(TokenizerFactoryFactory.class, clazz)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
|
@ -350,42 +306,27 @@ public class AnalysisModule extends AbstractModule {
|
|||
String analyzerName = entry.getKey();
|
||||
Settings analyzerSettings = entry.getValue();
|
||||
|
||||
Class<? extends AnalyzerProvider> type = null;
|
||||
try {
|
||||
type = analyzerSettings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "AnalyzerProvider");
|
||||
} catch (NoClassSettingsException e) {
|
||||
// nothing found, see if its in bindings as a binding name
|
||||
if (analyzerSettings.get("type") != null) {
|
||||
type = analyzersBindings.analyzers.get(Strings.toUnderscoreCase(analyzerSettings.get("type")));
|
||||
if (type == null) {
|
||||
type = analyzersBindings.analyzers.get(Strings.toCamelCase(analyzerSettings.get("type")));
|
||||
}
|
||||
}
|
||||
if (type == null) {
|
||||
// no specific type, check if it has a tokenizer associated with it
|
||||
String tokenizerName = analyzerSettings.get("tokenizer");
|
||||
if (tokenizerName != null) {
|
||||
// we have a tokenizer, use the CustomAnalyzer
|
||||
type = CustomAnalyzerProvider.class;
|
||||
} else {
|
||||
throw new IllegalArgumentException("failed to find analyzer type [" + analyzerSettings.get("type") + "] or tokenizer for [" + analyzerName + "]", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == null) {
|
||||
// no specific type, check if it has a tokenizer associated with it
|
||||
String tokenizerName = analyzerSettings.get("tokenizer");
|
||||
if (tokenizerName != null) {
|
||||
// we have a tokenizer, use the CustomAnalyzer
|
||||
String typeName = analyzerSettings.get("type");
|
||||
Class<? extends AnalyzerProvider> type;
|
||||
if (typeName == null) {
|
||||
if (analyzerSettings.get("tokenizer") != null) {
|
||||
// custom analyzer, need to add it
|
||||
type = CustomAnalyzerProvider.class;
|
||||
} else {
|
||||
throw new IllegalArgumentException("failed to find analyzer type [" + analyzerSettings.get("type") + "] or tokenizer for [" + analyzerName + "]");
|
||||
throw new IllegalArgumentException("Analyzer [" + analyzerName + "] must have a type associated with it");
|
||||
}
|
||||
} else if (typeName.equals("custom")) {
|
||||
type = CustomAnalyzerProvider.class;
|
||||
} else {
|
||||
type = analyzersBindings.analyzers.get(typeName);
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Unknown Analyzer type [" + typeName + "] for [" + analyzerName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
analyzerBinder.addBinding(analyzerName).toProvider(FactoryProvider.newFactory(AnalyzerProviderFactory.class, type)).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
|
||||
// go over the analyzers in the bindings and register the ones that are not configured
|
||||
for (Map.Entry<String, Class<? extends AnalyzerProvider>> entry : analyzersBindings.analyzers.entrySet()) {
|
||||
String analyzerName = entry.getKey();
|
||||
|
@ -398,11 +339,8 @@ public class AnalysisModule extends AbstractModule {
|
|||
if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) {
|
||||
continue;
|
||||
}
|
||||
// register it as default under the name
|
||||
if (indicesAnalysisService != null && indicesAnalysisService.hasAnalyzer(analyzerName)) {
|
||||
// don't register it here, we will use explicitly register it in the AnalysisService
|
||||
// analyzerBinder.addBinding(analyzerName).toProvider(FactoryProvider.newFactory(AnalyzerProviderFactory.class, clazz)).in(Scopes.SINGLETON);
|
||||
} else {
|
||||
// register if it's not builtin
|
||||
if (indicesAnalysisService.hasAnalyzer(analyzerName) == false) {
|
||||
analyzerBinder.addBinding(analyzerName).toProvider(FactoryProvider.newFactory(AnalyzerProviderFactory.class, clazz)).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.index.cache.query;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.AliasOrIndex;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Scopes;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -43,8 +45,12 @@ public class QueryCacheModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(QueryCache.class)
|
||||
.to(settings.getAsClass(QueryCacheSettings.QUERY_CACHE_TYPE, IndexQueryCache.class, "org.elasticsearch.index.cache.query.", "QueryCache"))
|
||||
.in(Scopes.SINGLETON);
|
||||
Class<? extends IndexQueryCache> queryCacheClass = IndexQueryCache.class;
|
||||
String customQueryCache = settings.get(QueryCacheSettings.QUERY_CACHE_TYPE);
|
||||
if (customQueryCache != null) {
|
||||
// TODO: make this only useable from tests
|
||||
queryCacheClass = Classes.loadClass(getClass().getClassLoader(), customQueryCache);
|
||||
}
|
||||
bind(QueryCache.class).to(queryCacheClass).in(Scopes.SINGLETON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,30 +22,14 @@ package org.elasticsearch.index.deletionpolicy;
|
|||
import org.apache.lucene.index.IndexDeletionPolicy;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.name.Names;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import static org.elasticsearch.index.deletionpolicy.DeletionPolicyModule.DeletionPolicySettings.TYPE;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DeletionPolicyModule extends AbstractModule {
|
||||
|
||||
public static class DeletionPolicySettings {
|
||||
public static final String TYPE = "index.deletionpolicy.type";
|
||||
}
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
public DeletionPolicyModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(IndexDeletionPolicy.class)
|
||||
.annotatedWith(Names.named("actual"))
|
||||
.to(settings.getAsClass(TYPE, KeepOnlyLastDeletionPolicy.class))
|
||||
.to(KeepOnlyLastDeletionPolicy.class)
|
||||
.asEagerSingleton();
|
||||
|
||||
bind(SnapshotDeletionPolicy.class)
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
package org.elasticsearch.index.shard;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.cache.query.index.IndexQueryCache;
|
||||
import org.elasticsearch.index.engine.IndexSearcherWrapper;
|
||||
import org.elasticsearch.index.engine.IndexSearcherWrappingService;
|
||||
import org.elasticsearch.index.engine.EngineFactory;
|
||||
|
@ -39,10 +41,6 @@ import org.elasticsearch.index.translog.TranslogService;
|
|||
public class IndexShardModule extends AbstractModule {
|
||||
|
||||
public static final String ENGINE_FACTORY = "index.engine.factory";
|
||||
private static final Class<? extends EngineFactory> DEFAULT_ENGINE_FACTORY_CLASS = InternalEngineFactory.class;
|
||||
|
||||
private static final String ENGINE_PREFIX = "org.elasticsearch.index.engine.";
|
||||
private static final String ENGINE_SUFFIX = "EngineFactory";
|
||||
|
||||
private final ShardId shardId;
|
||||
private final Settings settings;
|
||||
|
@ -72,7 +70,13 @@ public class IndexShardModule extends AbstractModule {
|
|||
bind(TranslogService.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
bind(EngineFactory.class).to(settings.getAsClass(ENGINE_FACTORY, DEFAULT_ENGINE_FACTORY_CLASS, ENGINE_PREFIX, ENGINE_SUFFIX));
|
||||
Class<? extends InternalEngineFactory> engineFactoryClass = InternalEngineFactory.class;
|
||||
String customEngineFactory = settings.get(ENGINE_FACTORY);
|
||||
if (customEngineFactory != null) {
|
||||
// TODO: make this only useable from tests
|
||||
engineFactoryClass = Classes.loadClass(getClass().getClassLoader(), customEngineFactory);
|
||||
}
|
||||
bind(EngineFactory.class).to(engineFactoryClass);
|
||||
bind(StoreRecoveryService.class).asEagerSingleton();
|
||||
bind(ShardPercolateService.class).asEagerSingleton();
|
||||
bind(ShardTermVectorsService.class).asEagerSingleton();
|
||||
|
|
|
@ -46,6 +46,12 @@ public class SimilarityModule extends AbstractModule {
|
|||
|
||||
public SimilarityModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
addSimilarity("default", DefaultSimilarityProvider.class);
|
||||
addSimilarity("BM25", BM25SimilarityProvider.class);
|
||||
addSimilarity("DFR", DFRSimilarityProvider.class);
|
||||
addSimilarity("IB", IBSimilarityProvider.class);
|
||||
addSimilarity("LMDirichlet", LMDirichletSimilarityProvider.class);
|
||||
addSimilarity("LMJelinekMercer", LMJelinekMercerSimilarityProvider.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,30 +66,25 @@ public class SimilarityModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Map<String, Class<? extends SimilarityProvider>> providers = Maps.newHashMap(similarities);
|
||||
MapBinder<String, SimilarityProvider.Factory> similarityBinder =
|
||||
MapBinder.newMapBinder(binder(), String.class, SimilarityProvider.Factory.class);
|
||||
|
||||
Map<String, Settings> similaritySettings = settings.getGroups(SIMILARITY_SETTINGS_PREFIX);
|
||||
for (Map.Entry<String, Settings> entry : similaritySettings.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Settings settings = entry.getValue();
|
||||
|
||||
Class<? extends SimilarityProvider> type =
|
||||
settings.getAsClass("type", null, "org.elasticsearch.index.similarity.", "SimilarityProvider");
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("SimilarityProvider [" + name + "] must have an associated type");
|
||||
String typeName = settings.get("type");
|
||||
if (typeName == null) {
|
||||
throw new IllegalArgumentException("Similarity [" + name + "] must have an associated type");
|
||||
} else if (similarities.containsKey(typeName) == false) {
|
||||
throw new IllegalArgumentException("Unknown Similarity type [" + typeName + "] for [" + name + "]");
|
||||
}
|
||||
providers.put(name, type);
|
||||
}
|
||||
|
||||
MapBinder<String, SimilarityProvider.Factory> similarityBinder =
|
||||
MapBinder.newMapBinder(binder(), String.class, SimilarityProvider.Factory.class);
|
||||
|
||||
for (Map.Entry<String, Class<? extends SimilarityProvider>> entry : providers.entrySet()) {
|
||||
similarityBinder.addBinding(entry.getKey()).toProvider(FactoryProvider.newFactory(SimilarityProvider.Factory.class, entry.getValue())).in(Scopes.SINGLETON);
|
||||
similarityBinder.addBinding(entry.getKey()).toProvider(FactoryProvider.newFactory(SimilarityProvider.Factory.class, similarities.get(typeName))).in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
for (PreBuiltSimilarityProvider.Factory factory : Similarities.listFactories()) {
|
||||
if (!providers.containsKey(factory.name())) {
|
||||
if (!similarities.containsKey(factory.name())) {
|
||||
similarityBinder.addBinding(factory.name()).toInstance(factory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,20 +19,22 @@
|
|||
|
||||
package org.elasticsearch.index.store;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class IndexStoreModule extends AbstractModule implements SpawnModules {
|
||||
public class IndexStoreModule extends AbstractModule {
|
||||
|
||||
public static final String STORE_TYPE = "index.store.type";
|
||||
|
||||
private final Settings settings;
|
||||
private final Map<String, Class<? extends IndexStore>> storeTypes = new HashMap<>();
|
||||
|
||||
public enum Type {
|
||||
NIOFS,
|
||||
|
@ -56,25 +58,30 @@ public class IndexStoreModule extends AbstractModule implements SpawnModules {
|
|||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
final String storeType = settings.get(STORE_TYPE, Type.DEFAULT.getSettingsKey());
|
||||
public void addIndexStore(String type, Class<? extends IndexStore> clazz) {
|
||||
storeTypes.put(type, clazz);
|
||||
}
|
||||
|
||||
private static boolean isBuiltinType(String storeType) {
|
||||
for (Type type : Type.values()) {
|
||||
if (type.match(storeType)) {
|
||||
return ImmutableList.of(new DefaultStoreModule());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final Class<? extends Module> indexStoreModule = settings.getAsClass(STORE_TYPE, null, "org.elasticsearch.index.store.", "IndexStoreModule");
|
||||
return ImmutableList.of(Modules.createModule(indexStoreModule, settings));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {}
|
||||
|
||||
private static class DefaultStoreModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
protected void configure() {
|
||||
final String storeType = settings.get(STORE_TYPE);
|
||||
if (storeType == null || isBuiltinType(storeType)) {
|
||||
bind(IndexStore.class).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends IndexStore> clazz = storeTypes.get(storeType);
|
||||
if (clazz == null) {
|
||||
throw new IllegalArgumentException("Unknown store type [" + storeType + "]");
|
||||
}
|
||||
bind(IndexStore.class).to(clazz).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
|
||||
public class CircuitBreakerModule extends AbstractModule {
|
||||
|
||||
public static final String IMPL = "indices.breaker.type";
|
||||
public static final String TYPE_KEY = "indices.breaker.type";
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
|
@ -34,6 +34,15 @@ public class CircuitBreakerModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(CircuitBreakerService.class).to(settings.getAsClass(IMPL, HierarchyCircuitBreakerService.class)).asEagerSingleton();
|
||||
String type = settings.get(TYPE_KEY);
|
||||
Class<? extends CircuitBreakerService> impl;
|
||||
if (type == null || type.equals("hierarchy")) {
|
||||
impl = HierarchyCircuitBreakerService.class;
|
||||
} else if (type.equals("none")) {
|
||||
impl = NoneCircuitBreakerService.class;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown circuit breaker type [" + type + "]");
|
||||
}
|
||||
bind(CircuitBreakerService.class).to(impl).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,8 @@ public interface Plugin {
|
|||
void processModule(Module module);
|
||||
|
||||
/**
|
||||
* Additional node settings loaded by the plugin
|
||||
* Additional node settings loaded by the plugin. Note that settings that are explicit in the nodes settings can't be
|
||||
* overwritten with the additional settings. These settings added if they don't exist.
|
||||
*/
|
||||
Settings additionalSettings();
|
||||
}
|
||||
|
|
|
@ -202,12 +202,11 @@ public class PluginsService extends AbstractComponent {
|
|||
}
|
||||
|
||||
public Settings updatedSettings() {
|
||||
Settings.Builder builder = Settings.settingsBuilder()
|
||||
.put(this.settings);
|
||||
final Settings.Builder builder = Settings.settingsBuilder();
|
||||
for (Tuple<PluginInfo, Plugin> plugin : plugins) {
|
||||
builder.put(plugin.v2().additionalSettings());
|
||||
}
|
||||
return builder.build();
|
||||
return builder.put(this.settings).build();
|
||||
}
|
||||
|
||||
public Collection<Class<? extends Module>> modules() {
|
||||
|
|
|
@ -20,13 +20,15 @@
|
|||
package org.elasticsearch.repositories;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.Modules;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.elasticsearch.common.Strings.toCamelCase;
|
||||
|
||||
/**
|
||||
|
@ -67,7 +69,11 @@ public class RepositoryModule extends AbstractModule implements SpawnModules {
|
|||
*/
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
return ImmutableList.of(Modules.createModule(loadTypeModule(repositoryName.type(), "org.elasticsearch.repositories.", "RepositoryModule"), globalSettings));
|
||||
Class<? extends Module> repoModuleClass = typesRegistry.type(repositoryName.type());
|
||||
if (repoModuleClass == null) {
|
||||
throw new IllegalArgumentException("Could not find repository type [" + repositoryName.getType() + "] for repository [" + repositoryName.getName() + "]");
|
||||
}
|
||||
return Collections.unmodifiableList(Arrays.asList(Modules.createModule(repoModuleClass, globalSettings)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,12 +83,4 @@ public class RepositoryModule extends AbstractModule implements SpawnModules {
|
|||
protected void configure() {
|
||||
bind(RepositorySettings.class).toInstance(new RepositorySettings(globalSettings, settings));
|
||||
}
|
||||
|
||||
private Class<? extends Module> loadTypeModule(String type, String prefixPackage, String suffixClassName) {
|
||||
Class<? extends Module> registered = typesRegistry.type(type);
|
||||
if (registered != null) {
|
||||
return registered;
|
||||
}
|
||||
return Classes.loadClass(globalSettings.getClassLoader(), type, prefixPackage, suffixClassName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,17 +75,6 @@ public class ScriptModule extends AbstractModule {
|
|||
scriptsBinder.addBinding(entry.getKey()).to(entry.getValue()).asEagerSingleton();
|
||||
}
|
||||
|
||||
// now, check for config based ones
|
||||
Map<String, Settings> nativeSettings = settings.getGroups("script.native");
|
||||
for (Map.Entry<String, Settings> entry : nativeSettings.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Class<? extends NativeScriptFactory> type = entry.getValue().getAsClass("type", NativeScriptFactory.class);
|
||||
if (type == NativeScriptFactory.class) {
|
||||
throw new IllegalArgumentException("type is missing for native script [" + name + "]");
|
||||
}
|
||||
scriptsBinder.addBinding(name).to(type).asEagerSingleton();
|
||||
}
|
||||
|
||||
Multibinder<ScriptEngineService> multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class);
|
||||
multibinder.addBinding().to(NativeScriptEngineService.class);
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
|
||||
public class DefaultSearchServiceModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(SearchService.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
}
|
|
@ -33,15 +33,7 @@ import org.elasticsearch.search.controller.SearchPhaseController;
|
|||
import org.elasticsearch.search.dfs.DfsPhase;
|
||||
import org.elasticsearch.search.fetch.FetchPhase;
|
||||
import org.elasticsearch.search.fetch.FetchSubPhaseModule;
|
||||
import org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase;
|
||||
import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsFetchSubPhase;
|
||||
import org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase;
|
||||
import org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase;
|
||||
import org.elasticsearch.search.fetch.script.ScriptFieldsFetchSubPhase;
|
||||
import org.elasticsearch.search.fetch.source.FetchSourceSubPhase;
|
||||
import org.elasticsearch.search.fetch.version.VersionFetchSubPhase;
|
||||
import org.elasticsearch.search.highlight.HighlightModule;
|
||||
import org.elasticsearch.search.highlight.HighlightPhase;
|
||||
import org.elasticsearch.search.query.QueryPhase;
|
||||
import org.elasticsearch.search.suggest.SuggestModule;
|
||||
|
||||
|
|
|
@ -19,16 +19,11 @@
|
|||
|
||||
package org.elasticsearch.search;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.SpawnModules;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import static org.elasticsearch.common.inject.Modules.createModule;
|
||||
|
||||
public class SearchServiceModule extends AbstractModule implements SpawnModules {
|
||||
public class SearchServiceModule extends AbstractModule {
|
||||
|
||||
public static final String IMPL = "search.service_impl";
|
||||
|
||||
|
@ -40,10 +35,12 @@ public class SearchServiceModule extends AbstractModule implements SpawnModules
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Module> spawnModules() {
|
||||
return ImmutableList.of(createModule(settings.getAsClass(IMPL, DefaultSearchServiceModule.class), settings));
|
||||
String impl = settings.get(IMPL);
|
||||
if (impl == null) {
|
||||
bind(SearchService.class).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends SearchService> implClass = Classes.loadClass(getClass().getClassLoader(), impl);
|
||||
bind(SearchService.class).to(implClass).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ import java.util.List;
|
|||
/**
|
||||
* The main module for the get (binding all get components together)
|
||||
*/
|
||||
public class AggregationModule extends AbstractModule implements SpawnModules{
|
||||
public class AggregationModule extends AbstractModule implements SpawnModules {
|
||||
|
||||
private List<Class<? extends Aggregator.Parser>> aggParsers = Lists.newArrayList();
|
||||
private List<Class<? extends PipelineAggregator.Parser>> pipelineAggParsers = Lists.newArrayList();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.transport;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
|
@ -29,6 +30,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.transport.local.LocalTransport;
|
||||
import org.elasticsearch.transport.netty.NettyTransport;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -37,9 +40,14 @@ public class TransportModule extends AbstractModule {
|
|||
public static final String TRANSPORT_TYPE_KEY = "transport.type";
|
||||
public static final String TRANSPORT_SERVICE_TYPE_KEY = "transport.service.type";
|
||||
|
||||
public static final String LOCAL_TRANSPORT = "local";
|
||||
public static final String NETTY_TRANSPORT = "netty";
|
||||
|
||||
private final ESLogger logger;
|
||||
private final Settings settings;
|
||||
|
||||
private final Map<String, Class<? extends TransportService>> transportServices = Maps.newHashMap();
|
||||
private final Map<String, Class<? extends Transport>> transports = Maps.newHashMap();
|
||||
private Class<? extends TransportService> configuredTransportService;
|
||||
private Class<? extends Transport> configuredTransport;
|
||||
private String configuredTransportServiceSource;
|
||||
|
@ -48,6 +56,22 @@ public class TransportModule extends AbstractModule {
|
|||
public TransportModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
addTransport(LOCAL_TRANSPORT, LocalTransport.class);
|
||||
addTransport(NETTY_TRANSPORT, NettyTransport.class);
|
||||
}
|
||||
|
||||
public void addTransportService(String name, Class<? extends TransportService> clazz) {
|
||||
Class<? extends TransportService> oldClazz = transportServices.put(name, clazz);
|
||||
if (oldClazz != null) {
|
||||
throw new IllegalArgumentException("Cannot register TransportService [" + name + "] to " + clazz.getName() + ", already registered to " + oldClazz.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void addTransport(String name, Class<? extends Transport> clazz) {
|
||||
Class<? extends Transport> oldClazz = transports.put(name, clazz);
|
||||
if (oldClazz != null) {
|
||||
throw new IllegalArgumentException("Cannot register Transport [" + name + "] to " + clazz.getName() + ", already registered to " + oldClazz.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,12 +80,14 @@ public class TransportModule extends AbstractModule {
|
|||
logger.info("Using [{}] as transport service, overridden by [{}]", configuredTransportService.getName(), configuredTransportServiceSource);
|
||||
bind(TransportService.class).to(configuredTransportService).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends TransportService> defaultTransportService = TransportService.class;
|
||||
Class<? extends TransportService> transportService = settings.getAsClass(TRANSPORT_SERVICE_TYPE_KEY, defaultTransportService, "org.elasticsearch.transport.", "TransportService");
|
||||
if (!TransportService.class.equals(transportService)) {
|
||||
bind(TransportService.class).to(transportService).asEagerSingleton();
|
||||
} else {
|
||||
String typeName = settings.get(TRANSPORT_SERVICE_TYPE_KEY);
|
||||
if (typeName == null) {
|
||||
bind(TransportService.class).asEagerSingleton();
|
||||
} else {
|
||||
if (transportServices.containsKey(typeName) == false) {
|
||||
throw new IllegalArgumentException("Unknown TransportService [" + typeName + "]");
|
||||
}
|
||||
bind(TransportService.class).to(transportServices.get(typeName)).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,9 +97,13 @@ public class TransportModule extends AbstractModule {
|
|||
logger.info("Using [{}] as transport, overridden by [{}]", configuredTransport.getName(), configuredTransportSource);
|
||||
bind(Transport.class).to(configuredTransport).asEagerSingleton();
|
||||
} else {
|
||||
Class<? extends Transport> defaultTransport = DiscoveryNode.localNode(settings) ? LocalTransport.class : NettyTransport.class;
|
||||
Class<? extends Transport> transport = settings.getAsClass(TRANSPORT_TYPE_KEY, defaultTransport, "org.elasticsearch.transport.", "Transport");
|
||||
bind(Transport.class).to(transport).asEagerSingleton();
|
||||
String defaultType = DiscoveryNode.localNode(settings) ? LOCAL_TRANSPORT : NETTY_TRANSPORT;
|
||||
String typeName = settings.get(TRANSPORT_TYPE_KEY, defaultType);
|
||||
Class<? extends Transport> clazz = transports.get(typeName);
|
||||
if (clazz == null) {
|
||||
throw new IllegalArgumentException("Unknown Transport [" + typeName + "]");
|
||||
}
|
||||
bind(Transport.class).to(clazz).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.search.action.SearchServiceTransportAction;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -143,7 +144,7 @@ public class IndicesRequestIT extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, InterceptingTransportService.class.getName())
|
||||
.extendArray("plugin.types", InterceptingTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -843,6 +844,24 @@ public class IndicesRequestIT extends ESIntegTestCase {
|
|||
|
||||
public static class InterceptingTransportService extends TransportService {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "intercepting-transport-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "an intercepting transport service for testing";
|
||||
}
|
||||
public void onModule(TransportModule transportModule) {
|
||||
transportModule.addTransportService("intercepting", InterceptingTransportService.class);
|
||||
}
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.builder().put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, "intercepting").build();
|
||||
}
|
||||
}
|
||||
|
||||
private final Set<String> actions = new HashSet<>();
|
||||
|
||||
private final Map<String, List<TransportRequest>> requests = new HashMap<>();
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.*;
|
||||
import org.junit.Test;
|
||||
|
@ -57,7 +58,7 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTests {
|
|||
TransportClient client = TransportClient.builder().settings(Settings.builder()
|
||||
.put("client.transport.sniff", false)
|
||||
.put("node.name", "transport_client_" + this.getTestName())
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, InternalTransportService.class.getName())
|
||||
.put("plugin.types", InternalTransportService.Plugin.class.getName())
|
||||
.put(headersSettings)
|
||||
.build()).build();
|
||||
|
||||
|
@ -71,8 +72,8 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTests {
|
|||
.put("client.transport.sniff", true)
|
||||
.put("cluster.name", "cluster1")
|
||||
.put("node.name", "transport_client_" + this.getTestName() + "_1")
|
||||
.put("client.transport.nodes_sampler_interval", "1s")
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, InternalTransportService.class.getName())
|
||||
.put("client.transport.nodes_sampler_interval", "1s")
|
||||
.put("plugin.types", InternalTransportService.Plugin.class.getName())
|
||||
.put(HEADER_SETTINGS)
|
||||
.put("path.home", createTempDir().toString())
|
||||
.build()).build();
|
||||
|
@ -95,6 +96,24 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTests {
|
|||
|
||||
public static class InternalTransportService extends TransportService {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-transport-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "a mock transport service";
|
||||
}
|
||||
public void onModule(TransportModule transportModule) {
|
||||
transportModule.addTransportService("internal", InternalTransportService.class);
|
||||
}
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.builder().put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, "internal").build();
|
||||
}
|
||||
}
|
||||
|
||||
CountDownLatch clusterStateLatch = new CountDownLatch(1);
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -143,8 +143,7 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
|
|||
return Settings.builder()
|
||||
// manual collection or upon cluster forming.
|
||||
.put(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT, "1s")
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.put("plugin.types", Plugin.class.getName())
|
||||
.putArray("plugin.types", Plugin.class.getName(), MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,10 @@ import org.junit.Test;
|
|||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder;
|
||||
import static org.elasticsearch.cluster.routing.RandomShardRoutingMutator.randomChange;
|
||||
import static org.elasticsearch.cluster.routing.RandomShardRoutingMutator.randomReason;
|
||||
import static org.elasticsearch.test.XContentTestUtils.convertToMap;
|
||||
import static org.elasticsearch.test.XContentTestUtils.mapsEqualIgnoringArrayOrder;
|
||||
import static org.elasticsearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
|
||||
import static org.elasticsearch.test.VersionUtils.randomVersion;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -151,7 +153,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
|
|||
assertThat(clusterStateFromDiffs.metaData().equalsAliases(clusterState.metaData()), is(true));
|
||||
|
||||
// JSON Serialization test - make sure that both states produce similar JSON
|
||||
assertThat(mapsEqualIgnoringArrayOrder(convertToMap(clusterStateFromDiffs), convertToMap(clusterState)), equalTo(true));
|
||||
assertNull(differenceBetweenMapsIgnoringArrayOrder(convertToMap(clusterStateFromDiffs), convertToMap(clusterState)));
|
||||
|
||||
// Smoke test - we cannot compare bytes to bytes because some elements might get serialized in different order
|
||||
// however, serialized size should remain the same
|
||||
|
@ -200,7 +202,7 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
|
|||
if (randomBoolean()) {
|
||||
builder.remove(index);
|
||||
} else {
|
||||
builder.add(randomIndexRoutingTable(index, clusterState.nodes().nodes().keys().toArray(String.class)));
|
||||
builder.add(randomChangeToIndexRoutingTable(clusterState.routingTable().indicesRouting().get(index), clusterState.nodes().nodes().keys().toArray(String.class)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,14 +224,34 @@ public class ClusterStateDiffIT extends ESIntegTestCase {
|
|||
IndexShardRoutingTable.Builder indexShard = new IndexShardRoutingTable.Builder(new ShardId(index, i));
|
||||
int replicaCount = randomIntBetween(1, 10);
|
||||
for (int j = 0; j < replicaCount; j++) {
|
||||
UnassignedInfo unassignedInfo = null;
|
||||
if (randomInt(5) == 1) {
|
||||
unassignedInfo = new UnassignedInfo(randomReason(), randomAsciiOfLength(10));
|
||||
}
|
||||
indexShard.addShard(
|
||||
TestShardRouting.newShardRouting(index, i, randomFrom(nodeIds), null, null, j == 0, ShardRoutingState.fromValue((byte) randomIntBetween(2, 4)), 1));
|
||||
TestShardRouting.newShardRouting(index, i, randomFrom(nodeIds), null, null, j == 0,
|
||||
ShardRoutingState.fromValue((byte) randomIntBetween(2, 4)), 1, unassignedInfo));
|
||||
}
|
||||
builder.addIndexShard(indexShard.build());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly updates index routing table in the cluster state
|
||||
*/
|
||||
private IndexRoutingTable randomChangeToIndexRoutingTable(IndexRoutingTable original, String[] nodes) {
|
||||
IndexRoutingTable.Builder builder = IndexRoutingTable.builder(original.getIndex());
|
||||
for (ObjectCursor<IndexShardRoutingTable> indexShardRoutingTable : original.shards().values()) {
|
||||
for (ShardRouting shardRouting : indexShardRoutingTable.value.shards()) {
|
||||
final ShardRouting newShardRouting = new ShardRouting(shardRouting);
|
||||
randomChange(newShardRouting, nodes);
|
||||
builder.addShard(indexShardRoutingTable.value, newShardRouting);
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly creates or removes cluster blocks
|
||||
*/
|
||||
|
|
|
@ -47,15 +47,6 @@ public class ShardsAllocatorModuleIT extends ESIntegTestCase {
|
|||
assertAllocatorInstance(build, BalancedShardsAllocator.class);
|
||||
}
|
||||
|
||||
public void testLoadByClassNameShardsAllocator() throws IOException {
|
||||
Settings build = settingsBuilder().put(ShardsAllocatorModule.TYPE_KEY, "BalancedShards").build();
|
||||
assertAllocatorInstance(build, BalancedShardsAllocator.class);
|
||||
|
||||
build = settingsBuilder().put(ShardsAllocatorModule.TYPE_KEY,
|
||||
"org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator").build();
|
||||
assertAllocatorInstance(build, BalancedShardsAllocator.class);
|
||||
}
|
||||
|
||||
private void assertAllocatorInstance(Settings settings, Class<? extends ShardsAllocator> clazz) throws IOException {
|
||||
while (cluster().size() != 0) {
|
||||
internalCluster().stopRandomDataNode();
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cluster.routing;
|
||||
|
||||
import static org.elasticsearch.test.ESTestCase.randomAsciiOfLength;
|
||||
import static org.elasticsearch.test.ESTestCase.randomFrom;
|
||||
import static org.elasticsearch.test.ESTestCase.randomInt;
|
||||
|
||||
/**
|
||||
* Utility class the makes random modifications to ShardRouting
|
||||
*/
|
||||
public final class RandomShardRoutingMutator {
|
||||
private RandomShardRoutingMutator() {
|
||||
|
||||
}
|
||||
|
||||
public static void randomChange(ShardRouting shardRouting, String[] nodes) {
|
||||
switch (randomInt(3)) {
|
||||
case 0:
|
||||
if (shardRouting.unassigned() == false) {
|
||||
shardRouting.moveToUnassigned(new UnassignedInfo(randomReason(), randomAsciiOfLength(10)));
|
||||
} else if (shardRouting.unassignedInfo() != null) {
|
||||
shardRouting.updateUnassignedInfo(new UnassignedInfo(randomReason(), randomAsciiOfLength(10)));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (shardRouting.unassigned()) {
|
||||
shardRouting.initialize(randomFrom(nodes));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (shardRouting.primary()) {
|
||||
shardRouting.moveFromPrimary();
|
||||
} else {
|
||||
shardRouting.moveToPrimary();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (shardRouting.initializing()) {
|
||||
shardRouting.moveToStarted();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static UnassignedInfo.Reason randomReason() {
|
||||
switch (randomInt(9)) {
|
||||
case 0:
|
||||
return UnassignedInfo.Reason.INDEX_CREATED;
|
||||
case 1:
|
||||
return UnassignedInfo.Reason.CLUSTER_RECOVERED;
|
||||
case 2:
|
||||
return UnassignedInfo.Reason.INDEX_REOPENED;
|
||||
case 3:
|
||||
return UnassignedInfo.Reason.DANGLING_INDEX_IMPORTED;
|
||||
case 4:
|
||||
return UnassignedInfo.Reason.NEW_INDEX_RESTORED;
|
||||
case 5:
|
||||
return UnassignedInfo.Reason.EXISTING_INDEX_RESTORED;
|
||||
case 6:
|
||||
return UnassignedInfo.Reason.REPLICA_ADDED;
|
||||
case 7:
|
||||
return UnassignedInfo.Reason.ALLOCATION_FAILED;
|
||||
case 8:
|
||||
return UnassignedInfo.Reason.NODE_LEFT;
|
||||
default:
|
||||
return UnassignedInfo.Reason.REROUTE_CANCELLED;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,35 +47,6 @@ public class SettingsTests extends ESTestCase {
|
|||
assertThat(settings.get("test.camel_case"), equalTo("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAsClass() {
|
||||
Settings settings = settingsBuilder()
|
||||
.put("test.class", "bar")
|
||||
.put("test.class.package", "org.elasticsearch.common.settings.bar")
|
||||
.build();
|
||||
|
||||
// Assert that defaultClazz is loaded if setting is not specified
|
||||
assertThat(settings.getAsClass("no.settings", FooTestClass.class, "org.elasticsearch.common.settings.", "TestClass").getName(),
|
||||
equalTo(FooTestClass.class.getName()));
|
||||
|
||||
// Assert that correct class is loaded if setting contain name without package
|
||||
assertThat(settings.getAsClass("test.class", FooTestClass.class, "org.elasticsearch.common.settings.", "TestClass").getName(),
|
||||
equalTo(BarTestClass.class.getName()));
|
||||
|
||||
// Assert that class cannot be loaded if wrong packagePrefix is specified
|
||||
try {
|
||||
settings.getAsClass("test.class", FooTestClass.class, "com.example.elasticsearch.test.unit..common.settings.", "TestClass");
|
||||
fail("Class with wrong package name shouldn't be loaded");
|
||||
} catch (NoClassSettingsException ex) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
// Assert that package name in settings is getting correctly applied
|
||||
assertThat(settings.getAsClass("test.class.package", FooTestClass.class, "com.example.elasticsearch.test.unit.common.settings.", "TestClass").getName(),
|
||||
equalTo(BarTestClass.class.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadFromDelimitedString() {
|
||||
Settings settings = settingsBuilder()
|
||||
|
@ -95,13 +66,6 @@ public class SettingsTests extends ESTestCase {
|
|||
assertThat(settings.toDelimitedString(';'), equalTo("key1=value1;key2=value2;"));
|
||||
}
|
||||
|
||||
@Test(expected = NoClassSettingsException.class)
|
||||
public void testThatAllClassNotFoundExceptionsAreCaught() {
|
||||
// this should be nGram in order to really work, but for sure not not throw a NoClassDefFoundError
|
||||
Settings settings = settingsBuilder().put("type", "ngram").build();
|
||||
settings.getAsClass("type", null, "org.elasticsearch.index.analysis.", "TokenFilterFactory");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplacePropertiesPlaceholderSystemProperty() {
|
||||
System.setProperty("sysProp1", "sysVal1");
|
||||
|
|
|
@ -143,7 +143,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
|||
.put(DiscoverySettings.PUBLISH_TIMEOUT, "1s") // <-- for hitting simulated network failures quickly
|
||||
.put("http.enabled", false) // just to make test quicker
|
||||
.put("gateway.local.list_timeout", "10s") // still long to induce failures but to long so test won't time out
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.put("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
|
||||
private void configureCluster(int numberOfNodes, int minimumMasterNode) throws ExecutionException, InterruptedException {
|
||||
|
|
|
@ -396,7 +396,7 @@ public class IndexWithShadowReplicasIT extends ESIntegTestCase {
|
|||
Settings nodeSettings = Settings.builder()
|
||||
.put("node.add_id_to_custom_path", false)
|
||||
.put("node.enable_custom_paths", true)
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.put("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
|
||||
String node1 = internalCluster().startNode(nodeSettings);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class TransportIndexFailuresIT extends ESIntegTestCase {
|
|||
.put(FaultDetection.SETTING_PING_RETRIES, "1") // <-- for hitting simulated network failures quickly
|
||||
.put(DiscoverySettings.PUBLISH_TIMEOUT, "1s") // <-- for hitting simulated network failures quickly
|
||||
.put("discovery.zen.minimum_master_nodes", 1)
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.put("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,11 +67,13 @@ public class AnalysisModuleTests extends ESTestCase {
|
|||
public AnalysisService getAnalysisService(Settings settings) {
|
||||
Index index = new Index("test");
|
||||
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
|
||||
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
|
||||
analysisModule.addTokenFilter("myfilter", MyFilterTokenFilterFactory.class);
|
||||
injector = new ModulesBuilder().add(
|
||||
new IndexSettingsModule(index, settings),
|
||||
new IndexNameModule(index),
|
||||
new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)))
|
||||
.createChildInjector(parentInjector);
|
||||
analysisModule)
|
||||
.createChildInjector(parentInjector);
|
||||
|
||||
return injector.getInstance(AnalysisService.class);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public class AnalyzerBackwardsCompatTests extends ESTokenStreamTestCase {
|
|||
builder.put("path.home", createTempDir().toString());
|
||||
AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(builder.build());
|
||||
NamedAnalyzer analyzer = analysisService.analyzer("foo");
|
||||
assertNotNull(analyzer);
|
||||
if (version.onOrAfter(noStopwordVersion)) {
|
||||
assertAnalyzesTo(analyzer, "this is bogus", new String[]{"this", "is", "bogus"});
|
||||
} else {
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.env.EnvironmentModule;
|
|||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexNameModule;
|
||||
import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilterFactory;
|
||||
import org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory;
|
||||
import org.elasticsearch.index.settings.IndexSettingsModule;
|
||||
import org.elasticsearch.indices.analysis.IndicesAnalysisModule;
|
||||
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
||||
|
@ -58,10 +59,12 @@ public class CompoundAnalysisTests extends ESTestCase {
|
|||
Index index = new Index("test");
|
||||
Settings settings = getJsonSettings();
|
||||
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
|
||||
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
|
||||
analysisModule.addTokenFilter("myfilter", MyFilterTokenFilterFactory.class);
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new IndexSettingsModule(index, settings),
|
||||
new IndexNameModule(index),
|
||||
new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)))
|
||||
analysisModule)
|
||||
.createChildInjector(parentInjector);
|
||||
|
||||
AnalysisService analysisService = injector.getInstance(AnalysisService.class);
|
||||
|
@ -83,10 +86,12 @@ public class CompoundAnalysisTests extends ESTestCase {
|
|||
private List<String> analyze(Settings settings, String analyzerName, String text) throws IOException {
|
||||
Index index = new Index("test");
|
||||
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
|
||||
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
|
||||
analysisModule.addTokenFilter("myfilter", MyFilterTokenFilterFactory.class);
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new IndexSettingsModule(index, settings),
|
||||
new IndexNameModule(index),
|
||||
new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)))
|
||||
analysisModule)
|
||||
.createChildInjector(parentInjector);
|
||||
|
||||
AnalysisService analysisService = injector.getInstance(AnalysisService.class);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"stopwords":["stop2-1", "stop2-2"]
|
||||
},
|
||||
"my":{
|
||||
"type":"org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory"
|
||||
"type":"myfilter"
|
||||
},
|
||||
"dict_dec":{
|
||||
"type":"dictionary_decompounder",
|
||||
|
|
|
@ -23,7 +23,7 @@ index :
|
|||
type : stop
|
||||
stopwords : [stop2-1, stop2-2]
|
||||
my :
|
||||
type : org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory
|
||||
type : myfilter
|
||||
dict_dec :
|
||||
type : dictionary_decompounder
|
||||
word_list : [donau, dampf, schiff, spargel, creme, suppe]
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.elasticsearch.index.cache.IndexCacheModule;
|
|||
import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
|
||||
import org.elasticsearch.index.settings.IndexSettingsModule;
|
||||
import org.elasticsearch.index.similarity.SimilarityModule;
|
||||
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.indices.query.IndicesQueriesModule;
|
||||
|
@ -80,7 +81,7 @@ public class TemplateQueryParserTest extends ESTestCase {
|
|||
new ScriptModule(settings),
|
||||
new IndexSettingsModule(index, settings),
|
||||
new IndexCacheModule(settings),
|
||||
new AnalysisModule(settings),
|
||||
new AnalysisModule(settings, new IndicesAnalysisService(settings)),
|
||||
new SimilarityModule(settings),
|
||||
new IndexNameModule(index),
|
||||
new FunctionScoreModule(),
|
||||
|
|
|
@ -98,7 +98,7 @@ public class CorruptedFileIT extends ESIntegTestCase {
|
|||
// we really need local GW here since this also checks for corruption etc.
|
||||
// and we need to make sure primaries are not just trashed if we don't have replicas
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.extendArray("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
// speed up recoveries
|
||||
.put(RecoverySettings.INDICES_RECOVERY_CONCURRENT_STREAMS, 10)
|
||||
.put(RecoverySettings.INDICES_RECOVERY_CONCURRENT_SMALL_FILE_STREAMS, 10)
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CorruptedTranslogIT extends ESIntegTestCase {
|
|||
// we really need local GW here since this also checks for corruption etc.
|
||||
// and we need to make sure primaries are not just trashed if we don't have replicas
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName()).build();
|
||||
.extendArray("plugin.types", MockTransportService.Plugin.class.getName()).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ExceptionRetryIT extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.extendArray("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ public class IndexRecoveryIT extends ESIntegTestCase {
|
|||
final Settings nodeSettings = Settings.builder()
|
||||
.put(RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK, "100ms")
|
||||
.put(RecoverySettings.INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT, "1s")
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.put("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.put(MockFSDirectoryService.RANDOM_PREVENT_DOUBLE_WRITE, false) // restarted recoveries will delete temp files and write them again
|
||||
.build();
|
||||
// start a master node
|
||||
|
|
|
@ -87,7 +87,7 @@ public class IndicesStoreIntegrationIT extends ESIntegTestCase {
|
|||
// which is between 1 and 2 sec can cause each of the shard deletion requests to timeout.
|
||||
// to prevent this we are setting the timeout here to something highish ie. the default in practice
|
||||
.put(IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT, new TimeValue(30, TimeUnit.SECONDS))
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.extendArray("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ public class RelocationIT extends ESIntegTestCase {
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName()).build();
|
||||
.put("plugin.types", MockTransportService.Plugin.class.getName()).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.extendArray("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.put(RecoverySettings.INDICES_RECOVERY_FILE_CHUNK_SIZE, new ByteSizeValue(randomIntBetween(50, 300), ByteSizeUnit.BYTES));
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.EnvironmentModule;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -49,15 +50,16 @@ public class NativeScriptTests extends ESTestCase {
|
|||
@Test
|
||||
public void testNativeScript() throws InterruptedException {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
.put("script.native.my.type", MyNativeScriptFactory.class.getName())
|
||||
.put("name", "testNativeScript")
|
||||
.put("path.home", createTempDir())
|
||||
.build();
|
||||
ScriptModule scriptModule = new ScriptModule(settings);
|
||||
scriptModule.registerScript("my", MyNativeScriptFactory.class);
|
||||
Injector injector = new ModulesBuilder().add(
|
||||
new EnvironmentModule(new Environment(settings)),
|
||||
new ThreadPoolModule(new ThreadPool(settings)),
|
||||
new SettingsModule(settings),
|
||||
new ScriptModule(settings)).createInjector();
|
||||
scriptModule).createInjector();
|
||||
|
||||
ScriptService scriptService = injector.getInstance(ScriptService.class);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.repositories.RepositoriesService;
|
||||
import org.elasticsearch.snapshots.mockstore.MockRepository;
|
||||
import org.elasticsearch.snapshots.mockstore.MockRepositoryPlugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -47,11 +48,18 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
|
||||
public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
|
||||
.extendArray("plugin.types", MockRepositoryPlugin.class.getName()).build();
|
||||
}
|
||||
|
||||
public static long getFailureCount(String repository) {
|
||||
long failureCount = 0;
|
||||
for (RepositoriesService repositoriesService : internalCluster().getDataNodeInstances(RepositoriesService.class)) {
|
||||
|
|
|
@ -303,7 +303,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
|
|||
logger.info("--> create repository");
|
||||
logger.info("--> creating repository");
|
||||
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", randomRepoPath())
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -352,7 +352,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
|
|||
logger.info("--> creating repository");
|
||||
Path repo = randomRepoPath();
|
||||
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", repo)
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
|
|
@ -33,12 +33,14 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
|
|||
import org.elasticsearch.repositories.RepositoryException;
|
||||
import org.elasticsearch.repositories.RepositoryVerificationException;
|
||||
import org.elasticsearch.snapshots.mockstore.MockRepositoryModule;
|
||||
import org.elasticsearch.snapshots.mockstore.MockRepositoryPlugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -211,12 +213,12 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
|
|||
.put("random_control_io_exception_rate", 1.0).build();
|
||||
logger.info("--> creating repository that cannot write any files - should fail");
|
||||
assertThrows(client.admin().cluster().preparePutRepository("test-repo-1")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(settings),
|
||||
.setType("mock").setSettings(settings),
|
||||
RepositoryVerificationException.class);
|
||||
|
||||
logger.info("--> creating repository that cannot write any files, but suppress verification - should be acked");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo-1")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(settings).setVerify(false));
|
||||
.setType("mock").setSettings(settings).setVerify(false));
|
||||
|
||||
logger.info("--> verifying repository");
|
||||
assertThrows(client.admin().cluster().prepareVerifyRepository("test-repo-1"), RepositoryVerificationException.class);
|
||||
|
@ -226,7 +228,7 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
|
|||
logger.info("--> creating repository");
|
||||
try {
|
||||
client.admin().cluster().preparePutRepository("test-repo-1")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName())
|
||||
.setType("mock")
|
||||
.setSettings(Settings.settingsBuilder()
|
||||
.put("location", location)
|
||||
.put("localize_location", true)
|
||||
|
@ -246,12 +248,12 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
|
|||
.put("random_control_io_exception_rate", 1.0).build();
|
||||
logger.info("--> creating repository that cannot write any files - should fail");
|
||||
assertThrows(client.admin().cluster().preparePutRepository("test-repo-1")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(settings),
|
||||
.setType("mock").setSettings(settings),
|
||||
RepositoryVerificationException.class);
|
||||
|
||||
logger.info("--> creating repository that cannot write any files, but suppress verification - should be acked");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo-1")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(settings).setVerify(false));
|
||||
.setType("mock").setSettings(settings).setVerify(false));
|
||||
|
||||
logger.info("--> verifying repository");
|
||||
assertThrows(client.admin().cluster().prepareVerifyRepository("test-repo-1"), RepositoryVerificationException.class);
|
||||
|
@ -261,7 +263,7 @@ public class RepositoriesIT extends AbstractSnapshotIntegTestCase {
|
|||
logger.info("--> creating repository");
|
||||
try {
|
||||
client.admin().cluster().preparePutRepository("test-repo-1")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName())
|
||||
.setType("mock")
|
||||
.setSettings(Settings.settingsBuilder()
|
||||
.put("location", location)
|
||||
.put("localize_location", true)
|
||||
|
|
|
@ -535,7 +535,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
|
||||
logger.info("--> creating repository");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", randomRepoPath())
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -585,7 +585,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
Client client = client();
|
||||
logger.info("--> creating repository");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", randomRepoPath())
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -672,7 +672,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
|
||||
logger.info("--> update repository with mock version");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", repositoryLocation)
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -714,7 +714,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
|
||||
logger.info("--> update repository with mock version");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", repositoryLocation)
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -1121,7 +1121,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
Path repositoryLocation = randomRepoPath();
|
||||
logger.info("--> creating repository");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", repositoryLocation)
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -1183,7 +1183,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
Path repositoryLocation = randomRepoPath();
|
||||
logger.info("--> creating repository");
|
||||
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", repositoryLocation)
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -1384,7 +1384,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
Path repositoryLocation = randomRepoPath();
|
||||
logger.info("--> creating repository");
|
||||
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(
|
||||
.setType("mock").setSettings(
|
||||
Settings.settingsBuilder()
|
||||
.put("location", repositoryLocation)
|
||||
.put("random", randomAsciiOfLength(10))
|
||||
|
@ -1711,7 +1711,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
|
||||
logger.info("--> creating repository");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(Settings.settingsBuilder()
|
||||
.setType("mock").setSettings(Settings.settingsBuilder()
|
||||
.put("location", randomRepoPath())
|
||||
.put("compress", randomBoolean())
|
||||
.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
|
||||
|
@ -1763,7 +1763,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|||
|
||||
logger.info("--> creating repository");
|
||||
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType(MockRepositoryModule.class.getCanonicalName()).setSettings(Settings.settingsBuilder()
|
||||
.setType("mock").setSettings(Settings.settingsBuilder()
|
||||
.put("location", randomRepoPath())
|
||||
.put("compress", randomBoolean())
|
||||
.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.elasticsearch.test;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
|
@ -31,6 +32,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.elasticsearch.test.junit.listeners.LoggingListener;
|
||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportModule;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -247,9 +250,10 @@ public abstract class ESBackcompatTestCase extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
protected Settings commonNodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.builder().put(requiredSettings())
|
||||
.put(TransportModule.TRANSPORT_TYPE_KEY, NettyTransport.class.getName()) // run same transport / disco as external
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, TransportService.class.getName());
|
||||
Settings.Builder builder = Settings.builder().put(requiredSettings());
|
||||
builder.put(TransportModule.TRANSPORT_TYPE_KEY, "netty"); // run same transport / disco as external
|
||||
builder.put("node.mode", "network");
|
||||
|
||||
if (compatibilityVersion().before(Version.V_1_3_2)) {
|
||||
// if we test against nodes before 1.3.2 we disable all the compression due to a known bug
|
||||
// see #7210
|
||||
|
|
|
@ -67,7 +67,6 @@ import org.elasticsearch.client.Client;
|
|||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||
|
@ -140,7 +139,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF
|
|||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.XContentTestUtils.convertToMap;
|
||||
import static org.elasticsearch.test.XContentTestUtils.mapsEqualIgnoringArrayOrder;
|
||||
import static org.elasticsearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
|
@ -1072,7 +1071,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||
// but we can compare serialization sizes - they should be the same
|
||||
assertEquals("clusterstate size does not match", masterClusterStateSize, localClusterStateSize);
|
||||
// Compare JSON serialization
|
||||
assertTrue("clusterstate JSON serialization does not match", mapsEqualIgnoringArrayOrder(masterStateMap, localStateMap));
|
||||
assertNull("clusterstate JSON serialization does not match", differenceBetweenMapsIgnoringArrayOrder(masterStateMap, localStateMap));
|
||||
} catch (AssertionError error) {
|
||||
logger.error("Cluster state from master:\n{}\nLocal cluster state:\n{}", masterClusterState.toString(), localClusterState.toString());
|
||||
throw error;
|
||||
|
|
|
@ -26,11 +26,15 @@ import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
|||
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.*;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
|
||||
import org.apache.lucene.store.StoreRateLimiting;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
|
@ -97,17 +101,17 @@ import org.elasticsearch.node.service.NodeService;
|
|||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.search.SearchServiceModule;
|
||||
import org.elasticsearch.test.cache.recycler.MockBigArraysModule;
|
||||
import org.elasticsearch.test.cache.recycler.MockPageCacheRecyclerModule;
|
||||
import org.elasticsearch.test.cache.recycler.MockBigArrays;
|
||||
import org.elasticsearch.test.cache.recycler.MockPageCacheRecycler;
|
||||
import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
|
||||
import org.elasticsearch.test.engine.MockEngineFactory;
|
||||
import org.elasticsearch.test.search.MockSearchServiceModule;
|
||||
import org.elasticsearch.test.search.MockSearchService;
|
||||
import org.elasticsearch.test.store.MockFSIndexStore;
|
||||
import org.elasticsearch.test.store.MockFSIndexStoreModule;
|
||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.transport.TransportModule;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.transport.netty.NettyTransport;
|
||||
import org.junit.Assert;
|
||||
|
@ -116,20 +120,35 @@ import java.io.Closeable;
|
|||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.apache.lucene.util.LuceneTestCase.*;
|
||||
import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY;
|
||||
import static org.apache.lucene.util.LuceneTestCase.rarely;
|
||||
import static org.apache.lucene.util.LuceneTestCase.usually;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
|
||||
import static org.elasticsearch.test.ESTestCase.assertBusy;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
|
@ -373,15 +392,14 @@ public final class InternalTestCluster extends TestCluster {
|
|||
Builder builder = Settings.settingsBuilder()
|
||||
.put(SETTING_CLUSTER_NODE_SEED, seed);
|
||||
if (ENABLE_MOCK_MODULES && usually(random)) {
|
||||
builder.put(IndexStoreModule.STORE_TYPE, MockFSIndexStoreModule.class.getName());
|
||||
builder.extendArray("plugin.types", MockTransportService.Plugin.class.getName(), MockFSIndexStore.Plugin.class.getName());
|
||||
builder.put(IndexShardModule.ENGINE_FACTORY, MockEngineFactory.class);
|
||||
builder.put(PageCacheRecyclerModule.CACHE_IMPL, MockPageCacheRecyclerModule.class.getName());
|
||||
builder.put(BigArraysModule.IMPL, MockBigArraysModule.class.getName());
|
||||
builder.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName());
|
||||
builder.put(SearchServiceModule.IMPL, MockSearchServiceModule.class.getName());
|
||||
builder.put(PageCacheRecyclerModule.CACHE_IMPL, MockPageCacheRecycler.class.getName());
|
||||
builder.put(BigArraysModule.IMPL, MockBigArrays.class.getName());
|
||||
builder.put(SearchServiceModule.IMPL, MockSearchService.class.getName());
|
||||
}
|
||||
if (isLocalTransportConfigured()) {
|
||||
builder.put(TransportModule.TRANSPORT_TYPE_KEY, AssertingLocalTransport.class.getName());
|
||||
builder.extendArray("plugin.types", AssertingLocalTransport.Plugin.class.getName());
|
||||
} else {
|
||||
builder.put(Transport.TransportSettings.TRANSPORT_TCP_COMPRESS, rarely(random));
|
||||
}
|
||||
|
|
|
@ -46,58 +46,80 @@ public final class XContentTestUtils {
|
|||
|
||||
|
||||
/**
|
||||
* Compares to maps generated from XContentObjects. The order of elements in arrays is ignored
|
||||
* Compares to maps generated from XContentObjects. The order of elements in arrays is ignored.
|
||||
*
|
||||
* @return null if maps are equal or path to the element where the difference was found
|
||||
*/
|
||||
public static boolean mapsEqualIgnoringArrayOrder(Map<String, Object> first, Map<String, Object> second) {
|
||||
public static String differenceBetweenMapsIgnoringArrayOrder(Map<String, Object> first, Map<String, Object> second) {
|
||||
return differenceBetweenMapsIgnoringArrayOrder("", first, second);
|
||||
}
|
||||
|
||||
private static String differenceBetweenMapsIgnoringArrayOrder(String path, Map<String, Object> first, Map<String, Object> second) {
|
||||
if (first.size() != second.size()) {
|
||||
return false;
|
||||
return path + ": sizes of the maps don't match: " + first.size() + " != " + second.size();
|
||||
}
|
||||
|
||||
for (String key : first.keySet()) {
|
||||
if (objectsEqualIgnoringArrayOrder(first.get(key), second.get(key)) == false) {
|
||||
return false;
|
||||
String reason = differenceBetweenObjectsIgnoringArrayOrder(path + "/" + key, first.get(key), second.get(key));
|
||||
if (reason != null) {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean objectsEqualIgnoringArrayOrder(Object first, Object second) {
|
||||
if (first == null ) {
|
||||
return second == null;
|
||||
private static String differenceBetweenObjectsIgnoringArrayOrder(String path, Object first, Object second) {
|
||||
if (first == null) {
|
||||
if (second == null) {
|
||||
return null;
|
||||
} else {
|
||||
return path + ": first element is null, the second element is not null";
|
||||
}
|
||||
} else if (first instanceof List) {
|
||||
if (second instanceof List) {
|
||||
if (second instanceof List) {
|
||||
List<Object> secondList = Lists.newArrayList((List<Object>) second);
|
||||
List<Object> firstList = (List<Object>) first;
|
||||
if (firstList.size() == secondList.size()) {
|
||||
String reason = path + ": no matches found";
|
||||
for (Object firstObj : firstList) {
|
||||
boolean found = false;
|
||||
for (Object secondObj : secondList) {
|
||||
if (objectsEqualIgnoringArrayOrder(firstObj, secondObj)) {
|
||||
reason = differenceBetweenObjectsIgnoringArrayOrder(path + "/*", firstObj, secondObj);
|
||||
if (reason == null) {
|
||||
secondList.remove(secondObj);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == false) {
|
||||
return false;
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
return secondList.isEmpty();
|
||||
if (secondList.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return path + ": the second list is not empty";
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
return path + ": sizes of the arrays don't match: " + firstList.size() + " != " + secondList.size();
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
return path + ": the second element is not an array";
|
||||
}
|
||||
} else if (first instanceof Map) {
|
||||
if (second instanceof Map) {
|
||||
return mapsEqualIgnoringArrayOrder((Map<String, Object>) first, (Map<String, Object>) second);
|
||||
return differenceBetweenMapsIgnoringArrayOrder(path, (Map<String, Object>) first, (Map<String, Object>) second);
|
||||
} else {
|
||||
return false;
|
||||
return path + ": the second element is not a map";
|
||||
}
|
||||
} else {
|
||||
return first.equals(second);
|
||||
if (first.equals(second)) {
|
||||
return null;
|
||||
} else {
|
||||
return path + ": the elements don't match: [" + first + "] != [" + second + "]";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.cache.recycler;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
|
||||
public class MockBigArraysModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(BigArrays.class).to(MockBigArrays.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.cache.recycler;
|
||||
|
||||
import org.elasticsearch.cache.recycler.PageCacheRecycler;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
|
||||
public class MockPageCacheRecyclerModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(PageCacheRecycler.class).to(MockPageCacheRecycler.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ public class NetworkPartitionIT extends ESIntegTestCase {
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, MockTransportService.class.getName())
|
||||
.put("plugin.types", MockTransportService.Plugin.class.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.lucene.search.QueryCachingPolicy;
|
|||
import org.apache.lucene.search.SearcherManager;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -87,7 +88,13 @@ public final class MockEngineSupport {
|
|||
final long seed = indexSettings.getAsLong(ESIntegTestCase.SETTING_INDEX_SEED, 0l);
|
||||
Random random = new Random(seed);
|
||||
final double ratio = indexSettings.getAsDouble(WRAP_READER_RATIO, 0.0d); // DISABLED by default - AssertingDR is crazy slow
|
||||
Class<? extends AssertingDirectoryReader> wrapper = indexSettings.getAsClass(READER_WRAPPER_TYPE, AssertingDirectoryReader.class);
|
||||
String readerWrapperType = indexSettings.get(READER_WRAPPER_TYPE);
|
||||
Class<? extends AssertingDirectoryReader > wrapper;
|
||||
if (readerWrapperType == null) {
|
||||
wrapper = AssertingDirectoryReader.class;
|
||||
} else {
|
||||
wrapper = Classes.loadClass(getClass().getClassLoader(), readerWrapperType);
|
||||
}
|
||||
boolean wrapReader = random.nextDouble() < ratio;
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Using [{}] for shard [{}] seed: [{}] wrapReader: [{}]", this.getClass().getName(), shardId, seed, wrapReader);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.search;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
|
||||
public class MockSearchServiceModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(SearchService.class).to(MockSearchService.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,10 +26,30 @@ import org.elasticsearch.index.settings.IndexSettings;
|
|||
import org.elasticsearch.index.settings.IndexSettingsService;
|
||||
import org.elasticsearch.index.store.DirectoryService;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
import org.elasticsearch.index.store.IndexStoreModule;
|
||||
import org.elasticsearch.indices.store.IndicesStore;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
public class MockFSIndexStore extends IndexStore {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-index-store";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "a mock index store for testing";
|
||||
}
|
||||
public void onModule(IndexStoreModule indexStoreModule) {
|
||||
indexStoreModule.addIndexStore("mock", MockFSIndexStore.class);
|
||||
}
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.builder().put(IndexStoreModule.STORE_TYPE, "mock").build();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public MockFSIndexStore(Index index, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService,
|
||||
IndicesStore indicesStore) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.VersionUtils;
|
||||
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
|
||||
|
@ -34,11 +35,26 @@ import org.elasticsearch.transport.local.LocalTransport;
|
|||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AssertingLocalTransport extends LocalTransport {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "asserting-local-transport";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "an asserting transport for testing";
|
||||
}
|
||||
public void onModule(TransportModule transportModule) {
|
||||
transportModule.addTransport("mock", AssertingLocalTransport.class);
|
||||
}
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.builder().put(TransportModule.TRANSPORT_TYPE_KEY, "mock").build();
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ASSERTING_TRANSPORT_MIN_VERSION_KEY = "transport.asserting.version.min";
|
||||
public static final String ASSERTING_TRANSPORT_MAX_VERSION_KEY = "transport.asserting.version.max";
|
||||
private final Random random;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.transport.TransportAddress;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.*;
|
||||
|
||||
|
@ -45,6 +46,24 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
*/
|
||||
public class MockTransportService extends TransportService {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-transport-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "a mock transport service for testing";
|
||||
}
|
||||
public void onModule(TransportModule transportModule) {
|
||||
transportModule.addTransportService("mock", MockTransportService.class);
|
||||
}
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.builder().put(TransportModule.TRANSPORT_SERVICE_TYPE_KEY, "mock").build();
|
||||
}
|
||||
}
|
||||
|
||||
private final Transport original;
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.ActionNotFoundTransportException;
|
||||
|
@ -66,7 +67,7 @@ public class NettyTransportIT extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put("node.mode", "network")
|
||||
.put(TransportModule.TRANSPORT_TYPE_KEY, ExceptionThrowingNettyTransport.class.getName()).build();
|
||||
.extendArray("plugin.types", ExceptionThrowingNettyTransport.Plugin.class.getName()).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -86,6 +87,24 @@ public class NettyTransportIT extends ESIntegTestCase {
|
|||
|
||||
public static final class ExceptionThrowingNettyTransport extends NettyTransport {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "exception-throwing-netty-transport";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "an exception throwing transport for testing";
|
||||
}
|
||||
public void onModule(TransportModule transportModule) {
|
||||
transportModule.addTransport("exception-throwing", ExceptionThrowingNettyTransport.class);
|
||||
}
|
||||
@Override
|
||||
public Settings additionalSettings() {
|
||||
return Settings.builder().put(TransportModule.TRANSPORT_TYPE_KEY, "exception-throwing").build();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public ExceptionThrowingNettyTransport(Settings settings, ThreadPool threadPool, NetworkService networkService, BigArrays bigArrays, Version version, NamedWriteableRegistry namedWriteableRegistry) {
|
||||
super(settings, threadPool, networkService, bigArrays, version, namedWriteableRegistry);
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.junit.annotations.Network;
|
||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.transport.TransportModule;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -49,23 +51,23 @@ public class NettyTransportMultiPortIntegrationIT extends ESIntegTestCase {
|
|||
randomPort = randomIntBetween(49152, 65525);
|
||||
randomPortRange = String.format(Locale.ROOT, "%s-%s", randomPort, randomPort+10);
|
||||
}
|
||||
return settingsBuilder()
|
||||
Settings.Builder builder = settingsBuilder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("network.host", "127.0.0.1")
|
||||
.put(TransportModule.TRANSPORT_TYPE_KEY, NettyTransport.class.getName())
|
||||
.put(TransportModule.TRANSPORT_TYPE_KEY, "netty")
|
||||
.put("node.mode", "network")
|
||||
.put("transport.profiles.client1.port", randomPortRange)
|
||||
.put("transport.profiles.client1.publish_host", "127.0.0.7")
|
||||
.put("transport.profiles.client1.publish_port", "4321")
|
||||
.put("transport.profiles.client1.reuse_address", true)
|
||||
.build();
|
||||
.put("transport.profiles.client1.reuse_address", true);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatTransportClientCanConnect() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(TransportModule.TRANSPORT_TYPE_KEY, NettyTransport.class.getName())
|
||||
.put(TransportModule.TRANSPORT_TYPE_KEY, "netty")
|
||||
.put("path.home", createTempDir().toString())
|
||||
.build();
|
||||
try (TransportClient transportClient = TransportClient.builder().settings(settings).loadConfigSettings(false).build()) {
|
||||
|
|
|
@ -22,11 +22,13 @@ import com.google.common.collect.Maps;
|
|||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.script.AbstractExecutableScript;
|
||||
import org.elasticsearch.script.ExecutableScript;
|
||||
import org.elasticsearch.script.NativeScriptEngineService;
|
||||
import org.elasticsearch.script.NativeScriptFactory;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptModule;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
|
@ -48,7 +50,7 @@ public class UpdateByNativeScriptIT extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("script.native.custom.type", CustomNativeScriptFactory.class.getName())
|
||||
.extendArray("plugin.types", CustomNativeScriptFactory.Plugin.class.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -69,7 +71,20 @@ public class UpdateByNativeScriptIT extends ESIntegTestCase {
|
|||
assertThat(data.get("foo").toString(), is("SETVALUE"));
|
||||
}
|
||||
|
||||
static class CustomNativeScriptFactory implements NativeScriptFactory {
|
||||
public static class CustomNativeScriptFactory implements NativeScriptFactory {
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-native-script";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "a mock native script for testing";
|
||||
}
|
||||
public void onModule(ScriptModule scriptModule) {
|
||||
scriptModule.registerScript("custom", CustomNativeScriptFactory.class);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ExecutableScript newScript(@Nullable Map<String, Object> params) {
|
||||
return new CustomScript(params);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<artifactId>elasticsearch-dev-tools</artifactId>
|
||||
<version>2.0.0-beta1-SNAPSHOT</version>
|
||||
<name>Elasticsearch Build Resources</name>
|
||||
<description>Tools to assist in building and developing in the Elasticsearch project</description>
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
But if you do this, then maven lifecycle does not execute any test (nor compile any test)
|
||||
-->
|
||||
<!--packaging>deb</packaging-->
|
||||
<description>The Debian distribution of Elasticsearch</description>
|
||||
|
||||
<properties>
|
||||
<deb.sign>false</deb.sign>
|
||||
|
|
|
@ -6,33 +6,4 @@ Depends: libc6, adduser
|
|||
Section: web
|
||||
Priority: optional
|
||||
Homepage: https://www.elastic.co/
|
||||
Description: Open Source, Distributed, RESTful Search Engine
|
||||
Elasticsearch is a distributed RESTful search engine built for the cloud.
|
||||
.
|
||||
Features include:
|
||||
.
|
||||
+ Distributed and Highly Available Search Engine.
|
||||
- Each index is fully sharded with a configurable number of shards.
|
||||
- Each shard can have one or more replicas.
|
||||
- Read / Search operations performed on either one of the replica shard.
|
||||
+ Multi Tenant with Multi Types.
|
||||
- Support for more than one index.
|
||||
- Support for more than one type per index.
|
||||
- Index level configuration (number of shards, index storage, ...).
|
||||
+ Various set of APIs
|
||||
- HTTP RESTful API
|
||||
- Native Java API.
|
||||
- All APIs perform automatic node operation rerouting.
|
||||
+ Document oriented
|
||||
- No need for upfront schema definition.
|
||||
- Schema can be defined per type for customization of the indexing process.
|
||||
+ Reliable, Asynchronous Write Behind for long term persistency.
|
||||
+ (Near) Real Time Search.
|
||||
+ Built on top of Lucene
|
||||
- Each shard is a fully functional Lucene index
|
||||
- All the power of Lucene easily exposed through simple
|
||||
configuration/plugins.
|
||||
+ Per operation consistency
|
||||
- Single document level operations are atomic, consistent, isolated and
|
||||
durable.
|
||||
+ Open Source under the Apache License, version 2 ("ALv2").
|
||||
Description: Elasticsearch is a distributed RESTful search engine built for the cloud. Reference documentation can be found at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html and the 'Elasticsearch: The Definitive Guide' book can be found at https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<artifactId>elasticsearch</artifactId>
|
||||
<name>Elasticsearch RPM Distribution</name>
|
||||
<packaging>rpm</packaging>
|
||||
<description>The RPM distribution of Elasticsearch</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -122,6 +123,7 @@
|
|||
<defaultUsername>root</defaultUsername>
|
||||
<defaultGroupname>root</defaultGroupname>
|
||||
<icon>${project.basedir}/src/main/resources/logo/elastic.gif</icon>
|
||||
<description>Elasticsearch is a distributed RESTful search engine built for the cloud. Reference documentation can be found at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html and the 'Elasticsearch: The Definitive Guide' book can be found at https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html</description>
|
||||
<mappings>
|
||||
<!-- Add bin directory -->
|
||||
<mapping>
|
||||
|
|
|
@ -10,6 +10,10 @@ logger:
|
|||
|
||||
# reduce the logging for aws, too much is logged under the default INFO
|
||||
com.amazonaws: WARN
|
||||
# aws will try to do some sketchy JMX stuff, but its not needed.
|
||||
com.amazonaws.jmx.SdkMBeanRegistrySupport: ERROR
|
||||
com.amazonaws.metrics.AwsSdkMetrics: ERROR
|
||||
|
||||
org.apache.http: INFO
|
||||
|
||||
# gateway
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
But if you do this, then maven lifecycle does not execute any test (nor compile any test)
|
||||
-->
|
||||
<!--packaging>pom</packaging-->
|
||||
<description>The TAR distribution of Elasticsearch</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
But if you do this, then maven lifecycle does not execute any test (nor compile any test)
|
||||
-->
|
||||
<!--packaging>pom</packaging-->
|
||||
<description>The ZIP distribution of Elasticsearch</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
@ -22,27 +22,19 @@ package org.elasticsearch.cloud.aws;
|
|||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AwsModule extends AbstractModule {
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
public static final String S3_SERVICE_TYPE_KEY = "cloud.aws.s3service.type";
|
||||
// pkg private so it is settable by tests
|
||||
static Class<? extends AwsS3Service> s3ServiceImpl = InternalAwsS3Service.class;
|
||||
|
||||
public AwsModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
public static Class<? extends AwsS3Service> getS3ServiceImpl() {
|
||||
return s3ServiceImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AwsS3Service.class).to(getS3ServiceClass(settings)).asEagerSingleton();
|
||||
bind(AwsS3Service.class).to(s3ServiceImpl).asEagerSingleton();
|
||||
bind(AwsEc2Service.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
public static Class<? extends AwsS3Service> getS3ServiceClass(Settings settings) {
|
||||
return settings.getAsClass(S3_SERVICE_TYPE_KEY, InternalAwsS3Service.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.ec2;
|
||||
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Ec2DiscoveryModule extends ZenDiscoveryModule {
|
||||
|
||||
@Inject
|
||||
public Ec2DiscoveryModule(Settings settings) {
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
addUnicastHostProvider(AwsEc2UnicastHostsProvider.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindDiscovery() {
|
||||
bind(Discovery.class).to(Ec2Discovery.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -24,6 +24,8 @@ import org.elasticsearch.cloud.aws.AwsModule;
|
|||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.ec2.Ec2Discovery;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.repositories.RepositoriesModule;
|
||||
import org.elasticsearch.repositories.s3.S3Repository;
|
||||
|
@ -57,7 +59,7 @@ public class CloudAwsPlugin extends AbstractPlugin {
|
|||
public Collection<Module> modules(Settings settings) {
|
||||
Collection<Module> modules = new ArrayList<>();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
modules.add(new AwsModule(settings));
|
||||
modules.add(new AwsModule());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
@ -66,7 +68,7 @@ public class CloudAwsPlugin extends AbstractPlugin {
|
|||
public Collection<Class<? extends LifecycleComponent>> services() {
|
||||
Collection<Class<? extends LifecycleComponent>> services = new ArrayList<>();
|
||||
if (settings.getAsBoolean("cloud.enabled", true)) {
|
||||
services.add(AwsModule.getS3ServiceClass(settings));
|
||||
services.add(AwsModule.getS3ServiceImpl());
|
||||
services.add(AwsEc2Service.class);
|
||||
}
|
||||
return services;
|
||||
|
@ -77,4 +79,8 @@ public class CloudAwsPlugin extends AbstractPlugin {
|
|||
repositoriesModule.registerRepository(S3Repository.TYPE, S3RepositoryModule.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void onModule(DiscoveryModule discoveryModule) {
|
||||
discoveryModule.addDiscoveryType("ec2", Ec2Discovery.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,8 +75,7 @@ public abstract class AbstractAwsTest extends ESIntegTestCase {
|
|||
Settings.Builder settings = Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("path.home", createTempDir())
|
||||
.put("plugin.types", CloudAwsPlugin.class.getName())
|
||||
.put(AwsModule.S3_SERVICE_TYPE_KEY, TestAwsS3Service.class)
|
||||
.extendArray("plugin.types", CloudAwsPlugin.class.getName(), TestAwsS3Service.Plugin.class.getName())
|
||||
.put("cloud.aws.test.random", randomInt())
|
||||
.put("cloud.aws.test.write_failures", 0.1)
|
||||
.put("cloud.aws.test.read_failures", 0.1);
|
||||
|
|
|
@ -22,13 +22,24 @@ import com.amazonaws.services.s3.AmazonS3;
|
|||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TestAwsS3Service extends InternalAwsS3Service {
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-s3-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "plugs in mock s3 service";
|
||||
}
|
||||
public void onModule(AwsModule awsModule) {
|
||||
awsModule.s3ServiceImpl = TestAwsS3Service.class;
|
||||
}
|
||||
}
|
||||
|
||||
IdentityHashMap<AmazonS3, TestAmazonS3> clients = new IdentityHashMap<AmazonS3, TestAmazonS3>();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.ElasticsearchException;
|
|||
import org.elasticsearch.cloud.azure.management.AzureComputeService;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceImpl;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeSettingsFilter;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
|
||||
|
@ -51,6 +52,18 @@ public class AzureModule extends AbstractModule {
|
|||
protected final ESLogger logger;
|
||||
private Settings settings;
|
||||
|
||||
// pkg private so it is settable by tests
|
||||
static Class<? extends AzureComputeService> computeServiceImpl = AzureComputeServiceImpl.class;
|
||||
static Class<? extends AzureStorageService> storageServiceImpl = AzureStorageServiceImpl.class;
|
||||
|
||||
public static Class<? extends AzureComputeService> getComputeServiceImpl() {
|
||||
return computeServiceImpl;
|
||||
}
|
||||
|
||||
public static Class<? extends AzureStorageService> getStorageServiceImpl() {
|
||||
return storageServiceImpl;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public AzureModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
|
@ -60,21 +73,18 @@ public class AzureModule extends AbstractModule {
|
|||
@Override
|
||||
protected void configure() {
|
||||
logger.debug("starting azure services");
|
||||
bind(AzureComputeSettingsFilter.class).asEagerSingleton();
|
||||
|
||||
// If we have set discovery to azure, let's start the azure compute service
|
||||
if (isDiscoveryReady(settings, logger)) {
|
||||
logger.debug("starting azure discovery service");
|
||||
bind(AzureComputeService.class)
|
||||
.to(settings.getAsClass(Management.API_IMPLEMENTATION, AzureComputeServiceImpl.class))
|
||||
.asEagerSingleton();
|
||||
bind(AzureComputeService.class).to(computeServiceImpl).asEagerSingleton();
|
||||
}
|
||||
|
||||
// If we have settings for azure repository, let's start the azure storage service
|
||||
if (isSnapshotReady(settings, logger)) {
|
||||
logger.debug("starting azure repository service");
|
||||
bind(AzureStorageService.class)
|
||||
.to(settings.getAsClass(Storage.API_IMPLEMENTATION, AzureStorageServiceImpl.class))
|
||||
.asEagerSingleton();
|
||||
bind(AzureStorageService.class).to(storageServiceImpl).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AzureModule;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeSettingsFilter;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.Discovery;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AzureDiscoveryModule extends ZenDiscoveryModule {
|
||||
|
||||
protected final ESLogger logger;
|
||||
private Settings settings;
|
||||
|
||||
public AzureDiscoveryModule(Settings settings) {
|
||||
super();
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
this.settings = settings;
|
||||
if (AzureModule.isDiscoveryReady(settings, logger)) {
|
||||
addUnicastHostProvider(AzureUnicastHostsProvider.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindDiscovery() {
|
||||
bind(AzureComputeSettingsFilter.class).asEagerSingleton();
|
||||
if (AzureModule.isDiscoveryReady(settings, logger)) {
|
||||
bind(Discovery.class).to(AzureDiscovery.class).asEagerSingleton();
|
||||
} else {
|
||||
logger.debug("disabling azure discovery features");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.store.smbmmapfs;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
|
||||
public class SmbMmapFsIndexStoreModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(IndexStore.class).to(SmbMmapFsIndexStore.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.store.smbsimplefs;
|
||||
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
|
||||
public class SmbSimpleFsIndexStoreModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(IndexStore.class).to(SmbSimpleFsIndexStore.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -24,6 +24,11 @@ import org.elasticsearch.common.inject.Module;
|
|||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.azure.AzureDiscovery;
|
||||
import org.elasticsearch.index.store.IndexStoreModule;
|
||||
import org.elasticsearch.index.store.smbmmapfs.SmbMmapFsIndexStore;
|
||||
import org.elasticsearch.index.store.smbsimplefs.SmbSimpleFsIndexStore;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.repositories.RepositoriesModule;
|
||||
import org.elasticsearch.repositories.azure.AzureRepository;
|
||||
|
@ -73,4 +78,13 @@ public class CloudAzurePlugin extends AbstractPlugin {
|
|||
((RepositoriesModule)module).registerRepository(AzureRepository.TYPE, AzureRepositoryModule.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void onModule(DiscoveryModule discoveryModule) {
|
||||
discoveryModule.addDiscoveryType("azure", AzureDiscovery.class);
|
||||
}
|
||||
|
||||
public void onModule(IndexStoreModule storeModule) {
|
||||
storeModule.addIndexStore("smb_mmap_fs", SmbMmapFsIndexStore.class);
|
||||
storeModule.addIndexStore("smb_simple_fs", SmbSimpleFsIndexStore.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,31 +17,44 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.cloud.azure.AzureModule;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugin.cloud.azure.CloudAzurePlugin;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
public abstract class AbstractAzureComputeServiceTest extends ESIntegTestCase {
|
||||
|
||||
private Class<? extends AzureComputeService> mock;
|
||||
private String mockPlugin;
|
||||
|
||||
public AbstractAzureComputeServiceTest(Class<? extends AzureComputeService> mock) {
|
||||
public AbstractAzureComputeServiceTest(String mockPlugin) {
|
||||
// We want to inject the Azure API Mock
|
||||
this.mock = mock;
|
||||
this.mockPlugin = mockPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder settings = Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("plugin.types", CloudAzurePlugin.class.getName());
|
||||
return settings.build();
|
||||
Settings.Builder builder = Settings.settingsBuilder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("discovery.type", "azure")
|
||||
// We need the network to make the mock working
|
||||
.put("node.mode", "network")
|
||||
.extendArray("plugin.types", CloudAzurePlugin.class.getName(), mockPlugin);
|
||||
|
||||
// We add a fake subscription_id to start mock compute service
|
||||
builder.put(Management.SUBSCRIPTION_ID, "fake")
|
||||
.put(Discovery.REFRESH, "5s")
|
||||
.put(Management.KEYSTORE_PATH, "dummy")
|
||||
.put(Management.KEYSTORE_PASSWORD, "dummy")
|
||||
.put(Management.SERVICE_NAME, "dummy");
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
protected void checkNumberOfNodes(int expected) {
|
||||
|
@ -50,21 +63,4 @@ public abstract class AbstractAzureComputeServiceTest extends ESIntegTestCase {
|
|||
assertNotNull(nodeInfos.getNodes());
|
||||
assertEquals(expected, nodeInfos.getNodes().length);
|
||||
}
|
||||
|
||||
protected Settings settingsBuilder() {
|
||||
Settings.Builder builder = Settings.settingsBuilder()
|
||||
.put("discovery.type", "azure")
|
||||
.put(Management.API_IMPLEMENTATION, mock)
|
||||
// We need the network to make the mock working
|
||||
.put("node.mode", "network");
|
||||
|
||||
// We add a fake subscription_id to start mock compute service
|
||||
builder.put(Management.SUBSCRIPTION_ID, "fake")
|
||||
.put(Discovery.REFRESH, "5s")
|
||||
.put(Management.KEYSTORE_PATH, "dummy")
|
||||
.put(Management.KEYSTORE_PASSWORD, "dummy")
|
||||
.put(Management.SERVICE_NAME, "dummy");
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
|
@ -17,17 +17,16 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.repositories.azure;
|
||||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import com.microsoft.azure.storage.StorageException;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureTest;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceMock;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugin.cloud.azure.CloudAzurePlugin;
|
||||
import org.elasticsearch.plugins.PluginsService;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.repositories.RepositoryMissingException;
|
||||
import org.elasticsearch.test.store.MockFSDirectoryService;
|
||||
import org.junit.After;
|
||||
|
@ -37,13 +36,24 @@ import java.net.URISyntaxException;
|
|||
|
||||
public abstract class AbstractAzureRepositoryServiceTest extends AbstractAzureTest {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-stoarge-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "plugs in a mock storage service for testing";
|
||||
}
|
||||
public void onModule(AzureModule azureModule) {
|
||||
azureModule.storageServiceImpl = AzureStorageServiceMock.class;
|
||||
}
|
||||
}
|
||||
|
||||
protected String basePath;
|
||||
private Class<? extends AzureStorageService> mock;
|
||||
|
||||
public AbstractAzureRepositoryServiceTest(Class<? extends AzureStorageService> mock,
|
||||
String basePath) {
|
||||
// We want to inject the Azure API Mock
|
||||
this.mock = mock;
|
||||
public AbstractAzureRepositoryServiceTest(String basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
|
@ -67,7 +77,7 @@ public abstract class AbstractAzureRepositoryServiceTest extends AbstractAzureTe
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.settingsBuilder()
|
||||
.put("plugin.types", CloudAzurePlugin.class.getName())
|
||||
.extendArray("plugin.types", CloudAzurePlugin.class.getName(), Plugin.class.getName())
|
||||
.put(Storage.API_IMPLEMENTATION, mock)
|
||||
.put(Storage.CONTAINER, "snapshots");
|
||||
|
|
@ -17,12 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.azure.management;
|
||||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import com.microsoft.windowsazure.management.compute.models.*;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceAbstractMock;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
|
@ -31,6 +33,20 @@ import java.net.InetAddress;
|
|||
*/
|
||||
public class AzureComputeServiceSimpleMock extends AzureComputeServiceAbstractMock {
|
||||
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-compute-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "plugs in a mock compute service for testing";
|
||||
}
|
||||
public void onModule(AzureModule azureModule) {
|
||||
azureModule.computeServiceImpl = AzureComputeServiceSimpleMock.class;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
protected AzureComputeServiceSimpleMock(Settings settings) {
|
||||
super(settings);
|
|
@ -17,13 +17,17 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.azure.management;
|
||||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import com.microsoft.windowsazure.management.compute.models.*;
|
||||
import org.elasticsearch.cloud.azure.AzureModule;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceAbstractMock;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.network.NetworkService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
import org.elasticsearch.plugins.AbstractPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
|
@ -32,6 +36,19 @@ import java.net.InetAddress;
|
|||
* Mock Azure API with two started nodes
|
||||
*/
|
||||
public class AzureComputeServiceTwoNodesMock extends AzureComputeServiceAbstractMock {
|
||||
public static class Plugin extends AbstractPlugin {
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-compute-service";
|
||||
}
|
||||
@Override
|
||||
public String description() {
|
||||
return "plugs in a mock compute service for testing";
|
||||
}
|
||||
public void onModule(AzureModule azureModule) {
|
||||
azureModule.computeServiceImpl = AzureComputeServiceTwoNodesMock.class;
|
||||
}
|
||||
}
|
||||
|
||||
NetworkService networkService;
|
||||
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceTwoNodesMock;
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureComputeServiceTest;
|
||||
import org.elasticsearch.cloud.azure.AzureComputeServiceTwoNodesMock;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -43,13 +44,13 @@ import static org.hamcrest.Matchers.nullValue;
|
|||
public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest {
|
||||
|
||||
public AzureMinimumMasterNodesTest() {
|
||||
super(AzureComputeServiceTwoNodesMock.class);
|
||||
super(AzureComputeServiceTwoNodesMock.Plugin.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final Settings settingsBuilder() {
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.settingsBuilder()
|
||||
.put(super.settingsBuilder())
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("discovery.zen.minimum_master_nodes", 2)
|
||||
// Make the test run faster
|
||||
.put("discovery.zen.join.timeout", "50ms")
|
||||
|
@ -61,7 +62,7 @@ public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest
|
|||
@Test
|
||||
public void simpleOnlyMasterNodeElection() throws IOException {
|
||||
logger.info("--> start data node / non master node");
|
||||
internalCluster().startNode(settingsBuilder());
|
||||
internalCluster().startNode();
|
||||
try {
|
||||
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().masterNodeId(), nullValue());
|
||||
fail("should not be able to find master");
|
||||
|
@ -69,7 +70,7 @@ public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest
|
|||
// all is well, no master elected
|
||||
}
|
||||
logger.info("--> start another node");
|
||||
internalCluster().startNode(settingsBuilder());
|
||||
internalCluster().startNode();
|
||||
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
|
||||
|
||||
logger.info("--> stop master node");
|
||||
|
@ -83,7 +84,7 @@ public class AzureMinimumMasterNodesTest extends AbstractAzureComputeServiceTest
|
|||
}
|
||||
|
||||
logger.info("--> start another node");
|
||||
internalCluster().startNode(settingsBuilder());
|
||||
internalCluster().startNode();
|
||||
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("1s").execute().actionGet().getState().nodes().masterNodeId(), notNullValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureComputeServiceTest;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceSimpleMock;
|
||||
import org.elasticsearch.cloud.azure.AzureComputeServiceSimpleMock;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -35,15 +36,14 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
||||
|
||||
public AzureSimpleTest() {
|
||||
super(AzureComputeServiceSimpleMock.class);
|
||||
super(AzureComputeServiceSimpleMock.Plugin.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void one_node_should_run_using_private_ip() {
|
||||
Settings.Builder settings = Settings.settingsBuilder()
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "private_ip")
|
||||
.put(super.settingsBuilder());
|
||||
.put(Discovery.HOST_TYPE, "private_ip");
|
||||
|
||||
logger.info("--> start one node");
|
||||
internalCluster().startNode(settings);
|
||||
|
@ -57,8 +57,7 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
|||
public void one_node_should_run_using_public_ip() {
|
||||
Settings.Builder settings = Settings.settingsBuilder()
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "public_ip")
|
||||
.put(super.settingsBuilder());
|
||||
.put(Discovery.HOST_TYPE, "public_ip");
|
||||
|
||||
logger.info("--> start one node");
|
||||
internalCluster().startNode(settings);
|
||||
|
@ -72,8 +71,7 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
|||
public void one_node_should_run_using_wrong_settings() {
|
||||
Settings.Builder settings = Settings.settingsBuilder()
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "do_not_exist")
|
||||
.put(super.settingsBuilder());
|
||||
.put(Discovery.HOST_TYPE, "do_not_exist");
|
||||
|
||||
logger.info("--> start one node");
|
||||
internalCluster().startNode(settings);
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureComputeServiceTest;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceTwoNodesMock;
|
||||
import org.elasticsearch.cloud.azure.AzureComputeServiceTwoNodesMock;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -35,7 +36,7 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
|
||||
|
||||
public AzureTwoStartedNodesTest() {
|
||||
super(AzureComputeServiceTwoNodesMock.class);
|
||||
super(AzureComputeServiceTwoNodesMock.Plugin.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -43,8 +44,7 @@ public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
|
|||
public void two_nodes_should_run_using_private_ip() {
|
||||
Settings.Builder settings = Settings.settingsBuilder()
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "private_ip")
|
||||
.put(super.settingsBuilder());
|
||||
.put(Discovery.HOST_TYPE, "private_ip");
|
||||
|
||||
logger.info("--> start first node");
|
||||
internalCluster().startNode(settings);
|
||||
|
@ -63,8 +63,7 @@ public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
|
|||
public void two_nodes_should_run_using_public_ip() {
|
||||
Settings.Builder settings = Settings.settingsBuilder()
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "public_ip")
|
||||
.put(super.settingsBuilder());
|
||||
.put(Discovery.HOST_TYPE, "public_ip");
|
||||
|
||||
logger.info("--> start first node");
|
||||
internalCluster().startNode(settings);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue