forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speedup Injector during concurrent node starts (elastic#118588)
Lets simplify this logic a little and lock on the injector instance instead of the class. Locking on the class actually wastes lots of time during test runs it turns out, especially with multi-cluster tests.
- Loading branch information
1 parent
38a34d9
commit 0cc08a9
Showing
8 changed files
with
24 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
server/src/main/java/org/elasticsearch/injection/guice/Scope.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,78 +16,22 @@ | |
|
||
package org.elasticsearch.injection.guice.internal; | ||
|
||
import org.elasticsearch.injection.guice.Scope; | ||
import org.elasticsearch.injection.guice.Scopes; | ||
import org.elasticsearch.injection.guice.Injector; | ||
|
||
/** | ||
* References a scope, either directly (as a scope instance), or indirectly (as a scope annotation). | ||
* The scope's eager or laziness is also exposed. | ||
* | ||
* @author [email protected] (Jesse Wilson) | ||
*/ | ||
public abstract class Scoping { | ||
|
||
public enum Scoping { | ||
/** | ||
* No scoping annotation has been applied. Note that this is different from {@code | ||
* in(Scopes.NO_SCOPE)}, where the 'NO_SCOPE' has been explicitly applied. | ||
*/ | ||
public static final Scoping UNSCOPED = new Scoping() { | ||
|
||
@Override | ||
public Scope getScopeInstance() { | ||
return Scopes.NO_SCOPE; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Scopes.NO_SCOPE.toString(); | ||
} | ||
|
||
}; | ||
|
||
public static final Scoping EAGER_SINGLETON = new Scoping() { | ||
|
||
@Override | ||
public Scope getScopeInstance() { | ||
return Scopes.SINGLETON; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "eager singleton"; | ||
} | ||
|
||
}; | ||
|
||
UNSCOPED, | ||
/** | ||
* Returns true if this scope was explicitly applied. If no scope was explicitly applied then the | ||
* scoping annotation will be used. | ||
* One instance per {@link Injector}. | ||
*/ | ||
public boolean isExplicitlyScoped() { | ||
return this != UNSCOPED; | ||
} | ||
|
||
/** | ||
* Returns true if this is the default scope. In this case a new instance will be provided for | ||
* each injection. | ||
*/ | ||
public boolean isNoScope() { | ||
return getScopeInstance() == Scopes.NO_SCOPE; | ||
} | ||
|
||
/** | ||
* Returns true if this scope is a singleton that should be loaded eagerly in {@code stage}. | ||
*/ | ||
public boolean isEagerSingleton() { | ||
return this == EAGER_SINGLETON; | ||
} | ||
|
||
/** | ||
* Returns the scope instance, or {@code null} if that isn't known for this instance. | ||
*/ | ||
public Scope getScopeInstance() { | ||
return null; | ||
} | ||
|
||
private Scoping() {} | ||
EAGER_SINGLETON | ||
} |