Class CsnFactory
- java.lang.Object
-
- org.apache.directory.api.ldap.model.csn.CsnFactory
-
public class CsnFactory extends Object
Generates a newCsn.- Author:
- Apache Directory Project
-
-
Field Summary
Fields Modifier and Type Field Description private intchangeCountThe integer used to disambiguate CSN generated at the same timeprivate static longlastTimestampThe last timestampprivate ObjectlockA lock used during the instance creationprivate static intPURGE_INSTANCEIDA special instance ID for a purge CSNprivate intreplicaIdThe replicaId to use for every CSN created by this factory
-
Constructor Summary
Constructors Constructor Description CsnFactory(int replicaId)Creates a new CsnFactory instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CsnnewInstance()Returns a newCsn.CsnnewInstance(long timestamp, int changeCount)Returns a newCsncreated from the given values.CsnnewPurgeCsn(long expirationDate)Generates a CSN used to purge data.voidsetReplicaId(int replicaId)Sets the replica ID
-
-
-
Field Detail
-
lastTimestamp
private static volatile long lastTimestamp
The last timestamp
-
changeCount
private int changeCount
The integer used to disambiguate CSN generated at the same time
-
replicaId
private int replicaId
The replicaId to use for every CSN created by this factory
-
PURGE_INSTANCEID
private static final int PURGE_INSTANCEID
A special instance ID for a purge CSN- See Also:
- Constant Field Values
-
lock
private Object lock
A lock used during the instance creation
-
-
Method Detail
-
newInstance
public Csn newInstance()
Returns a newCsn. Generated CSN can be duplicate if user generates CSNs more than 2G times a milliseconds.- Returns:
- The new generated CSN
-
newInstance
public Csn newInstance(long timestamp, int changeCount)
Returns a newCsncreated from the given values. This method is not to be used except for test purposes.- Parameters:
timestamp- The timestamp to usechangeCount- The change count to use- Returns:
- The new generated CSN
-
newPurgeCsn
public Csn newPurgeCsn(long expirationDate)
Generates a CSN used to purge data. Its replicaID is not associated to a server.- Parameters:
expirationDate- The time up to the first CSN we want to keep- Returns:
- The new generated CSN
-
setReplicaId
public void setReplicaId(int replicaId)
Sets the replica ID- Parameters:
replicaId- The replica ID
-
-