Class MockUnclusteredIngestionHistory
- java.lang.Object
-
- com.attivio.service.MockUnclusteredIngestionHistory
-
- All Implemented Interfaces:
IngestionHistoryApi
,java.io.Closeable
,java.lang.AutoCloseable
public class MockUnclusteredIngestionHistory extends java.lang.Object implements IngestionHistoryApi, java.io.Closeable
acts like UnclusteredIngestionHistory (hsql) and HBaseIngetsionHistory. Resides in this package since needed by TestCuratorFrameworkBuilder1. children(grandchildren) of children(child) - api's undefined consequences specific for this class this class will create a map using the child key with the grandchild being the child. Once created these children are never referenced. That means getting a list of children for a document will not get these grandchildren. Deleting a document will not remove these grandchildren.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
MockUnclusteredIngestionHistory.Data
-
Constructor Summary
Constructors Constructor Description MockUnclusteredIngestionHistory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
childCreated(java.lang.String namespace, java.lang.String key, java.lang.String childKey)
Marks thechildKey
as one created by the record associated withkey
.void
clear(java.lang.String namespace)
Removes all historical information associated with thenamespace
.void
close()
protected java.util.List<java.lang.String>
getAllChildData(java.lang.String namespace)
protected java.util.List<java.lang.String>
getAllDocumentData(java.lang.String namespace)
java.lang.Iterable<java.lang.String>
getChildren(java.lang.String namespace, java.lang.String key)
Returns an Iterable of the children that were marked as created via theIngestionHistoryApi.childCreated(String, String, String)
method.java.util.Date
getPreviousStartTime(java.lang.String namespace)
Returns the start time for the last session for thisnamespace
.byte[]
getSignature(java.lang.String namespace, java.lang.String key)
Returns the last signature associated with the key ornull
if no signature is present.java.util.Date
getStartTime(java.lang.String namespace)
Returns the start time of the current session for thisnamespace
.java.lang.Iterable<java.lang.String>
getUnvisited(java.lang.String namespace)
Returns anIterable
of the keys that have not been visited in the current session.java.lang.Iterable<java.lang.String>
getUnvisited(java.lang.String namespace, java.util.Date since)
Returns anIterable
of the keys that have not been visited since the timesince
.void
removeDocumentByKey(java.lang.String namespace, java.lang.String key)
Removes a document using the keyjava.util.Date
startSession(java.lang.String namespace)
Starts a new session for the namespace.protected void
updateDocumentWithDate(java.lang.String namespace, java.lang.String key, byte[] signature, java.util.Date useDate)
protected void
updateDocumentWithDate(java.lang.String namespace, java.lang.String key, java.util.Date useDate)
*****************************************************************************************************************void
visit(java.lang.String namespace, java.lang.String key, byte[] signature)
Records thekey
as having been visited updates its associated signature.
-
-
-
Method Detail
-
startSession
public java.util.Date startSession(java.lang.String namespace) throws AttivioException
Description copied from interface:IngestionHistoryApi
Starts a new session for the namespace. The current time is used to establish the start time for this session. Subsequent calls toIngestionHistoryApi.getStartTime(String)
will return the new session start time.- Specified by:
startSession
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)- Returns:
- the session start time
- Throws:
AttivioException
-
getStartTime
public java.util.Date getStartTime(java.lang.String namespace) throws AttivioException
Description copied from interface:IngestionHistoryApi
Returns the start time of the current session for thisnamespace
. The return value is the same as the value returned by the lastIngestionHistoryApi.startSession(String)
call for thisnamespace
. If no session has ever been started, returnsnull
.- Specified by:
getStartTime
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)- Returns:
- the start time for this namespace
- Throws:
AttivioException
-
getPreviousStartTime
public java.util.Date getPreviousStartTime(java.lang.String namespace) throws AttivioException
Description copied from interface:IngestionHistoryApi
Returns the start time for the last session for thisnamespace
. If no previous session exists, returnsnull
.- Specified by:
getPreviousStartTime
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)- Returns:
- previous start time
- Throws:
AttivioException
-
visit
public void visit(java.lang.String namespace, java.lang.String key, byte[] signature) throws AttivioException
Description copied from interface:IngestionHistoryApi
Records thekey
as having been visited updates its associated signature. The signature is commonly used to detect whether an object has changed since the last ingestion (by storing a checksum or message digest of the content). The visit time is also recorded.- Specified by:
visit
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)key
- a record key or document ID.signature
- an arbitrary value indicating a signature to associate with the key, may benull
.- Throws:
AttivioException
-
getSignature
public byte[] getSignature(java.lang.String namespace, java.lang.String key) throws AttivioException
Description copied from interface:IngestionHistoryApi
Returns the last signature associated with the key ornull
if no signature is present.- Specified by:
getSignature
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)key
- a record key or document ID.- Returns:
- the signature associated with the key
- Throws:
AttivioException
-
getUnvisited
public java.lang.Iterable<java.lang.String> getUnvisited(java.lang.String namespace) throws AttivioException
Description copied from interface:IngestionHistoryApi
Returns anIterable
of the keys that have not been visited in the current session. The unvisited keys are those for which there has been aIngestionHistoryApi.visit(String, String, byte[])
call at some point, but not one since the lastIngestionHistoryApi.startSession(String)
call. This allows a connector to record visits each time it runs and get a list of documents that are not present on subsequent runs. Since these documents have been removed from the source system, the connector may decide to remove them from the Attivio system.A call to
remove()
on the returned iterator will remove the visit and signature information from the history for the associated key. All child associations (seeIngestionHistoryApi.childCreated(String, String, String)
of removed keys are also removed.- Specified by:
getUnvisited
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)- Returns:
- a Iterable of unvisited keys
- Throws:
AttivioException
-
getUnvisited
public java.lang.Iterable<java.lang.String> getUnvisited(java.lang.String namespace, java.util.Date since) throws AttivioException
Description copied from interface:IngestionHistoryApi
Returns anIterable
of the keys that have not been visited since the timesince
. The unvisited keys are those for which there has been aIngestionHistoryApi.visit(String, String, byte[])
call at some point, but not one since the timesince
. This allows a connector to record visits each time it runs and get a list of documents that are not present on subsequent runs. Since these documents have been removed from the source system, the connector may decide to remove them from the Attivio system.A call to
remove()
on the returned iterator will remove the visit and signature information from the history for the associated key. All child associations (seeIngestionHistoryApi.childCreated(String, String, String)
of removed keys are also removed.- Specified by:
getUnvisited
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)since
- the mininum visit date to consider a record as visited.- Returns:
- an Iterable of unvisited keys
- Throws:
AttivioException
-
childCreated
public void childCreated(java.lang.String namespace, java.lang.String key, java.lang.String childKey) throws AttivioException
Description copied from interface:IngestionHistoryApi
Marks thechildKey
as one created by the record associated withkey
. All children associated withkey
are returned by the Iterable returned by a subsequent call toIngestionHistoryApi.getChildren(String, String)
. The expectation is that the child document has not previously been created. If the signature of the parent document id has changed remove the children documents and add the ones found in the new version of the parent document. Adding a child that already existed will have undefined consequences.This does not support children of children, only supports parent document and it's children. Children of children will have undefined consequences.
- Specified by:
childCreated
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)key
- a record key or document ID.childKey
- a record key or document ID.- Throws:
AttivioException
-
getChildren
public java.lang.Iterable<java.lang.String> getChildren(java.lang.String namespace, java.lang.String key) throws AttivioException
Description copied from interface:IngestionHistoryApi
Returns an Iterable of the children that were marked as created via theIngestionHistoryApi.childCreated(String, String, String)
method. When using the returned Iterable and removing children then the expectation is that all the children are removed.- Specified by:
getChildren
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)key
- a record key or document ID.- Returns:
- an Iterable of childKeys for the
key
- Throws:
AttivioException
-
clear
public void clear(java.lang.String namespace) throws AttivioException
Description copied from interface:IngestionHistoryApi
Removes all historical information associated with thenamespace
.- Specified by:
clear
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)- Throws:
AttivioException
-
removeDocumentByKey
public void removeDocumentByKey(java.lang.String namespace, java.lang.String key) throws AttivioException
Description copied from interface:IngestionHistoryApi
Removes a document using the key- Specified by:
removeDocumentByKey
in interfaceIngestionHistoryApi
- Parameters:
namespace
- a namespace to use (e.g., connector or source name)key
- a record key or document ID.- Throws:
AttivioException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
updateDocumentWithDate
protected void updateDocumentWithDate(java.lang.String namespace, java.lang.String key, java.util.Date useDate) throws AttivioException
*****************************************************************************************************************- Throws:
AttivioException
-
getAllChildData
protected java.util.List<java.lang.String> getAllChildData(java.lang.String namespace) throws AttivioException
- Throws:
AttivioException
-
getAllDocumentData
protected java.util.List<java.lang.String> getAllDocumentData(java.lang.String namespace) throws AttivioException
- Throws:
AttivioException
-
updateDocumentWithDate
protected void updateDocumentWithDate(java.lang.String namespace, java.lang.String key, byte[] signature, java.util.Date useDate) throws AttivioException
- Throws:
AttivioException
-
-