ccs.beetree
Class BeeTreeCompactor

java.lang.Object
  extended by ccs.beetree.BeeTreeCompactor

public class BeeTreeCompactor
extends java.lang.Object

Handles the problem of compacting a BeeTree. This involves:


BeeTreeCompactor is MT-UNSAFE and therefore this object must not be shared betweeen threads.

The compaction must not be thread-locked, or it will abort. The compaction looks after its own locking.


Constructor Summary
BeeTreeCompactor(BeeTree bt, boolean isPWChange, byte[] newpw, BeeTreeObserver bto, int wipeMode)
          Construct a BeeTreeCompactor.
BeeTreeCompactor(BeeTree bt, boolean isPWChange, byte[] newpw, BeeTreeObserver bto, int wipeMode, BeeTreeFilter btf)
          Construct a BeeTreeCompactor.
 
Method Summary
 void run()
          Perform the compaction procedure.
 void setIntervalMillis(int intervalMillis)
          Set the approximate minimum interval between status reports to the BeeTreeObserver during the object-transfer (main) phase of the compaction.
 void setStrip(boolean isStrip)
          Set whether to strip unprintable characters from keys before sending status reports to any BeeTreeObserver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeeTreeCompactor

public BeeTreeCompactor(BeeTree bt,
                        boolean isPWChange,
                        byte[] newpw,
                        BeeTreeObserver bto,
                        int wipeMode)
                 throws java.io.IOException
Construct a BeeTreeCompactor.

Parameters:
bt - The BeeTree to compact.
isPWChange - Whether the password is to be changed.
newpw - The passphrase bytes to change to. If null, the database becomes plaintext. Ignored unless isPWChange is true.
bto - If non-null, receives regular progress reports as the procedure progresses.
wipeMode - A value from ccs.utils.FileKiller describing what to do with the old (uncompacted) copy of the database.
Throws:
java.io.IOException - if a temporary file could not be created.

BeeTreeCompactor

public BeeTreeCompactor(BeeTree bt,
                        boolean isPWChange,
                        byte[] newpw,
                        BeeTreeObserver bto,
                        int wipeMode,
                        BeeTreeFilter btf)
                 throws java.io.IOException
Construct a BeeTreeCompactor.

Parameters:
bt - The BeeTree to compact. The necessary swap file will be created in the same directory.
isPWChange - Whether the password is to be changed.
newpw - The passphrase bytes to change to. If null, the database becomes plaintext. Ignored unless isPWChange is true.
bto - If non-null, receives regular progress reports as the procedure progresses.
wipeMode - A value from ccs.utils.FileKiller describing what to do with the old (uncompacted) copy of the database.
btf - If non-null, allows the beetree contents to be filtered.
Throws:
java.io.IOException - if a temporary file could not be created.
Method Detail

setStrip

public void setStrip(boolean isStrip)
Set whether to strip unprintable characters from keys before sending status reports to any BeeTreeObserver. Default true.


setIntervalMillis

public void setIntervalMillis(int intervalMillis)
Set the approximate minimum interval between status reports to the BeeTreeObserver during the object-transfer (main) phase of the compaction. Minimum value is 10. Default, and generally recommended, is 500.


run

public void run()
         throws java.io.IOException
Perform the compaction procedure.

Throws:
BeeException - if a minor problem occurred.
ConsistencyException - if a severe problem occurred.
java.io.IOException - if an I/O failure occurred.