gr.uoa.di.madgik.grs.store.buffer
Class CacheBufferStore

java.lang.Object
  extended by java.lang.Thread
      extended by gr.uoa.di.madgik.grs.store.buffer.CacheBufferStore
All Implemented Interfaces:
IBufferStore, java.lang.Runnable

public class CacheBufferStore
extends java.lang.Thread
implements IBufferStore

Implementation of the IBufferStore which utilizes FileRecordStore instances to store the Records accessed through the incoming locators

Author:
gpapanikos

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Nested classes/interfaces inherited from interface gr.uoa.di.madgik.grs.store.buffer.IBufferStore
IBufferStore.MultiplexType
 
Field Summary
static IBufferStore.MultiplexType DefaultMultiplexType
          The default IBufferStore.MultiplexType currently set to IBufferStore.MultiplexType.FIFO
static CacheManager manager
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CacheBufferStore()
          Create new instance
 
Method Summary
 void associateStoreReader(BufferStoreReader reader)
          Associates a BufferStoreReader with the IBufferStore that is has been initialized to access.
 void dispose()
          Disposes all the resources that are internally managed by the IBufferStore
 java.util.ArrayList<BufferStoreEntry> getEntries()
          Retrieves the BufferStoreEntrys that represent the status for all incoming locators and their respective readers and status as well as their persistency location and IRecordStores
 long getInactivityTimeout()
          The timeout of the inactivity period after which the IBufferStore is eligible for disposal.
 java.util.concurrent.TimeUnit getInactivityTimeUnit()
          The time unit used to define the timeout of the inactivity period after which the IBufferStore is eligible for disposal.
 java.lang.String getKey()
          Retrieves the key by which this IBufferStore is registered and referenced through a GRSRegistry
 long getLastActivityTime()
          Retrieves the last activity time over this IBufferStore
 java.net.URI[] getLocators()
          Retrieves the locators over which the IBufferStore operates
 java.lang.Object getModificationObject()
          Retrieves a synchronization object that can be used in a standard wait / notify block to notify requesters of when an additional object has been made available in the underlying storage from the input readers
 IBufferStore.MultiplexType getMultiplexType()
          Retrieves the IBufferStore.MultiplexType indicating the way the input locators are used and in which order their data is received
 long getReaderTimeout()
          Retrieves the timeout that should be used by the readers utilized to access the input locators.
 java.util.concurrent.TimeUnit getReaderTimeoutTimeUnit()
          Retrieves the timeout unit that should be used by the readers utilized to access the input locators.
 void initialize()
          Make any needed initialization before the IBufferStore.store() is called to start the storing procedure
 void markActivity()
          Update the last activity time to the current time
 void run()
          
 void setKey(java.lang.String key)
          Sets the key by which this IBufferStore is registered and referenced through a GRSRegistry
 void setLocators(java.net.URI[] locators)
          Sets the incoming locators that should be stored
 void setMultiplexType(IBufferStore.MultiplexType multiplex)
          Sets the IBufferStore.MultiplexType indicating the way the input locators are used and in which order their data is received
 void setReaderTimeout(long timeout)
          Sets the timeout that should be used by the readers utilized to access the input locators.
 void setReaderTimeoutTimeUnit(java.util.concurrent.TimeUnit unit)
          Sets the timeout unit that should be used by the readers utilized to access the input locators.
 void store()
          Start retrieving data from the input locators and storing them according to the specific IBufferStore implementation
 
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

DefaultMultiplexType

public static final IBufferStore.MultiplexType DefaultMultiplexType
The default IBufferStore.MultiplexType currently set to IBufferStore.MultiplexType.FIFO


manager

public static CacheManager manager
Constructor Detail

CacheBufferStore

public CacheBufferStore()
Create new instance

Method Detail

associateStoreReader

public void associateStoreReader(BufferStoreReader reader)
Associates a BufferStoreReader with the IBufferStore that is has been initialized to access. On disposal of the IBufferStore, the associated BufferStoreReaders are also disposed

Specified by:
associateStoreReader in interface IBufferStore
Parameters:
reader - the reader to associate
See Also:
IBufferStore.associateStoreReader(gr.uoa.di.madgik.grs.store.buffer.BufferStoreReader)

setKey

public void setKey(java.lang.String key)
Sets the key by which this IBufferStore is registered and referenced through a GRSRegistry

Specified by:
setKey in interface IBufferStore
Parameters:
key - the key
See Also:
IBufferStore.setKey(java.lang.String)

getKey

public java.lang.String getKey()
Retrieves the key by which this IBufferStore is registered and referenced through a GRSRegistry

Specified by:
getKey in interface IBufferStore
Returns:
the key
See Also:
IBufferStore.getKey()

getModificationObject

public java.lang.Object getModificationObject()
Retrieves a synchronization object that can be used in a standard wait / notify block to notify requesters of when an additional object has been made available in the underlying storage from the input readers

Specified by:
getModificationObject in interface IBufferStore
Returns:
the synchronization object
See Also:
IBufferStore.getModificationObject()

getEntries

public java.util.ArrayList<BufferStoreEntry> getEntries()
Retrieves the BufferStoreEntrys that represent the status for all incoming locators and their respective readers and status as well as their persistency location and IRecordStores

Specified by:
getEntries in interface IBufferStore
Returns:
the list of persistency entries per incoming locator
See Also:
IBufferStore.getEntries()

