com.unister.semweb.drums.sync
Class SyncManager<Data extends AbstractKVStorable>

java.lang.Object
  extended by java.lang.Thread
      extended by com.unister.semweb.drums.sync.SyncManager<Data>
Type Parameters:
Data - an implementation of AbstractKVStorable, e.g. GeneralStorable
All Implemented Interfaces:
java.lang.Runnable

public class SyncManager<Data extends AbstractKVStorable>
extends java.lang.Thread

An instance of a SyncManager is a thread, that handles the synchronization of Buckets with their corresponding parts on disk. The policy for synchronizing is as following:

  • get the bucket with the most elements and synchronize it, if there are still resources
  • try to synchronize the next full bucket


  • The SyncManager instantiates new SyncThreads. Each SyncThread uses a special Synchronizer to move data from cache to disk.

    Author:
    Martin Nettling, Nils Thieme

    Nested Class Summary
     
    Nested classes/interfaces inherited from class java.lang.Thread
    java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
     
    Field Summary
     BucketContainer<Data> bucketContainer
              Contains the buckets.
    static double MINFILL_BEFORE_SYNC
              at least this fill level of a bucket must been reached, before synchronizing for this bucket is started
     
    Fields inherited from class java.lang.Thread
    MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
     
    Constructor Summary
    SyncManager(BucketContainer<Data> bucketContainer, ISynchronizerFactory<Data> synchronizerFactory, DRUMSParameterSet<Data> gp)
              Instantiates a new SyncManager with an already instantiated BucketContainer.
     
    Method Summary
     java.util.Set<Bucket<Data>> getActualProcessingBuckets()
               
     BucketContainer<Data> getBucketContainer()
               
     long getMaxBucketStorageTime()
               
     int getNumberOfActiveThreads()
               
     long getNumberOfElementsInserted()
               
     long getNumberOfElementsUpdated()
               
     int getNumberOfMaximalThreads()
               
     java.lang.String getPathToDbFiles()
               
     void run()
               
     void setMaxBucketStorageTime(long maxBucketStorageTime)
              Sets the maximal time that a bucket can linger within the BucketContainer without synchronization to hard drive.
     void setSynchronizer(ISynchronizerFactory<Data> factory)
              overwrites the SynchronizerFactory.
     void shutdown()
              Initiates the shutdown.
     void startForceMode()
              Initiates the a synchronizing of all buckets.
     void stopForceMode()
              Stops forcing the DRUMS to synchronize all Buckets
     void sumUpInserted(long toSumUp)
              Sums the number of inserted elements.
     void sumUpUpdated(long toSumUp)
              Sums the number of updated elements.
     
    Methods inherited from class java.lang.Thread
    activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    MINFILL_BEFORE_SYNC

    public static final double MINFILL_BEFORE_SYNC
    at least this fill level of a bucket must been reached, before synchronizing for this bucket is started

    See Also:
    Constant Field Values

    bucketContainer

    public final BucketContainer<Data extends AbstractKVStorable> bucketContainer
    Contains the buckets.

    Constructor Detail

    SyncManager

    public SyncManager(BucketContainer<Data> bucketContainer,
                       ISynchronizerFactory<Data> synchronizerFactory,
                       DRUMSParameterSet<Data> gp)
    Instantiates a new SyncManager with an already instantiated BucketContainer. The defined number of Threads in DRUMSParameterSet will show the number of allowed SyncThreads used to synchronize the AbstractKVStorables from the Buckets in BucketContainer to the HDD.

    Parameters:
    bucketContainer -
    synchronizerFactory -
    gp -
    Method Detail

    run

    public void run()
    Specified by:
    run in interface java.lang.Runnable
    Overrides:
    run in class java.lang.Thread

    setSynchronizer

    public void setSynchronizer(ISynchronizerFactory<Data> factory)
    overwrites the SynchronizerFactory. Be very careful

    Parameters:
    factory -

    stopForceMode

    public void stopForceMode()
    Stops forcing the DRUMS to synchronize all Buckets


    startForceMode

    public void startForceMode()
    Initiates the a synchronizing of all buckets. All actual buckets with elements will be processed. Be careful. If someone refills the buckets, the thread won't shut down.


    shutdown

    public void shutdown()
    Initiates the shutdown. All actual buckets with elements will be processed. Be careful. If someone refills the buckets, the thread won't shut down.


    getPathToDbFiles

    public java.lang.String getPathToDbFiles()
    Returns:
    the directory of the database files.

    getMaxBucketStorageTime

    public long getMaxBucketStorageTime()
    Returns:
    the current maximal time that a bucket can linger within the BucketContainer.

    setMaxBucketStorageTime

    public void setMaxBucketStorageTime(long maxBucketStorageTime)
    Sets the maximal time that a bucket can linger within the BucketContainer without synchronization to hard drive.

    Parameters:
    maxBucketStorageTime -

    getActualProcessingBuckets

    public java.util.Set<Bucket<Data>> getActualProcessingBuckets()
    Returns:
    a set of buckets which are currently in a synchronization process.

    getBucketContainer

    public BucketContainer<Data> getBucketContainer()
    Returns:
    the BucketContainer.

    getNumberOfActiveThreads

    public int getNumberOfActiveThreads()
    Returns:
    the number of buffer threads that are currently active.

    getNumberOfMaximalThreads

    public int getNumberOfMaximalThreads()
    Returns:
    the maximal number of buffer threads that are allowed.

    sumUpInserted

    public void sumUpInserted(long toSumUp)
    Sums the number of inserted elements.

    Parameters:
    toSumUp -

    sumUpUpdated

    public void sumUpUpdated(long toSumUp)
    Sums the number of updated elements.

    Parameters:
    toSumUp -

    getNumberOfElementsInserted

    public long getNumberOfElementsInserted()
    Returns:
    the overall number of inserted elements to the file storage.

    getNumberOfElementsUpdated

    public long getNumberOfElementsUpdated()
    Returns:
    the overall number of updated elements of the file storage.