1414 * See ASPChunkStorage for details.
1515 *
1616 * @see AASPStorage
17- * @see AASPReader
1817 * @author thsc
1918 */
2019public abstract class AASPEngine implements AASPStorage , AASPProtocolEngine {
@@ -37,6 +36,7 @@ public abstract class AASPEngine implements AASPStorage, AASPProtocolEngine {
3736 protected AASPMemento memento = null ;
3837
3938 /* private */ final private AASPChunkStorage chunkStorage ;
39+ private boolean dropDeliveredChunks = false ;
4040
4141 protected AASPEngine (AASPChunkStorage chunkStorage )
4242 throws AASPException , IOException {
@@ -87,7 +87,7 @@ public void add(CharSequence urlTarget, CharSequence message) throws IOException
8787
8888 private String getLogStart () {
8989 StringBuilder b = new StringBuilder ();
90- b .append ("ASP3Engine (" );
90+ b .append ("AASPEngine (" );
9191 b .append (this .owner );
9292 b .append (") " );
9393
@@ -208,10 +208,10 @@ public void handleConnection(InputStream is, OutputStream os,
208208 //>>>>>>>>>>>>>>>>>>>debug
209209
210210 // is not a public chunk
211- if (!this .isPublic (chunk )) {
211+ if (!this .isPublic (chunk )) {
212212 List <CharSequence > recipients = chunk .getRecipients ();
213213
214- if (!recipients .contains (peer )) {
214+ if (!recipients .contains (peer )) {
215215 continue ;
216216 }
217217 }
@@ -234,13 +234,20 @@ public void handleConnection(InputStream is, OutputStream os,
234234 System .out .println (b .toString ());
235235 //>>>>>>>>>>>>>>>>>>>debug
236236 // empty?
237- if (chunk .getRecipients ().isEmpty ()) {
238- chunk .drop ();
239- //<<<<<<<<<<<<<<<<<<debug
240- b = new StringBuilder ();
241- b .append (this .getLogStart ());
242- b .append ("chunk dropped" );
243- System .out .println (b .toString ());
237+ if (chunk .getRecipients ().isEmpty ()) {
238+ if (this .isDropDeliveredChunks ()) {
239+ chunk .drop ();
240+ //<<<<<<<<<<<<<<<<<<debug
241+ b = new StringBuilder ();
242+ b .append (this .getLogStart ());
243+ b .append ("chunk dropped" );
244+ System .out .println (b .toString ());
245+ } else {
246+ b = new StringBuilder ();
247+ b .append (this .getLogStart ());
248+ b .append ("drop flag set false - engine does not remove delivered chunks" );
249+ System .out .println (b .toString ());
250+ }
244251 }
245252 }
246253
@@ -297,6 +304,14 @@ public void handleConnection(InputStream is, OutputStream os,
297304// }
298305 }
299306
307+ private boolean isDropDeliveredChunks () {
308+ return this .dropDeliveredChunks ;
309+ }
310+
311+ public void setDropDeliveredChunks (boolean drop ) {
312+ this .dropDeliveredChunks = drop ;
313+ }
314+
300315 static int nextEra (int workingEra ) {
301316 if (workingEra == Integer .MAX_VALUE ) {
302317 return 0 ;
@@ -375,7 +390,10 @@ private synchronized void incrementEra() throws IOException {
375390 this .era = this .getNextEra (this .era );
376391
377392 // drop very very old chunks - if available
378- this .chunkStorage .dropChunks (this .era );
393+ this .chunkStorage .dropChunks (this .era );
394+
395+ // persistent values
396+ if (this .memento != null ) this .memento .save (this );
379397 }
380398
381399 /**
0 commit comments