Class ReplicationCache
java.lang.Object
com.sonyericsson.hudson.plugins.gerrit.trigger.replication.ReplicationCache
Replication cache for RefReplicated events.
- Author:
- Hugo Arès <hugo.ares@ericsson.com>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA factory class for ReplicationCache. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCache expiration in minutes. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ReplicationCache(long expiration, TimeUnit unit) Constructor use by default constructor and for unit tests. -
Method Summary
Modifier and TypeMethodDescriptioncom.sonymobile.tools.gerrit.gerritevents.dto.events.RefReplicatedgetIfPresent(String gerritServer, String gerritProject, String ref, String slaveHost) Return the cached RefReplicated associated with the specified parameters, if found.booleanInitialize cache.booleanisExpired(long timestamp) Returns if the specified time stamp is expired.voidput(com.sonymobile.tools.gerrit.gerritevents.dto.events.RefReplicated refReplicated) Cache the specified RefReplicated.voidsetCreationTime(long time) Set creation time for Replication Cache.
-
Field Details
-
DEFAULT_EXPIRATION_IN_MINUTES
public static final int DEFAULT_EXPIRATION_IN_MINUTESCache expiration in minutes.
-
-
Constructor Details
-
ReplicationCache
public ReplicationCache()Default constructor. -
ReplicationCache
Constructor use by default constructor and for unit tests.- Parameters:
expiration- Cache expirationunit- the unit that expiration is expressed in
-
-
Method Details
-
setCreationTime
public void setCreationTime(long time) Set creation time for Replication Cache.- Parameters:
time- when cache was created
-
initialize
public boolean initialize()Initialize cache.- Returns:
- true if success
-
put
public void put(com.sonymobile.tools.gerrit.gerritevents.dto.events.RefReplicated refReplicated) Cache the specified RefReplicated.- Parameters:
refReplicated- the event to cache
-
isExpired
public boolean isExpired(long timestamp) Returns if the specified time stamp is expired. Note that we also need to check if the event would have been received before the cache was even created as would be the case of a Jenkins restart.- Parameters:
timestamp- the time stamp to check.- Returns:
- true if expired, otherwise false
-
getIfPresent
public com.sonymobile.tools.gerrit.gerritevents.dto.events.RefReplicated getIfPresent(String gerritServer, String gerritProject, String ref, String slaveHost) Return the cached RefReplicated associated with the specified parameters, if found.- Parameters:
gerritServer- The gerritServergerritProject- The gerritProjectref- The refslaveHost- The slaveHost- Returns:
- the RefReplicated if found, otherwise null
-