Remove and ban ImmutableSet#of
This commit is contained in:
parent
b0ab02e35c
commit
04c570461e
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.ElasticsearchGenerationException;
|
||||
import org.elasticsearch.cluster.AbstractDiffable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -36,6 +35,8 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -61,7 +62,7 @@ public class AliasMetaData extends AbstractDiffable<AliasMetaData> {
|
|||
if (searchRouting != null) {
|
||||
searchRoutingValues = Collections.unmodifiableSet(Strings.splitStringByCommaToSet(searchRouting));
|
||||
} else {
|
||||
searchRoutingValues = ImmutableSet.of();
|
||||
searchRoutingValues = emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.cluster.metadata;
|
|||
import com.carrotsearch.hppc.ObjectHashSet;
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.cluster.Diff;
|
||||
import org.elasticsearch.cluster.Diffable;
|
||||
|
@ -59,12 +59,26 @@ import org.elasticsearch.rest.RestStatus;
|
|||
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.settings.Settings.readSettingsFromStream;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.settings.Settings.writeSettingsToStream;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, FromXContentBuilder<MetaData>, ToXContent {
|
||||
|
||||
|
@ -729,16 +743,16 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
|
|||
}
|
||||
|
||||
/** All known byte-sized cluster settings. */
|
||||
public static final Set<String> CLUSTER_BYTES_SIZE_SETTINGS = ImmutableSet.of(
|
||||
public static final Set<String> CLUSTER_BYTES_SIZE_SETTINGS = unmodifiableSet(newHashSet(
|
||||
IndicesStore.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC,
|
||||
RecoverySettings.INDICES_RECOVERY_FILE_CHUNK_SIZE,
|
||||
RecoverySettings.INDICES_RECOVERY_TRANSLOG_SIZE,
|
||||
RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC,
|
||||
RecoverySettings.INDICES_RECOVERY_MAX_SIZE_PER_SEC);
|
||||
RecoverySettings.INDICES_RECOVERY_MAX_SIZE_PER_SEC));
|
||||
|
||||
|
||||
/** All known time cluster settings. */
|
||||
public static final Set<String> CLUSTER_TIME_SETTINGS = ImmutableSet.of(
|
||||
public static final Set<String> CLUSTER_TIME_SETTINGS = unmodifiableSet(newHashSet(
|
||||
IndicesTTLService.INDICES_TTL_INTERVAL,
|
||||
RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC,
|
||||
RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK,
|
||||
|
@ -749,7 +763,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
|
|||
InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL,
|
||||
InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT,
|
||||
DiscoverySettings.PUBLISH_TIMEOUT,
|
||||
InternalClusterService.SETTING_CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD);
|
||||
InternalClusterService.SETTING_CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD));
|
||||
|
||||
/** As of 2.0 we require units for time and byte-sized settings. This methods adds default units to any cluster settings that don't
|
||||
* specify a unit. */
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
|
@ -29,7 +30,6 @@ import org.elasticsearch.cluster.routing.UnassignedInfo;
|
|||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
|
@ -41,6 +41,9 @@ import org.elasticsearch.script.ScriptService;
|
|||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
* This service is responsible for upgrading legacy index metadata to the current version
|
||||
* <p>
|
||||
|
@ -217,7 +220,7 @@ public class MetaDataIndexUpgradeService extends AbstractComponent {
|
|||
}
|
||||
|
||||
/** All known byte-sized settings for an index. */
|
||||
public static final Set<String> INDEX_BYTES_SIZE_SETTINGS = ImmutableSet.of(
|
||||
public static final Set<String> INDEX_BYTES_SIZE_SETTINGS = unmodifiableSet(newHashSet(
|
||||
"index.merge.policy.floor_segment",
|
||||
"index.merge.policy.max_merged_segment",
|
||||
"index.merge.policy.max_merge_size",
|
||||
|
@ -227,10 +230,10 @@ public class MetaDataIndexUpgradeService extends AbstractComponent {
|
|||
"index.store.throttle.max_bytes_per_sec",
|
||||
"index.translog.flush_threshold_size",
|
||||
"index.translog.fs.buffer_size",
|
||||
"index.version_map_size");
|
||||
"index.version_map_size"));
|
||||
|
||||
/** All known time settings for an index. */
|
||||
public static final Set<String> INDEX_TIME_SETTINGS = ImmutableSet.of(
|
||||
public static final Set<String> INDEX_TIME_SETTINGS = unmodifiableSet(newHashSet(
|
||||
"index.gateway.wait_for_mapping_update_post_recovery",
|
||||
"index.shard.wait_for_mapping_update_post_recovery",
|
||||
"index.gc_deletes",
|
||||
|
@ -252,7 +255,7 @@ public class MetaDataIndexUpgradeService extends AbstractComponent {
|
|||
"index.translog.flush_threshold_period",
|
||||
"index.translog.interval",
|
||||
"index.translog.sync_interval",
|
||||
UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING);
|
||||
UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING));
|
||||
|
||||
/**
|
||||
* Elasticsearch 2.0 requires units on byte/memory and time settings; this method adds the default unit to any such settings that are
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.common;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.lucene.util.BytesRefBuilder;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.io.FastStringReader;
|
||||
|
@ -30,7 +29,21 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -443,7 +456,8 @@ public class Strings {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public static final ImmutableSet<Character> INVALID_FILENAME_CHARS = ImmutableSet.of('\\', '/', '*', '?', '"', '<', '>', '|', ' ', ',');
|
||||
public static final Set<Character> INVALID_FILENAME_CHARS = unmodifiableSet(
|
||||
newHashSet('\\', '/', '*', '?', '"', '<', '>', '|', ' ', ','));
|
||||
|
||||
public static boolean validFileName(String fileName) {
|
||||
for (int i = 0; i < fileName.length(); i++) {
|
||||
|
@ -596,7 +610,7 @@ public class Strings {
|
|||
result[res++] = builder.toString();
|
||||
builder.setLength(0);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
builder.append(s.charAt(i));
|
||||
}
|
||||
|
@ -1010,11 +1024,11 @@ public class Strings {
|
|||
|
||||
private Strings() {
|
||||
}
|
||||
|
||||
|
||||
public static byte[] toUTF8Bytes(CharSequence charSequence) {
|
||||
return toUTF8Bytes(charSequence, new BytesRefBuilder());
|
||||
}
|
||||
|
||||
|
||||
public static byte[] toUTF8Bytes(CharSequence charSequence, BytesRefBuilder spare) {
|
||||
spare.copyChars(charSequence);
|
||||
return Arrays.copyOf(spare.bytes(), spare.length());
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.Annotations;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
|
@ -47,6 +46,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
* Handles {@link Binder#bind} and {@link Binder#bindConstant} elements.
|
||||
*
|
||||
|
@ -282,7 +284,7 @@ class BindingProcessor extends AbstractProcessor {
|
|||
// It's unfortunate that we have to maintain a blacklist of specific
|
||||
// classes, but we can't easily block the whole package because of
|
||||
// all our unit tests.
|
||||
private static final Set<Class<?>> FORBIDDEN_TYPES = ImmutableSet.of(
|
||||
private static final Set<Class<?>> FORBIDDEN_TYPES = unmodifiableSet(newHashSet(
|
||||
AbstractModule.class,
|
||||
Binder.class,
|
||||
Binding.class,
|
||||
|
@ -292,7 +294,7 @@ class BindingProcessor extends AbstractProcessor {
|
|||
Module.class,
|
||||
Provider.class,
|
||||
Scope.class,
|
||||
TypeLiteral.class);
|
||||
TypeLiteral.class));
|
||||
// TODO(jessewilson): fix BuiltInModule, then add Stage
|
||||
|
||||
interface CreationListener {
|
||||
|
|
|
@ -16,14 +16,12 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.InstanceBindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.InternalFactory;
|
||||
import org.elasticsearch.common.inject.internal.MatcherAndConverter;
|
||||
import org.elasticsearch.common.inject.internal.SourceProvider;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.TypeListenerBinding;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
@ -35,6 +33,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
/**
|
||||
* @author jessewilson@google.com (Jesse Wilson)
|
||||
*/
|
||||
|
@ -155,7 +155,8 @@ class InheritingState implements State {
|
|||
Key key = entry.getKey();
|
||||
BindingImpl<?> binding = (BindingImpl<?>) entry.getValue();
|
||||
Object value = binding.getProvider().get();
|
||||
x.put(key, new InstanceBindingImpl<Object>(injector, key, SourceProvider.UNKNOWN_SOURCE, new InternalFactory.Instance(value), ImmutableSet.<InjectionPoint>of(), value));
|
||||
x.put(key, new InstanceBindingImpl<Object>(injector, key, SourceProvider.UNKNOWN_SOURCE, new InternalFactory.Instance(value),
|
||||
emptySet(), value));
|
||||
}
|
||||
this.explicitBindingsMutable.clear();
|
||||
this.explicitBindingsMutable.putAll(x);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.Classes;
|
||||
import org.elasticsearch.common.inject.internal.Annotations;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
|
@ -35,7 +34,6 @@ import org.elasticsearch.common.inject.internal.ToStringBuilder;
|
|||
import org.elasticsearch.common.inject.spi.BindingTargetVisitor;
|
||||
import org.elasticsearch.common.inject.spi.ConvertedConstantBinding;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.ProviderBinding;
|
||||
import org.elasticsearch.common.inject.spi.ProviderKeyBinding;
|
||||
import org.elasticsearch.common.inject.util.Providers;
|
||||
|
@ -54,6 +52,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.elasticsearch.common.inject.internal.Annotations.findScopeAnnotation;
|
||||
|
||||
/**
|
||||
|
@ -221,7 +221,7 @@ class InjectorImpl implements Injector, Lookups {
|
|||
|
||||
|
||||
return new InstanceBindingImpl<>(this, key, SourceProvider.UNKNOWN_SOURCE,
|
||||
factory, ImmutableSet.<InjectionPoint>of(), membersInjector);
|
||||
factory, emptySet(), membersInjector);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +379,7 @@ class InjectorImpl implements Injector, Lookups {
|
|||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return ImmutableSet.<Dependency<?>>of(Dependency.get(getSourceKey()));
|
||||
return singleton(Dependency.get(getSourceKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -502,7 +502,7 @@ class InjectorImpl implements Injector, Lookups {
|
|||
InternalFactory<TypeLiteral<T>> factory = new ConstantFactory<>(
|
||||
Initializables.of(value));
|
||||
return new InstanceBindingImpl<>(this, key, SourceProvider.UNKNOWN_SOURCE,
|
||||
factory, ImmutableSet.<InjectionPoint>of(), value);
|
||||
factory, emptySet(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.MatcherAndConverter;
|
||||
|
@ -27,6 +26,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
/**
|
||||
* The inheritable data within an injector. This class is intended to allow parent and local
|
||||
* injector data to be accessed as a unit.
|
||||
|
@ -79,7 +80,7 @@ interface State {
|
|||
|
||||
@Override
|
||||
public Iterable<MatcherAndConverter> getConvertersThisLevel() {
|
||||
return ImmutableSet.of();
|
||||
return emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.elasticsearch.common.inject.assistedinject;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -43,6 +42,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
|
@ -338,6 +338,6 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
|||
}
|
||||
|
||||
private static ConfigurationException newConfigurationException(String format, Object... args) {
|
||||
return new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
|
||||
return new ConfigurationException(singleton(new Message(Errors.format(format, args))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.CreationException;
|
||||
|
@ -50,6 +48,7 @@ import java.util.Formatter;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
|
||||
/**
|
||||
|
@ -319,7 +318,7 @@ public final class Errors implements Serializable {
|
|||
} else if (throwable instanceof CreationException) {
|
||||
return ((CreationException) throwable).getErrorMessages();
|
||||
} else {
|
||||
return ImmutableSet.of();
|
||||
return emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
|
@ -27,6 +26,8 @@ import org.elasticsearch.common.inject.spi.PrivateElements;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
public class ExposedBindingImpl<T> extends BindingImpl<T> implements ExposedBinding<T> {
|
||||
|
||||
private final PrivateElements privateElements;
|
||||
|
@ -50,7 +51,7 @@ public class ExposedBindingImpl<T> extends BindingImpl<T> implements ExposedBind
|
|||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return ImmutableSet.<Dependency<?>>of(Dependency.get(Key.get(Injector.class)));
|
||||
return singleton(Dependency.get(Key.get(Injector.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,18 +18,29 @@
|
|||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.GenericDeclaration;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.WildcardType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
/**
|
||||
* Static methods for working with types that we aren't publishing in the
|
||||
* public {@code Types} API.
|
||||
|
@ -65,7 +76,7 @@ public class MoreTypes {
|
|||
public static <T> TypeLiteral<T> makeKeySafe(TypeLiteral<T> type) {
|
||||
if (!isFullySpecified(type.getType())) {
|
||||
String message = type + " cannot be used as a key; It is not fully specified.";
|
||||
throw new ConfigurationException(ImmutableSet.of(new Message(message)));
|
||||
throw new ConfigurationException(singleton(new Message(message)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
|
||||
package org.elasticsearch.common.inject.multibindings;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.binder.LinkedBindingBuilder;
|
||||
import org.elasticsearch.common.inject.multibindings.Multibinder.RealMultibinder;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
|
@ -32,6 +35,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.elasticsearch.common.inject.util.Types.newParameterizedType;
|
||||
import static org.elasticsearch.common.inject.util.Types.newParameterizedTypeWithOwner;
|
||||
|
||||
|
@ -261,15 +265,15 @@ public abstract class MapBinder<K, V> {
|
|||
binder.getProvider(valueKey)));
|
||||
return binder.bind(valueKey);
|
||||
}
|
||||
|
||||
|
||||
public static class MapBinderProviderWithDependencies<K,V> implements ProviderWithDependencies<Map<K, Provider<V>>> {
|
||||
private Map<K, Provider<V>> providerMap;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes") // code is silly stupid with generics
|
||||
private final RealMapBinder binder;
|
||||
private final Set<Dependency<?>> dependencies;
|
||||
private final Provider<Set<Entry<K, Provider<V>>>> provider;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes") // code is silly stupid with generics
|
||||
MapBinderProviderWithDependencies(RealMapBinder binder, Set<Dependency<?>> dependencies, Provider<Set<Entry<K, Provider<V>>>> provider) {
|
||||
this.binder = binder;
|
||||
|
@ -306,8 +310,7 @@ public abstract class MapBinder<K, V> {
|
|||
public void configure(Binder binder) {
|
||||
Multibinder.checkConfiguration(!isInitialized(), "MapBinder was already initialized");
|
||||
|
||||
final ImmutableSet<Dependency<?>> dependencies
|
||||
= ImmutableSet.<Dependency<?>>of(Dependency.get(entrySetBinder.getSetKey()));
|
||||
final Set<Dependency<?>> dependencies = singleton(Dependency.get(entrySetBinder.getSetKey()));
|
||||
|
||||
// binds a Map<K, Provider<V>> from a collection of Map<Entry<K, Provider<V>>
|
||||
final Provider<Set<Entry<K, Provider<V>>>> entrySetProvider = binder
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject.multibindings;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Binding;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
|
@ -44,6 +42,8 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
|
@ -321,7 +321,7 @@ public abstract class Multibinder<T> {
|
|||
return;
|
||||
}
|
||||
|
||||
throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
|
||||
throw new ConfigurationException(singleton(new Message(Errors.format(format, args))));
|
||||
}
|
||||
|
||||
static <T> T checkNotNull(T reference, String name) {
|
||||
|
@ -330,7 +330,7 @@ public abstract class Multibinder<T> {
|
|||
}
|
||||
|
||||
NullPointerException npe = new NullPointerException(name);
|
||||
throw new ConfigurationException(ImmutableSet.of(
|
||||
new Message(Collections.emptyList(), npe.toString(), npe)));
|
||||
throw new ConfigurationException(singleton(
|
||||
new Message(emptyList(), npe.toString(), npe)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.elasticsearch.gateway;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
|
@ -45,6 +44,7 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
|
@ -80,6 +80,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
this.action = (List<BaseNodesResponse<T>, T>) action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
this.closed = true;
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
|
||||
// if we are still fetching, return null to indicate it
|
||||
if (hasAnyNodeFetching(cache) == true) {
|
||||
return new FetchResult<>(shardId, null, ImmutableSet.<String>of(), ImmutableSet.<String>of());
|
||||
return new FetchResult<>(shardId, null, emptySet(), emptySet());
|
||||
} else {
|
||||
// nothing to fetch, yay, build the return value
|
||||
Map<DiscoveryNode, T> fetchData = new HashMap<>();
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.gateway;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -110,7 +109,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
|
|||
if (state.blocks().disableStatePersistence()) {
|
||||
// reset the current metadata, we need to start fresh...
|
||||
this.previousMetaData = null;
|
||||
previouslyWrittenIndices = ImmutableSet.of();
|
||||
previouslyWrittenIndices = emptySet();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.fielddata.plain;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.index.DocValues;
|
||||
import org.apache.lucene.index.SortedDocValues;
|
||||
import org.apache.lucene.util.Accountable;
|
||||
|
@ -34,6 +32,8 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -92,7 +92,7 @@ abstract class AbstractAtomicParentChildFieldData implements AtomicParentChildFi
|
|||
public long ramBytesUsed() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<Accountable> getChildResources() {
|
||||
return Collections.emptyList();
|
||||
|
@ -109,7 +109,7 @@ abstract class AbstractAtomicParentChildFieldData implements AtomicParentChildFi
|
|||
|
||||
@Override
|
||||
public Set<String> types() {
|
||||
return ImmutableSet.of();
|
||||
return emptySet();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.fielddata.plain;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
|
@ -30,7 +29,6 @@ import org.elasticsearch.index.fielddata.FieldDataType;
|
|||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType.Names;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
@ -42,6 +40,9 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/** {@link IndexFieldData} impl based on Lucene's doc values. Caching is done on the Lucene side. */
|
||||
public abstract class DocValuesIndexFieldData {
|
||||
|
||||
|
@ -79,9 +80,7 @@ public abstract class DocValuesIndexFieldData {
|
|||
}
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
|
||||
private static final Set<String> BINARY_INDEX_FIELD_NAMES = ImmutableSet.of(UidFieldMapper.NAME, IdFieldMapper.NAME);
|
||||
private static final Set<String> NUMERIC_INDEX_FIELD_NAMES = ImmutableSet.of(TimestampFieldMapper.NAME);
|
||||
private static final Set<String> BINARY_INDEX_FIELD_NAMES = unmodifiableSet(newHashSet(UidFieldMapper.NAME, IdFieldMapper.NAME));
|
||||
|
||||
private NumericType numericType;
|
||||
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
package org.elasticsearch.index.fieldvisitor;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.StoredFieldVisitor;
|
||||
import org.apache.lucene.index.StoredFieldVisitor;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -46,20 +47,19 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.lucene.index.StoredFieldVisitor;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
* Base {@link StoredFieldVisitor} that retrieves all non-redundant metadata.
|
||||
*/
|
||||
public class FieldsVisitor extends StoredFieldVisitor {
|
||||
|
||||
private static final Set<String> BASE_REQUIRED_FIELDS = ImmutableSet.of(
|
||||
private static final Set<String> BASE_REQUIRED_FIELDS = unmodifiableSet(newHashSet(
|
||||
UidFieldMapper.NAME,
|
||||
TimestampFieldMapper.NAME,
|
||||
TTLFieldMapper.NAME,
|
||||
RoutingFieldMapper.NAME,
|
||||
ParentFieldMapper.NAME
|
||||
);
|
||||
ParentFieldMapper.NAME));
|
||||
|
||||
private final boolean loadSource;
|
||||
private final Set<String> requiredFields;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.rest;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -31,17 +30,19 @@ import org.elasticsearch.rest.support.RestUtils;
|
|||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.elasticsearch.rest.RestStatus.*;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSetCopyWith;
|
||||
import static org.elasticsearch.rest.RestStatus.BAD_REQUEST;
|
||||
import static org.elasticsearch.rest.RestStatus.OK;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class RestController extends AbstractLifecycleComponent<RestController> {
|
||||
|
||||
private ImmutableSet<String> relevantHeaders = ImmutableSet.of();
|
||||
|
||||
private final PathTrie<RestHandler> getHandlers = new PathTrie<>(RestUtils.REST_DECODER);
|
||||
private final PathTrie<RestHandler> postHandlers = new PathTrie<>(RestUtils.REST_DECODER);
|
||||
private final PathTrie<RestHandler> putHandlers = new PathTrie<>(RestUtils.REST_DECODER);
|
||||
|
@ -51,6 +52,8 @@ public class RestController extends AbstractLifecycleComponent<RestController> {
|
|||
|
||||
private final RestHandlerFilter handlerFilter = new RestHandlerFilter();
|
||||
|
||||
private Set<String> relevantHeaders = emptySet();
|
||||
|
||||
// non volatile since the assumption is that pre processors are registered on startup
|
||||
private RestFilter[] filters = new RestFilter[0];
|
||||
|
||||
|
@ -81,7 +84,7 @@ public class RestController extends AbstractLifecycleComponent<RestController> {
|
|||
* By default no headers get copied but it is possible to extend this behaviour via plugins by calling this method.
|
||||
*/
|
||||
public synchronized void registerRelevantHeaders(String... headers) {
|
||||
relevantHeaders = new ImmutableSet.Builder<String>().addAll(relevantHeaders).add(headers).build();
|
||||
relevantHeaders = unmodifiableSet(newHashSetCopyWith(relevantHeaders, headers));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +92,7 @@ public class RestController extends AbstractLifecycleComponent<RestController> {
|
|||
* its corresponding {@link org.elasticsearch.transport.TransportRequest}(s).
|
||||
* By default no headers get copied but it is possible to extend this behaviour via plugins by calling {@link #registerRelevantHeaders(String...)}.
|
||||
*/
|
||||
public ImmutableSet<String> relevantHeaders() {
|
||||
public Set<String> relevantHeaders() {
|
||||
return relevantHeaders;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.search.highlight;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.lucene.search.highlight.DefaultEncoder;
|
||||
import org.apache.lucene.search.highlight.Encoder;
|
||||
import org.apache.lucene.search.highlight.SimpleHTMLEncoder;
|
||||
|
@ -32,6 +31,8 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
public final class HighlightUtils {
|
||||
|
||||
//U+2029 PARAGRAPH SEPARATOR (PS): each value holds a discrete passage for highlighting (postings highlighter)
|
||||
|
@ -47,7 +48,7 @@ public final class HighlightUtils {
|
|||
boolean forceSource = searchContext.highlight().forceSource(field);
|
||||
List<Object> textsToHighlight;
|
||||
if (!forceSource && mapper.fieldType().stored()) {
|
||||
CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(ImmutableSet.of(mapper.fieldType().names().indexName()), false);
|
||||
CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(singleton(mapper.fieldType().names().indexName()), false);
|
||||
hitContext.reader().document(hitContext.docId(), fieldVisitor);
|
||||
textsToHighlight = fieldVisitor.fields().get(mapper.fieldType().names().indexName());
|
||||
if (textsToHighlight == null) {
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.elasticsearch;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonLocation;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.codehaus.groovy.runtime.typehandling.GroovyCastException;
|
||||
|
@ -39,6 +38,7 @@ import org.elasticsearch.cluster.routing.RoutingValidationException;
|
|||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||
import org.elasticsearch.cluster.routing.TestShardRouting;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.breaker.CircuitBreakingException;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
|
@ -60,7 +60,6 @@ import org.elasticsearch.index.engine.CreateFailedEngineException;
|
|||
import org.elasticsearch.index.engine.IndexFailedEngineException;
|
||||
import org.elasticsearch.index.engine.RecoveryEngineException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.index.query.TestParsingException;
|
||||
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
|
||||
import org.elasticsearch.index.shard.IndexShardState;
|
||||
|
@ -100,6 +99,8 @@ import java.nio.file.attribute.BasicFileAttributes;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
public class ExceptionSerializationTests extends ESTestCase {
|
||||
|
||||
public void testExceptionRegistration()
|
||||
|
@ -534,7 +535,7 @@ public class ExceptionSerializationTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testClusterBlockException() throws IOException {
|
||||
ClusterBlockException ex = serialize(new ClusterBlockException(ImmutableSet.of(DiscoverySettings.NO_MASTER_BLOCK_WRITES)));
|
||||
ClusterBlockException ex = serialize(new ClusterBlockException(singleton(DiscoverySettings.NO_MASTER_BLOCK_WRITES)));
|
||||
assertEquals("blocked by: [SERVICE_UNAVAILABLE/2/no master];", ex.getMessage());
|
||||
assertTrue(ex.blocks().contains(DiscoverySettings.NO_MASTER_BLOCK_WRITES));
|
||||
assertEquals(1, ex.blocks().size());
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.cluster;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionModule;
|
||||
|
@ -207,7 +205,7 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
|
|||
MockTransportService mockTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, internalTestCluster.getMasterName());
|
||||
|
||||
final AtomicBoolean timeout = new AtomicBoolean(false);
|
||||
final Set<String> blockedActions = ImmutableSet.of(NodesStatsAction.NAME, NodesStatsAction.NAME + "[n]", IndicesStatsAction.NAME, IndicesStatsAction.NAME + "[n]");
|
||||
final Set<String> blockedActions = newHashSet(NodesStatsAction.NAME, NodesStatsAction.NAME + "[n]", IndicesStatsAction.NAME, IndicesStatsAction.NAME + "[n]");
|
||||
// drop all outgoing stats requests to force a timeout.
|
||||
for (DiscoveryNode node : internalTestCluster.clusterService().state().getNodes()) {
|
||||
mockTransportService.addDelegate(node, new MockTransportService.DelegateTransport(mockTransportService.original()) {
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.explain;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.search.Explanation;
|
||||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||
import org.elasticsearch.action.explain.ExplainResponse;
|
||||
|
@ -42,6 +40,7 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
|
@ -60,7 +59,7 @@ public class ExplainActionIT extends ESIntegTestCase {
|
|||
ensureGreen("test");
|
||||
|
||||
client().prepareIndex("test", "test", "1").setSource("field", "value1").get();
|
||||
|
||||
|
||||
ExplainResponse response = client().prepareExplain(indexOrAlias(), "test", "1")
|
||||
.setQuery(QueryBuilders.matchAllQuery()).get();
|
||||
assertNotNull(response);
|
||||
|
@ -145,7 +144,7 @@ public class ExplainActionIT extends ESIntegTestCase {
|
|||
assertThat(response.getGetResult().getId(), equalTo("1"));
|
||||
Set<String> fields = new HashSet<>(response.getGetResult().getFields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly added via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("obj1.field1")));
|
||||
assertThat(fields, equalTo(singleton("obj1.field1")));
|
||||
assertThat(response.getGetResult().getFields().get("obj1.field1").getValue().toString(), equalTo("value1"));
|
||||
assertThat(response.getGetResult().isSourceEmpty(), equalTo(true));
|
||||
|
||||
|
@ -162,7 +161,7 @@ public class ExplainActionIT extends ESIntegTestCase {
|
|||
assertThat(response.getGetResult().getId(), equalTo("1"));
|
||||
fields = new HashSet<>(response.getGetResult().getFields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly added via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("obj1.field1")));
|
||||
assertThat(fields, equalTo(singleton("obj1.field1")));
|
||||
assertThat(response.getGetResult().getFields().get("obj1.field1").getValue().toString(), equalTo("value1"));
|
||||
assertThat(response.getGetResult().isSourceEmpty(), equalTo(false));
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.gateway;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.FailedNodeException;
|
||||
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
|
||||
|
@ -39,6 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
|
||||
|
@ -56,6 +56,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
private ThreadPool threadPool;
|
||||
private TestFetch test;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -74,7 +75,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.addSimulation(node1.getId(), response1);
|
||||
|
||||
// first fetch, no data, still on going
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
assertThat(test.reroute.get(), equalTo(0));
|
||||
|
||||
|
@ -84,7 +85,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
assertThat(test.reroute.get(), equalTo(1));
|
||||
test.close();
|
||||
try {
|
||||
test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
fail("fetch data should fail when closed");
|
||||
} catch (IllegalStateException e) {
|
||||
// all is well
|
||||
|
@ -98,7 +99,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.addSimulation(node1.getId(), response1);
|
||||
|
||||
// first fetch, no data, still on going
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
assertThat(test.reroute.get(), equalTo(0));
|
||||
|
||||
|
@ -106,7 +107,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.fireSimulationAndWait(node1.getId());
|
||||
// verify we get back the data node
|
||||
assertThat(test.reroute.get(), equalTo(1));
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(true));
|
||||
assertThat(fetchData.getData().size(), equalTo(1));
|
||||
assertThat(fetchData.getData().get(node1), sameInstance(response1));
|
||||
|
@ -119,7 +120,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.addSimulation(node1.getId(), failure1);
|
||||
|
||||
// first fetch, no data, still on going
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
assertThat(test.reroute.get(), equalTo(0));
|
||||
|
||||
|
@ -127,19 +128,19 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.fireSimulationAndWait(node1.getId());
|
||||
// failure, fetched data exists, but has no data
|
||||
assertThat(test.reroute.get(), equalTo(1));
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(true));
|
||||
assertThat(fetchData.getData().size(), equalTo(0));
|
||||
|
||||
// on failure, we reset the failure on a successive call to fetchData, and try again afterwards
|
||||
test.addSimulation(node1.getId(), response1);
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
|
||||
test.fireSimulationAndWait(node1.getId());
|
||||
// 2 reroutes, cause we have a failure that we clear
|
||||
assertThat(test.reroute.get(), equalTo(3));
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(true));
|
||||
assertThat(fetchData.getData().size(), equalTo(1));
|
||||
assertThat(fetchData.getData().get(node1), sameInstance(response1));
|
||||
|
@ -152,7 +153,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.addSimulation(node2.getId(), response2);
|
||||
|
||||
// no fetched data, 2 requests still on going
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
assertThat(test.reroute.get(), equalTo(0));
|
||||
|
||||
|
@ -160,14 +161,14 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.fireSimulationAndWait(node1.getId());
|
||||
// there is still another on going request, so no data
|
||||
assertThat(test.getNumberOfInFlightFetches(), equalTo(1));
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
|
||||
// fire the second simulation, this should allow us to get the data
|
||||
test.fireSimulationAndWait(node2.getId());
|
||||
// no more ongoing requests, we should fetch the data
|
||||
assertThat(test.reroute.get(), equalTo(2));
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(true));
|
||||
assertThat(fetchData.getData().size(), equalTo(2));
|
||||
assertThat(fetchData.getData().get(node1), sameInstance(response1));
|
||||
|
@ -181,21 +182,21 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.addSimulation(node2.getId(), failure2);
|
||||
|
||||
// no fetched data, 2 requests still on going
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
assertThat(test.reroute.get(), equalTo(0));
|
||||
|
||||
// fire the first response, it should trigger a reroute
|
||||
test.fireSimulationAndWait(node1.getId());
|
||||
assertThat(test.reroute.get(), equalTo(1));
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
|
||||
// fire the second simulation, this should allow us to get the data
|
||||
test.fireSimulationAndWait(node2.getId());
|
||||
assertThat(test.reroute.get(), equalTo(2));
|
||||
// since one of those failed, we should only have one entry
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(true));
|
||||
assertThat(fetchData.getData().size(), equalTo(1));
|
||||
assertThat(fetchData.getData().get(node1), sameInstance(response1));
|
||||
|
@ -207,7 +208,7 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
test.addSimulation(node1.getId(), response1);
|
||||
|
||||
// no fetched data, 2 requests still on going
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
AsyncShardFetch.FetchResult<Response> fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
assertThat(test.reroute.get(), equalTo(0));
|
||||
|
||||
|
@ -218,14 +219,14 @@ public class AsyncShardFetchTests extends ESTestCase {
|
|||
nodes = DiscoveryNodes.builder(nodes).put(node2).build();
|
||||
test.addSimulation(node2.getId(), response2);
|
||||
// no fetch data, has a new node introduced
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(false));
|
||||
|
||||
// fire the second simulation, this should allow us to get the data
|
||||
test.fireSimulationAndWait(node2.getId());
|
||||
|
||||
// since one of those failed, we should only have one entry
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, ImmutableSet.<String>of());
|
||||
fetchData = test.fetchData(nodes, MetaData.EMPTY_META_DATA, emptySet());
|
||||
assertThat(fetchData.hasData(), equalTo(true));
|
||||
assertThat(fetchData.getData().size(), equalTo(2));
|
||||
assertThat(fetchData.getData().get(node1), sameInstance(response1));
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.get;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
|
@ -52,9 +50,17 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
public class GetActionIT extends ESIntegTestCase {
|
||||
|
||||
|
@ -295,7 +301,7 @@ public class GetActionIT extends ESIntegTestCase {
|
|||
assertThat(response.getType(), equalTo("type1"));
|
||||
Set<String> fields = new HashSet<>(response.getFields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("field")));
|
||||
assertThat(fields, equalTo(singleton("field")));
|
||||
assertThat(response.getFields().get("field").getValues().size(), equalTo(2));
|
||||
assertThat(response.getFields().get("field").getValues().get(0).toString(), equalTo("1"));
|
||||
assertThat(response.getFields().get("field").getValues().get(1).toString(), equalTo("2"));
|
||||
|
@ -307,7 +313,7 @@ public class GetActionIT extends ESIntegTestCase {
|
|||
assertThat(response.getId(), equalTo("1"));
|
||||
fields = new HashSet<>(response.getFields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("field")));
|
||||
assertThat(fields, equalTo(singleton("field")));
|
||||
assertThat(response.getFields().get("field").getValues().size(), equalTo(2));
|
||||
assertThat(response.getFields().get("field").getValues().get(0).toString(), equalTo("1"));
|
||||
assertThat(response.getFields().get("field").getValues().get(1).toString(), equalTo("2"));
|
||||
|
@ -319,7 +325,7 @@ public class GetActionIT extends ESIntegTestCase {
|
|||
assertThat(response.getId(), equalTo("1"));
|
||||
fields = new HashSet<>(response.getFields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("field")));
|
||||
assertThat(fields, equalTo(singleton("field")));
|
||||
assertThat(response.getFields().get("field").getValues().size(), equalTo(2));
|
||||
assertThat(response.getFields().get("field").getValues().get(0).toString(), equalTo("1"));
|
||||
assertThat(response.getFields().get("field").getValues().get(1).toString(), equalTo("2"));
|
||||
|
@ -329,7 +335,7 @@ public class GetActionIT extends ESIntegTestCase {
|
|||
assertThat(response.getId(), equalTo("1"));
|
||||
fields = new HashSet<>(response.getFields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("field")));
|
||||
assertThat(fields, equalTo(singleton("field")));
|
||||
assertThat(response.getFields().get("field").getValues().size(), equalTo(2));
|
||||
assertThat(response.getFields().get("field").getValues().get(0).toString(), equalTo("1"));
|
||||
assertThat(response.getFields().get("field").getValues().get(1).toString(), equalTo("2"));
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.index.IndexAction;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
|
@ -40,6 +39,7 @@ import org.junit.Test;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
|
||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
|
||||
|
@ -118,12 +118,12 @@ public class TransportIndexFailuresIT extends ESIntegTestCase {
|
|||
TransportService mockTransportService = internalCluster().getInstance(TransportService.class, primaryNode);
|
||||
((MockTransportService) mockTransportService).addFailToSendNoConnectRule(
|
||||
internalCluster().getInstance(Discovery.class, replicaNode).localNode(),
|
||||
ImmutableSet.of(IndexAction.NAME + "[r]")
|
||||
singleton(IndexAction.NAME + "[r]")
|
||||
);
|
||||
mockTransportService = internalCluster().getInstance(TransportService.class, replicaNode);
|
||||
((MockTransportService) mockTransportService).addFailToSendNoConnectRule(
|
||||
internalCluster().getInstance(Discovery.class, primaryNode).localNode(),
|
||||
ImmutableSet.of(IndexAction.NAME + "[r]")
|
||||
singleton(IndexAction.NAME + "[r]")
|
||||
);
|
||||
|
||||
logger.info("--> indexing into primary");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.script;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.ContextAndHeaderHolder;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
|
@ -41,6 +40,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class NativeScriptTests extends ESTestCase {
|
|||
ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, null);
|
||||
Map<String, NativeScriptFactory> nativeScriptFactoryMap = new HashMap<>();
|
||||
nativeScriptFactoryMap.put("my", new MyNativeScriptFactory());
|
||||
Set<ScriptEngineService> scriptEngineServices = ImmutableSet.<ScriptEngineService>of(new NativeScriptEngineService(settings, nativeScriptFactoryMap));
|
||||
Set<ScriptEngineService> scriptEngineServices = singleton(new NativeScriptEngineService(settings, nativeScriptFactoryMap));
|
||||
ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(new ArrayList<ScriptContext.Plugin>());
|
||||
ScriptService scriptService = new ScriptService(settings, environment, scriptEngineServices, resourceWatcherService, scriptContextRegistry);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.script;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||
|
@ -38,13 +38,16 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
|
||||
// TODO: this needs to be a base test class, and all scripting engines extend it
|
||||
public class ScriptModesTests extends ESTestCase {
|
||||
|
||||
private static final Set<String> ALL_LANGS = ImmutableSet.of(GroovyScriptEngineService.NAME, MustacheScriptEngineService.NAME, "custom", "test");
|
||||
private static final Set<String> ALL_LANGS = unmodifiableSet(
|
||||
newHashSet(GroovyScriptEngineService.NAME, MustacheScriptEngineService.NAME, "custom", "test"));
|
||||
|
||||
static final String[] ENABLE_VALUES = new String[]{"on", "true", "yes", "1"};
|
||||
static final String[] DISABLE_VALUES = new String[]{"off", "false", "no", "0"};
|
||||
|
@ -71,7 +74,7 @@ public class ScriptModesTests extends ESTestCase {
|
|||
}
|
||||
scriptContextRegistry = new ScriptContextRegistry(contexts.values());
|
||||
scriptContexts = scriptContextRegistry.scriptContexts().toArray(new ScriptContext[scriptContextRegistry.scriptContexts().size()]);
|
||||
scriptEngines = buildScriptEnginesByLangMap(ImmutableSet.of(
|
||||
scriptEngines = buildScriptEnginesByLangMap(newHashSet(
|
||||
new GroovyScriptEngineService(Settings.EMPTY),
|
||||
new MustacheScriptEngineService(Settings.EMPTY),
|
||||
//add the native engine just to make sure it gets filtered out
|
||||
|
@ -195,7 +198,7 @@ public class ScriptModesTests extends ESTestCase {
|
|||
Settings.Builder builder = Settings.builder()
|
||||
.put(specificEngineOpSettings(GroovyScriptEngineService.NAME, ScriptType.INLINE, ScriptContext.Standard.MAPPING), randomFrom(DISABLE_VALUES))
|
||||
.put(specificEngineOpSettings(GroovyScriptEngineService.NAME, ScriptType.INLINE, ScriptContext.Standard.UPDATE), randomFrom(DISABLE_VALUES));
|
||||
ImmutableSet<String> groovyLangSet = ImmutableSet.of(GroovyScriptEngineService.NAME);
|
||||
Set<String> groovyLangSet = singleton(GroovyScriptEngineService.NAME);
|
||||
Set<String> allButGroovyLangSet = new HashSet<>(ALL_LANGS);
|
||||
allButGroovyLangSet.remove(GroovyScriptEngineService.NAME);
|
||||
this.scriptModes = new ScriptModes(scriptEngines, scriptContextRegistry, builder.build());
|
||||
|
@ -211,7 +214,7 @@ public class ScriptModesTests extends ESTestCase {
|
|||
Settings.Builder builder = Settings.builder().put("script.inline", randomFrom(DISABLE_VALUES))
|
||||
.put(specificEngineOpSettings(MustacheScriptEngineService.NAME, ScriptType.INLINE, ScriptContext.Standard.AGGS), randomFrom(ENABLE_VALUES))
|
||||
.put(specificEngineOpSettings(MustacheScriptEngineService.NAME, ScriptType.INLINE, ScriptContext.Standard.SEARCH), randomFrom(ENABLE_VALUES));
|
||||
ImmutableSet<String> mustacheLangSet = ImmutableSet.of(MustacheScriptEngineService.NAME);
|
||||
Set<String> mustacheLangSet = singleton(MustacheScriptEngineService.NAME);
|
||||
Set<String> allButMustacheLangSet = new HashSet<>(ALL_LANGS);
|
||||
allButMustacheLangSet.remove(MustacheScriptEngineService.NAME);
|
||||
this.scriptModes = new ScriptModes(scriptEngines, scriptContextRegistry, builder.build());
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.elasticsearch.script;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.ContextAndHeaderHolder;
|
||||
import org.elasticsearch.common.HasContextAndHeaders;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
@ -42,6 +41,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
@ -75,7 +75,7 @@ public class ScriptServiceTests extends ESTestCase {
|
|||
.put("path.conf", genericConfigFolder)
|
||||
.build();
|
||||
resourceWatcherService = new ResourceWatcherService(baseSettings, null);
|
||||
scriptEngineServices = ImmutableSet.of(new TestEngineService(), new GroovyScriptEngineService(baseSettings),
|
||||
scriptEngineServices = newHashSet(new TestEngineService(), new GroovyScriptEngineService(baseSettings),
|
||||
new MustacheScriptEngineService(baseSettings));
|
||||
scriptEnginesByLangMap = ScriptModesTests.buildScriptEnginesByLangMap(scriptEngineServices);
|
||||
//randomly register custom script contexts
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.elasticsearch.search.fields;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
|
@ -55,7 +53,9 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.elasticsearch.client.Requests.refreshRequest;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
|
@ -63,7 +63,10 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFail
|
|||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -170,21 +173,21 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
||||
Set<String> fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("sNum1", "sNum1_field", "date1")));
|
||||
assertThat(fields, equalTo(newHashSet("sNum1", "sNum1_field", "date1")));
|
||||
assertThat((Double) response.getHits().getAt(0).fields().get("sNum1").values().get(0), equalTo(1.0));
|
||||
assertThat((Double) response.getHits().getAt(0).fields().get("sNum1_field").values().get(0), equalTo(1.0));
|
||||
assertThat((Long) response.getHits().getAt(0).fields().get("date1").values().get(0), equalTo(0l));
|
||||
assertThat(response.getHits().getAt(1).id(), equalTo("2"));
|
||||
fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("sNum1", "sNum1_field", "date1")));
|
||||
assertThat(fields, equalTo(newHashSet("sNum1", "sNum1_field", "date1")));
|
||||
assertThat((Double) response.getHits().getAt(1).fields().get("sNum1").values().get(0), equalTo(2.0));
|
||||
assertThat((Double) response.getHits().getAt(1).fields().get("sNum1_field").values().get(0), equalTo(2.0));
|
||||
assertThat((Long) response.getHits().getAt(1).fields().get("date1").values().get(0), equalTo(25000l));
|
||||
assertThat(response.getHits().getAt(2).id(), equalTo("3"));
|
||||
fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("sNum1", "sNum1_field", "date1")));
|
||||
assertThat(fields, equalTo(newHashSet("sNum1", "sNum1_field", "date1")));
|
||||
assertThat((Double) response.getHits().getAt(2).fields().get("sNum1").values().get(0), equalTo(3.0));
|
||||
assertThat((Double) response.getHits().getAt(2).fields().get("sNum1_field").values().get(0), equalTo(3.0));
|
||||
assertThat((Long) response.getHits().getAt(2).fields().get("date1").values().get(0), equalTo(120000l));
|
||||
|
@ -201,17 +204,17 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
||||
fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("sNum1")));
|
||||
assertThat(fields, equalTo(singleton("sNum1")));
|
||||
assertThat((Double) response.getHits().getAt(0).fields().get("sNum1").values().get(0), equalTo(2.0));
|
||||
assertThat(response.getHits().getAt(1).id(), equalTo("2"));
|
||||
fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("sNum1")));
|
||||
assertThat(fields, equalTo(singleton("sNum1")));
|
||||
assertThat((Double) response.getHits().getAt(1).fields().get("sNum1").values().get(0), equalTo(4.0));
|
||||
assertThat(response.getHits().getAt(2).id(), equalTo("3"));
|
||||
fields = new HashSet<>(response.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("sNum1")));
|
||||
assertThat(fields, equalTo(singleton("sNum1")));
|
||||
assertThat((Double) response.getHits().getAt(2).fields().get("sNum1").values().get(0), equalTo(6.0));
|
||||
}
|
||||
|
||||
|
@ -239,7 +242,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(response.getHits().getAt(i).id(), equalTo(Integer.toString(i)));
|
||||
Set<String> fields = new HashSet<>(response.getHits().getAt(i).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("uid")));
|
||||
assertThat(fields, equalTo(singleton("uid")));
|
||||
assertThat((String)response.getHits().getAt(i).fields().get("uid").value(), equalTo("type1#" + Integer.toString(i)));
|
||||
}
|
||||
|
||||
|
@ -254,7 +257,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(response.getHits().getAt(i).id(), equalTo(Integer.toString(i)));
|
||||
Set<String> fields = new HashSet<>(response.getHits().getAt(i).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("id")));
|
||||
assertThat(fields, equalTo(singleton("id")));
|
||||
assertThat((String)response.getHits().getAt(i).fields().get("id").value(), equalTo(Integer.toString(i)));
|
||||
}
|
||||
|
||||
|
@ -269,7 +272,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(response.getHits().getAt(i).id(), equalTo(Integer.toString(i)));
|
||||
Set<String> fields = new HashSet<>(response.getHits().getAt(i).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("type")));
|
||||
assertThat(fields, equalTo(singleton("type")));
|
||||
assertThat((String)response.getHits().getAt(i).fields().get("type").value(), equalTo("type1"));
|
||||
}
|
||||
|
||||
|
@ -285,7 +288,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(response.getHits().getAt(i).id(), equalTo(Integer.toString(i)));
|
||||
Set<String> fields = new HashSet<>(response.getHits().getAt(i).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("uid", "type", "id")));
|
||||
assertThat(fields, equalTo(newHashSet("uid", "type", "id")));
|
||||
assertThat((String)response.getHits().getAt(i).fields().get("uid").value(), equalTo("type1#" + Integer.toString(i)));
|
||||
assertThat((String)response.getHits().getAt(i).fields().get("type").value(), equalTo("type1"));
|
||||
assertThat((String)response.getHits().getAt(i).fields().get("id").value(), equalTo(Integer.toString(i)));
|
||||
|
@ -406,7 +409,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
Set<String> fields = new HashSet<>(searchResponse.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("byte_field", "short_field", "integer_field", "long_field",
|
||||
assertThat(fields, equalTo(newHashSet("byte_field", "short_field", "integer_field", "long_field",
|
||||
"float_field", "double_field", "date_field", "boolean_field", "binary_field")));
|
||||
|
||||
|
||||
|
@ -585,7 +588,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
assertThat(searchResponse.getHits().hits().length, equalTo(1));
|
||||
Set<String> fields = new HashSet<>(searchResponse.getHits().getAt(0).fields().keySet());
|
||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||
assertThat(fields, equalTo((Set<String>) ImmutableSet.of("byte_field", "short_field", "integer_field", "long_field",
|
||||
assertThat(fields, equalTo(newHashSet("byte_field", "short_field", "integer_field", "long_field",
|
||||
"float_field", "double_field", "date_field", "boolean_field", "string_field")));
|
||||
|
||||
assertThat(searchResponse.getHits().getAt(0).fields().get("byte_field").value().toString(), equalTo("1"));
|
||||
|
|
|
@ -133,6 +133,13 @@ com.google.common.collect.ImmutableSet#copyOf(java.lang.Iterable)
|
|||
com.google.common.collect.ImmutableSet#copyOf(java.util.Iterator)
|
||||
com.google.common.collect.ImmutableSet#copyOf(java.util.Collection)
|
||||
com.google.common.collect.ImmutableSet#copyOf(java.lang.Object[])
|
||||
com.google.common.collect.ImmutableSet#of()
|
||||
com.google.common.collect.ImmutableSet#of(java.lang.Object)
|
||||
com.google.common.collect.ImmutableSet#of(java.lang.Object, java.lang.Object)
|
||||
com.google.common.collect.ImmutableSet#of(java.lang.Object, java.lang.Object, java.lang.Object)
|
||||
com.google.common.collect.ImmutableSet#of(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)
|
||||
com.google.common.collect.ImmutableSet#of(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)
|
||||
com.google.common.collect.ImmutableSet#of(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object[])
|
||||
|
||||
@defaultMessage Do not violate java's access system
|
||||
java.lang.reflect.AccessibleObject#setAccessible(boolean)
|
||||
|
|
Loading…
Reference in New Issue