|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neo4j.kernel.impl.nioneo.store.CommonAbstractStore
public abstract class CommonAbstractStore
Contains common implementation for AbstractStore and
AbstractDynamicStore.
| Field Summary | |
|---|---|
static String |
ALL_STORES_VERSION
|
protected static Logger |
logger
|
protected String |
storageFileName
|
static String |
UNKNOWN_VERSION
|
| Constructor Summary | |
|---|---|
CommonAbstractStore(String fileName,
Map<?,?> config,
IdType idType)
Opens and validates the store contained in fileName
loading any configuration defined in config. |
|
| Method Summary | |
|---|---|
protected PersistenceWindow |
acquireWindow(long position,
OperationType type)
Acquires a PersistenceWindow for position and
operation type. |
static String |
buildTypeDescriptorAndVersion(String typeDescriptor)
|
static long |
calculateMappedMemory(Map<?,?> config,
String storageFileName)
Returns memory assigned for memory mapped windows in bytes. |
protected void |
checkStorage()
|
protected void |
checkVersion()
|
void |
close()
Closes this store. |
protected void |
closeIdGenerator()
Closed the IdGenerator used by this store |
protected void |
closeStorage()
This method should close/release all resources that the implementation of this store has allocated and is called just before the close()
method returns. |
protected void |
createIdGenerator(String fileName)
|
protected abstract long |
figureOutHighestIdInUse()
|
void |
flushAll()
|
void |
freeId(long id)
Frees an id for this store's IdGenerator. |
Map<?,?> |
getConfig()
Returns the configuration map if set in constructor. |
protected abstract int |
getEffectiveRecordSize()
|
protected FileChannel |
getFileChannel()
Returns a FileChannel to this storage's file. |
protected FileSystemAbstraction |
getFileSystem()
|
long |
getHighestPossibleIdInUse()
|
long |
getHighId()
Return the highest id in use. |
IdType |
getIdType()
|
protected boolean |
getIfMemoryMapped()
|
long |
getNumberOfIdsInUse()
|
String |
getStorageFileName()
Returns the name of this store. |
protected String |
getStoreDir()
|
protected boolean |
getStoreOk()
If store is "not ok" false is returned. |
String |
getTypeAndVersionDescriptor()
|
abstract String |
getTypeDescriptor()
Returns the type and version that identifies this store. |
WindowPoolStats |
getWindowPoolStats()
|
protected void |
initStorage()
Called from the constructor after the end header has been checked. |
boolean |
isInRecoveryMode()
|
protected void |
loadStorage()
Should do first validation on store validating stuff like version and id generator. |
void |
logVersions(StringLogger msgLog)
|
protected static long |
longFromIntAndMod(long base,
long modifier)
|
void |
makeStoreOk()
If store is not ok a call to this method will rebuild the IdGenerator used by this store and if successful mark it as
ok. |
long |
nextId()
Returns the next id for this store's IdGenerator. |
protected void |
openIdGenerator(boolean firstTime)
Opens the IdGenerator used by this store. |
protected IdGenerator |
openIdGenerator(String fileName,
int grabSize,
boolean firstTime)
|
protected void |
openReadOnlyIdGenerator(int recordSize)
|
protected abstract void |
readAndVerifyBlockSize()
|
protected abstract void |
rebuildIdGenerator()
Should rebuild the id generator from scratch. |
void |
rebuildIdGenerators()
|
protected void |
registerIdFromUpdateRecord(long id)
|
protected void |
releaseFileLockAndCloseFileChannel()
|
protected void |
releaseWindow(PersistenceWindow window)
Releases the window and writes the data (async) if the window was a PersistenceRow. |
void |
setHighId(long highId)
Sets the highest id in use (use this when rebuilding id generator). |
protected void |
setRecovered()
|
protected void |
setStoreNotOk(Throwable cause)
Marks this store as "not ok". |
protected void |
setWindowPool(PersistenceWindowPool pool)
Sets the PersistenceWindowPool for this store to use. |
String |
toString()
|
protected void |
unsetRecovered()
|
protected void |
updateHighId()
|
protected void |
verifyCorrectTypeDescriptorAndVersion()
|
protected abstract void |
verifyFileSizeAndTruncate()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ALL_STORES_VERSION
public static final String UNKNOWN_VERSION
protected static final Logger logger
protected final String storageFileName
| Constructor Detail |
|---|
public CommonAbstractStore(String fileName,
Map<?,?> config,
IdType idType)
fileName
loading any configuration defined in config. After
validation the initStorage method is called.
If the store had a clean shutdown it will be marked as ok
and the getStoreOk() method will return true.
If a problem was found when opening the store the makeStoreOk()
must be invoked.
throws IOException if the unable to open the storage or if the
initStorage method fails
fileName - The name of the storeconfig - The configuration for store (may be null)idType - The Id used to index into this store| Method Detail |
|---|
public String getTypeAndVersionDescriptor()
public static String buildTypeDescriptorAndVersion(String typeDescriptor)
public void logVersions(StringLogger msgLog)
protected static long longFromIntAndMod(long base,
long modifier)
public abstract String getTypeDescriptor()
protected void checkStorage()
protected void checkVersion()
protected void loadStorage()
protected abstract int getEffectiveRecordSize()
protected abstract void verifyFileSizeAndTruncate()
throws IOException
IOException
protected abstract void readAndVerifyBlockSize()
throws IOException
IOException
protected void verifyCorrectTypeDescriptorAndVersion()
throws IOException
IOExceptionprotected abstract void rebuildIdGenerator()
protected void initStorage()
persistence windows and other resources that
are needed by overriding this implementation.
This default implementation does nothing.
protected void closeStorage()
close()
method returns. Override this method to clean up stuff created in
initStorage() method.
This default implementation does nothing.
protected FileSystemAbstraction getFileSystem()
protected void setStoreNotOk(Throwable cause)
protected boolean getStoreOk()
false is returned.
protected void setWindowPool(PersistenceWindowPool pool)
PersistenceWindowPool for this store to use. Normally
this is set in the loadStorage() method. This method must be
invoked with a valid "pool" before any of the
acquireWindow(long, OperationType)
releaseWindow(PersistenceWindow)
flushAll()
close()
methods are invoked.
pool - The window pool this store should usepublic long nextId()
IdGenerator.
public void freeId(long id)
IdGenerator.
id - The id to freepublic long getHighId()
public void setHighId(long highId)
highId - The high id to set.protected boolean getIfMemoryMapped()
public static long calculateMappedMemory(Map<?,?> config,
String storageFileName)
memory mapped windows in bytes. The
configuration map passed in one constructor is checked for an entry with
this stores name.
config - Map of configuration parametersstorageFileName - Name of the file on disk
public void makeStoreOk()
IdGenerator used by this store and if successful mark it as
ok.
public void rebuildIdGenerators()
public Map<?,?> getConfig()
null if no
configuration map set.protected String getStoreDir()
protected PersistenceWindow acquireWindow(long position,
OperationType type)
PersistenceWindow for position and
operation type. Window must be released after operation
has been performed via releaseWindow(PersistenceWindow).
position - The record positiontype - The operation type
protected void releaseWindow(PersistenceWindow window)
window was a PersistenceRow.
window - The window to be releasedpublic void flushAll()
public boolean isInRecoveryMode()
protected void setRecovered()
protected void unsetRecovered()
public String getStorageFileName()
protected void openIdGenerator(boolean firstTime)
IdGenerator used by this store.
protected IdGenerator openIdGenerator(String fileName,
int grabSize,
boolean firstTime)
protected abstract long figureOutHighestIdInUse()
protected void createIdGenerator(String fileName)
protected void openReadOnlyIdGenerator(int recordSize)
protected void closeIdGenerator()
IdGenerator used by this store
public void close()
This method will start by invoking the closeStorage() method
giving the implementing store way to do anything that it needs to do
before the fileChannel is closed.
protected void releaseFileLockAndCloseFileChannel()
protected final FileChannel getFileChannel()
FileChannel to this storage's file. If
close() method has been invoked null will be
returned.
public long getHighestPossibleIdInUse()
public long getNumberOfIdsInUse()
public WindowPoolStats getWindowPoolStats()
public IdType getIdType()
protected void registerIdFromUpdateRecord(long id)
protected void updateHighId()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||