Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-07-2008, 07:08 PM
Member
 
Join Date: Oct 2008
Posts: 1
Rep Power: 0
antony75 is on a distinguished road
Default data loss in the secure file transfer using java
Hi,

My java Appllication uses the sftp(secure file transfer protocol) for file transferring. when the load is high like 150 GB , data loss occuring for some files especially last chunk of data is missing.

Core file transfer code

while (true)

{

int read = bis.read(buffer); //Reading bytes into the byte array (buffer) from network stream (bis).

if (read==-1) {

break; //Break the loop, if there are no more bytes available in the InputStream.

}

bos.write(buffer,0,read); //Writing the same number of bytes what we read into buffer byte array into OutputStream

complete.update(buffer,0,read); //Giving the same number of bytes what we read above to the checksum calculation.

bytesSoFar += read; //Incrementing the bytes that we have read from the source.


//if the bytes transferred are equal to the source file size

If (bytesSoFar == fileInfo.getFileSize().intValue())

{

// Calculate the file checksum.

// Update DbAuditLog with checksum and no. of bytes read

}

else

{

// Update DbAuditLog with no. of bytes read

}

}

bos.flush();


Please help , why the data loss is happening when the big size files transfer

Note:

1.150 gb not a single file multiple files.

2.SFTP no java specific API, So connection is happening through java .io.sockect connection

Due to data loss, checksum also not correct.
This issue not occurring continuously.. some times whole transfer failing or success.

Is NFS mount plays any role when this occurrence happening .. OS is HP-UX ia64 itanium version.

Now we are observing with glance tool which is provided by hp to analyze system activity

Application is running along with jconsole.

All the transaction are running under multithreaded way.. that means,most of the txns run multi threaded way , few txns run under singel thread. it depends on the threads available in the thread pool.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-08-2008, 09:01 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 571
Rep Power: 2
fishtoprecords is on a distinguished road
Default
You need to make sure you are reading any partially filled last buffer blocks.

SFTP is just SSH + FTP. What is doing your encryption?

How big are these files? Sending things bigger than 2GB can cause all sorts of issues.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-07-2009, 12:39 PM
Member
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0
jfileupload is on a distinguished road
Lightbulb Try with a working Java SFTP tool
You should make a test with an applet that supports SFTP such as JFileUpload (there is a free full featured trial). If it works then it means that you have a problem in your code.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-07-2009, 08:37 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,149
Rep Power: 2
CJSLMAN is on a distinguished road
Default
Don't know if it will help with your problem, but you should always close you outputstreams:
Code:
bos.close();
You should also close your program's inputstream when finished.

Luck,
CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-09-2009, 06:56 AM
Senior Member
 
Join Date: Jan 2009
Posts: 319
Rep Power: 1
toadaly is on a distinguished road
Default
My guess is an exception is being thrown that you are not handling. If the socket disconnects mid transfer (which can happen), or if you get a file write error (which can also happen), the code you have here will result in a partial file.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fast Data Transfer 0.9.1 Java Tip Java Announcements 0 04-24-2008 06:41 PM
Fast Data Transfer 0.8.5 JavaBean Java Announcements 0 11-12-2007 06:11 PM
Fast Data Transfer 0.6.7 Jamie Java Announcements 0 06-14-2007 02:55 PM
Fast Data Transfer 0.6.4 levent Java Announcements 0 05-21-2007 10:11 AM
Fast Data Transfer 0.6.4 levent Java Announcements 0 05-20-2007 08:55 AM


All times are GMT +2. The time now is 03:26 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org