edu.iris.Fissures.seed.container
Class SeedVolumeMMAPContainer

java.lang.Object
  extended by java.util.Observable
      extended by edu.iris.Fissures.seed.container.SeedVolumeMMAPContainer
All Implemented Interfaces:
MMAPContainer<SeedObjectTag,java.lang.String>, ObjectContainer

public class SeedVolumeMMAPContainer
extends java.util.Observable
implements MMAPContainer<SeedObjectTag,java.lang.String>, ObjectContainer

Container for maintaining ID annotated edit logs using memory map indices for retrieval. We make this container an Observable one, so that outside observers, such as the view layer, can know that something has changed with the container.

Version:
5/10/2013
Author:
Robert Casey, IRIS DMC

Field Summary
 int stationCount
           
 int stationsPending
           
 
Constructor Summary
SeedVolumeMMAPContainer()
           
SeedVolumeMMAPContainer(java.io.File filePath)
           
SeedVolumeMMAPContainer(java.lang.String pathName)
           
SeedVolumeMMAPContainer(java.lang.String baseDir, java.lang.String name)
           
 
Method Summary
 int acquire()
           
 int acquire(long pos)
           
 int acquire(SeedObjectTag tag, long pos)
           
 void add(java.lang.Object addThis)
          Add provided object to the container
 void addAbbrevToContext(int lookupField, java.lang.String abbrevBlocketteStr)
           
 void addData(java.lang.String blocketteStr)
           
 void addDataAndNotify(java.lang.String blocketteStr)
           
 boolean checkForCollision(SeedObjectTag tag)
           
 void closeJournal()
           
 void consumerCloseAndWait()
           
 boolean containsKey(SeedObjectTag tag)
           
 void delete(SeedObjectTag tag)
           
 void deleteAndNotify(SeedObjectTag tag)
           
 void deleteData(SeedObjectTag tag)
           
 SeedObjectTag generateContextTag(java.lang.String blocketteStr)
           
 java.lang.Object get(int refNum)
          Find and return the object matching to refNum
 java.lang.String get(java.nio.MappedByteBuffer buf)
           
 java.nio.MappedByteBuffer get(SeedObjectTag tag)
           
 SeedObjectTag getAbbreviation(SeedObjectTag sourceTag, int referenceField)
           
 Blockette getBlockette(SeedObjectTag tag)
           
 java.util.List<SeedObjectTag> getChildTags(SeedObjectTag parentTag)
           
 java.util.List<SeedObjectTag> getChildTags(java.lang.String parentID)
           
 SeedObjectTag getContext()
           
 int getLatestStageNum(SeedObjectTag parentChannel)
           
 java.nio.MappedByteBuffer getNext()
          Get next object from established iterator list.
 Blockette getNextBlockette()
           
 int getStationCount()
           
 int getStationsPending()
           
static java.lang.String getString(java.nio.MappedByteBuffer mbb)
           
 java.util.List<SeedObjectTag> getTagList()
           
 java.util.List<SeedObjectTag> getTagList(int catNum)
           
 java.util.List<SeedObjectTag> getTagListByType(int blkType)
           
 java.util.List<SeedObjectTag> getTagsBetween(SeedObjectTag startTag, SeedObjectTag endTag)
           
 int getUniqueAbbreviationIndex(SeedObjectTag tag)
           
 int importChildren(java.io.InputStream inStream)
           
 int importData(java.io.File file)
           
 int importData(java.io.InputStream inStream)
           
 int importData(java.lang.String fileName)
           
 boolean isActive(SeedObjectTag tag)
           
 int iterate()
           
 int iterate(int catNum)
           
 int iterate(int volNum, int catNum)
          Locate all objects belonging to volume volNum and of category catNum.
 int iterate(java.util.List<SeedObjectTag> tagList)
           
 int iterate(java.lang.String queryStr)
           
 boolean locate(int refNum)
          Locate the object matching to refNum and return true if found
 void logAssertion(SeedObjectTag tag, java.nio.MappedByteBuffer mbb)
           
 void logCollision(SeedObjectTag tag)
           
 void logContext(SeedObjectTag tag)
           
