public class BulkIngester
extends java.lang.Object
ErrorCallback
, FinishedCallback
, AbortCallback
, and
StatusCallback
, and do something useful when their handler
methods are called (which happens in the response thread).
allocateBulkPort
web service method
in the manage
web service), the four callback objects etc. as defined in the
constructor
.
begin
method to start the response thread. If this
is not called, an IOException will be thrown.
sendRecord
repeatedly to send
Data.Record
objects to the data domain.
endIngest
to terminate the
response thread and close the socket.
Modifier | Constructor and Description |
---|---|
protected |
BulkIngester(java.io.DataInputStream din,
java.io.DataOutputStream dout,
ErrorCallback errorCallback,
FinishedCallback finishedCallback,
AbortCallback abortCallback,
StatusCallback statusCallback)
Alternative constructor for unit testing only.
|
|
BulkIngester(java.lang.String host,
int port,
javax.net.SocketFactory socketFactory,
java.lang.String transactionId,
boolean doFinalMerge,
boolean doUpdateSpellingDictionary,
long socketTimeoutMillis,
ErrorCallback errorCallback,
FinishedCallback finishedCallback,
AbortCallback abortCallback,
StatusCallback statusCallback)
Creates a BulkIngester object which can be used to send data to the
Data Domain using the Bulk Ingest protocol.
|
Modifier and Type | Method and Description |
---|---|
void |
begin()
Spawn a thread to asynchronously read the data domain's responses.
|
void |
endIngest()
Terminates the response thread and closes the socket.
|
void |
requestStatusUpdate()
Poll the data domain on its current status.
|
void |
sendCancel()
Tell the data domain that the client wants to cancel the bulk ingest process.
|
void |
sendRecord(Data.Record rec)
Sends the provided record over the wire to the data domain.
|
public BulkIngester(java.lang.String host, int port, javax.net.SocketFactory socketFactory, java.lang.String transactionId, boolean doFinalMerge, boolean doUpdateSpellingDictionary, long socketTimeoutMillis, ErrorCallback errorCallback, FinishedCallback finishedCallback, AbortCallback abortCallback, StatusCallback statusCallback) throws java.io.IOException
host
- hostname of the Data Domain. Cannot be null.port
- bulk ingest port of the Data Domain.socketFactory
- SocketFactory to use to create socket for bulk ingest. Cannot be null.transactionId
- The transaction to perform this ingest against. Can be null to signify no outer transaction.doFinalMerge
- Should we instruct the dgraph to perform a final merge after ingest? Setting it to true degrades ingest performance. If you're performing multiple bulk ingests, you should set this to false for all but the last ingest job.doUpdateSpellingDictionary
- Should we instruct the dgraph to update the spelling dictionaries after ingest? Setting it to true degrades ingest performance. If performing multiple bulk ingests, you should set this to false for all but the last ingest job.socketTimeoutMillis
- Timeout for connection to dgraph (in milliseconds).errorCallback
- Callback to invoke when there is an error from the dgraph. Not all errors are fatal. Cannot be null.finishedCallback
- Callback to invoke when the bulk ingest process finishes successfully. Cannot be null.abortCallback
- Callback to invoke when there is a fatal ingest error. Cannot be null.statusCallback
- Callback that is invoked periodically with ingest statistics. Cannot be null.java.io.IOException
- if we could not create a connection to the dgraph.protected BulkIngester(java.io.DataInputStream din, java.io.DataOutputStream dout, ErrorCallback errorCallback, FinishedCallback finishedCallback, AbortCallback abortCallback, StatusCallback statusCallback)
din
- dout
- errorCallback
- ErrorCallback object to handle error conditions.finishedCallback
- FinishedCallback object to be called when ingestion finishes.abortCallback
- AbortCallback object to handle aborts.statusCallback
- StatusCallback object to handle status updates.public void begin() throws java.io.IOException
java.lang.IllegalStateException
- if begin() has already been called.java.io.IOException
- when messages could not be sent to the dgraph.public void endIngest() throws java.io.IOException, java.lang.InterruptedException
java.lang.IllegalStateException
- if you haven't called begin() first.java.io.IOException
- when messages could not be sent to the dgraphjava.lang.InterruptedException
- when blocking was interruptedpublic void sendRecord(Data.Record rec) throws java.io.IOException
rec
- The record
to send.java.io.IOException
- when messages could not be sent to the dgraphjava.lang.IllegalStateException
- if begin() has not been called.java.lang.IllegalArgumentException
- if rec has not been initialized.public void requestStatusUpdate() throws java.io.IOException
java.io.IOException
public void sendCancel() throws java.io.IOException
java.io.IOException