Package com.attivio.sdk.service
Class MockIngestAuditApi
- java.lang.Object
-
- com.attivio.sdk.service.MockIngestAuditApi
-
- All Implemented Interfaces:
AieSystemAuditApi,AuditReaderApi,AuditWriterApi
public class MockIngestAuditApi extends java.lang.Object implements AieSystemAuditApi, AuditReaderApi
Mock implementation of both theAuditWriterApiandAuditReaderApiinterfaces.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMockIngestAuditApi.AuditDetailCollectorstatic classMockIngestAuditApi.ClientDatastatic classMockIngestAuditApi.CorrelationIdFilterstatic classMockIngestAuditApi.DateFilterstatic classMockIngestAuditApi.DocIdCollectorclassMockIngestAuditApi.FilteredIterablestatic classMockIngestAuditApi.IdFilterstatic classMockIngestAuditApi.NoDetailFilterstatic classMockIngestAuditApi.ResultCodeFilterstatic classMockIngestAuditApi.SequenceIdFilter
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.util.UUID,MockIngestAuditApi.ClientData>clientMap-
Fields inherited from interface com.attivio.sdk.client.audit.AuditReaderApi
UNAVAILABLE
-
-
Constructor Summary
Constructors Constructor Description MockIngestAuditApi()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longaudit(AuditDetail detail)Writes the audit information to the store.longaudit(java.util.List<AuditDetail> details)Writes a batch of audit information to the store.voidclientHeartbeat(java.util.UUID clientId)Updates the audit information to show that the client is still active so that the client will continue to be returned byAuditReaderApi.getActiveClients().voidclientName(java.util.UUID clientId, java.lang.String name)Sets a name to be associated with the client.java.lang.Iterable<java.util.UUID>getActiveClients()Returns the clientIds for all active clients.CloseableIterable<AuditDetail>getAll(java.util.UUID clientId, long startSeq, long count)java.lang.Iterable<AuditDetail>getAuditDetails(java.lang.String docId, java.util.Date start, java.util.Date end)Returns anIterableofAuditDetails associated with the document.java.lang.Iterable<AuditDetail>getAuditDetails(java.lang.String docId, java.util.UUID clientId)Returns anIterableofAuditDetails associated with the document.java.lang.Iterable<AuditDetail>getByCorrelationId(java.util.UUID clientId, java.util.UUID correlationId)Get all audit details for a document via itscorrelationId.java.lang.Iterable<java.lang.String>getCreatedDocuments(java.util.Date start, java.util.Date end)Returns a list of IDs for all documents which were received by the system or created within the system during the specified date range.java.lang.Iterable<java.lang.String>getCreatedDocuments(java.util.UUID clientId)Returns a list of IDs for all documents which were received by the system or created within the system by the specified clientId.java.lang.Iterable<java.lang.String>getDocuments(java.util.EnumSet<ProcessingResultCode> codeSet, java.util.Date start, java.util.Date end)Returns a list of IDs for all documents for which aresultCodeincodeSetwas received at some point during content processing.java.lang.Iterable<java.lang.String>getDocuments(java.util.EnumSet<ProcessingResultCode> codeSet, java.util.UUID clientId)Returns a list of IDs for all documents for which aresultCodeincodeSetwas received at some point during content processing.java.util.List<ErrorRow>getErrorSummary(java.util.UUID clientId)java.lang.Iterable<java.util.UUID>getInactiveClients()Returns the clientIds for all inactive clients.longgetLastLossDetectionSequence(java.util.UUID clientId)java.lang.Iterable<AuditDetail>getLostDetails(long startSeq, long endSeq)Returns all audit detail events that have been flagged as LOST and have a sequence id >=startSeqand <endSeq.java.lang.Iterable<java.lang.String>getProcessedDocuments(java.util.Date start, java.util.Date end)Returns a list of IDs for all documents which have completed processing during the specified date range.java.lang.Iterable<java.lang.String>getProcessedDocuments(java.util.UUID clientId)Returns a list of IDs for all documents which have completed processing which were sent by the specified client.java.lang.Iterable<java.lang.String>getSearchableDocuments(java.lang.String indexName, java.util.Date start, java.util.Date end)Returns anIterableof IDs for all documents which became searchable during the specified date range.java.lang.Iterable<java.lang.String>getSearchableDocuments(java.lang.String indexName, java.util.UUID clientId)Returns anIterableof IDs for all documents that are searchable and were fed by the specified client.AuditClientSummarygetSummary(java.util.UUID clientId)voidmakeInactive(java.util.UUID clientId)Marks the clientId as inactive.voidpurge(java.util.Date start, java.util.Date end)Purges all audit data within the time range.voidpurge(java.util.UUID clientId)Purges all audit data associated with the client ID.intpurgeInactiveClients(long lastInactiveTimeToKeep)Purges the audit data for all clients that are inactive and went inactive beforelastInactiveTimeToKeepstatic voidreset()voidsetLastLossDetectionSequence(java.util.UUID clientId, long seq)Updates the last sequence number considered for loss detection forclientId.java.lang.Iterable<AuditDetail>sort(java.util.List<AuditDetail> details)voidtruncateAll()Truncates all data tables containing audit information.voidupdateSummary(AuditClientSummary summary)Updates the summary record to the provided value.AuditClientSummarywaitForCompletion(java.util.UUID clientId)Waits until all documents and messages created by this client have completed processing.AuditClientSummarywaitForCompletion(java.util.UUID clientId, long timeout)Waits until all documents and messages created by this client have completed processing.java.util.DatewhenSearchable(java.lang.String indexName, java.util.UUID clientId)Returns the earliest date an index commit was received after all documents for the client were indexed.java.util.DatewhenSearchable(java.lang.String indexName, java.util.UUID clientId, java.lang.String docId)Returns the earliest date an index commit was received after the document was indexed.
-
-
-
Field Detail
-
clientMap
public static java.util.Map<java.util.UUID,MockIngestAuditApi.ClientData> clientMap
-
-
Method Detail
-
reset
public static void reset()
-
getCreatedDocuments
public java.lang.Iterable<java.lang.String> getCreatedDocuments(java.util.Date start, java.util.Date end) throws AttivioExceptionReturns a list of IDs for all documents which were received by the system or created within the system during the specified date range.- Specified by:
getCreatedDocumentsin interfaceAuditReaderApi- Parameters:
start- the inclusive start date.end- the exclusive end date.- Throws:
AttivioException- if query cannot be executed
-
getCreatedDocuments
public java.lang.Iterable<java.lang.String> getCreatedDocuments(java.util.UUID clientId) throws AttivioExceptionReturns a list of IDs for all documents which were received by the system or created within the system by the specified clientId.- Specified by:
getCreatedDocumentsin interfaceAuditReaderApi- Parameters:
clientId- restricts results to clientId,nullnot allowed.- Throws:
AttivioException- if query cannot be executed
-
getSearchableDocuments
public java.lang.Iterable<java.lang.String> getSearchableDocuments(java.lang.String indexName, java.util.Date start, java.util.Date end) throws AttivioExceptionReturns anIterableof IDs for all documents which became searchable during the specified date range. Indexed documents become searchable when an associated commit is received. The component with name<indexName>-content-dispatchergeneratesProcessingResultCode.OKresult codes for each document it sees document it processes. Once it generates an associatedOKresult for aCommitmessage, those documents are searchable.A reference algorithm is to find the latest commit (
T1) that occurred before the start of the time range and the latest commit (T2) before the end of the time range. Then any documents that reached the indexer in the time rangeT1-T2are the ones that became searchable.- Specified by:
getSearchableDocumentsin interfaceAuditReaderApi- Parameters:
indexName- the name of the index. To look up index related information, the actual Attivio component that interfaces to the index must be determined. TheindexNameis used to compute this component name. This is done by adding the suffix-content-dispatcherto theindexName. Additionally ifindexNamedoes not supply the workflow where the component is located (specified by a name followed by a .), the default nameindexer.will be prepended.start- the inclusive start date.end- the exclusive end date.- Throws:
AttivioException- if query cannot be executed
-
getSearchableDocuments
public java.lang.Iterable<java.lang.String> getSearchableDocuments(java.lang.String indexName, java.util.UUID clientId) throws AttivioExceptionReturns anIterableof IDs for all documents that are searchable and were fed by the specified client. Indexed documents become searchable when an associated commit is received. The component with name<indexName>-content-dispatchergeneratesProcessingResultCode.OKresult codes for each document it sees document it processes. Once it generates an associatedOKresult for aCommitmessage, those documents are searchable.- Specified by:
getSearchableDocumentsin interfaceAuditReaderApi- Parameters:
indexName- the name of the index. To look up index related information, the actual Attivio component that interfaces to the index must be determined. TheindexNameis used to compute this component name. This is done by adding the suffix-content-dispatcherto theindexName. Additionally ifindexNamedoes not supply the workflow where the component is located (specified by a name followed by a .), the default nameindexer.will be prepended.clientId- restricts results to clientId,nullnot allowed.- Throws:
AttivioException- if query cannot be executed
-
getProcessedDocuments
public java.lang.Iterable<java.lang.String> getProcessedDocuments(java.util.Date start, java.util.Date end) throws AttivioExceptionReturns a list of IDs for all documents which have completed processing during the specified date range. A document is considered complete when all possible side-effects of processing the document have occurred. This state is associated with the receipt of anAuditDetailfor the document with aresultCodeofProcessingResultCode.COMPLETED.- Specified by:
getProcessedDocumentsin interfaceAuditReaderApi- Parameters:
start- the inclusive start date.end- the exclusive end date.- Throws:
AttivioException- if query cannot be executed
-
getProcessedDocuments
public java.lang.Iterable<java.lang.String> getProcessedDocuments(java.util.UUID clientId) throws AttivioExceptionReturns a list of IDs for all documents which have completed processing which were sent by the specified client. A document is considered complete when all possible side-effects of processing the document have occurred. This state is associated with the receipt of anAuditDetailfor the document with aresultCodeofProcessingResultCode.COMPLETED.- Specified by:
getProcessedDocumentsin interfaceAuditReaderApi- Parameters:
clientId- restricts results to clientId,nullnot allowed.- Throws:
AttivioException- if query cannot be executed
-
getDocuments
public java.lang.Iterable<java.lang.String> getDocuments(java.util.EnumSet<ProcessingResultCode> codeSet, java.util.UUID clientId) throws AttivioException
Returns a list of IDs for all documents for which aresultCodeincodeSetwas received at some point during content processing. Since there are multiple content processing stages codes may appear multiple times and multiple codes may match. The returned list will be restricted to documents fed byclientId.- Specified by:
getDocumentsin interfaceAuditReaderApi- Parameters:
codeSet- set of result codes to matchclientId- restricts results to clientId,nullnot allowed.- Returns:
- an
Iterableof document IDs. Document IDs appear at most once. - Throws:
AttivioException- if query cannot be executed
-
getDocuments
public java.lang.Iterable<java.lang.String> getDocuments(java.util.EnumSet<ProcessingResultCode> codeSet, java.util.Date start, java.util.Date end) throws AttivioException
Returns a list of IDs for all documents for which aresultCodeincodeSetwas received at some point during content processing. Since there are multiple content processing stages codes may appear multiple times and multiple codes may match. The returned list will be restricted to documents fed within the specified time range.- Specified by:
getDocumentsin interfaceAuditReaderApi- Parameters:
codeSet- set of result codes to matchstart- the inclusive start date.end- the exclusive end date.- Returns:
- an
Iterableof document IDs. Document IDs appear at most once. - Throws:
AttivioException- if query cannot be executed
-
whenSearchable
public java.util.Date whenSearchable(java.lang.String indexName, java.util.UUID clientId, java.lang.String docId) throws AttivioExceptionReturns the earliest date an index commit was received after the document was indexed. A document is considered indexed after the receipt of aProcessingResultCode.OKaudit result for the index content dispatcher component (<indexName>-content-dispatcher). Documents which are not markedOKby the indexer are not considered by this method as they will never become searchable.- Specified by:
whenSearchablein interfaceAuditReaderApi- Parameters:
indexName- the name of the index. To look up index related information, the actual Attivio component that interfaces to the index must be determined. TheindexNameis used to compute this component name. This is done by adding the suffix-content-dispatcherto theindexName. Additionally ifindexNamedoes not supply the workflow where the component is located (specified by a name followed by a .), the default nameindexer.will be prepended.clientId- restricts results to clientId,nullnot allowed.- Returns:
- the date when document
docIdbecame searchable ornullif not yet searchable - Throws:
AttivioException- if query cannot be executed
-
whenSearchable
public java.util.Date whenSearchable(java.lang.String indexName, java.util.UUID clientId) throws AttivioExceptionReturns the earliest date an index commit was received after all documents for the client were indexed. A document is considered indexed after the receipt of aProcessingResultCode.OKaudit result for the index content dispatcher component (<indexName>-content-dispatcher). Documents which are not markedOKby the indexer are not considered by this method as they will never become searchable.- Specified by:
whenSearchablein interfaceAuditReaderApi- Parameters:
indexName- the name of the index. To look up index related information, the actual Attivio component that interfaces to the index must be determined. TheindexNameis used to compute this component name. This is done by adding the suffix-content-dispatcherto theindexName. Additionally ifindexNamedoes not supply the workflow where the component is located (specified by a name followed by a .), the default nameindexer.will be prepended.clientId- restricts results to clientId,nullnot allowed.- Returns:
- the date when all documents submitted (so far) by client
clientIdbecame searchable ornullif all documents are not yet searchable or no documents have been submitted by the client. - Throws:
AttivioException- if query cannot be executed
-
waitForCompletion
public AuditClientSummary waitForCompletion(java.util.UUID clientId) throws AttivioException
Waits until all documents and messages created by this client have completed processing. If this method is called while feeding of new documents or messages occur in a separate thread or process, it may hang indefinitely or return prematurely. The only way to ensure that no processing associated with the client is occurring is to feed and waitForCompletion from the same thread of control.- Specified by:
waitForCompletionin interfaceAuditReaderApi- Parameters:
clientId- restricts results to clientId,nullnot allowed.- Returns:
- summary information about the client ingestion state or
nullif the client does not exist. - Throws:
AttivioException- if query cannot be executed
-
waitForCompletion
public AuditClientSummary waitForCompletion(java.util.UUID clientId, long timeout) throws AttivioException
Waits until all documents and messages created by this client have completed processing. If this method is called while feeding of new documents or messages occur in a separate thread or process, it may hang indefinitely or return prematurely. The only way to ensure that no processing associated with the client is occurring is to feed and waitForCompletion from the same thread of control.- Specified by:
waitForCompletionin interfaceAuditReaderApi- Returns:
- the associated
AuditClientSummaryif waited successfully,nullif timeout occurred or client does not exist. - Throws:
AttivioException- if query cannot be executed
-
getSummary
public AuditClientSummary getSummary(java.util.UUID clientId) throws AttivioException
- Specified by:
getSummaryin interfaceAuditReaderApi- Parameters:
clientId- restricts results to clientId,nullnot allowed.- Returns:
- summary information about the client ingestion state or
nullif the client does not exist. - Throws:
AttivioException- if query cannot be executed
-
audit
public long audit(java.util.List<AuditDetail> details) throws AttivioException
Description copied from interface:AuditWriterApiWrites a batch of audit information to the store. After this call completes, the client referenced by the audit record will be active and will be returned byAuditReaderApi.getActiveClients(). Note, that if an exception is encountered while storing the audit information, the rest of the list will still be attempted to be stored. All exceptions encountered while persisting the list are returned with any exception after the first added as suppressed exceptions of the first.- Specified by:
auditin interfaceAuditWriterApi- Returns:
- the sequence id for the last audit record in the list.
- Throws:
AttivioException- if the audit information could not be stored
-
audit
public long audit(AuditDetail detail) throws AttivioException
Description copied from interface:AuditWriterApiWrites the audit information to the store. After this call completes, the client referenced by the audit record will be active and will be returned byAuditReaderApi.getActiveClients().- Specified by:
auditin interfaceAuditWriterApi- Returns:
- the sequence id for the audit record
- Throws:
AttivioException- if the audit information could not be stored
-
getActiveClients
public java.lang.Iterable<java.util.UUID> getActiveClients() throws AttivioExceptionReturns the clientIds for all active clients.- Specified by:
getActiveClientsin interfaceAuditReaderApi- Returns:
- an Iterable of clientIds
- Throws:
AttivioException
-
getInactiveClients
public java.lang.Iterable<java.util.UUID> getInactiveClients() throws AttivioExceptionReturns the clientIds for all inactive clients.- Specified by:
getInactiveClientsin interfaceAuditReaderApi- Returns:
- an Iterable of clientIds
- Throws:
AttivioException
-
getAll
public CloseableIterable<AuditDetail> getAll(java.util.UUID clientId, long startSeq, long count) throws AttivioException
- Specified by:
getAllin interfaceAuditReaderApistartSeq- starting sequence ID for responsecount- the maximum number of audit details to return, useLong.MAX_VALUEfor all- Returns:
- all audit information for the client
- Throws:
AttivioException
-
getByCorrelationId
public java.lang.Iterable<AuditDetail> getByCorrelationId(java.util.UUID clientId, java.util.UUID correlationId) throws AttivioException
Get all audit details for a document via itscorrelationId.- Specified by:
getByCorrelationIdin interfaceAuditReaderApi- Throws:
AttivioException
-
getAuditDetails
public java.lang.Iterable<AuditDetail> getAuditDetails(java.lang.String docId, java.util.UUID clientId) throws AttivioException
Returns anIterableofAuditDetails associated with the document. This list may include the audit information for a number of components and will include the creation and completion audit records if available. This method may be called while the document is still being processed.- Specified by:
getAuditDetailsin interfaceAuditReaderApi- Parameters:
docId- the document ID to matchclientId- restricts results to clientId,nullnot allowed.- Throws:
AttivioException- if query cannot be executed
-
getAuditDetails
public java.lang.Iterable<AuditDetail> getAuditDetails(java.lang.String docId, java.util.Date start, java.util.Date end) throws AttivioException
Returns anIterableofAuditDetails associated with the document. This list may include the audit information for a number of components and will include the creation and completion audit records if available. This method may be called while the document is still being processed.nullvalues forstartandendwill return all available audit records for the document.- Specified by:
getAuditDetailsin interfaceAuditReaderApi- Parameters:
docId- the document ID to matchstart- the inclusive start date.end- the exclusive end date.- Throws:
AttivioException- if query cannot be executed
-
getLostDetails
public java.lang.Iterable<AuditDetail> getLostDetails(long startSeq, long endSeq) throws AttivioException
Description copied from interface:AuditReaderApiReturns all audit detail events that have been flagged as LOST and have a sequence id >=startSeqand <endSeq.NOTE: this method is used internally to replay LOST messages for fault tolerance.
- Specified by:
getLostDetailsin interfaceAuditReaderApi- Throws:
AttivioException
-
sort
public java.lang.Iterable<AuditDetail> sort(java.util.List<AuditDetail> details)
-
makeInactive
public void makeInactive(java.util.UUID clientId) throws AttivioExceptionMarks the clientId as inactive. The client will no longer be returned byAuditReaderApi.getActiveClients().- Specified by:
makeInactivein interfaceAuditWriterApi- Throws:
AttivioException
-
clientHeartbeat
public void clientHeartbeat(java.util.UUID clientId) throws AttivioExceptionUpdates the audit information to show that the client is still active so that the client will continue to be returned byAuditReaderApi.getActiveClients().- Specified by:
clientHeartbeatin interfaceAuditWriterApi- Throws:
AttivioException
-
clientName
public void clientName(java.util.UUID clientId, java.lang.String name) throws AttivioExceptionSets a name to be associated with the client. After calling this method,AuditReaderApi.getSummary(UUID)is guaranteed to return a non-nullvalue with clientName and lastActionTime having the value of the set time.- Specified by:
clientNamein interfaceAuditWriterApi- Throws:
AttivioException
-
purge
public void purge(java.util.UUID clientId) throws AttivioExceptionDescription copied from interface:AuditWriterApiPurges all audit data associated with the client ID.- Specified by:
purgein interfaceAuditWriterApi- Parameters:
clientId- restricts results to clientId,nullnot allowed.- Throws:
AttivioException
-
purge
public void purge(java.util.Date start, java.util.Date end) throws AttivioExceptionDescription copied from interface:AuditWriterApiPurges all audit data within the time range.
Ifstartandendare bothnull, deletes all records and summary records. Otherwise, summary records are retained. If deleting individual summary records is required, useAuditWriterApi.purge(UUID)instead- Specified by:
purgein interfaceAuditWriterApi- Parameters:
start- the inclusive start date.end- the exclusive end date.- Throws:
AttivioException
-
purgeInactiveClients
public int purgeInactiveClients(long lastInactiveTimeToKeep) throws AttivioExceptionPurges the audit data for all clients that are inactive and went inactive beforelastInactiveTimeToKeep- Specified by:
purgeInactiveClientsin interfaceAuditWriterApi- Returns:
- number of clients that were purged
- Throws:
AttivioException
-
truncateAll
public void truncateAll() throws AttivioExceptionTruncates all data tables containing audit information. This is provided at the system level as an efficient way to get rid of all audit related data.- Specified by:
truncateAllin interfaceAieSystemAuditApi- Throws:
AttivioException
-
getErrorSummary
public java.util.List<ErrorRow> getErrorSummary(java.util.UUID clientId)
- Specified by:
getErrorSummaryin interfaceAieSystemAuditApi
-
updateSummary
public void updateSummary(AuditClientSummary summary) throws AttivioException
Updates the summary record to the provided value. Used to correct the summary when audit updates get out of sync.- Specified by:
updateSummaryin interfaceAieSystemAuditApi- Throws:
AttivioException
-
setLastLossDetectionSequence
public void setLastLossDetectionSequence(java.util.UUID clientId, long seq) throws AttivioExceptionUpdates the last sequence number considered for loss detection forclientId. Used by loss detection to determine which detail records to be considered for the next round of loss detection. Note, that the storage and retrieval mechanism assume that the sequence numbers stored are always increasing. Attempts to set a lower sequence number will result in undefined behavior. If no activity exists forclientIdthen result is undefined.- Specified by:
setLastLossDetectionSequencein interfaceAieSystemAuditApi- Throws:
AttivioException
-
getLastLossDetectionSequence
public long getLastLossDetectionSequence(java.util.UUID clientId) throws AttivioException- Specified by:
getLastLossDetectionSequencein interfaceAieSystemAuditApi- Returns:
- the last sequence number set or -1 if never set.
- Throws:
AttivioException
-
-