static void main(java.lang.String[] args)
           
 void openJournal(java.io.File filePath)
           
 void openJournal(java.io.File filePath, boolean overwrite)
           
 void openJournal(java.lang.String pathName)
           
 void openJournal(java.lang.String pathName, boolean overwrite)
           
 void openJournal(java.lang.String baseDir, java.lang.String name)
           
 void openJournal(java.lang.String baseDir, java.lang.String name, boolean overwrite)
           
 void registerObserver(java.util.Observer o)
           
 boolean reinstate(SeedObjectTag tag)
           
 java.lang.Object remove(int refNum)
          Remove the object matching to refNum
 void rename(SeedObjectTag oldTag, SeedObjectTag newTag)
           
 void renameAndNotify(SeedObjectTag oldTag, SeedObjectTag newTag)
           
 void rollBack()
           
 void rollBack(SeedObjectTag tag)
           
 void setAbbreviation(SeedObjectTag tag, java.nio.MappedByteBuffer mbb)
           
 void setActive(SeedObjectTag tag, boolean isActive)
           
 void setContext(SeedObjectTag context)
           
 void setUpdateLookup(boolean b)
           
 SeedObjectTag tagForCollision(SeedObjectTag tag)
           
 void update(SeedObjectTag tag, java.lang.String blocketteStr)
           
 void update(SeedObjectTag tag, java.lang.String blocketteStr, boolean reinstate)
           
 void updateAndNotify(SeedObjectTag tag, java.lang.String blocketteStr, boolean reinstate)
           
 void updateLatest(java.lang.String blocketteStr, java.lang.Boolean updateLookup)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stationsPending

public int stationsPending

stationCount

public int stationCount
Constructor Detail

SeedVolumeMMAPContainer

public SeedVolumeMMAPContainer()

SeedVolumeMMAPContainer

public SeedVolumeMMAPContainer(java.lang.String pathName)
                        throws java.io.FileNotFoundException,
                               java.io.IOException,
                               ContainerException
Throws:
java.io.FileNotFoundException
java.io.IOException
ContainerException

SeedVolumeMMAPContainer

public SeedVolumeMMAPContainer(java.lang.String baseDir,
                               java.lang.String name)
                        throws java.io.FileNotFoundException,
                               java.io.IOException,
                               ContainerException
Throws:
java.io.FileNotFoundException
java.io.IOException
ContainerException

SeedVolumeMMAPContainer

public SeedVolumeMMAPContainer(java.io.File filePath)
                        throws java.io.FileNotFoundException,
                               java.io.IOException,
                               ContainerException
Throws:
java.io.FileNotFoundException
java.io.IOException
ContainerException
Method Detail

addData

public void addData(java.lang.String blocketteStr)
             throws ContainerException,
                    java.io.IOException
Specified by:
addData in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

addDataAndNotify

public void addDataAndNotify(java.lang.String blocketteStr)
                      throws ContainerException,
                             java.io.IOException
Throws:
ContainerException
java.io.IOException

addAbbrevToContext

public void addAbbrevToContext(int lookupField,
                               java.lang.String abbrevBlocketteStr)
                        throws SeedException,
                               ContainerException,
                               java.io.IOException
Throws:
SeedException
ContainerException
java.io.IOException

update

public void update(SeedObjectTag tag,
                   java.lang.String blocketteStr)
            throws ContainerException,
                   java.io.IOException
Specified by:
update in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

update

public void update(SeedObjectTag tag,
                   java.lang.String blocketteStr,
                   boolean reinstate)
            throws ContainerException,
                   java.io.IOException
Throws:
ContainerException
java.io.IOException

updateAndNotify

public void updateAndNotify(SeedObjectTag tag,
                            java.lang.String blocketteStr,
                            boolean reinstate)
                     throws ContainerException,
                            java.io.IOException
Throws:
ContainerException
java.io.IOException

updateLatest

public void updateLatest(java.lang.String blocketteStr,
                         java.lang.Boolean updateLookup)
                  throws ContainerException,
                         java.io.IOException,
                         SeedException
Throws:
ContainerException
java.io.IOException
SeedException

importData

public int importData(java.io.InputStream inStream)
               throws ContainerException,
                      java.io.IOException,
                      SeedException
Throws:
ContainerException
java.io.IOException
SeedException

importData

public int importData(java.io.File file)
               throws ContainerException,
                      java.io.IOException,
                      SeedException
Throws:
ContainerException
java.io.IOException
SeedException

importData

public int importData(java.lang.String fileName)
               throws ContainerException,
                      java.io.IOException,
                      SeedException
Throws:
ContainerException
java.io.IOException
SeedException

importChildren

public int importChildren(java.io.InputStream inStream)
                   throws ContainerException,
                          java.io.IOException,
                          SeedException
Throws:
ContainerException
java.io.IOException
SeedException

delete

