Remove and ban ImmutableSet#copyOf
It was used heavily in the Guice we've embedded.
This commit is contained in:
parent
6ecda41485
commit
b0ab02e35c
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.cluster.block;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.cluster.AbstractDiffable;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
|
@ -152,7 +151,7 @@ public class ClusterBlocks extends AbstractDiffable<ClusterBlocks> {
|
|||
if (global(level).isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new ClusterBlockException(ImmutableSet.copyOf(global(level)));
|
||||
return new ClusterBlockException(global(level));
|
||||
}
|
||||
|
||||
public void indexBlockedRaiseException(ClusterBlockLevel level, String index) throws ClusterBlockException {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.cluster.routing.allocation;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.cluster.ClusterInfo;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
|
@ -34,6 +33,9 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* The {@link RoutingAllocation} keep the state of the current allocation
|
||||
* of shards and holds the {@link AllocationDeciders} which are responsible
|
||||
|
@ -220,13 +222,13 @@ public class RoutingAllocation {
|
|||
|
||||
public Set<String> getIgnoreNodes(ShardId shardId) {
|
||||
if (ignoredShardToNodes == null) {
|
||||
return ImmutableSet.of();
|
||||
return emptySet();
|
||||
}
|
||||
Set<String> ignore = ignoredShardToNodes.get(shardId);
|
||||
if (ignore == null) {
|
||||
return ImmutableSet.of();
|
||||
return emptySet();
|
||||
}
|
||||
return ImmutableSet.copyOf(ignore);
|
||||
return unmodifiableSet(new HashSet<>(ignore));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,12 +16,15 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
* Thrown when a programming error such as a misplaced annotation, illegal binding, or unsupported
|
||||
|
@ -31,15 +34,14 @@ import java.util.Locale;
|
|||
* @since 2.0
|
||||
*/
|
||||
public final class ConfigurationException extends RuntimeException {
|
||||
|
||||
private final ImmutableSet<Message> messages;
|
||||
private final Set<Message> messages;
|
||||
private Object partialValue = null;
|
||||
|
||||
/**
|
||||
* Creates a ConfigurationException containing {@code messages}.
|
||||
*/
|
||||
public ConfigurationException(Iterable<Message> messages) {
|
||||
this.messages = ImmutableSet.copyOf(messages);
|
||||
this.messages = unmodifiableSet(newHashSet(messages));
|
||||
initCause(Errors.getOnlyCause(this.messages));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
|
||||
|
@ -29,14 +28,13 @@ import java.util.Collection;
|
|||
* @author crazybob@google.com (Bob Lee)
|
||||
*/
|
||||
public class CreationException extends RuntimeException {
|
||||
|
||||
private final ImmutableSet<Message> messages;
|
||||
private final Collection<Message> messages;
|
||||
|
||||
/**
|
||||
* Creates a CreationException containing {@code messages}.
|
||||
*/
|
||||
public CreationException(Collection<Message> messages) {
|
||||
this.messages = ImmutableSet.copyOf(messages);
|
||||
this.messages = messages;
|
||||
if (this.messages.isEmpty()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.*;
|
||||
import org.elasticsearch.common.inject.internal.BindingImpl;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.internal.ErrorsException;
|
||||
import org.elasticsearch.common.inject.internal.InternalContext;
|
||||
import org.elasticsearch.common.inject.internal.Stopwatch;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.util.iterable.Iterables;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Builds a tree of injectors. This is a primary injector, plus child injectors needed for each
|
||||
|
@ -182,35 +182,38 @@ class InjectorBuilder {
|
|||
* Loads eager singletons, or all singletons if we're in Stage.PRODUCTION. Bindings discovered
|
||||
* while we're binding these singletons are not be eager.
|
||||
*/
|
||||
public void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors) {
|
||||
@SuppressWarnings("unchecked") // casting Collection<Binding> to Collection<BindingImpl> is safe
|
||||
Set<BindingImpl<?>> candidateBindings = ImmutableSet.copyOf(Iterables.concat(
|
||||
(Collection) injector.state.getExplicitBindingsThisLevel().values(),
|
||||
injector.jitBindings.values()));
|
||||
for (final BindingImpl<?> binding : candidateBindings) {
|
||||
if (binding.getScoping().isEagerSingleton(stage)) {
|
||||
try {
|
||||
injector.callInContext(new ContextualCallable<Void>() {
|
||||
Dependency<?> dependency = Dependency.get(binding.getKey());
|
||||
public void loadEagerSingletons(InjectorImpl injector, Stage stage, Errors errors) {
|
||||
for (final Binding<?> binding : injector.state.getExplicitBindingsThisLevel().values()) {
|
||||
loadEagerSingletons(injector, stage, errors, (BindingImpl<?>)binding);
|
||||
}
|
||||
for (final Binding<?> binding : injector.jitBindings.values()) {
|
||||
loadEagerSingletons(injector, stage, errors, (BindingImpl<?>)binding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call(InternalContext context) {
|
||||
context.setDependency(dependency);
|
||||
Errors errorsForBinding = errors.withSource(dependency);
|
||||
try {
|
||||
binding.getInternalFactory().get(errorsForBinding, context, dependency);
|
||||
} catch (ErrorsException e) {
|
||||
errorsForBinding.merge(e.getErrors());
|
||||
} finally {
|
||||
context.setDependency(null);
|
||||
}
|
||||
private void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors, BindingImpl<?> binding) {
|
||||
if (binding.getScoping().isEagerSingleton(stage)) {
|
||||
try {
|
||||
injector.callInContext(new ContextualCallable<Void>() {
|
||||
Dependency<?> dependency = Dependency.get(binding.getKey());
|
||||
|
||||
return null;
|
||||
@Override
|
||||
public Void call(InternalContext context) {
|
||||
context.setDependency(dependency);
|
||||
Errors errorsForBinding = errors.withSource(dependency);
|
||||
try {
|
||||
binding.getInternalFactory().get(errorsForBinding, context, dependency);
|
||||
} catch (ErrorsException e) {
|
||||
errorsForBinding.merge(e.getErrors());
|
||||
} finally {
|
||||
context.setDependency(null);
|
||||
}
|
||||
});
|
||||
} catch (ErrorsException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (ErrorsException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.elasticsearch.common.inject.Scopes.SINGLETON;
|
||||
|
||||
/**
|
||||
|
@ -185,7 +186,7 @@ class InjectorShell {
|
|||
injector.state.putBinding(key,
|
||||
new ProviderInstanceBindingImpl<>(injector, key, SourceProvider.UNKNOWN_SOURCE,
|
||||
injectorFactory, Scoping.UNSCOPED, injectorFactory,
|
||||
ImmutableSet.<InjectionPoint>of()));
|
||||
emptySet()));
|
||||
}
|
||||
|
||||
private static class InjectorFactory implements InternalFactory<Injector>, Provider<Injector> {
|
||||
|
@ -222,7 +223,7 @@ class InjectorShell {
|
|||
injector.state.putBinding(key,
|
||||
new ProviderInstanceBindingImpl<>(injector, key,
|
||||
SourceProvider.UNKNOWN_SOURCE, loggerFactory, Scoping.UNSCOPED,
|
||||
loggerFactory, ImmutableSet.<InjectionPoint>of()));
|
||||
loggerFactory, emptySet()));
|
||||
}
|
||||
|
||||
private static class LoggerFactory implements InternalFactory<Logger>, Provider<Logger> {
|
||||
|
|
|
@ -16,12 +16,16 @@
|
|||
|
||||
package org.elasticsearch.common.inject;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.internal.Errors;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Indicates that there was a runtime failure while providing an instance.
|
||||
|
@ -31,14 +35,13 @@ import java.util.Collections;
|
|||
* @since 2.0
|
||||
*/
|
||||
public final class ProvisionException extends RuntimeException {
|
||||
|
||||
private final ImmutableSet<Message> messages;
|
||||
private final Set<Message> messages;
|
||||
|
||||
/**
|
||||
* Creates a ConfigurationException containing {@code messages}.
|
||||
*/
|
||||
public ProvisionException(Iterable<Message> messages) {
|
||||
this.messages = ImmutableSet.copyOf(messages);
|
||||
this.messages = unmodifiableSet(newHashSet(messages));
|
||||
if (this.messages.isEmpty()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
@ -47,11 +50,11 @@ public final class ProvisionException extends RuntimeException {
|
|||
|
||||
public ProvisionException(String message, Throwable cause) {
|
||||
super(cause);
|
||||
this.messages = ImmutableSet.of(new Message(Collections.emptyList(), message, cause));
|
||||
this.messages = singleton(new Message(Collections.emptyList(), message, cause));
|
||||
}
|
||||
|
||||
public ProvisionException(String message) {
|
||||
this.messages = ImmutableSet.of(new Message(message));
|
||||
this.messages = singleton(new Message(message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ 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;
|
||||
import org.elasticsearch.common.inject.Injector;
|
||||
|
@ -37,10 +38,13 @@ import java.lang.reflect.Proxy;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* Provides a factory that combines the caller's arguments with injector-supplied values to
|
||||
* construct objects.
|
||||
|
@ -279,7 +283,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
|||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
Set<Dependency<?>> dependencies = new HashSet<>();
|
||||
for (AssistedConstructor<?> constructor : factoryMethodToConstructor.values()) {
|
||||
for (Parameter parameter : constructor.getAllParameters()) {
|
||||
if (!parameter.isProvidedByFactory()) {
|
||||
|
@ -287,7 +291,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
|||
}
|
||||
}
|
||||
}
|
||||
return ImmutableSet.copyOf(dependencies);
|
||||
return unmodifiableSet(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,18 +16,25 @@
|
|||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.TypeLiteral;
|
||||
import org.elasticsearch.common.inject.binder.AnnotatedBindingBuilder;
|
||||
import org.elasticsearch.common.inject.spi.Element;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.Message;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* Bind a non-constant key.
|
||||
*
|
||||
|
@ -85,11 +92,11 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
|
|||
for (Message message : e.getErrorMessages()) {
|
||||
binder.addError(message);
|
||||
}
|
||||
injectionPoints = e.getPartialValue();
|
||||
injectionPoints = unmodifiableSet(new HashSet<>(e.getPartialValue()));
|
||||
}
|
||||
} else {
|
||||
binder.addError(BINDING_TO_NULL);
|
||||
injectionPoints = ImmutableSet.of();
|
||||
injectionPoints = emptySet();
|
||||
}
|
||||
|
||||
BindingImpl<T> base = getBinding();
|
||||
|
@ -110,7 +117,7 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
|
|||
for (Message message : e.getErrorMessages()) {
|
||||
binder.addError(message);
|
||||
}
|
||||
injectionPoints = e.getPartialValue();
|
||||
injectionPoints = unmodifiableSet(new HashSet<>(e.getPartialValue()));
|
||||
}
|
||||
|
||||
BindingImpl<T> base = getBinding();
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.binder.AnnotatedConstantBindingBuilder;
|
||||
import org.elasticsearch.common.inject.binder.ConstantBindingBuilder;
|
||||
import org.elasticsearch.common.inject.spi.Element;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
/**
|
||||
* Bind a constant.
|
||||
*
|
||||
|
@ -130,7 +130,7 @@ public final class ConstantBindingBuilderImpl<T>
|
|||
}
|
||||
|
||||
setBinding(new InstanceBindingImpl<>(
|
||||
base.getSource(), key, base.getScoping(), ImmutableSet.<InjectionPoint>of(), instanceAsT));
|
||||
base.getSource(), key, base.getScoping(), emptySet(), instanceAsT));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
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;
|
||||
|
@ -49,6 +50,8 @@ import java.util.Formatter;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
|
||||
/**
|
||||
* A collection of error messages. If this type is passed as a method parameter, the method is
|
||||
* considered to have executed successfully only if new errors were not added to this collection.
|
||||
|
@ -463,7 +466,7 @@ public final class Errors implements Serializable {
|
|||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
return unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,27 +16,33 @@
|
|||
|
||||
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;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.spi.*;
|
||||
import org.elasticsearch.common.inject.spi.BindingTargetVisitor;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.HasDependencies;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.InstanceBinding;
|
||||
import org.elasticsearch.common.inject.util.Providers;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
public class InstanceBindingImpl<T> extends BindingImpl<T> implements InstanceBinding<T> {
|
||||
|
||||
final T instance;
|
||||
final Provider<T> provider;
|
||||
final ImmutableSet<InjectionPoint> injectionPoints;
|
||||
final Set<InjectionPoint> injectionPoints;
|
||||
|
||||
public InstanceBindingImpl(Injector injector, Key<T> key, Object source,
|
||||
InternalFactory<? extends T> internalFactory, Set<InjectionPoint> injectionPoints,
|
||||
T instance) {
|
||||
super(injector, key, source, internalFactory, Scoping.UNSCOPED);
|
||||
this.injectionPoints = ImmutableSet.copyOf(injectionPoints);
|
||||
this.injectionPoints = injectionPoints;
|
||||
this.instance = instance;
|
||||
this.provider = Providers.of(instance);
|
||||
}
|
||||
|
@ -44,7 +50,7 @@ public class InstanceBindingImpl<T> extends BindingImpl<T> implements InstanceBi
|
|||
public InstanceBindingImpl(Object source, Key<T> key, Scoping scoping,
|
||||
Set<InjectionPoint> injectionPoints, T instance) {
|
||||
super(source, key, scoping);
|
||||
this.injectionPoints = ImmutableSet.copyOf(injectionPoints);
|
||||
this.injectionPoints = injectionPoints;
|
||||
this.instance = instance;
|
||||
this.provider = Providers.of(instance);
|
||||
}
|
||||
|
@ -72,7 +78,7 @@ public class InstanceBindingImpl<T> extends BindingImpl<T> implements InstanceBi
|
|||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return instance instanceof HasDependencies
|
||||
? ImmutableSet.copyOf(((HasDependencies) instance).getDependencies())
|
||||
? unmodifiableSet(new HashSet<>((((HasDependencies) instance).getDependencies())))
|
||||
: Dependency.forInjectionPoints(injectionPoints);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,20 +16,26 @@ limitations under the License.
|
|||
|
||||
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;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.spi.*;
|
||||
import org.elasticsearch.common.inject.spi.BindingTargetVisitor;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.HasDependencies;
|
||||
import org.elasticsearch.common.inject.spi.InjectionPoint;
|
||||
import org.elasticsearch.common.inject.spi.ProviderInstanceBinding;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
public final class ProviderInstanceBindingImpl<T> extends BindingImpl<T>
|
||||
implements ProviderInstanceBinding<T> {
|
||||
|
||||
final Provider<? extends T> providerInstance;
|
||||
final ImmutableSet<InjectionPoint> injectionPoints;
|
||||
final Set<InjectionPoint> injectionPoints;
|
||||
|
||||
public ProviderInstanceBindingImpl(Injector injector, Key<T> key,
|
||||
Object source, InternalFactory<? extends T> internalFactory, Scoping scoping,
|
||||
|
@ -37,13 +43,13 @@ public final class ProviderInstanceBindingImpl<T> extends BindingImpl<T>
|
|||
Set<InjectionPoint> injectionPoints) {
|
||||
super(injector, key, source, internalFactory, scoping);
|
||||
this.providerInstance = providerInstance;
|
||||
this.injectionPoints = ImmutableSet.copyOf(injectionPoints);
|
||||
this.injectionPoints = injectionPoints;
|
||||
}
|
||||
|
||||
public ProviderInstanceBindingImpl(Object source, Key<T> key, Scoping scoping,
|
||||
Set<InjectionPoint> injectionPoints, Provider<? extends T> providerInstance) {
|
||||
super(source, key, scoping);
|
||||
this.injectionPoints = ImmutableSet.copyOf(injectionPoints);
|
||||
this.injectionPoints = injectionPoints;
|
||||
this.providerInstance = providerInstance;
|
||||
}
|
||||
|
||||
|
@ -65,7 +71,7 @@ public final class ProviderInstanceBindingImpl<T> extends BindingImpl<T>
|
|||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return providerInstance instanceof HasDependencies
|
||||
? ImmutableSet.copyOf(((HasDependencies) providerInstance).getDependencies())
|
||||
? unmodifiableSet(new HashSet<>((((HasDependencies) providerInstance).getDependencies())))
|
||||
: Dependency.forInjectionPoints(injectionPoints);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,11 @@
|
|||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.*;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Exposed;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
import org.elasticsearch.common.inject.PrivateBinder;
|
||||
import org.elasticsearch.common.inject.Provider;
|
||||
import org.elasticsearch.common.inject.spi.Dependency;
|
||||
import org.elasticsearch.common.inject.spi.ProviderWithDependencies;
|
||||
|
||||
|
@ -37,7 +40,7 @@ public class ProviderMethod<T> implements ProviderWithDependencies<T> {
|
|||
private final Class<? extends Annotation> scopeAnnotation;
|
||||
private final Object instance;
|
||||
private final Method method;
|
||||
private final ImmutableSet<Dependency<?>> dependencies;
|
||||
private final Set<Dependency<?>> dependencies;
|
||||
private final List<Provider<?>> parameterProviders;
|
||||
private final boolean exposed;
|
||||
|
||||
|
@ -45,7 +48,7 @@ public class ProviderMethod<T> implements ProviderWithDependencies<T> {
|
|||
* @param method the method to invoke. Its return type must be the same type as {@code key}.
|
||||
*/
|
||||
ProviderMethod(Key<T> key, Method method, Object instance,
|
||||
ImmutableSet<Dependency<?>> dependencies, List<Provider<?>> parameterProviders,
|
||||
Set<Dependency<?>> dependencies, List<Provider<?>> parameterProviders,
|
||||
Class<? extends Annotation> scopeAnnotation) {
|
||||
this.key = key;
|
||||
this.scopeAnnotation = scopeAnnotation;
|
||||
|
|
|
@ -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.Key;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
|
@ -31,8 +30,12 @@ import java.lang.annotation.Annotation;
|
|||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* Creates bindings to methods annotated with {@literal @}{@link Provides}. Use the scope and
|
||||
|
@ -94,7 +97,7 @@ public final class ProviderMethodsModule implements Module {
|
|||
Errors errors = new Errors(method);
|
||||
|
||||
// prepare the parameter providers
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
Set<Dependency<?>> dependencies = new HashSet<>();
|
||||
List<Provider<?>> parameterProviders = new ArrayList<>();
|
||||
List<TypeLiteral<?>> parameterTypes = typeLiteral.getParameterTypes(method);
|
||||
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
|
||||
|
@ -115,7 +118,7 @@ public final class ProviderMethodsModule implements Module {
|
|||
binder.addError(message);
|
||||
}
|
||||
|
||||
return new ProviderMethod<>(key, method, delegate, ImmutableSet.copyOf(dependencies),
|
||||
return new ProviderMethod<>(key, method, delegate, unmodifiableSet(dependencies),
|
||||
parameterProviders, scopeAnnotation);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package org.elasticsearch.common.inject.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.util.iterable.Iterables;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* Provides access to the calling line of code.
|
||||
|
@ -34,35 +34,29 @@ public class SourceProvider {
|
|||
*/
|
||||
public static final Object UNKNOWN_SOURCE = "[unknown source]";
|
||||
|
||||
private final ImmutableSet<String> classNamesToSkip;
|
||||
private final Set<String> classNamesToSkip;
|
||||
|
||||
public SourceProvider() {
|
||||
this.classNamesToSkip = ImmutableSet.of(SourceProvider.class.getName());
|
||||
this.classNamesToSkip = singleton(SourceProvider.class.getName());
|
||||
}
|
||||
|
||||
public static final SourceProvider DEFAULT_INSTANCE
|
||||
= new SourceProvider(ImmutableSet.of(SourceProvider.class.getName()));
|
||||
public static final SourceProvider DEFAULT_INSTANCE = new SourceProvider();
|
||||
|
||||
private SourceProvider(Iterable<String> classesToSkip) {
|
||||
this.classNamesToSkip = ImmutableSet.copyOf(classesToSkip);
|
||||
@SuppressWarnings("rawtypes")
|
||||
private SourceProvider(SourceProvider copy, Class[] moreClassesToSkip) {
|
||||
Set<String> classNamesToSkip = new HashSet<>(copy.classNamesToSkip);
|
||||
for (Class toSkip : moreClassesToSkip) {
|
||||
classNamesToSkip.add(toSkip.getName());
|
||||
}
|
||||
this.classNamesToSkip = unmodifiableSet(classNamesToSkip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new instance that also skips {@code moreClassesToSkip}.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public SourceProvider plusSkippedClasses(Class... moreClassesToSkip) {
|
||||
return new SourceProvider(Iterables.concat(classNamesToSkip, asStrings(moreClassesToSkip)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class names as Strings
|
||||
*/
|
||||
private static List<String> asStrings(Class... classes) {
|
||||
List<String> strings = new ArrayList<>();
|
||||
for (Class c : classes) {
|
||||
strings.add(c.getName());
|
||||
}
|
||||
return strings;
|
||||
return new SourceProvider(this, moreClassesToSkip);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
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;
|
||||
|
@ -37,11 +38,14 @@ import java.lang.annotation.Annotation;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* An API to bind multiple values separately, only to later inject them as a
|
||||
* complete collection. Multibinder is intended for use in your application's
|
||||
|
@ -238,9 +242,8 @@ public abstract class Multibinder<T> {
|
|||
@Inject
|
||||
public void initialize(Injector injector) {
|
||||
providers = new ArrayList<>();
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
Set<Dependency<?>> dependencies = new HashSet<>();
|
||||
for (Binding<?> entry : injector.findBindingsByType(elementType)) {
|
||||
|
||||
if (keyMatches(entry.getKey())) {
|
||||
@SuppressWarnings("unchecked") // protected by findBindingsByType()
|
||||
Binding<T> binding = (Binding<T>) entry;
|
||||
|
@ -249,7 +252,7 @@ public abstract class Multibinder<T> {
|
|||
}
|
||||
}
|
||||
|
||||
this.dependencies = ImmutableSet.copyOf(dependencies);
|
||||
this.dependencies = unmodifiableSet(dependencies);
|
||||
this.binder = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
package org.elasticsearch.common.inject.spi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.toFlatSet;
|
||||
|
||||
/**
|
||||
* A variable that can be resolved by an injector.
|
||||
* <p>
|
||||
|
@ -60,11 +60,8 @@ public final class Dependency<T> {
|
|||
* Returns the dependencies from the given injection points.
|
||||
*/
|
||||
public static Set<Dependency<?>> forInjectionPoints(Set<InjectionPoint> injectionPoints) {
|
||||
List<Dependency<?>> dependencies = new ArrayList<>();
|
||||
for (InjectionPoint injectionPoint : injectionPoints) {
|
||||
dependencies.addAll(injectionPoint.getDependencies());
|
||||
}
|
||||
return ImmutableSet.copyOf(dependencies);
|
||||
return unmodifiableSet(
|
||||
injectionPoints.stream().map(InjectionPoint::getDependencies).collect(toFlatSet()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.elasticsearch.common.inject.spi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.common.inject.ConfigurationException;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Key;
|
||||
|
@ -38,10 +39,12 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.inject.internal.MoreTypes.getRawType;
|
||||
|
||||
/**
|
||||
|
@ -253,13 +256,13 @@ public final class InjectionPoint {
|
|||
* of the valid injection points.
|
||||
*/
|
||||
public static Set<InjectionPoint> forStaticMethodsAndFields(TypeLiteral type) {
|
||||
List<InjectionPoint> sink = new ArrayList<>();
|
||||
Set<InjectionPoint> result = new HashSet<>();
|
||||
Errors errors = new Errors();
|
||||
|
||||
addInjectionPoints(type, Factory.FIELDS, true, sink, errors);
|
||||
addInjectionPoints(type, Factory.METHODS, true, sink, errors);
|
||||
addInjectionPoints(type, Factory.FIELDS, true, result, errors);
|
||||
addInjectionPoints(type, Factory.METHODS, true, result, errors);
|
||||
|
||||
ImmutableSet<InjectionPoint> result = ImmutableSet.copyOf(sink);
|
||||
result = unmodifiableSet(result);
|
||||
if (errors.hasErrors()) {
|
||||
throw new ConfigurationException(errors.getMessages()).withPartialValue(result);
|
||||
}
|
||||
|
@ -293,14 +296,14 @@ public final class InjectionPoint {
|
|||
* of the valid injection points.
|
||||
*/
|
||||
public static Set<InjectionPoint> forInstanceMethodsAndFields(TypeLiteral<?> type) {
|
||||
List<InjectionPoint> sink = new ArrayList<>();
|
||||
Set<InjectionPoint> result = new HashSet<>();
|
||||
Errors errors = new Errors();
|
||||
|
||||
// TODO (crazybob): Filter out overridden members.
|
||||
addInjectionPoints(type, Factory.FIELDS, false, sink, errors);
|
||||
addInjectionPoints(type, Factory.METHODS, false, sink, errors);
|
||||
addInjectionPoints(type, Factory.FIELDS, false, result, errors);
|
||||
addInjectionPoints(type, Factory.METHODS, false, result, errors);
|
||||
|
||||
ImmutableSet<InjectionPoint> result = ImmutableSet.copyOf(sink);
|
||||
result = unmodifiableSet(result);
|
||||
if (errors.hasErrors()) {
|
||||
throw new ConfigurationException(errors.getMessages()).withPartialValue(result);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.elasticsearch.common.inject.util;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Binder;
|
||||
import org.elasticsearch.common.inject.Binding;
|
||||
|
@ -40,6 +39,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
* Static utility methods for creating and working with instances of {@link Module}.
|
||||
*
|
||||
|
@ -94,15 +96,14 @@ public final class Modules {
|
|||
* Returns a new module that installs all of {@code modules}.
|
||||
*/
|
||||
public static Module combine(Module... modules) {
|
||||
return combine(ImmutableSet.copyOf(modules));
|
||||
return combine(Arrays.asList(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new module that installs all of {@code modules}.
|
||||
*/
|
||||
public static Module combine(Iterable<? extends Module> modules) {
|
||||
// TODO: infer type once JI-9019884 is fixed
|
||||
final Set<Module> modulesSet = ImmutableSet.<Module>copyOf(modules);
|
||||
final Set<? extends Module> modulesSet = newHashSet(modules);
|
||||
return new Module() {
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
|
@ -131,11 +132,10 @@ public final class Modules {
|
|||
}
|
||||
|
||||
private static final class RealOverriddenModuleBuilder implements OverriddenModuleBuilder {
|
||||
private final ImmutableSet<Module> baseModules;
|
||||
private final Set<Module> baseModules;
|
||||
|
||||
private RealOverriddenModuleBuilder(Iterable<? extends Module> baseModules) {
|
||||
// TODO: infer type once JI-9019884 is fixed
|
||||
this.baseModules = ImmutableSet.<Module>copyOf(baseModules);
|
||||
this.baseModules = unmodifiableSet(newHashSet(baseModules));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,11 +21,17 @@ package org.elasticsearch.common.util.set;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class Sets {
|
||||
|
@ -66,6 +72,14 @@ public final class Sets {
|
|||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects {@code Stream<Collection<T>>} into {@code Set<T>}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Collector<Collection<T>, Set<T>, Set<T>> toFlatSet() {
|
||||
return (Collector<Collection<T>, Set<T>, Set<T>>) (Object) ToFlatSetCollector.INSTANCE;
|
||||
}
|
||||
|
||||
public static <T> Set<T> newConcurrentHashSet() {
|
||||
return Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
@ -89,4 +103,39 @@ public final class Sets {
|
|||
union.addAll(right);
|
||||
return union;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects {@code Stream<Collection<T>>} into {@code Set<T>}.
|
||||
*/
|
||||
private static enum ToFlatSetCollector implements Collector<Collection<Object>, Set<Object>, Set<Object>> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Supplier<Set<Object>> supplier() {
|
||||
return HashSet::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiConsumer<Set<Object>, Collection<Object>> accumulator() {
|
||||
return Collection::addAll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryOperator<Set<Object>> combiner() {
|
||||
return (lhs, rhs) -> {
|
||||
lhs.addAll(rhs);
|
||||
return lhs;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<Set<Object>, Set<Object>> finisher() {
|
||||
return Function.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<java.util.stream.Collector.Characteristics> characteristics() {
|
||||
return EnumSet.of(Collector.Characteristics.IDENTITY_FINISH, Collector.Characteristics.UNORDERED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.elasticsearch.gateway;
|
|||
|
||||
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.ElasticsearchTimeoutException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
|
@ -38,7 +39,13 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
|||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.transport.ReceiveTimeoutTransportException;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
/**
|
||||
* Allows to asynchronously fetch shard related data from other nodes for allocation, without blocking
|
||||
|
@ -143,7 +150,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
}
|
||||
}
|
||||
}
|
||||
Set<String> allIgnoreNodes = ImmutableSet.copyOf(nodesToIgnore);
|
||||
Set<String> allIgnoreNodes = unmodifiableSet(new HashSet<>(nodesToIgnore));
|
||||
// clear the nodes to ignore, we had a successful run in fetching everything we can
|
||||
// we need to try them if another full run is needed
|
||||
nodesToIgnore.clear();
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.analysis;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.lucene.analysis.charfilter.HTMLStripCharFilter;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
|
@ -28,26 +27,26 @@ import org.elasticsearch.index.Index;
|
|||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HtmlStripCharFilterFactory extends AbstractCharFilterFactory {
|
||||
|
||||
private final ImmutableSet<String> escapedTags;
|
||||
private final Set<String> escapedTags;
|
||||
|
||||
@Inject
|
||||
public HtmlStripCharFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
|
||||
super(index, indexSettings, name);
|
||||
String[] escapedTags = settings.getAsArray("escaped_tags");
|
||||
if (escapedTags.length > 0) {
|
||||
this.escapedTags = ImmutableSet.copyOf(escapedTags);
|
||||
this.escapedTags = unmodifiableSet(newHashSet(escapedTags));
|
||||
} else {
|
||||
this.escapedTags = null;
|
||||
}
|
||||
}
|
||||
|
||||
public ImmutableSet<String> escapedTags() {
|
||||
public Set<String> escapedTags() {
|
||||
return escapedTags;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.indices;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.util.CollectionUtil;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
|
@ -87,14 +87,15 @@ import java.io.IOException;
|
|||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||
|
@ -162,11 +163,11 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
|
|||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
ImmutableSet<String> indices = ImmutableSet.copyOf(this.indices.keySet());
|
||||
ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown"));
|
||||
|
||||
// Copy indices because we modify it asynchronously in the body of the loop
|
||||
Set<String> indices = new HashSet<>(this.indices.keySet());
|
||||
final CountDownLatch latch = new CountDownLatch(indices.size());
|
||||
|
||||
final ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown"));
|
||||
|
||||
for (final String index : indices) {
|
||||
indicesStopExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.cluster;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionModule;
|
||||
|
@ -59,7 +60,10 @@ import java.util.Set;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.util.set.Sets.newHashSet;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
@ -89,8 +93,7 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public static class BlockingActionFilter extends org.elasticsearch.action.support.ActionFilter.Simple {
|
||||
|
||||
ImmutableSet<String> blockedActions = ImmutableSet.of();
|
||||
private Set<String> blockedActions = emptySet();
|
||||
|
||||
@Inject
|
||||
public BlockingActionFilter(Settings settings) {
|
||||
|
@ -116,7 +119,7 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void blockActions(String... actions) {
|
||||
blockedActions = ImmutableSet.copyOf(actions);
|
||||
blockedActions = unmodifiableSet(newHashSet(actions));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,10 @@ com.google.common.io.Files
|
|||
com.google.common.primitives.Ints
|
||||
com.google.common.collect.ImmutableMap#entrySet()
|
||||
com.google.common.collect.ImmutableSet#builder()
|
||||
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[])
|
||||
|
||||
@defaultMessage Do not violate java's access system
|
||||
java.lang.reflect.AccessibleObject#setAccessible(boolean)
|
||||
|
|
Loading…
Reference in New Issue