Package com.google.gerrit.server.index
Class VersionManager
- java.lang.Object
-
- com.google.gerrit.server.index.VersionManager
-
- All Implemented Interfaces:
LifecycleListener
,EventListener
public abstract class VersionManager extends Object implements LifecycleListener
Trigger for online reindexing in case the index version in use is not the latest.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
VersionManager.Version<V>
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,IndexDefinition<?,?,?>>
defs
protected boolean
onlineUpgrade
protected Map<String,OnlineReindexer<?,?,?>>
reindexers
protected String
runReindexMsg
protected SitePaths
sitePaths
-
Constructor Summary
Constructors Modifier Constructor Description protected
VersionManager(SitePaths sitePaths, PluginSetContext<OnlineUpgradeListener> listeners, Collection<IndexDefinition<?,?,?>> defs, boolean onlineUpgrade)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
activateLatestIndex(String name)
Activate the latest index if the current index is not already the latest.protected GerritIndexStatus
createIndexStatus()
static boolean
getOnlineUpgrade(org.eclipse.jgit.lib.Config cfg)
protected <K,V,I extends Index<K,V>>
voidinitIndex(IndexDefinition<K,V,I> def, GerritIndexStatus cfg)
boolean
isKnownIndex(String name)
Tells if an index with this name is currently known or not.protected abstract <K,V,I extends Index<K,V>>
TreeMap<Integer,VersionManager.Version<V>>scanVersions(IndexDefinition<K,V,I> def, GerritIndexStatus cfg)
void
start()
Invoked when the server is starting.boolean
startReindexer(String name, boolean force)
Start the online reindexer if the current index is not already the latest.void
stop()
Invoked when the server is stopping.
-
-
-
Field Detail
-
onlineUpgrade
protected final boolean onlineUpgrade
-
runReindexMsg
protected final String runReindexMsg
-
sitePaths
protected final SitePaths sitePaths
-
defs
protected final Map<String,IndexDefinition<?,?,?>> defs
-
reindexers
protected final Map<String,OnlineReindexer<?,?,?>> reindexers
-
-
Constructor Detail
-
VersionManager
protected VersionManager(SitePaths sitePaths, PluginSetContext<OnlineUpgradeListener> listeners, Collection<IndexDefinition<?,?,?>> defs, boolean onlineUpgrade)
-
-
Method Detail
-
getOnlineUpgrade
public static boolean getOnlineUpgrade(org.eclipse.jgit.lib.Config cfg)
-
start
public void start()
Description copied from interface:LifecycleListener
Invoked when the server is starting.- Specified by:
start
in interfaceLifecycleListener
-
stop
public void stop()
Description copied from interface:LifecycleListener
Invoked when the server is stopping.- Specified by:
stop
in interfaceLifecycleListener
-
startReindexer
public boolean startReindexer(String name, boolean force) throws ReindexerAlreadyRunningException
Start the online reindexer if the current index is not already the latest.- Parameters:
name
- index nameforce
- start re-index- Returns:
- true if started, otherwise false.
- Throws:
ReindexerAlreadyRunningException
-
activateLatestIndex
public boolean activateLatestIndex(String name) throws ReindexerAlreadyRunningException
Activate the latest index if the current index is not already the latest.- Parameters:
name
- index name- Returns:
- true if index was activated, otherwise false.
- Throws:
ReindexerAlreadyRunningException
-
isKnownIndex
public boolean isKnownIndex(String name)
Tells if an index with this name is currently known or not.- Parameters:
name
- index name- Returns:
- true if index is known and can be used, otherwise false.
-
initIndex
protected <K,V,I extends Index<K,V>> void initIndex(IndexDefinition<K,V,I> def, GerritIndexStatus cfg)
-
createIndexStatus
protected GerritIndexStatus createIndexStatus()
-
scanVersions
protected abstract <K,V,I extends Index<K,V>> TreeMap<Integer,VersionManager.Version<V>> scanVersions(IndexDefinition<K,V,I> def, GerritIndexStatus cfg)
-
-