public void delete(SeedObjectTag tag)
            throws ContainerException,
                   java.io.IOException
Specified by:
delete in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

deleteData

public void deleteData(SeedObjectTag tag)
                throws ContainerException,
                       java.io.IOException
Throws:
ContainerException
java.io.IOException

deleteAndNotify

public void deleteAndNotify(SeedObjectTag tag)
                     throws ContainerException,
                            java.io.IOException
Throws:
ContainerException
java.io.IOException

reinstate

public boolean reinstate(SeedObjectTag tag)
                  throws ContainerException,
                         java.io.IOException
Specified by:
reinstate in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

rename

public void rename(SeedObjectTag oldTag,
                   SeedObjectTag newTag)
            throws ContainerException,
                   java.io.IOException
Specified by:
rename in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

renameAndNotify

public void renameAndNotify(SeedObjectTag oldTag,
                            SeedObjectTag newTag)
                     throws ContainerException,
                            java.io.IOException
Throws:
ContainerException
java.io.IOException

logAssertion

public void logAssertion(SeedObjectTag tag,
                         java.nio.MappedByteBuffer mbb)
                  throws ContainerException,
                         java.io.IOException
Throws:
ContainerException
java.io.IOException

logCollision

public void logCollision(SeedObjectTag tag)
                  throws java.io.IOException,
                         ContainerException
Throws:
java.io.IOException
ContainerException

logContext

public void logContext(SeedObjectTag tag)
                throws java.io.IOException,
                       ContainerException
Throws:
java.io.IOException
ContainerException

get

public java.nio.MappedByteBuffer get(SeedObjectTag tag)
                              throws ContainerException
Specified by:
get in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException

get

public java.lang.String get(java.nio.MappedByteBuffer buf)
                     throws ContainerException
Specified by:
get in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException

getBlockette

public Blockette getBlockette(SeedObjectTag tag)
                       throws ContainerException,
                              SeedException
Throws:
ContainerException
SeedException

setContext

public void setContext(SeedObjectTag context)
Specified by:
setContext in interface MMAPContainer<SeedObjectTag,java.lang.String>

getContext

public SeedObjectTag getContext()

iterate

public int iterate()
Specified by:
iterate in interface MMAPContainer<SeedObjectTag,java.lang.String>
Specified by:
iterate in interface ObjectContainer

iterate

public int iterate(int volNum,
                   int catNum)
Description copied from interface: ObjectContainer
Locate all objects belonging to volume volNum and of category catNum. Initialize an iteration list that can be traversed by getNext(). Return the number of objects in the iterator list.

Specified by:
iterate in interface ObjectContainer

iterate

public int iterate(int catNum)
Specified by:
iterate in interface ObjectContainer

iterate

public int iterate(java.lang.String queryStr)

iterate

public int iterate(java.util.List<SeedObjectTag> tagList)

getNext

public java.nio.MappedByteBuffer getNext()
Description copied from interface: ObjectContainer
Get next object from established iterator list. If iterator has no objects, then return null.

Specified by:
getNext in interface MMAPContainer<SeedObjectTag,java.lang.String>
Specified by:
getNext in interface ObjectContainer

getNextBlockette

public Blockette getNextBlockette()
                           throws SeedException
Throws:
SeedException

getTagList

public java.util.List<SeedObjectTag> getTagList()
                                         throws ContainerException
Specified by:
getTagList in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException

getTagList

public java.util.List<SeedObjectTag> getTagList(int catNum)
                                         throws ContainerException
Throws:
ContainerException

getTagListByType

public java.util.List<SeedObjectTag> getTagListByType(int blkType)
                                               throws ContainerException
Throws:
ContainerException

getChildTags

public java.util.List<SeedObjectTag> getChildTags(java.lang.String parentID)
                                           throws ContainerException
Throws:
ContainerException

getChildTags

public java.util.List<SeedObjectTag> getChildTags(SeedObjectTag parentTag)
                                           throws ContainerException
Throws:
ContainerException

getTagsBetween

public java.util.List<SeedObjectTag> getTagsBetween(SeedObjectTag startTag,
                                                    SeedObjectTag endTag)
                                             throws ContainerException
Throws:
ContainerException

getStationsPending

public int getStationsPending()

getStationCount

public int getStationCount()

checkForCollision

public boolean checkForCollision(SeedObjectTag tag)

tagForCollision

public SeedObjectTag tagForCollision(SeedObjectTag tag)
                              throws ContainerException,
                                     java.io.IOException
