From: Mailing l. f. S. c. m. <jtc...@li...> - 2007-08-27 15:35:05
|
Revision: 2754 http://jtcfrost.svn.sourceforge.net/jtcfrost/?rev=2754&view=rev Author: bback Date: 2007-08-25 06:08:37 -0700 (Sat, 25 Aug 2007) Log Message: ----------- - cleanup Modified Paths: -------------- trunk/frost-wot/source/frost/storage/perst/SharedFilesCHKKeyStorage.java Modified: trunk/frost-wot/source/frost/storage/perst/SharedFilesCHKKeyStorage.java =================================================================== --- trunk/frost-wot/source/frost/storage/perst/SharedFilesCHKKeyStorage.java 2007-08-25 12:39:34 UTC (rev 2753) +++ trunk/frost-wot/source/frost/storage/perst/SharedFilesCHKKeyStorage.java 2007-08-25 13:08:37 UTC (rev 2754) @@ -18,7 +18,6 @@ */ package frost.storage.perst; -import java.io.*; import java.util.*; import org.garret.perst.*; @@ -164,19 +163,9 @@ // first search for CHK keys that were created by us, but were never send { Iterator<SharedFilesCHKKey> i = storageRoot.chkKeys.iterator(); - boolean commitNeeded = false; while(i.hasNext()) { SharedFilesCHKKey sfk; - try { - sfk = i.next(); - } catch(org.garret.perst.StorageError e) { - // remove from index - i.remove(); - if( !commitNeeded ) { - commitNeeded = true; - } - continue; - } + sfk = i.next(); if( sfk.getSeenCount() == 0 ) { keysToSend.add(sfk); if( keysToSend.size() >= ownKeysToSend ) { @@ -184,12 +173,8 @@ } } } - if( commitNeeded ) { - commitStore(); - } } - maxKeys -= keysToSend.size(); // then search for other files to send, but don't include other new files from us @@ -208,19 +193,9 @@ // first collect ALL other keys to send, then sort them and choose maxKeys items List<SharedFilesCHKKey> otherKeysToSend = new ArrayList<SharedFilesCHKKey>(); Iterator<SharedFilesCHKKey> i = storageRoot.chkKeys.iterator(); - boolean commitNeeded = false; while(i.hasNext()) { SharedFilesCHKKey sfk; - try { - sfk = i.next(); - } catch(org.garret.perst.StorageError e) { - // remove from index - i.remove(); - if( !commitNeeded ) { - commitNeeded = true; - } - continue; - } + sfk = i.next(); if( sfk.isDownloaded() && sfk.isValid() && sfk.getLastSeen() < maxLastSeen @@ -230,9 +205,6 @@ otherKeysToSend.add(sfk); } } - if( commitNeeded ) { - commitStore(); - } Collections.sort(otherKeysToSend, seenCountComparator); @@ -261,29 +233,15 @@ List<SharedFilesCHKKey> keysToDownload = new ArrayList<SharedFilesCHKKey>(); - boolean commitNeeded = false; for(Iterator<SharedFilesCHKKey> i = storageRoot.chkKeys.iterator(); i.hasNext(); ) { SharedFilesCHKKey sfk; - try { - sfk = i.next(); - } catch(org.garret.perst.StorageError e) { - // remove from index - i.remove(); - if( !commitNeeded ) { - commitNeeded = true; - } - continue; - } + sfk = i.next(); if( !sfk.isDownloaded() && sfk.getDownloadRetries() < maxRetries) { keysToDownload.add(sfk); } } - - if( commitNeeded ) { - commitStore(); - } Collections.sort(keysToDownload, lastDownloadTryStopTimeComparator); @@ -356,22 +314,12 @@ while(i.hasNext()) { SharedFilesCHKKey sfk; - try { - sfk = i.next(); - } catch(org.garret.perst.StorageError e) { - // remove from index - i.remove(); - continue; - } + sfk = i.next(); if( sfk.getLastSeen() > 0 && sfk.getLastSeen() < minVal ) { i.remove(); // remove from iterated index sfk.deallocate(); // remove from Storage deletedCount++; } - if( (deletedCount % 300) == 0 ) { - // all 300 items do commit - commitStore(); - } } commitStore(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |