Package jetbrains.buildServer
Class MockCustomDataStorage
- java.lang.Object
-
- jetbrains.buildServer.MockCustomDataStorage
-
- All Implemented Interfaces:
CustomDataStorage
public class MockCustomDataStorage extends Object implements CustomDataStorage
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.CustomDataStorage
CustomDataStorage.ConflictResolution
-
-
Constructor Summary
Constructors Constructor Description MockCustomDataStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears data in custom data storage.void
dispose()
Disposes (destroys) this custom data storage.void
flush()
Flushes data to the persistent storage immediately, otherwise flush is performed automatically with some delay.void
flush(CustomDataStorage.ConflictResolution conflictResolutionMode)
Flushes data to the persistent storage immediately with the specified conflict resolution mode.Date
getDataLoadTime()
For a storage whose values have been loaded from the database returns the timestamp when the data was loaded.String
getValue(String key)
Returns value stored for the specified keyMap<String,String>
getValues()
Retrieves values from the storageboolean
isDirty()
void
putValue(String key, String value)
Puts specified value into the storage.void
putValues(Map<String,String> data)
Puts values into the storage but does not flush the data yet, note that existing data will be completely overwritten.void
putValuesAndFlush(Map<String,String> data)
Same asCustomDataStorage.putValues(Map)
but if storage is not created yet, then the method ensures that the storage will be created with the provided data so that other processes could see it's data immediately.void
refresh()
Refreshes data from the underlying storagevoid
scheduleFlush()
Performs flush of data asynchronously in a separate threadCustomDataStorage.ConflictResolution.IGNORE_OURS
mode is used for the conflict resolution.void
updateValues(Map<String,String> newOrChangedValues, Set<String> removedKeys)
Puts values from newOrChangedValues map to the storage and removes keys provided via removedKeys set.
-
-
-
Method Detail
-
putValues
public void putValues(@NotNull Map<String,String> data)
Description copied from interface:CustomDataStorage
Puts values into the storage but does not flush the data yet, note that existing data will be completely overwritten. If this is a new storage which is not yet flushed on disk or in database, then an empty record for this storage will be allocated and will become visible to other processes. But another process will see the storage with empty map of data until the process which created the storage flushes it.- Specified by:
putValues
in interfaceCustomDataStorage
- Parameters:
data
- custom data to put into the storage
-
updateValues
public void updateValues(@NotNull Map<String,String> newOrChangedValues, @NotNull Set<String> removedKeys)
Description copied from interface:CustomDataStorage
Puts values from newOrChangedValues map to the storage and removes keys provided via removedKeys set. If removedKeys and newOrChangedValues map has the same key, then the value from newOrChangedValues will be stored and key won't be removed. If newOrChangedValues has null value for some key, then an exception will be thrown.- Specified by:
updateValues
in interfaceCustomDataStorage
- Parameters:
newOrChangedValues
- new values to put in the storageremovedKeys
- keys to remove from the storage
-
putValuesAndFlush
public void putValuesAndFlush(@NotNull Map<String,String> data)
Description copied from interface:CustomDataStorage
Same asCustomDataStorage.putValues(Map)
but if storage is not created yet, then the method ensures that the storage will be created with the provided data so that other processes could see it's data immediately. If the storage already exists, then this is equivalent to:putValues(map); flush();
- Specified by:
putValuesAndFlush
in interfaceCustomDataStorage
-
getValues
@Nullable public Map<String,String> getValues()
Description copied from interface:CustomDataStorage
Retrieves values from the storage- Specified by:
getValues
in interfaceCustomDataStorage
- Returns:
- custom data map or null if there were no data
-
getValue
@Nullable public String getValue(@NotNull String key)
Description copied from interface:CustomDataStorage
Returns value stored for the specified key- Specified by:
getValue
in interfaceCustomDataStorage
- Parameters:
key
- key- Returns:
- stored value or null
-
putValue
public void putValue(@NotNull String key, @Nullable String value)
Description copied from interface:CustomDataStorage
Puts specified value into the storage. If value is null then data with specified key is removed from the storage.- Specified by:
putValue
in interfaceCustomDataStorage
- Parameters:
key
- keyvalue
- value
-
flush
public void flush()
Description copied from interface:CustomDataStorage
Flushes data to the persistent storage immediately, otherwise flush is performed automatically with some delay.CustomDataStorage.ConflictResolution.IGNORE_OURS
mode is used for the conflict resolution.- Specified by:
flush
in interfaceCustomDataStorage
-
flush
public void flush(@NotNull CustomDataStorage.ConflictResolution conflictResolutionMode) throws CustomDataConflictException
Description copied from interface:CustomDataStorage
Flushes data to the persistent storage immediately with the specified conflict resolution mode.- Specified by:
flush
in interfaceCustomDataStorage
- Throws:
CustomDataConflictException
- if a conflict is detected and the conflict resolution mode is set toCustomDataStorage.ConflictResolution.FAIL
-
scheduleFlush
public void scheduleFlush()
Description copied from interface:CustomDataStorage
Performs flush of data asynchronously in a separate threadCustomDataStorage.ConflictResolution.IGNORE_OURS
mode is used for the conflict resolution.- Specified by:
scheduleFlush
in interfaceCustomDataStorage
-
clear
public void clear()
Description copied from interface:CustomDataStorage
Clears data in custom data storage. Same asCustomDataStorage.putValues(Map)
called with empty map.- Specified by:
clear
in interfaceCustomDataStorage
-
dispose
public void dispose()
Description copied from interface:CustomDataStorage
Disposes (destroys) this custom data storage.- Specified by:
dispose
in interfaceCustomDataStorage
-
refresh
public void refresh()
Description copied from interface:CustomDataStorage
Refreshes data from the underlying storage- Specified by:
refresh
in interfaceCustomDataStorage
-
isDirty
public boolean isDirty()
- Specified by:
isDirty
in interfaceCustomDataStorage
- Returns:
- true if this custom data storage was modified but the data is not persisted yet
-
getDataLoadTime
@Nullable public Date getDataLoadTime()
Description copied from interface:CustomDataStorage
For a storage whose values have been loaded from the database returns the timestamp when the data was loaded. If the storage has been obtained but getValues() or getValue() methods were not called, then the data may not be loaded into the storage yet. In such cases null is returned as the load time. Storage modifications via put* methods do not affect the load time.- Specified by:
getDataLoadTime
in interfaceCustomDataStorage
- Returns:
- the timestamp of the last fetching of the storage data from the database
-
-