public abstract class SQLMetadataStorageActionHandler<EntryType,StatusType,LogType,LockType> extends Object implements MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
Constructor and Description |
---|
SQLMetadataStorageActionHandler(SQLMetadataConnector connector,
com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
MetadataStorageActionHandlerTypes<EntryType,StatusType,LogType,LockType> types,
String entryTypeName,
String entryTable,
String logTable,
String lockTable) |
Modifier and Type | Method and Description |
---|---|
boolean |
addLock(String entryId,
LockType lock)
Add a lock to the given entry
|
boolean |
addLog(String entryId,
LogType log)
Add a log to the entry with the given id.
|
protected abstract org.skife.jdbi.v2.Query<Map<String,Object>> |
createInactiveStatusesSinceQuery(org.skife.jdbi.v2.Handle handle,
org.joda.time.DateTime timestamp,
Integer maxNumStatuses) |
List<Pair<EntryType,StatusType>> |
getActiveEntriesWithStatus()
Return all active entries with their respective status
|
protected SQLMetadataConnector |
getConnector() |
Pair<org.joda.time.DateTime,String> |
getCreatedDateAndDataSource(String entryId)
Return createdDate and dataSource for the given id
|
com.google.common.base.Optional<EntryType> |
getEntry(String entryId)
Retrieves the entry with the given id.
|
protected String |
getEntryTable() |
List<StatusType> |
getInactiveStatusesSince(org.joda.time.DateTime timestamp,
Integer maxNumStatuses)
Return up to
maxNumStatuses statuses for inactive entries created on or later than the given timestamp |
protected com.fasterxml.jackson.databind.ObjectMapper |
getJsonMapper() |
Long |
getLockId(String entryId,
LockType lock)
Returns the lock id for the given entry and the lock.
|
Map<Long,LockType> |
getLocks(String entryId)
Returns the locks for the given entry
|
List<LogType> |
getLogs(String entryId)
Returns the logs for the entry with the given id.
|
com.google.common.base.Optional<StatusType> |
getStatus(String entryId)
Retrieve the status for the entry with the given id.
|
protected com.fasterxml.jackson.core.type.TypeReference |
getStatusType() |
void |
insert(String id,
org.joda.time.DateTime timestamp,
String dataSource,
EntryType entry,
boolean active,
StatusType status)
Creates a new entry.
|
void |
removeLock(long lockId)
Remove the lock with the given lock id.
|
boolean |
replaceLock(String entryId,
long oldLockId,
LockType newLock)
Replace an existing lock with a new lock.
|
boolean |
setStatus(String entryId,
boolean active,
StatusType status)
Sets or updates the status for any active entry with the given id.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInactiveStatusesSince
public SQLMetadataStorageActionHandler(SQLMetadataConnector connector, com.fasterxml.jackson.databind.ObjectMapper jsonMapper, MetadataStorageActionHandlerTypes<EntryType,StatusType,LogType,LockType> types, String entryTypeName, String entryTable, String logTable, String lockTable)
protected SQLMetadataConnector getConnector()
protected com.fasterxml.jackson.databind.ObjectMapper getJsonMapper()
protected com.fasterxml.jackson.core.type.TypeReference getStatusType()
protected String getEntryTable()
public void insert(String id, org.joda.time.DateTime timestamp, String dataSource, EntryType entry, boolean active, StatusType status) throws EntryExistsException
MetadataStorageActionHandler
insert
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
id
- entry idtimestamp
- timestamp this entry was createddataSource
- datasource associated with this entryentry
- object representing this entryactive
- active or inactive flagstatus
- status object associated wit this object, can be nullEntryExistsException
public boolean setStatus(String entryId, boolean active, StatusType status)
MetadataStorageActionHandler
setStatus
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idactive
- activestatus
- statuspublic com.google.common.base.Optional<EntryType> getEntry(String entryId)
MetadataStorageActionHandler
getEntry
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idpublic com.google.common.base.Optional<StatusType> getStatus(String entryId)
MetadataStorageActionHandler
getStatus
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idpublic List<Pair<EntryType,StatusType>> getActiveEntriesWithStatus()
MetadataStorageActionHandler
getActiveEntriesWithStatus
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
public List<StatusType> getInactiveStatusesSince(org.joda.time.DateTime timestamp, @Nullable Integer maxNumStatuses)
MetadataStorageActionHandler
maxNumStatuses
statuses for inactive entries created on or later than the given timestampgetInactiveStatusesSince
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
timestamp
- timestampmaxNumStatuses
- maxNumStatusesprotected abstract org.skife.jdbi.v2.Query<Map<String,Object>> createInactiveStatusesSinceQuery(org.skife.jdbi.v2.Handle handle, org.joda.time.DateTime timestamp, @Nullable Integer maxNumStatuses)
@Nullable public Pair<org.joda.time.DateTime,String> getCreatedDateAndDataSource(String entryId)
MetadataStorageActionHandler
getCreatedDateAndDataSource
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
public boolean addLock(String entryId, LockType lock)
MetadataStorageActionHandler
addLock
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idlock
- lock to addpublic boolean replaceLock(String entryId, long oldLockId, LockType newLock)
MetadataStorageActionHandler
replaceLock
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idoldLockId
- lock to be replacednewLock
- lock to be addedpublic void removeLock(long lockId)
MetadataStorageActionHandler
removeLock
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
lockId
- lock idpublic boolean addLog(String entryId, LogType log)
MetadataStorageActionHandler
addLog
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idlog
- log to addpublic List<LogType> getLogs(String entryId)
MetadataStorageActionHandler
getLogs
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry idpublic Map<Long,LockType> getLocks(String entryId)
MetadataStorageActionHandler
getLocks
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
entryId
- entry id@Nullable public Long getLockId(String entryId, LockType lock)
MetadataStorageActionHandler
getLockId
in interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
Copyright © 2011–2018. All rights reserved.