public void store ( DataSink sink ) { try { localControlChannel . resetReplyCount ( ) ; if ( session . transferMode != GridFTPSession . MODE_EBLOCK ) { // // no EBLOCK // EBlockParallelTransferContext context = ( EBlockParallelTransferContext ) createTransferContext ( ) ; context . setEodsTotal ( 0 ) ; if ( session . serverMode == Session . SERVER_PASSIVE ) { transferThreadManager . passiveConnect ( sink , context , 1 , serverSocket ) ; } else { //1 non reusable connection transferThreadManager . startTransfer ( sink , context , 1 , ManagedSocketBox . NON_REUSABLE ) ; } } else if ( session . serverMode != GridFTPSession . SERVER_EPAS && session . serverMode != GridFTPSession . SERVER_PASSIVE ) { // // EBLOCK, local server not passive // exceptionToControlChannel ( new DataChannelException ( DataChannelException . BAD_SERVER_MODE ) , "refusing to store with active mode" ) ; } else { // // EBLOCK, local server passive // // data channels will // share this transfer context EBlockParallelTransferContext context = ( EBlockParallelTransferContext ) createTransferContext ( ) ; // we are the passive side, so we don't really get to decide // how many connections will be used int willReuseConnections = socketPool . countFree ( ) ; int needNewConnections = 0 ; if ( gSession . parallel > willReuseConnections ) { needNewConnections = gSession . parallel - willReuseConnections ; } logger . debug ( "will reuse " + willReuseConnections + " connections and start " + needNewConnections + " new ones." ) ; transferThreadManager . startTransfer ( sink , context , willReuseConnections , ManagedSocketBox . REUSABLE ) ; if ( needNewConnections > 0 ) { transferThreadManager . passiveConnect ( sink , context , needNewConnections , serverSocket ) ; } } } catch ( Exception e ) { exceptionToControlChannel ( e , "ocurred during store()" ) ; } }
Store the data from the data channel to the data sink . Does not block . If operation fails exception might be thrown via local control channel .