public final class IteratorClient extends java.lang.Object implements LogMappable
Constructor and Description |
---|
IteratorClient(ScrapingSession session,
java.lang.String iteratorId,
java.lang.String host,
java.lang.String deploymentLocation,
java.lang.String username,
java.lang.String password)
Create the facade that will interact with the web iterator at the specified URL
|
IteratorClient(ScrapingSession session,
java.lang.String uniqueId,
java.lang.String iteratorId,
java.lang.String host,
java.lang.String deploymentLocation,
java.lang.String username,
java.lang.String password)
Create the facade that will interact with the web iterator at the specified URL
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.util.Map<java.lang.String,java.lang.Object> |
convertMap()
Converts the current object into a mapping of key-value pairs that can be logged
|
static java.lang.String |
generateUniqueId(java.lang.String name)
Generates a unique ID based on the given name.
|
static java.lang.String |
generateUniqueId(java.lang.String name,
long seed)
Generates a unique ID based on the given name.
|
java.lang.Object |
getCurrentValue(java.lang.String field)
Gets the current iteration value found for the given field name.
|
java.util.Map<java.lang.String,java.lang.Object> |
getCurrentValues()
Returns a copy of the current values in the iteration
|
IteratorInstance |
getInstance()
Returns the instance this client is connecting to
|
java.lang.Integer |
getLastIterationPk()
More for debugging than anything, this method returns the last pk (on the instance values) in the database that was returned by the iterator
|
java.util.Map<java.lang.String,java.lang.Object> |
getNextValues()
Returns a map of the next values from the iterator
|
java.util.Map<java.lang.String,java.lang.Object> |
getNextValues(java.lang.Integer localPort)
Returns a map of the next values from the iterator
|
java.util.Map<java.lang.String,java.lang.Object> |
getNextValues(java.lang.Integer localPort,
java.lang.String accessURL)
Returns a map of the next values from the iterator
|
java.util.Map<java.lang.String,java.lang.Object> |
getNextValues(java.lang.String accessURL)
Returns a map of the next values from the iterator
|
java.lang.Integer |
getOffset()
More for debugging than anything, this method returns the last offset that was returned by the iterator
|
java.util.Map<java.lang.String,java.lang.Object> |
getRandomValues()
Returns a map of the next values from the iterator, but they will be a random available iteration rather than a predictable order
|
java.util.Map<java.lang.String,java.lang.Object> |
getRandomValues(java.lang.Integer localPort)
Returns a map of the next values from the iterator, but they will be a random available iteration rather than a predictable order
|
java.util.Map<java.lang.String,java.lang.Object> |
getRandomValues(java.lang.Integer localPort,
java.lang.String accessURL)
Returns a map of the next values from the iterator, but they will be a random available iteration rather than a predictable order
|
java.util.Map<java.lang.String,java.lang.Object> |
getRandomValues(java.lang.String accessURL)
Returns a map of the next values from the iterator, but they will be a random available iteration rather than a predictable order
|
boolean |
hasNext()
Checks to see if there is another iteration that can occur
|
boolean |
isClosed()
Returns whether or not this client is closed.
|
void |
reportErrorOnIteration()
Reports successful iteration completion of the last grabbed iterator value, and causes the current iteration to be repeated later
|
void |
reportErrorOnIteration(java.lang.Integer records)
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportErrorOnIteration(java.lang.String message)
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportErrorOnIteration(java.lang.String message,
java.lang.Integer records)
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportErrorOnIteration(java.lang.String message,
java.lang.Integer records,
boolean rerunImmediately)
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportSuccessOnIteration()
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportSuccessOnIteration(java.lang.Integer records)
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportSuccessOnIteration(java.lang.String message)
Reports successful iteration completion of the last grabbed iterator value
|
void |
reportSuccessOnIteration(java.lang.String message,
java.lang.Integer records)
Reports successful iteration completion of the last grabbed iterator value
|
void |
setCurrentValuesInSession()
Sets the value of each field in the session, as SEARCH_[FIELD_NAME]
|
void |
setPingOnSameRecordCount(boolean pingOnSameRecordCount)
Sets the client to send pings to the server even if the session hasn't found any new records since the last ping.
|
boolean |
shouldPing()
Returns true if this client is in a state that it is allowed to ping, false otherwise
|
boolean |
wasReportedComplete()
Returns whether or not the last iteration has been reported yet, either as an error or success
|
public IteratorClient(ScrapingSession session, java.lang.String uniqueId, java.lang.String iteratorId, java.lang.String host, java.lang.String deploymentLocation, java.lang.String username, java.lang.String password)
session
- The scraping sessionuniqueId
- The unique id of the iterator instanceiteratorId
- The name of the iteratorhost
- The host where the Iterator API is located, including the port if neededdeploymentLocation
- The path on the host where the API is found, such as /IteratorAPI username
- The username for using the iteratorpassword
- The password for the iteratorAuthorizationException
- If the connection failed to authenticatejava.lang.IllegalStateException
- If the specified iterator instance could not be found or createdpublic IteratorClient(ScrapingSession session, @NotNull java.lang.String iteratorId, java.lang.String host, java.lang.String deploymentLocation, java.lang.String username, java.lang.String password)
session
- The scraping sessioniteratorId
- The name of the iteratorhost
- The host where the Iterator API is located, including the port if neededdeploymentLocation
- The path on the host where the API is found, such as /IteratorAPI username
- The username for using the iteratorpassword
- The password for the iteratorAuthorizationException
- If the connection failed to authenticatejava.lang.IllegalStateException
- If the specified iterator instance could not be found or created@Nullable public static java.lang.String generateUniqueId(@NotNull java.lang.String name)
name
- The name to use when generating the id@Nullable public static java.lang.String generateUniqueId(@NotNull java.lang.String name, long seed)
name
- The name to use when generating the idseed
- The random seed to use for generating the idpublic void setPingOnSameRecordCount(boolean pingOnSameRecordCount)
pingOnSameRecordCount
- True if the client should ping the server for this iteration even if record counts haven't changed.public java.util.Map<java.lang.String,java.lang.Object> getCurrentValues()
public java.util.Map<java.lang.String,java.lang.Object> getNextValues()
public java.util.Map<java.lang.String,java.lang.Object> getNextValues(java.lang.Integer localPort)
localPort
- The local port and URL to connect to the location this is running onpublic java.util.Map<java.lang.String,java.lang.Object> getNextValues(java.lang.String accessURL)
accessURL
- The URL that can be used to access the interface for the location this is runningpublic java.util.Map<java.lang.String,java.lang.Object> getNextValues(@Nullable java.lang.Integer localPort, java.lang.String accessURL)
localPort
- The local port and URL to connect to the location this is running onaccessURL
- The URL that can be used to access the interface for the location this is runningpublic java.util.Map<java.lang.String,java.lang.Object> getRandomValues()
public java.util.Map<java.lang.String,java.lang.Object> getRandomValues(java.lang.Integer localPort)
localPort
- The local port and URL to connect to the location this is running onpublic java.util.Map<java.lang.String,java.lang.Object> getRandomValues(java.lang.String accessURL)
accessURL
- The URL that can be used to access the interface for the location this is runningpublic java.util.Map<java.lang.String,java.lang.Object> getRandomValues(@Nullable java.lang.Integer localPort, java.lang.String accessURL)
localPort
- The local port and URL to connect to the location this is running onaccessURL
- The URL that can be used to access the interface for the location this is runningpublic void setCurrentValuesInSession()
public java.lang.Integer getOffset()
public java.lang.Integer getLastIterationPk()
public boolean shouldPing()
public boolean wasReportedComplete()
public java.lang.Object getCurrentValue(@Nullable java.lang.String field)
field
- The field, not case-sensitive, for which to get the valuepublic boolean hasNext()
public void reportErrorOnIteration()
public void reportErrorOnIteration(java.lang.String message)
message
- A message to include with the run data for this iterationpublic void reportErrorOnIteration(java.lang.Integer records)
records
- The number of records to report for this iterationpublic void reportErrorOnIteration(java.lang.String message, java.lang.Integer records)
message
- A message to include with the run data for this iterationrecords
- The number of records to report for this iterationpublic void reportErrorOnIteration(java.lang.String message, @Nullable java.lang.Integer records, boolean rerunImmediately)
message
- A message to include with the run data for this iterationrecords
- The number of records to report for this iterationrerunImmediately
- True if the iteration should be rerun again as soon as a new iteration is requested, false to wait until other iterations have runpublic void reportSuccessOnIteration()
public void reportSuccessOnIteration(java.lang.String message)
message
- A message to include with the run data for this iterationpublic void reportSuccessOnIteration(java.lang.Integer records)
records
- The number of records to report for this iterationpublic void reportSuccessOnIteration(java.lang.String message, @Nullable java.lang.Integer records)
message
- A message to include with the run data for this iterationrecords
- The number of records to report for this iteration@Nullable public IteratorInstance getInstance()
public boolean isClosed()
@NotNull public java.util.Map<java.lang.String,java.lang.Object> convertMap()
LogMappable
convertMap
in interface LogMappable
public void close() throws java.lang.Exception
java.lang.Exception