public class BufferedPushAPI extends PipedPushAPI implements java.io.Flushable, java.io.Closeable
Modifier and Type | Class and Description |
---|---|
protected class |
BufferedPushAPI.BufferedPushAPINotify
Thread termination notifier.
|
static interface |
BufferedPushAPI.Notifiable
Interface used when an object wants to notify an event.
|
protected static class |
BufferedPushAPI.TBuffer
Class aimed to buffer a generic operation (add, delete..) Upper-level
synchronization is necessary.
|
protected static class |
BufferedPushAPI.ThreadVarFinalizer
Class used to handle thread finalization in thread-mapped hashtable.
|
protected static class |
BufferedPushAPI.ThreadVarFinalizerItem
Class used to handle thread finalization in thread-mapped hashtable.
|
protected class |
BufferedPushAPI.TOperationBuffer
Class aimed to buffer all operations (add,update..) in a given thread.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ConcurrentLinkedQueue<java.lang.Long> |
cleaners
Cleaners, list of ids of threads which died before cleaning up their
buffers.
|
static long |
defaultMaxBytes
Default maximum total size of buffered documents (estimated)
|
static int |
defaultMaxDocuments
Default maximum number of buffered documents per operation.
|
protected static int |
DOCUMENT_OVERHEAD_PENALTY
Penalty applied to estimate documents size for each document.
|
protected static int |
ELEMENT_OVERHEAD_PENALTY
Penalty applied to estimate documents size for each sub-element.
|
protected long |
maxBytes
Maximum document total size to buffer
|
protected int |
maxDocuments
Number of buffered documents
|
protected BufferedPushAPI.BufferedPushAPINotify |
notifier
Thread termination notifier.
|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
producers
Lock for the ConcurrentHashMap ; readers will only use (read/write) their
current buffer ; writer is allowed to enumerate all thread buffers.
|
protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,BufferedPushAPI.TOperationBuffer> |
threadBuffer
Thread buffers.
|
defaultLogger, isBestEffortOnStopSession, jlogger, logger, parent
DEFAULT_CHECKPOINT_NAME, STREAMING_BLOCK_SIZE
Constructor and Description |
---|
BufferedPushAPI(PushAPI parent)
Create a new BufferedPushAPI
|
BufferedPushAPI(PushAPI parent,
int maxDocuments)
Create a new BufferedPushAPI
|
BufferedPushAPI(PushAPI parent,
int maxDocuments,
long maxBytes)
Create a new BufferedPushAPI
|
Modifier and Type | Method and Description |
---|---|
void |
addDocument(Document document)
Adds a document.
|
void |
addDocumentList(Document[] documents)
Adds a set of documents.
|
void |
clearAllCheckpoints()
Resets all the checkpoints values.
|
void |
close()
Closes the BufferedPushAPI object.
|
static PushAPI |
createPushAPIPlugin(PushAPI papi,
java.lang.String[] keys,
java.lang.String[] values)
Create a new BufferedPushAPI (PushAPI plugin pipe constructor)
|
void |
deleteDocument(java.lang.String uri)
Deletes a document specified by its URI.
|
void |
deleteDocumentList(int[] did,
int[] slices)
Deletes a list of documents specified by their dids and slices.
|
void |
deleteDocumentList(java.lang.String[] uris)
Deletes a list of documents specified by their URIs.
|
void |
deleteDocumentRootPath(java.lang.String rootPath,
boolean recursive,
boolean clearCache)
Deletes a set of documents corresponding to a URI prefix.
|
void |
deleteDocumentsWithPrefix(java.lang.String prefix,
boolean clearCache)
Deletes a set of documents corresponding to a URI prefix.
|
protected void |
finalize()
Finalizer.
|
void |
flush()
Flush all pending buffers.
|
void |
flushAll()
Flush all buffers for all threads.
|
void |
flushCurrent()
Flush current thread's buffer.
|
protected void |
flushDeadBuffers()
Process dead thread buffers in the PAPI (flushes commands).
|
void |
free()
Flush and clear all buffers for all threads.
|
protected BufferedPushAPI.TOperationBuffer |
getThreadBuffer(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock lock) |
protected BufferedPushAPI.TOperationBuffer |
getThreadBuffer(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock lock,
boolean create) |
protected long |
getThreadBufferKey() |
java.math.BigInteger |
setCheckpoint(java.lang.String value,
java.lang.String name,
boolean sync)
Sets a checkpoint in the push server.
|
void |
startPushSession()
Starts a new session on the push server.
|
void |
stopPushSession(boolean releaseConnections)
Stops the current session on the push server.
|
void |
sync()
Deprecated.
since V6R2015x, replaced by
synchronize() |
java.math.BigInteger |
synchronize()
Forces the synchronization of all pending operations before returning.
|
void |
triggerIndexingJob()
Forces the processing of all pending operations synchronized to disk.
|
void |
triggerIndexingJobWhenIdle()
Wait for indexing to be idle, and forces the processing of all pending
operations synchronized to disk.
|
void |
updateDocument(Document doc,
java.lang.String[] fields)
Partially updates a document.
|
void |
updateDocumentList(Document[] docList,
java.lang.String[][] fieldsList)
Updates a set of documents.
|
void |
updateDocumentMetas(java.lang.String uri,
java.lang.String stamp,
MetaContainer metaContainer)
Updates the stamp and the meta data of a document, using a strict meta to field
mapping.
|
void |
updateDocumentMetasList(java.lang.String[] uriList,
java.lang.String[] stampList,
MetaContainer[] metaContainerList)
Updates a set of the stamp and meta data for given documents.
|
areDocumentsSearchable, areDocumentsSearchable, clearCheckpoints, countSyncedEntries, debug, enumerateCheckpointInfo, enumerateCheckpointInfo, enumerateSyncedEntries, error, getBestEffortOnStopSession, getCheckpoint, getCheckpoint, getConnectorName, getDocumentStatus, getDocumentStatusList, getLogger, getParent, info, isTraceEnabled, log, ping, setBestEffortOnStopSession, setLogger, suggestSyncedEntries, trace, warning
countSyncedEntries, deleteDocumentRootPath, deleteDocumentRootPath, deleteDocumentsWithPrefix, enumerateSyncedEntries, getCheckpoint, getDocumentDidsAndSlices, setCheckpoint, setCheckpoint, setCheckpoint
public static final int defaultMaxDocuments
public static final long defaultMaxBytes
protected static final int DOCUMENT_OVERHEAD_PENALTY
protected static final int ELEMENT_OVERHEAD_PENALTY
protected final int maxDocuments
protected final long maxBytes
protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,BufferedPushAPI.TOperationBuffer> threadBuffer
protected java.util.concurrent.locks.ReentrantReadWriteLock producers
protected BufferedPushAPI.BufferedPushAPINotify notifier
protected java.util.concurrent.ConcurrentLinkedQueue<java.lang.Long> cleaners
public BufferedPushAPI(PushAPI parent)
parent
- the original PAPImaxDocuments
- buffer size in documentpublic BufferedPushAPI(PushAPI parent, int maxDocuments)
parent
- the original PAPImaxDocuments
- buffer size in document, or @c -1 if unlimitedpublic BufferedPushAPI(PushAPI parent, int maxDocuments, long maxBytes)
parent
- the original PAPImaxDocuments
- buffered size in documentmaxBytes
- maximum buffered total document size in bytespublic static PushAPI createPushAPIPlugin(PushAPI papi, java.lang.String[] keys, java.lang.String[] values) throws java.lang.Exception
papi
- upstream PushAPIkeys
- configuration keys (see below)keys
- configuration values
Configuration keys are:
java.lang.Exception
protected long getThreadBufferKey()
protected BufferedPushAPI.TOperationBuffer getThreadBuffer(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock lock, boolean create)
protected BufferedPushAPI.TOperationBuffer getThreadBuffer(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock lock)
protected void flushDeadBuffers() throws PushAPIException
PushAPIException
public void flushCurrent() throws PushAPIException
PushAPIException
public void flushAll() throws PushAPIException
PushAPIException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
protected void finalize() throws java.io.IOException
finalize
in class java.lang.Object
java.io.IOException
public void free() throws PushAPIException
PushAPIException
public void addDocument(Document document) throws PushAPIException
PushAPI
addDocument
in class PipedPushAPI
document
- Document to be added.PushAPIException
- upon errorpublic void addDocumentList(Document[] documents) throws PushAPIException
PushAPI
addDocumentList
in class PipedPushAPI
documents
- Documents to be added.PushAPIException
- upon error.public void clearAllCheckpoints() throws PushAPIException
PushAPI
clearAllCheckpoints
in class PipedPushAPI
PushAPIException
- upon errorpublic void deleteDocument(java.lang.String uri) throws PushAPIException
PushAPI
deleteDocument
in class PipedPushAPI
uri
- the URI of the document to deletePushAPIException
- upon errorpublic void deleteDocumentList(java.lang.String[] uris) throws PushAPIException
PushAPI
deleteDocumentList
in class PipedPushAPI
uris
- the list of URIs of the documents to deletePushAPIException
- upon errorpublic void deleteDocumentList(int[] did, int[] slices) throws PushAPIException
PushAPI
deleteDocumentList
in class PipedPushAPI
slices
- the list of slices to delete.PushAPIException
public void deleteDocumentRootPath(java.lang.String rootPath, boolean recursive, boolean clearCache) throws PushAPIException
PushAPI
rootPath
prefix will be deleted.deleteDocumentRootPath
in class PipedPushAPI
rootPath
- a URI prefix used to select the documents to be deleted."A"
would select all URIs in the form
"A/xyz"
"A/B"
would select all URIs in the form
"A/B/xyz"
recursive
- The recursive flag indicates if the URI pattern specified in
rootPath should match multiple depth levels in the URI tree. For
example the rootPath "A/B"
will always match "A/B/C"
, but will match "A/B/C/D"
only if recursive
is true
. In CloudView 5.1 recursive is always
true.clearCache
- The clearCache flag indicates if we want to delete documents
from the document cache when they are deleted from the index.PushAPIException
public void deleteDocumentsWithPrefix(java.lang.String prefix, boolean clearCache) throws PushAPIException
PushAPI
prefix
will be deleted.deleteDocumentsWithPrefix
in class PipedPushAPI
prefix
- a URI prefix used to select the documents to be deleted.clearCache
- The clearCache flag indicates if we want to delete documents
from the document cache when they are deleted from the index.PushAPIException
public java.math.BigInteger setCheckpoint(java.lang.String value, java.lang.String name, boolean sync) throws PushAPIException
PushAPI
PushAPI.areDocumentsSearchable(BigInteger)
for more information.setCheckpoint
in class PipedPushAPI
value
- the value of the checkpoint.name
- the name of the checkpoint.sync
- if all the pending operations in the task log should be
synchronized to disk before returning.PushAPIException
- upon errorPushAPI.synchronize()
,
PushAPI.areDocumentsSearchable(BigInteger)
public void startPushSession() throws PushAPIException
PushAPI
stopPushSession
),
if the push server restarts for any reason, an exception will be thrown.
The connector should then engage a recovery procedure.startPushSession
in class PipedPushAPI
PushAPISessionExistsException
- if the session is already started.PushAPIException
- if any another error occurred.public void stopPushSession(boolean releaseConnections) throws PushAPIException
PushAPI
stopPushSession
in class PipedPushAPI
PushAPISessionNotFoundException
- if session is not started.PushAPIException
- if another error occurred.startPushSession}
public void sync() throws PushAPIException
synchronize()
PushAPI
PushAPI.synchronize()
has been introduced and returns a serial.sync
in class PipedPushAPI
PushAPIException
- upon errorpublic java.math.BigInteger synchronize() throws PushAPIException
PushAPI
synchronize
in class PipedPushAPI
PushAPIException
- upon errorpublic void triggerIndexingJob() throws PushAPIException
PushAPI
triggerIndexingJob
in class PipedPushAPI
PushAPIException
- upon errorpublic void triggerIndexingJobWhenIdle() throws PushAPIException
PushAPI
triggerIndexingJobWhenIdle
in class PipedPushAPI
PushAPIException
- upon errorpublic void updateDocument(Document doc, java.lang.String[] fields) throws PushAPIException
PushAPI
updateDocument
in class PipedPushAPI
doc
- a Document object specifying the URI of the document to be
updated. Parts and metas that are not updated with the document
are fetched from the document cache, so the document cache
*must* be enabled, and only documents added after the document cache
has been enabled can be updated. Old values of multivalued metas will be dropped,
if you want to update a multivalued meta you have to put new values and
also the old values you want to keep in the document.fields
- Not used for the moment.PushAPIException
public void updateDocumentList(Document[] docList, java.lang.String[][] fieldsList) throws PushAPIException
PushAPI
updateDocumentList
in class PipedPushAPI
docList
- the list of documents to updatefieldsList
- for each document, the fields to be updatedPushAPIException
- upon errorPushAPI.updateDocument(Document, String[])
public void updateDocumentMetas(java.lang.String uri, java.lang.String stamp, MetaContainer metaContainer) throws PushAPIException
PushAPI
PushAPI.updateDocument(Document, String[])
which
automatically creates the list of index fields from the meta names found in
the meta data container.PushAPI.updateDocument(Document, String[])
, this gives:
MetaContainer cont = new MetaContainer();
cont.addMeta("organization", "myneworg");
papi.updateDocument("mydocument", null, cont);
If the document does not exist yet, an error is returned by the push
server.updateDocumentMetas
in class PipedPushAPI
uri
- the URI of the document to updatestamp
- the new document stampmetaContainer
- the container of meta to be updatedPushAPIException
- upon errorpublic void updateDocumentMetasList(java.lang.String[] uriList, java.lang.String[] stampList, MetaContainer[] metaContainerList) throws PushAPIException
PushAPI
PushAPI.updateDocument(Document, String[])
which
automatically creates the list of index fields from the meta names found in
the meta data container.updateDocumentMetasList
in class PipedPushAPI
uriList
- the URIs of the documents to updatestampList
- the list of new stampsmetaContainerList
- the list of meta data containersPushAPIException
- upon errorPushAPI.updateDocumentMetas(java.lang.String, java.lang.String, com.exalead.papi.helper.MetaContainer)
Copyright © 2021 Dassault Systèmes, All Rights Reserved.