|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectopenr66.client.AbstractTransfer
openr66.client.SendThroughClient
public abstract class SendThroughClient
Class for Send Through client
This class does not included the real file transfer since it is up to the business project
to implement how to read new data to be sent to the remote host. If an error occurs,
no transfer log is kept.
1) Configuration must have been loaded
2) Pipeline and NetworkTransaction must have been initiated:
Configuration.configuration.pipelineInit();
NetworkTransaction networkTransaction = new NetworkTransaction();
3) Prepare the request of transfer:
R66Future futureReq = new R66Future(true);
SendThroughClient transaction = new SendThroughClient(futureReq,...);
if (! transaction.initiateRequest()) { error }
4) Once initiateRequest() gives true, you are ready to send the data in through mode like:
byte[] data = readOrGetInSomeWayData();
DataBlock block = transaction.transformToDataBlock(data);
futureWrite = transaction.writeWhenPossible(block);
5) Once you have finished, so this is the last block, you have to do the following:
If the last block is not empty:
DataBlock block = transaction.transformToDataBlock(data);
block.setEOF(true);
Or if the last block is empty:
DataBlock block = transaction.transformToDataBlock(null);
Then
futureWrite = transaction.writeWhenPossible(block);
futureWrite.awaitUninterruptibly();
6) If everything is in success:
transaction.finalizeRequest();
And now wait for the transfer to finish:
futureReq.awaitUninterruptibly();
R66Result result = futureReq.getResult();
7) If there is the need to re-do, just re-execute the steps from 3 to 6.
Don't forget at the very end to finish the global structure (steps 3 to 6 no more executed):
networkTransaction.closeAll();
8) In case of errors during steps 4 or 5 (and only those), call the following:
{@link TestSendThroughClient} Class as example of usage
Field Summary | |
---|---|
protected LocalChannelReference |
localChannelReference
|
protected NetworkTransaction |
networkTransaction
|
protected DbTaskRunner |
taskRunner
|
Fields inherited from class openr66.client.AbstractTransfer |
---|
block, blocksize, dateFormat, fileinfo, fileInfo, filename, future, id, idt, ismd5, isMD5, localFilename, logger, nolog, remoteHost, rhost, rule, rulename, startTime, ttimestart |
Constructor Summary | |
---|---|
SendThroughClient(R66Future future,
String remoteHost,
String filename,
String rulename,
String fileinfo,
boolean isMD5,
int blocksize,
long id,
NetworkTransaction networkTransaction)
|
Method Summary | |
---|---|
void |
finalizeRequest()
Finalize the request |
boolean |
initiateRequest()
Prior to call this method, the pipeline and NetworkTransaction must have been initialized. |
void |
run()
DO NOT CALL THIS! |
void |
transferInError(OpenR66Exception e)
To be used in case of error after a correct initiate of the request |
goldengate.common.file.DataBlock |
transformToDataBlock(byte[] data)
Utility method for send through mode |
org.jboss.netty.channel.ChannelFuture |
writeWhenPossible(goldengate.common.file.DataBlock block)
Write the next block when the channel is ready to prevent OOM |
Methods inherited from class openr66.client.AbstractTransfer |
---|
getParams, initRequest |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final NetworkTransaction networkTransaction
protected LocalChannelReference localChannelReference
protected DbTaskRunner taskRunner
Constructor Detail |
---|
public SendThroughClient(R66Future future, String remoteHost, String filename, String rulename, String fileinfo, boolean isMD5, int blocksize, long id, NetworkTransaction networkTransaction)
future
- remoteHost
- filename
- rulename
- fileinfo
- isMD5
- blocksize
- networkTransaction
- id
- Method Detail |
---|
public void run()
public boolean initiateRequest()
public void finalizeRequest()
public void transferInError(OpenR66Exception e)
e
- public org.jboss.netty.channel.ChannelFuture writeWhenPossible(goldengate.common.file.DataBlock block) throws OpenR66RunnerErrorException, OpenR66ProtocolPacketException, OpenR66ProtocolSystemException
block
-
OpenR66RunnerErrorException
OpenR66ProtocolPacketException
OpenR66ProtocolSystemException
public goldengate.common.file.DataBlock transformToDataBlock(byte[] data)
data
- the data byte, if null it is the last block
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |