public class InMemoryProctorStore extends Object implements ProctorStore
These are design notes of this in-memory store.
Initially it stores following data * a single dummy revision in matrix history. * no test definition.
the dummy revision is required for the following purpose. * getLatestVersion() can avoid an exception even in initialized state. * getCurrent*() can avoid an exception as they relies on getLatestVersion()
With default constructor, Revision id is a sequential number. First revision id is "0" and first update will create a revision "1". If you want to control revision id generation (e.g. if you want to make sure it's unique in more than single stores), create and pass to the constructor your custom id generator.
Internally, it stores single data structures to support all queries. * globalHistory: a linked list of update records order by recency
| Constructor and Description |
|---|
InMemoryProctorStore() |
InMemoryProctorStore(Supplier<String> revisionIdGenerator) |
| Modifier and Type | Method and Description |
|---|---|
void |
addTestDefinition(ChangeMetadata changeMetadata,
String testName,
TestDefinition testDefinition,
Map<String,String> metadata)
Add new test definition to this store.
|
static Supplier<String> |
autoincrementRevisionIdGenerator() |
boolean |
cleanUserWorkspace(String username) |
void |
close() |
void |
deleteTestDefinition(ChangeMetadata changeMetadata,
String previousVersion,
String testName,
TestDefinition testDefinition) |
Map<String,List<Revision>> |
getAllHistories()
Get all the revisions for all tests in history
Same revision may appear in two or more lists if multiple tests are modified in the revision.
|
TestDefinition |
getCurrentTestDefinition(String testName) |
TestMatrixVersion |
getCurrentTestMatrix() |
List<Revision> |
getHistory(String testName,
int start,
int limit) |
List<Revision> |
getHistory(String testName,
String revisionId,
int start,
int limit) |
String |
getLatestVersion() |
List<Revision> |
getMatrixHistory(Instant sinceInclusive,
Instant untilExclusive) |
List<Revision> |
getMatrixHistory(int start,
int limit) |
String |
getName()
This method returns a name of the ProctorStore instance for logging purpose.
|
RevisionDetails |
getRevisionDetails(String revisionId) |
TestDefinition |
getTestDefinition(String testName,
String revisionId) |
List<TestEdit> |
getTestEdits(String testName,
int start,
int limit) |
List<TestEdit> |
getTestEdits(String testName,
String revision,
int start,
int limit) |
TestMatrixVersion |
getTestMatrix(String revisionId) |
void |
refresh()
Update the local state with the remote database.
|
void |
updateTestDefinition(ChangeMetadata changeMetadata,
String previousVersion,
String testName,
TestDefinition testDefinition,
Map<String,String> metadata)
Updates a test with testName that already exists in this store
Fails with Exception when testName does not exist, or
neither testDefinition nor metadata has changes to current version
|
void |
verifySetup()
Verifies the data store object is ready to operate.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddTestDefinition, addTestDefinition, deleteTestDefinition, deleteTestDefinition, updateTestDefinition, updateTestDefinitionpublic static Supplier<String> autoincrementRevisionIdGenerator()
public String getName()
ProctorStoregetName in interface ProctorStore@Nonnull public String getLatestVersion()
getLatestVersion in interface ProctorReaderpublic TestMatrixVersion getTestMatrix(String revisionId) throws StoreException
getTestMatrix in interface ProctorReaderrevisionId - id of the revisionStoreException - if the revision is not found.@CheckForNull public TestDefinition getTestDefinition(String testName, String revisionId) throws StoreException
getTestDefinition in interface ProctorReadertestName - name of the testrevisionId - id of the revisionStoreException - if the revision is not found.@Nonnull public List<Revision> getMatrixHistory(int start, int limit)
getMatrixHistory in interface ProctorReaderstart - offset of the first revision (0-indexed)limit - limit of the number of revisions, -1 might be usable for unlimited (depending on implementation)@Nonnull public List<Revision> getMatrixHistory(Instant sinceInclusive, Instant untilExclusive)
getMatrixHistory in interface ProctorReadersinceInclusive - earliest dateuntilExclusive - latest date@Nonnull public List<Revision> getHistory(String testName, String revisionId, int start, int limit) throws StoreException
getHistory in interface ProctorReadertestName - name of the teststart - offset of the first revision (0-indexed)limit - limit of the number of revisions, -1 might be usable for unlimited (depending on implementation)StoreException - if the revision is not found.@CheckForNull public RevisionDetails getRevisionDetails(String revisionId) throws StoreException
getRevisionDetails in interface ProctorReaderrevisionId - id of the revisionStoreException@Nonnull public List<TestEdit> getTestEdits(String testName, int start, int limit) throws StoreException
getTestEdits in interface ProctorReadertestName - to get test editsstart - offset of the first revision (0-indexed)limit - limit of the number of test editsStoreException - if the revision is not found@Nonnull public List<TestEdit> getTestEdits(String testName, String revision, int start, int limit) throws StoreException
getTestEdits in interface ProctorReadertestName - to get test editsrevision - from which the search of test edit is initiatedstart - offset of the first revision (0-indexed)limit - limit of the number of test editsStoreException - if the revision is not found@Nonnull public Map<String,List<Revision>> getAllHistories()
ProctorReadergetAllHistories in interface ProctorReaderpublic TestMatrixVersion getCurrentTestMatrix() throws StoreException
getCurrentTestMatrix in interface ProctorReaderStoreException@CheckForNull public TestDefinition getCurrentTestDefinition(String testName) throws StoreException
getCurrentTestDefinition in interface ProctorReadertestName - name of the test.StoreException@Nonnull public List<Revision> getHistory(String testName, int start, int limit) throws StoreException
getHistory in interface ProctorReadertestName - name of the teststart - offset of the first revision (0-indexed)limit - limit of the number of revisions, -1 might be usable for unlimited (depending on implementation)StoreExceptionpublic void addTestDefinition(ChangeMetadata changeMetadata, String testName, TestDefinition testDefinition, Map<String,String> metadata) throws StoreException.TestUpdateException
ProctorWriteraddTestDefinition in interface ProctorWriterStoreException.TestUpdateException - on invalid inputspublic void updateTestDefinition(ChangeMetadata changeMetadata, String previousVersion, String testName, TestDefinition testDefinition, Map<String,String> metadata) throws StoreException.TestUpdateException
ProctorWriterupdateTestDefinition in interface ProctorWriterStoreException.TestUpdateExceptionpublic void deleteTestDefinition(ChangeMetadata changeMetadata, String previousVersion, String testName, TestDefinition testDefinition) throws StoreException.TestUpdateException
deleteTestDefinition in interface ProctorWriterStoreException.TestUpdateException - whenpublic boolean cleanUserWorkspace(String username)
cleanUserWorkspace in interface ProctorWriterpublic void verifySetup()
ProctorReaderverifySetup in interface ProctorReaderverifySetup in interface ProctorWriterpublic void refresh()
ProctorReaderrefresh in interface ProctorReaderpublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2022. All rights reserved.