public class HttpPushAPI extends PushAPI implements IHttpPushAPI
DEFAULT_CHECKPOINT_NAME, STREAMING_BLOCK_SIZE
DEFAULT_NDOC_COMPACTION, HTTP_PAPI_VERSION, HTTPPAPI_VERSION_KEY, PREFIX_PARAMETER
Constructor and Description |
---|
HttpPushAPI(Protocol protocol,
java.lang.String host,
java.lang.String port,
java.lang.String connectorName,
java.lang.String connectorType,
java.lang.String login,
java.lang.String password,
java.util.Map<java.lang.String,java.lang.String> extraHttpParameters) |
HttpPushAPI(Protocol protocol,
java.lang.String host,
java.lang.String port,
java.lang.String urlPrefix,
java.lang.String connectorName,
java.lang.String connectorType,
java.lang.String login,
java.lang.String password,
java.util.Map<java.lang.String,java.lang.String> extraHttpParameters) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptAllCertificate() |
void |
addDocument(Document document)
Adds a document.
|
void |
addDocumentList(Document[] documents)
Adds a set of documents.
|
boolean |
areDocumentsSearchable(java.math.BigInteger serial)
Checks whether documents sent prior a given setCheckpoint operation
are searchable.
|
boolean |
areDocumentsSearchable(java.math.BigInteger serial,
boolean onAllReplicas,
boolean ignoreDetachedReplicas)
Checks whether documents sent prior a given setCheckpoint operation
are searchable.
|
void |
clearAllCheckpoints()
Resets all the checkpoints values.
|
void |
clearCheckpoints(java.lang.String prefix)
Resets all the checkpoints whose name starts with the specified prefix.
|
protected java.net.HttpURLConnection |
connect(java.net.URL url) |
long |
countSyncedEntries(java.lang.String rootPath,
EnumerationMode mode)
Counts the number of synchronized entries.
|
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.
|
java.lang.Iterable<CheckpointInfo> |
enumerateCheckpointInfo()
Enumerates all the checkpoints known by the system (synchronized).
|
java.lang.Iterable<CheckpointInfo> |
enumerateCheckpointInfo(boolean showSynchronizedOnly)
Enumerates all the checkpoints.
|
java.lang.Iterable<SyncedEntry> |
enumerateSyncedEntries(java.lang.String rootPath,
EnumerationMode mode)
Enumerates synchronized entries.
|
protected void |
get(java.net.HttpURLConnection connection,
com.google.protobuf.GeneratedMessageV3 message) |
java.lang.String |
getCheckpoint(java.lang.String name)
Gets the value of a named checkpoint in the indexing process.
|
CheckpointInfo |
getCheckpoint(java.lang.String name,
boolean showSynchronizedOnly)
Gets the checkpoint detailed information.
|
java.lang.String |
getConnectorName()
Gets the name of the connector associated to this push client.
|
java.lang.String |
getConnectorType() |
DocumentStatus |
getDocumentStatus(java.lang.String uri)
Gets document status.
|
DocumentStatus[] |
getDocumentStatusList(java.lang.String[] uris)
Gets the status of a given list of documents in the push server.
|
java.lang.String |
getLogin() |
java.lang.String |
getPassword() |
long |
getSessionId() |
java.lang.String |
getUrl() |
boolean |
hasSession() |
void |
ping()
Tests the connection with the server.
|
protected void |
post(java.net.HttpURLConnection connection,
com.google.protobuf.GeneratedMessageV3 message) |
void |
setAcceptAllCertificate(boolean acceptAllCertificate) |
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.
|
java.lang.String[] |
suggestSyncedEntries(java.lang.String rootPath,
int limit)
Suggest synchronized entries.
|
void |
sync()
Deprecated.
|
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 |
updateDocument(Document doc,
java.lang.String[] fields)
Partially updates a document.
|
void |
updateDocumentList(Document[] documents,
java.lang.String[][] fieldsList)
Updates a set of documents.
|
void |
updateDocumentMetas(java.lang.String uri,
java.lang.String stamp,
MetaContainer metaContainer)
Deprecated.
|
void |
updateDocumentMetasList(java.lang.String[] uriList,
java.lang.String[] stampList,
MetaContainer[] metaContainerList)
Deprecated.
|
protected java.net.URL |
url(java.lang.String subPath) |
countSyncedEntries, deleteDocumentRootPath, deleteDocumentRootPath, deleteDocumentsWithPrefix, enumerateSyncedEntries, getCheckpoint, getDocumentDidsAndSlices, setCheckpoint, setCheckpoint, setCheckpoint, triggerIndexingJobWhenIdle
public HttpPushAPI(Protocol protocol, java.lang.String host, java.lang.String port, java.lang.String urlPrefix, java.lang.String connectorName, java.lang.String connectorType, java.lang.String login, java.lang.String password, java.util.Map<java.lang.String,java.lang.String> extraHttpParameters)
public HttpPushAPI(Protocol protocol, java.lang.String host, java.lang.String port, java.lang.String connectorName, java.lang.String connectorType, java.lang.String login, java.lang.String password, java.util.Map<java.lang.String,java.lang.String> extraHttpParameters)
public void ping() throws PushAPIException
This test should be called after the construction of the Push API. The purpose of this method is to:
ping
in class PushAPI
PushAPIException
- upon error (invalid connector name or IO error)public void addDocument(Document document) throws PushAPIException
addDocument
in class PushAPI
document
- Document to be added.PushAPIException
- upon errorpublic void addDocumentList(Document[] documents) throws PushAPIException
addDocumentList
in class PushAPI
documents
- Documents to be added.PushAPIException
- upon error.public void updateDocument(Document doc, java.lang.String[] fields) throws PushAPIException
This method updates a document which must have the same URI as the one to be updated. Note that the fields parameter is useless for the moment, it is not handled yet.
This methods also updates the indexed document stamp.
updateDocument
in class PushAPI
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
- PushAPIException
@Deprecated public void updateDocumentMetas(java.lang.String uri, java.lang.String stamp, MetaContainer metaContainer) throws PushAPIException
This method should be used with caution. It's actually a simple wrapper on
top of the method updateDocument(Document, String[])
which
automatically creates the list of index fields from the meta names found in
the meta data container.
This method will often not do what you want, because of internal remapping between metas and fields. If you use this method to update the meta "meta1", but it's actually sent to an index field document_meta1 (as it's often the case with the data model), the update will not work as expected.
If we reuse the sample described in the comments of the method
updateDocument(Document, String[])
, this gives:
MetaContainer cont = new MetaContainer();
cont.addMeta("organization", "myneworg");
papi.updateDocument("mydocument", null, cont);
updateDocumentMetas
in class PushAPI
uri
- the URI of the document to updatestamp
- the new document stampmetaContainer
- the container of meta to be updatedPushAPIException
- upon errorpublic void updateDocumentList(Document[] documents, java.lang.String[][] fieldsList) throws PushAPIException
If one of the documents does not exist, an error is returned by the push server. As the update document commands are processed sequentially, all the updates prior to the one which failed are taken into account. However, consider it is required to send again the whole set of documents once the document in error has been removed from the list.
updateDocumentList
in class PushAPI
documents
- the list of documents to updatefieldsList
- for each document, the fields to be updatedPushAPIException
- upon errorupdateDocument(Document, String[])
@Deprecated public void updateDocumentMetasList(java.lang.String[] uriList, java.lang.String[] stampList, MetaContainer[] metaContainerList) throws PushAPIException
This method should be used with caution. It's actually a simple wrapper on
top of the method updateDocument(Document, String[])
which
automatically creates the list of index fields from the meta names found in
the meta data container.
This method will often not do what you want, because of internal remapping between metas and fields. If you use this method to update the meta "meta1", but it's actually sent to an index field document_meta1 (as it's often the case with the data model), the update will not work as expected.
If one of the documents does not exist, an error is returned by the push server. As the update document commands are processed sequentially, all the updates priori to the one which failed are taken into account. However, consider it is require to send again the whole set of documents once the document in error has been removed from the list.
updateDocumentMetasList
in class PushAPI
uriList
- the URIs of the documents to updatestampList
- the list of new stampsmetaContainerList
- the list of meta data containersPushAPIException
- upon errorupdateDocumentMetas(java.lang.String, java.lang.String, com.exalead.papi.helper.MetaContainer)
public void deleteDocument(java.lang.String uri) throws PushAPIException
If the document does not exist yet, the instruction is silently ignored.
deleteDocument
in class PushAPI
uri
- the URI of the document to deletePushAPIException
- upon errorpublic void deleteDocumentList(java.lang.String[] uris) throws PushAPIException
For each document which do not exist yet, the instruction is silently ignored.
deleteDocumentList
in class PushAPI
uris
- the list of URIs of the documents to deletePushAPIException
- upon errorpublic void deleteDocumentList(int[] did, int[] slices) throws PushAPIException
deleteDocumentList
in class PushAPI
did
- the list of dids to delete.slices
- no longer exist in apolloPushAPIException
public void deleteDocumentRootPath(java.lang.String rootPath, boolean recursive, boolean clearCache) throws PushAPIException
All the documents matching the rootPath
prefix will be deleted.
deleteDocumentRootPath
in class PushAPI
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 PushAPI
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 DocumentStatus getDocumentStatus(java.lang.String uri) throws PushAPIException
Look up an URI in the CloudView push server and return the corresponding
document's status if it exists. The status of a document indicates if the
document currently exists in the push server and the corresponding stamp
value if any. Note that the information retrieved by this method indicates
only the document's status in the CloudView indexing queue, and does not
indicate whether the document is actually visible to search queries. To
check if a document is visible to search queries, please refer to the
areDocumentsSearchable
method.
getDocumentStatus
in class PushAPI
uri
- the URI to be looked up.getDocumentStatus
method always returns a non-null
DocumentStatus
object. To check if
the document actually exists in the index, please use the
DocumentStatus.isExist()
method.PushAPIException
DocumentStatus
public DocumentStatus[] getDocumentStatusList(java.lang.String[] uris) throws PushAPIException
getDocumentStatusList
in class PushAPI
uris
- the URIs of the documents for which the status should be retrieved.PushAPIException
- upon errorpublic java.math.BigInteger setCheckpoint(java.lang.String value, java.lang.String name, boolean sync) throws PushAPIException
Checkpoints are used when:
areDocumentsSearchable(BigInteger)
for more information.setCheckpoint
in class PushAPI
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 errorsynchronize()
,
areDocumentsSearchable(BigInteger)
public java.lang.String getCheckpoint(java.lang.String name) throws PushAPIException
getCheckpoint
in class PushAPI
name
- the name of the checkpointPushAPIException
- upon errorsetCheckpoint(String, String, boolean)
public CheckpointInfo getCheckpoint(java.lang.String name, boolean showSynchronizedOnly) throws PushAPIException
getCheckpoint
in class PushAPI
name
- the name of the checkpoint to retrieve.showSynchronizedOnly
- if true, then returns the last synchronized (i.e safe) checkpoint,
otherwise returns the unsynchronized checkpoint (in memory only)
when more recent than the last synchronized one.value
is empty, then it means the checkpoint is not defined.PushAPIException
setCheckpoint(String, String, boolean)
public void clearAllCheckpoints() throws PushAPIException
clearAllCheckpoints
in class PushAPI
PushAPIException
- upon errorpublic void clearCheckpoints(java.lang.String prefix) throws PushAPIException
PushAPI
clearCheckpoints
in class PushAPI
prefix
- Checkpoint name prefixPushAPIException
- upon errorpublic java.lang.Iterable<CheckpointInfo> enumerateCheckpointInfo() throws PushAPIException
enumerateCheckpointInfo
in class PushAPI
PushAPIException
- upon errorsetCheckpoint(String, String, boolean)
,
synchronize()
public java.lang.Iterable<CheckpointInfo> enumerateCheckpointInfo(boolean showSynchronizedOnly)
PushAPI
enumerateCheckpointInfo
in class PushAPI
showSynchronizedOnly
- if true, then returns synchronized (i.e safe) checkpoints,
otherwise returns the unsynchronized checkpoints (in memory only)
when more recent than the synchronized ones.PushAPI.setCheckpoint(String, String, boolean)
,
PushAPI.synchronize()
@Deprecated public void sync() throws PushAPIException
synchronize()
has been introduced and returns a serial.sync
in class PushAPI
PushAPIException
- upon errorpublic java.math.BigInteger synchronize() throws PushAPIException
Returns the serial of the last pending operation before the synchronize.
synchronize
in class PushAPI
PushAPIException
- upon errorpublic void triggerIndexingJob() throws PushAPIException
Indexing operations are processed asynchronously, using a batch of operations found in the task logs. An internal scheduler periodically triggers indexing operations but you can also use this API call to force the indexing. Refer to EXALEAD CloudView documentation for more information on the scheduling of indexing jobs.
Note that this call only impacts operation which are already synchronized to disk. Synchronization to disk happens periodically, and it can also be forced by using the setCheckpoint call with the sync parameter or by using the sync call.triggerIndexingJob
in class PushAPI
PushAPIException
- upon errorpublic boolean areDocumentsSearchable(java.math.BigInteger serial) throws PushAPIException
areDocumentsSearchable
in class PushAPI
serial
- the serial returned by a setCheckpoint operationPushAPIException
- upon errorpublic boolean areDocumentsSearchable(java.math.BigInteger serial, boolean onAllReplicas, boolean ignoreDetachedReplicas) throws PushAPIException
PushAPI
areDocumentsSearchable
in class PushAPI
serial
- the serial returned by a setCheckpoint operationonAllReplicas
- true if the serial must be available on all replicas, false otherwiseignoreDetachedReplicas
- true if detached replicas should not be taken into account, false otherwisePushAPIException
- upon errorpublic java.lang.Iterable<SyncedEntry> enumerateSyncedEntries(java.lang.String rootPath, EnumerationMode mode) throws PushAPIException
Synchronized entries are entries that have been effectively synchronized to disk. This method allows you to enumerate both documents but also folders. Folders are virtual objects built from the document hierarchical view.
enumerateSyncedEntries
in class PushAPI
rootPath
- URI prefix used to select a subset of the corpus. Empty string can
be used to enumerate the whole collection. The character '/' is used
to build a hierarchical view of your corpus.mode
- the enumeration mode.PushAPIException
- upon error#sync()}
public long countSyncedEntries(java.lang.String rootPath, EnumerationMode mode) throws PushAPIException
countSyncedEntries
in class PushAPI
rootPath
- URI prefix used to select a subset of the corpus. Empty string can
be used to delete the whole collection. The character '/' is used
to build a hierarchical view of your corpus.mode
- the enumeration mode.PushAPIException
- upon error.public java.lang.String[] suggestSyncedEntries(java.lang.String rootPath, int limit) throws PushAPIException
PushAPI
suggestSyncedEntries
in class PushAPI
rootPath
- URI prefix used to select a subset of the corpus. Empty string can
be used to enumerate the whole collection. The character '/' is used
to build a hierarchical view of your corpus.limit
- maximum number of suggestions.PushAPIException
- upon error#sync()}
public java.lang.String getConnectorName()
getConnectorName
in class PushAPI
public void startPushSession() throws PushAPIException
Between the beginning and the end of a session (stopPushSession(boolean)
),
if the push server restarts for any reason, an exception will be thrown.
The connector should then engage a recovery procedure.
startPushSession
in class PushAPI
PushAPIException
- if any another error occurred.public void stopPushSession(boolean releaseConnections) throws PushAPIException
stopPushSession
in class PushAPI
releaseConnections
- Try to release persistent connections to save resources.PushAPIException
- if another error occurred.#startPushSession()}
public java.lang.String getLogin()
getLogin
in interface IHttpPushAPI
public java.lang.String getPassword()
getPassword
in interface IHttpPushAPI
public java.lang.String getConnectorType()
getConnectorType
in interface IHttpPushAPI
public boolean acceptAllCertificate()
acceptAllCertificate
in interface IHttpPushAPI
public boolean hasSession()
hasSession
in interface IHttpPushAPI
public java.lang.String getUrl()
getUrl
in interface IHttpPushAPI
public long getSessionId()
getSessionId
in interface IHttpPushAPI
public void setAcceptAllCertificate(boolean acceptAllCertificate)
protected java.net.URL url(java.lang.String subPath) throws java.net.MalformedURLException, java.io.UnsupportedEncodingException
java.net.MalformedURLException
java.io.UnsupportedEncodingException
protected java.net.HttpURLConnection connect(java.net.URL url) throws java.net.ConnectException
java.net.ConnectException
protected void post(java.net.HttpURLConnection connection, com.google.protobuf.GeneratedMessageV3 message) throws java.io.IOException
java.io.IOException
protected void get(java.net.HttpURLConnection connection, com.google.protobuf.GeneratedMessageV3 message) throws java.io.IOException
java.io.IOException
Copyright © 2021 Dassault Systèmes, All Rights Reserved.