Throws:
ContainerException
java.io.IOException

generateContextTag

public SeedObjectTag generateContextTag(java.lang.String blocketteStr)
                                 throws SeedException
Throws:
SeedException

openJournal

public void openJournal(java.io.File filePath,
                        boolean overwrite)
                 throws java.io.IOException,
                        ContainerException
Throws:
java.io.IOException
ContainerException

openJournal

public void openJournal(java.lang.String baseDir,
                        java.lang.String name,
                        boolean overwrite)
                 throws java.io.IOException,
                        ContainerException
Throws:
java.io.IOException
ContainerException

openJournal

public void openJournal(java.lang.String pathName,
                        boolean overwrite)
                 throws java.io.IOException,
                        ContainerException
Throws:
java.io.IOException
ContainerException

openJournal

public void openJournal(java.io.File filePath)
                 throws java.io.IOException,
                        ContainerException
Specified by:
openJournal in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
java.io.IOException
ContainerException

openJournal

public void openJournal(java.lang.String baseDir,
                        java.lang.String name)
                 throws java.io.IOException,
                        ContainerException
Specified by:
openJournal in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
java.io.IOException
ContainerException

openJournal

public void openJournal(java.lang.String pathName)
                 throws java.io.IOException,
                        ContainerException
Specified by:
openJournal in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
java.io.IOException
ContainerException

closeJournal

public void closeJournal()
                  throws java.io.IOException
Throws:
java.io.IOException

rollBack

public void rollBack(SeedObjectTag tag)
              throws ContainerException,
                     java.io.IOException
Specified by:
rollBack in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

rollBack

public void rollBack()
              throws ContainerException,
                     java.io.IOException
Specified by:
rollBack in interface MMAPContainer<SeedObjectTag,java.lang.String>
Throws:
ContainerException
java.io.IOException

containsKey

public boolean containsKey(SeedObjectTag tag)

isActive

public boolean isActive(SeedObjectTag tag)

setActive

public void setActive(SeedObjectTag tag,
                      boolean isActive)

registerObserver

public void registerObserver(java.util.Observer o)

setUpdateLookup

public void setUpdateLookup(boolean b)

acquire

public int acquire()
            throws ContainerException,
                   SeedException
Throws:
ContainerException
SeedException

acquire

public int acquire(long pos)
            throws ContainerException,
                   SeedException
Throws:
ContainerException
SeedException

acquire

public int acquire(SeedObjectTag tag,
                   long pos)
            throws ContainerException,
                   SeedException
Throws:
ContainerException
SeedException

setAbbreviation

public void setAbbreviation(SeedObjectTag tag,
                            java.nio.MappedByteBuffer mbb)
                     throws SeedException,
                            ContainerException,
                            java.io.IOException
Throws:
SeedException
ContainerException
java.io.IOException

getAbbreviation

public SeedObjectTag getAbbreviation(SeedObjectTag sourceTag,
                                     int referenceField)
                              throws SeedException,
                                     ContainerException
Throws:
SeedException
ContainerException

getUniqueAbbreviationIndex

public int getUniqueAbbreviationIndex(SeedObjectTag tag)
                               throws SeedException,
                                      ContainerException
Throws:
SeedException
ContainerException

getLatestStageNum

public int getLatestStageNum(SeedObjectTag parentChannel)
                      throws ContainerException
Throws:
ContainerException

getString

public static java.lang.String getString(java.nio.MappedByteBuffer mbb)

consumerCloseAndWait

public void consumerCloseAndWait()
                          throws ContainerException
Throws:
ContainerException

add

public void add(java.lang.Object addThis)
         throws java.lang.Exception
Description copied from interface: ObjectContainer
Add provided object to the container

Specified by:
add in interface ObjectContainer
Throws:
java.lang.Exception

get

public java.lang.Object get(int refNum)
                     throws ContainerException
Description copied from interface: ObjectContainer
Find and return the object matching to refNum

Specified by:
get in interface ObjectContainer
Throws:
ContainerException

remove

public java.lang.Object remove(int refNum)
                        throws ContainerException
Description copied from interface: ObjectContainer
Remove the object matching to refNum

Specified by:
remove in interface ObjectContainer
Throws:
ContainerException

locate

public boolean locate(int refNum)
               throws ContainerException
Description copied from interface: ObjectContainer
Locate the object matching to refNum and return true if found

Specified by:
locate in interface ObjectContainer
Throws:
ContainerException

main

public static void main(java.lang.String[] args)