syncjammer-users Mailing List for SyncJammer
Status: Beta
Brought to you by:
robertmacgrogan
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
From: Robert M. <rob...@ya...> - 2003-11-05 15:31:00
|
Hi, Donald. You're not being a pest at all. You're helping me realize that I need to do some cleanup work on Syncjammer. You're suggestion is a good one. In fact, in SourceJammer (which I originally wrote the streamFileToFile() method for) I've already made a similar change. Actually, I made a more generic method called inputStreamToOutputStream(): public static void inputStreamToOutputStream(InputStream stmIn, OutputStream stmOut) throws IOException{ byte[] buffer = null; int iBufferSize = BUFFER_SIZE; buffer = new byte[iBufferSize]; boolean bKeepStreaming = true; while (bKeepStreaming){ int iBytes = stmIn.read(buffer); if (iBytes == -1){ bKeepStreaming = false; } else{ if (iBytes < iBufferSize){ bKeepStreaming = false; } stmOut.write(buffer, 0, iBytes); }//end else some bytes returned. }//end while } This method is called by streamFileToFile(). Well, sort of . . . public static void oldStreamFileToFile(File source, File target) throws IOException{ FileInputStream stmIn = new FileInputStream(source); FileOutputStream stmOut = new FileOutputStream(target); int iBufferSize = BUFFER_SIZE; inputStreamToOutputStream(stmIn, stmOut); stmIn.close(); stmOut.close(); target.setLastModified(source.lastModified()); } The method is actually called "oldStreamFileToFile()" because I was doing some experimentation to figure out the most efficient way to copy files in Java. Here are the methods SourceJammer uses as its standard now: public static void handlerStreamFileToFile(File source, File target) throws IOException{ FileOutputStream stmOut = new FileOutputStream(target); try{ handlerStreamFileToOutputStream(source, stmOut); } finally{ stmOut.close(); } target.setLastModified(source.lastModified()); } public static void handlerStreamFileToOutputStream(File source, OutputStream target) throws IOException{ FileDataSource dataSource = new FileDataSource(source); DataHandler handler = new DataHandler(dataSource); handler.writeTo(target); } Of course this only works under Java 1.4 or later because it uses nio. Anyway, this is a little bit faster and as you can see the code is much simpler. Thanks for your positive comment about the readability of my code. I do strive for that, if I don't always accomplish it. Oh and your other question . . . No, SyncJammer does not delete remote files. I would not be that difficult to change it so that it does this. I decided not to on the first pass as sort of a safety feature--so that SyncJammer does not delete files that you end up wishing were still backed up. Thanks. --Rob --- "Holliday, Donald B. (LNG-CSP)" <Don...@le...> wrote: > It appears that SyncJammer copies new and modified files to the destination, > but does not delete files from the destination if they are deleted from the > source. Is that correct? > > In jammer.filesys.FileSysUtil there is a method public static void > streamFileToFile(File source, File target). > The code is nicely written and easy to understand. It is: > > public static void streamFileToFile(File source, File target) > throws IOException{ > FileInputStream stmIn = new FileInputStream(source); > FileOutputStream stmOut = new FileOutputStream(target); > int iBufferSize = BUFFER_SIZE; > > boolean bKeepReading = true; > byte[] buffer = null; > while(bKeepReading){ > buffer = new byte[iBufferSize]; > int iNumRead = stmIn.read(buffer); > if (iNumRead == -1){ > bKeepReading = false; > } > else{ > stmOut.write(buffer); > if (iNumRead < iBufferSize){ > bKeepReading = false; > } > } > } > stmIn.close(); > stmIn.close(); > } > > I noticed that variables "iNumRead" and "buffer" is allocated inside the > while loop. BUFFER_SIZE = 1024. This means that an additional 1K of memory > plus the size of an int is allocated on every trip through the while loop. > Is there a reason that these variables have to be reallocated inside the > loop, or could it have been allocated one time outside the loop and reused. > I know this approach guarantees a clean buffer every time the read statement > fills it, but looks to be expensive when copying large directory structures > (I just copied over 7000 files in 4.5 hours). > > Perhaps something like: > > boolean bKeepReading = true; > byte[] buffer = new byte[iBufferSize]; > int iNumRead = 0; > while(bKeepReading){ > iNumRead = stmIn.read(buffer); > if (iNumRead == -1){ > bKeepReading = false; > } > else{ > stmOut.write(buffer, 0, iNumRead); > if (iNumRead < iBufferSize){ > bKeepReading = false; > } > } > } > stmIn.close(); > stmIn.close(); > } > > This way no memory allocations are made inside a tightly wrapped loop that > may have many iterations. Of course, I haven't compiled and tested the > modified code. Just asking. > > Also, it looks like stmIn.close(); is called twice, and stmOut.close(); is > never called. I assume this is a copy paste that didn't get updated (I do > this on a regular basis.) > > Sorry to be a pest, but I really like the tool and am trying to understand > it better. > > Thanks, > > Donald Holliday > (719) 481-7501 V > Donald.Holliday@LexisNexis.com > __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree |
From: Robert M. <rob...@ya...> - 2003-11-03 23:32:06
|
Hi, Donald. Wow. I haven't gotten a message about SyncJammer in a long time! I suppose that SyncJammer is still technically in release 1.0 beta 5, but I've been using the current release in production myself for well over a year, so I'd call it production quality. I should take a look at it and see if I can just do a new official 1.0 release. That might generate more traffic at the very least. And, yes, you're right, the "jammer" packages are not available for download anywhere. I'll have to fix that. Thanks for the positive commentary on SourceJammer. An Eclipse plugin is supposed to be in the works by a SourceJammer user, but I have not heard from him in a while, so I'm not sure when to expect it. (I'd like to have this myself) --Rob --- "Holliday, Donald B. (LNG-CSP)" <Don...@le...> wrote: > I'm evaluating SyncJammer and noticed that the readme's say it is Beta 5. > Is that still true, or is it really Release 1.0. > It appears that the jammer.util package is missing from > http://dev.sourcejammer.org/BrowseArchive?Command=go_project&id=3&parent=2. > I noticed that a number of classes include > import jammer.util.ConfigurationException; > or > import jammer.util.ExceptionChain; > I couldn't find the code for this on the SyncJammer site. Is it available > somewhere else? > > I installed SourceJammer at home last night. I don't have any experience > with it yet, but it was very easy to install, configure, and check files in. > Looks to be a very nice piece of work. Be nice if it was a plug-in for > Eclipse 2.x. > > Thanks, > > Donald Holliday > (719) 481-7501 V > Donald.Holliday@LexisNexis.com > __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ |
From: Robert M. <rob...@ya...> - 2002-10-10 22:30:29
|
Hi, Andre. I never did see a file attached to your patch message. Could you check that out? Also, I just released a new version of SyncJammer that hides the sync.jam files under both Windows and Linux. And it will be able to read the old sync.jam files, so it won't try to re-sync everything. Check it out . . . Thanks. --Rob --- Andre Schild <A.S...@aa...> wrote: > Hello Robert, > > >Hi, Andre. I'll look at the patch. And that's a good idea about the > sync.jam files. > >i've actuallybeen meaning to do that . . . > > For the linux hidden files just changing the line in > SyncFileChecker.java would be enough. > > public static final String SERIALIZED_OBJECT_NAME = ".sync.jam"; > > Of course this change will result in a "resync" of all existing > installations.... > Perhaps use sync.jam as "default-name" but let it be configurable in > the XML file would be better.... > > > But for Windows there seems to be no java method to acomplish this, > just a method isHidden to test for the file flag, but no setHidden > method. > So should we implement a win32-only solution, or just forget about it > ? > > André > > aarboard ag > internet - networks - screen&print design - multimedia > Egliweg 10 - Postfach 214 - CH-2560 Nidau (Switzerland) > Phone +41 32 332 9714 - Fax +41 32 332 9715 > www.aarboard.ch - a.s...@aa... __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com |