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 theAuditWriterApi
andAuditReaderApi
interfaces.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MockIngestAuditApi.AuditDetailCollector
static class
MockIngestAuditApi.ClientData
static class
MockIngestAuditApi.CorrelationIdFilter
static class
MockIngestAuditApi.DateFilter
static class
MockIngestAuditApi.DocIdCollector
class
MockIngestAuditApi.FilteredIterable
static class
MockIngestAuditApi.IdFilter
static class
MockIngestAuditApi.NoDetailFilter
static class
MockIngestAuditApi.ResultCodeFilter
static class
MockIngestAuditApi.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 long
audit(AuditDetail detail)
Writes the audit information to the store.long
audit(java.util.List<AuditDetail> details)
Writes a batch of audit information to the store.void
clientHeartbeat(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()
.void
clientName(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<java.util.UUID>
getAllClients()
Returns the clientIds for all clients sorted by clientId for ease of comparison.java.lang.Iterable<AuditDetail>
getAuditDetails(java.lang.String docId, java.util.Date start, java.util.Date end)
Returns anIterable
ofAuditDetail
s associated with the document.java.lang.Iterable<AuditDetail>
getAuditDetails(java.lang.String docId, java.util.UUID clientId)
Returns anIterable
ofAuditDetail
s 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 aresultCode
incodeSet
was 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 aresultCode
incodeSet
was 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.long
getLastLossDetectionSequence(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 >=startSeq
and <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 anIterable
of 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 anIterable
of IDs for all documents that are searchable and were fed by the specified client.AuditClientSummary
getSummary(java.util.UUID clientId)
void
makeInactive(java.util.UUID clientId)
Marks the clientId as inactive.void
purge(java.util.Date start, java.util.Date end)
Purges all audit data within the time range.void
purge(java.util.UUID clientId)
Purges all audit data associated with the client ID.int
purgeInactiveClients(long lastInactiveTimeToKeep)
Purges the audit data for all clients that are inactive and went inactive beforelastInactiveTimeToKeep
static void
reset()
void
setLastLossDetectionSequence(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)
void
truncateAll()
Truncates all data tables containing audit information.void
updateSummary(AuditClientSummary summary)
Updates the summary record to the provided value.AuditClientSummary
waitForCompletion(java.util.UUID clientId)
Waits until all documents and messages created by this client have completed processing.AuditClientSummary
waitForCompletion(java.util.UUID clientId, long timeout)
Waits until all documents and messages created by this client have completed processing.java.util.Date
whenSearchable(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.Date
whenSearchable(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 AttivioException
Returns 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:
getCreatedDocuments
in 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 AttivioException
Returns a list of IDs for all documents which were received by the system or created within the system by the specified clientId.- Specified by:
getCreatedDocuments
in interfaceAuditReaderApi
- Parameters:
clientId
- restricts results to clientId,null
not 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 AttivioException
Returns anIterable
of 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-dispatcher
generatesProcessingResultCode.OK
result codes for each document it sees document it processes. Once it generates an associatedOK
result for aCommit
message, 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-T2
are the ones that became searchable.- Specified by:
getSearchableDocuments
in 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. TheindexName
is used to compute this component name. This is done by adding the suffix-content-dispatcher
to theindexName
. Additionally ifindexName
does 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 AttivioException
Returns anIterable
of 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-dispatcher
generatesProcessingResultCode.OK
result codes for each document it sees document it processes. Once it generates an associatedOK
result for aCommit
message, those documents are searchable.- Specified by:
getSearchableDocuments
in 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. TheindexName
is used to compute this component name. This is done by adding the suffix-content-dispatcher
to theindexName
. Additionally ifindexName
does 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,null
not 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 AttivioException
Returns 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 anAuditDetail
for the document with aresultCode
ofProcessingResultCode.COMPLETED
.- Specified by:
getProcessedDocuments
in 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 AttivioException
Returns 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 anAuditDetail
for the document with aresultCode
ofProcessingResultCode.COMPLETED
.- Specified by:
getProcessedDocuments
in interfaceAuditReaderApi
- Parameters:
clientId
- restricts results to clientId,null
not 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 aresultCode
incodeSet
was 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:
getDocuments
in interfaceAuditReaderApi
- Parameters:
codeSet
- set of result codes to matchclientId
- restricts results to clientId,null
not allowed.- Returns:
- an
Iterable
of 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 aresultCode
incodeSet
was 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:
getDocuments
in interfaceAuditReaderApi
- Parameters:
codeSet
- set of result codes to matchstart
- the inclusive start date.end
- the exclusive end date.- Returns:
- an
Iterable
of 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 AttivioException
Returns the earliest date an index commit was received after the document was indexed. A document is considered indexed after the receipt of aProcessingResultCode.OK
audit result for the index content dispatcher component (<indexName>-content-dispatcher
). Documents which are not markedOK
by the indexer are not considered by this method as they will never become searchable.- Specified by:
whenSearchable
in 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. TheindexName
is used to compute this component name. This is done by adding the suffix-content-dispatcher
to theindexName
. Additionally ifindexName
does 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,null
not allowed.- Returns:
- the date when document
docId
became searchable ornull
if 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 AttivioException
Returns 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.OK
audit result for the index content dispatcher component (<indexName>-content-dispatcher
). Documents which are not markedOK
by the indexer are not considered by this method as they will never become searchable.- Specified by:
whenSearchable
in 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. TheindexName
is used to compute this component name. This is done by adding the suffix-content-dispatcher
to theindexName
. Additionally ifindexName
does 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,null
not allowed.- Returns:
- the date when all documents submitted (so far) by client
clientId
became searchable ornull
if 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:
waitForCompletion
in interfaceAuditReaderApi
- Parameters:
clientId
- restricts results to clientId,null
not allowed.- Returns:
- summary information about the client ingestion state or
null
if 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:
waitForCompletion
in interfaceAuditReaderApi
- Returns:
- the associated
AuditClientSummary
if waited successfully,null
if 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:
getSummary
in interfaceAuditReaderApi
- Parameters:
clientId
- restricts results to clientId,null
not allowed.- Returns:
- summary information about the client ingestion state or
null
if 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:AuditWriterApi
Writes 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:
audit
in 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:AuditWriterApi
Writes 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:
audit
in 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 AttivioException
Returns the clientIds for all active clients.- Specified by:
getActiveClients
in interfaceAuditReaderApi
- Returns:
- an Iterable of clientIds
- Throws:
AttivioException
-
getInactiveClients
public java.lang.Iterable<java.util.UUID> getInactiveClients() throws AttivioException
Returns the clientIds for all inactive clients.- Specified by:
getInactiveClients
in interfaceAuditReaderApi
- Returns:
- an Iterable of clientIds
- Throws:
AttivioException
-
getAllClients
public java.lang.Iterable<java.util.UUID> getAllClients() throws AttivioException
Returns the clientIds for all clients sorted by clientId for ease of comparison.- Specified by:
getAllClients
in 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:
getAll
in interfaceAuditReaderApi
startSeq
- starting sequence ID for responsecount
- the maximum number of audit details to return, useLong.MAX_VALUE
for 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:
getByCorrelationId
in interfaceAuditReaderApi
- Throws:
AttivioException
-
getAuditDetails
public java.lang.Iterable<AuditDetail> getAuditDetails(java.lang.String docId, java.util.UUID clientId) throws AttivioException
Returns anIterable
ofAuditDetail
s 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:
getAuditDetails
in interfaceAuditReaderApi
- Parameters:
docId
- the document ID to matchclientId
- restricts results to clientId,null
not 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 anIterable
ofAuditDetail
s 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.null
values forstart
andend
will return all available audit records for the document.- Specified by:
getAuditDetails
in 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:AuditReaderApi
Returns all audit detail events that have been flagged as LOST and have a sequence id >=startSeq
and <endSeq
.NOTE: this method is used internally to replay LOST messages for fault tolerance.
- Specified by:
getLostDetails
in interfaceAuditReaderApi
- Throws:
AttivioException
-
sort
public java.lang.Iterable<AuditDetail> sort(java.util.List<AuditDetail> details)
-
makeInactive
public void makeInactive(java.util.UUID clientId) throws AttivioException
Marks the clientId as inactive. The client will no longer be returned byAuditReaderApi.getActiveClients()
.- Specified by:
makeInactive
in interfaceAuditWriterApi
- Throws:
AttivioException
-
clientHeartbeat
public void clientHeartbeat(java.util.UUID clientId) throws AttivioException
Updates the audit information to show that the client is still active so that the client will continue to be returned byAuditReaderApi.getActiveClients()
.- Specified by:
clientHeartbeat
in interfaceAuditWriterApi
- Throws:
AttivioException
-
clientName
public void clientName(java.util.UUID clientId, java.lang.String name) throws AttivioException
Sets a name to be associated with the client. After calling this method,AuditReaderApi.getSummary(UUID)
is guaranteed to return a non-null
value with clientName and lastActionTime having the value of the set time.- Specified by:
clientName
in interfaceAuditWriterApi
- Throws:
AttivioException
-
purge
public void purge(java.util.UUID clientId) throws AttivioException
Description copied from interface:AuditWriterApi
Purges all audit data associated with the client ID.- Specified by:
purge
in interfaceAuditWriterApi
- Parameters:
clientId
- restricts results to clientId,null
not allowed.- Throws:
AttivioException
-
purge
public void purge(java.util.Date start, java.util.Date end) throws AttivioException
Description copied from interface:AuditWriterApi
Purges all audit data within the time range.
Ifstart
andend
are 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:
purge
in interfaceAuditWriterApi
- Parameters:
start
- the inclusive start date.end
- the exclusive end date.- Throws:
AttivioException
-
purgeInactiveClients
public int purgeInactiveClients(long lastInactiveTimeToKeep) throws AttivioException
Purges the audit data for all clients that are inactive and went inactive beforelastInactiveTimeToKeep
- Specified by:
purgeInactiveClients
in interfaceAuditWriterApi
- Returns:
- number of clients that were purged
- Throws:
AttivioException
-
truncateAll
public void truncateAll() throws AttivioException
Truncates 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:
truncateAll
in interfaceAieSystemAuditApi
- Throws:
AttivioException
-
getErrorSummary
public java.util.List<ErrorRow> getErrorSummary(java.util.UUID clientId)
- Specified by:
getErrorSummary
in 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:
updateSummary
in interfaceAieSystemAuditApi
- Throws:
AttivioException
-
setLastLossDetectionSequence
public void setLastLossDetectionSequence(java.util.UUID clientId, long seq) throws AttivioException
Updates 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 forclientId
then result is undefined.- Specified by:
setLastLossDetectionSequence
in interfaceAieSystemAuditApi
- Throws:
AttivioException
-
getLastLossDetectionSequence
public long getLastLossDetectionSequence(java.util.UUID clientId) throws AttivioException
- Specified by:
getLastLossDetectionSequence
in interfaceAieSystemAuditApi
- Returns:
- the last sequence number set or -1 if never set.
- Throws:
AttivioException
-
-