getMultiplexType

public IBufferStore.MultiplexType getMultiplexType()
Retrieves the IBufferStore.MultiplexType indicating the way the input locators are used and in which order their data is received

Specified by:
getMultiplexType in interface IBufferStore
Returns:
the type of multiplex
See Also:
IBufferStore.getMultiplexType()

setMultiplexType

public void setMultiplexType(IBufferStore.MultiplexType multiplex)
                      throws GRS2BufferStoreInvalidOperationException
Sets the IBufferStore.MultiplexType indicating the way the input locators are used and in which order their data is received

Specified by:
setMultiplexType in interface IBufferStore
Parameters:
multiplex - the type of multiplex
Throws:
GRS2BufferStoreInvalidOperationException
See Also:
IBufferStore.setMultiplexType(gr.uoa.di.madgik.grs.store.buffer.IBufferStore.MultiplexType)

getReaderTimeout

public long getReaderTimeout()
Retrieves the timeout that should be used by the readers utilized to access the input locators. This value is interpreted in conjunction with IBufferStore.getReaderTimeoutTimeUnit()

Specified by:
getReaderTimeout in interface IBufferStore
Returns:
the timeout
See Also:
IBufferStore.getReaderTimeout()

setReaderTimeout

public void setReaderTimeout(long timeout)
Sets the timeout that should be used by the readers utilized to access the input locators. This value is interpreted in conjunction with IBufferStore.setReaderTimeoutTimeUnit(TimeUnit)

Specified by:
setReaderTimeout in interface IBufferStore
Parameters:
timeout - the timeout
See Also:
IBufferStore.setReaderTimeout(long)

getReaderTimeoutTimeUnit

public java.util.concurrent.TimeUnit getReaderTimeoutTimeUnit()
Retrieves the timeout unit that should be used by the readers utilized to access the input locators. This value is interpreted in conjunction with IBufferStore.getReaderTimeout()

Specified by:
getReaderTimeoutTimeUnit in interface IBufferStore
Returns:
the timeout time unit
See Also:
IBufferStore.getReaderTimeoutTimeUnit()

setReaderTimeoutTimeUnit

public void setReaderTimeoutTimeUnit(java.util.concurrent.TimeUnit unit)
Sets the timeout unit that should be used by the readers utilized to access the input locators. This value is interpreted in conjunction with IBufferStore.setReaderTimeout(long)

Specified by:
setReaderTimeoutTimeUnit in interface IBufferStore
Parameters:
unit - the timeout time unit
See Also:
IBufferStore.setReaderTimeoutTimeUnit(java.util.concurrent.TimeUnit)

getInactivityTimeout

public long getInactivityTimeout()
The timeout of the inactivity period after which the IBufferStore is eligible for disposal. This value is to be interpreted in conjunction with the value of IBufferStore.getInactivityTimeUnit()

Specified by:
getInactivityTimeout in interface IBufferStore
Returns:
the timeout value
See Also:
IBufferStore.getInactivityTimeout()

getInactivityTimeUnit

public java.util.concurrent.TimeUnit getInactivityTimeUnit()
The time unit used to define the timeout of the inactivity period after which the IBufferStore is eligible for disposal. This value is to be interpreted in conjunction with the value of IBufferStore.getInactivityTimeout()

Specified by:
getInactivityTimeUnit in interface IBufferStore
Returns:
the time unit of the timeout
See Also:
IBufferStore.getInactivityTimeUnit()

getLocators

public java.net.URI[] getLocators()
Retrieves the locators over which the IBufferStore operates

Specified by:
getLocators in interface IBufferStore
Returns:
the locators
See Also:
IBufferStore.getLocators()

getLastActivityTime

public long getLastActivityTime()
Retrieves the last activity time over this IBufferStore

Specified by:
getLastActivityTime in interface IBufferStore
Returns:
the last activity time
See Also:
IBufferStore.getLastActivityTime()

markActivity

public void markActivity()
Update the last activity time to the current time

Specified by:
markActivity in interface IBufferStore
See Also:
IBufferStore.markActivity()

setLocators

public void setLocators(java.net.URI[] locators)
                 throws GRS2BufferStoreInvalidOperationException
Sets the incoming locators that should be stored

Specified by:
setLocators in interface IBufferStore
Parameters:
locators - the locators which data should be stored
Throws:
GRS2BufferStoreInvalidOperationException
See Also:
IBufferStore.setLocators(java.net.URI[])

initialize

public void initialize()
                throws GRS2BufferStoreInvalidOperationException
Make any needed initialization before the IBufferStore.store() is called to start the storing procedure

Specified by:
initialize in interface IBufferStore
Throws:
GRS2BufferStoreInvalidOperationException
See Also:
IBufferStore.initialize()

store

public void store()
Start retrieving data from the input locators and storing them according to the specific IBufferStore implementation

Starts the execution in a daemon background thread

Specified by:
store in interface IBufferStore
See Also:
IBufferStore.store()

dispose

public void dispose()
Disposes all the resources that are internally managed by the IBufferStore

Specified by:
dispose in interface IBufferStore
See Also:
IBufferStore.dispose()

run

public void run()

In the context of the execution thread initiated by store() procedure, the thread loads in its thread of execution the defined IMultiplex implementation and forwards the execution to it. The multiplexing implementations used are FifoMultiplex and FirstAvailableMultiplex depending on the value of getMultiplexType()

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Thread.run()