public final class DBData extends java.lang.Object implements DBDataInterface
Modifier and Type | Class and Description |
---|---|
static class |
DBData.SLOW_LOAD_LOCATION
where should we run slowly
|
Modifier and Type | Field and Description |
---|---|
static int |
CACHE_COMPRESS_SIZE
The size of the field data before we should compress it ?
|
static int |
CACHE_LOAD_SEGMENTS
The maximum number of segments to load into the cache without a direct request
|
static java.lang.String |
ENV_DATA_CLASSES_HIGH
Classes that will be put into med-high cost cache
|
static java.lang.String |
ENV_DATA_CLASSES_LOW
Classes that will be put into med-low cost cache
|
static java.util.concurrent.atomic.AtomicLong |
LINKAGE_FUSE
the linkage fuse
|
static java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.FutureTask<LayerData>> |
LOADING_MAP |
static int |
MAX_READ_AHEAD
The maximum number of additional rows to read ahead
|
static java.lang.String |
NOTIFY_CREATED
Notify when a new create is created.
|
static java.lang.String |
NOTIFY_DELETED
Notify when a record is deleted
|
static java.lang.String |
NOTIFY_MODIFIED
Notify when a record is modified
|
long |
rowId
the actual row id
|
static boolean |
SLOW_LOAD_ALLOWED
DEBUG ONLY Allow an artificially slow load time at selected spots of the code.
|
static java.lang.String |
SLOW_LOAD_LOCATION1
Location 1 for debug.
|
static VersionENV |
VERSION
the version to use
|
Modifier and Type | Method and Description |
---|---|
void |
addDependanceListener(DependanceListener dl)
Add a dependence listener
|
boolean |
checkDirty(VirtualDB layer,
LayerData layerData,
long transId)
Check if this layer data needs to be reloaded
|
boolean |
checkDirty(VirtualDB layer,
long transId)
Check if this layer data needs to be reloaded
|
DBObject |
createDBObject(DataSource ds,
Hint hint)
Create a DBObject for this row
|
void |
dispose(DBObject theObject)
dispose of the object
|
static boolean |
doesClassListen(GlobalId classId)
Does this class Id listen ?
If we don't know anything about the class yet ie.
|
boolean |
existedAt(java.util.Date date)
Did this row exists at this date.
|
static DBData |
fetchKey(GlobalKey gk)
Find the raw data based on a Global Key
|
LayerData |
fetchLayerData(VirtualDB layer)
fetch the layer data for this record
|
static DBData |
find(long rowId,
DBClass requestedClass)
The only method of finding/creating a DBData
THREAD SAFE: This method must ensure that only one DBData per database
record ever exists.
|
static DBData |
find(long rowId,
DBClass requestedClass,
boolean create)
The only method of finding/creating a DBData
THREAD SAFE: This method must ensure that only one DBData per database
record ever exists.
|
static DBData |
find(long rowId,
GlobalKeyId rootClassId)
find
|
static DBData |
find(long rowId,
GlobalKeyId rootClassId,
boolean create)
find
|
int |
getBaseLayerId()
The base layer
|
static MemoryHandler.Cost |
getCost(DBClass dbClass)
the cost of the class
|
GlobalKey |
getGlobalKey(Hint hint)
The globalKey for this DBData.
|
GlobalKey |
getGlobalKey(VirtualDB layer,
DBField field,
Hint hint)
retrieve the global key for this field.
|
LayerData |
getLayerData(VirtualDB layer,
Hint hint)
Return the layer data for this record
|
long |
getLinkedRowId(VirtualDB layer,
DBField field,
Hint hint)
Get the linked row id if known.
|
java.lang.Object |
getRawValue(VirtualDB layer,
DBField field,
Hint hint)
Retrieves the raw data for the specified field
the supplied virtual db indicates how the object views the data for this field
We will scroll down the virtual db tree until we find a value for the field.
|
DBClass |
getRealDBClass(VirtualDB layer,
Hint hint)
Return the REAL DBClass if known else null.
|
GlobalKeyId |
getRootDBClassId()
The root class for this record
|
long |
getRowId()
The row id for this database object.
|
long |
getTransId(VirtualDB layer,
Hint hint)
The current transaction id for this database object.
|
static int |
getVersion()
The version being used.
|
boolean |
hasLayerDataLoaded(VirtualDB layer)
Have we loaded this layer
|
boolean |
hasRawFieldInLayer(VirtualDB layer,
DBField field,
Hint hint)
Does raw data for a field exist in this layer ? This ignores the final flag
as it is used for deleting data.
|
boolean |
hasRawRowInLayer(VirtualDB layer,
Hint hint)
Does raw data for a field exist in this layer ? This ignores the final flag
as it is used for deleting data.
|
static boolean |
isClassWatched(DBClass rootClass)
is this class watched ?
|
boolean |
isDeleted(VirtualDB layer,
Hint hint)
Is the database object deleted.
|
boolean |
isFinal(VirtualDB layer,
Hint hint)
Is this layer's data marked as final ?
No changes may be recorded for a record that is final from below.
|
boolean |
isLoaded(int layerID)
is loaded ?
|
boolean |
isLocked()
is this data locked in memory ?
|
static long[] |
listRowsInMemory(GlobalKeyId rootClassId)
list in memory rows for this class
|
static DBData |
load(DBObject obj,
long transId)
Load the DBData from an object just saved INTERNAL ONLY
|
void |
lock()
lock the record into memory
|
static boolean |
recordsLoaded(GlobalId classId)
Are any records for this class loaded ?
|
void |
register(DBObject theObject)
registers any objects that contain this data object
this allows us to notify these objects of any changes made to the data
Now that we have a initiated DBObject we can test to see if this class type is
a dependenceListener.
|
void |
reloadLayer(VirtualDB vDB)
Reloads this layer's data from the raw database.
|
static void |
reloadLayer(VirtualDB layer,
DBClass theClass,
long[] rowsToReload,
long transNr)
Reload the data for the layer that relates to the virtual database
|
static void |
removeSaveLock(MutableDataSource ds)
Remove all locks held by mutable data source.
|
static void |
simulateSlowLoad(int milliSecondsPerLoad,
DBData.SLOW_LOAD_LOCATION slowLocation)
simulate slow load
|
static void |
stats(StatsCollector collector)
The statistics
|
static void |
takeSaveLock(MutableDataSource ds,
DBObject[] list)
Prevent multiple saves of the same record within the one application.
|
void |
unlock()
remove the hard link on this record.
|
static void |
unlockAll(GlobalKeyId rootClassId)
unlock
|
public static final VersionENV VERSION
public static final int MAX_READ_AHEAD
public static final java.lang.String NOTIFY_CREATED
public static final java.lang.String NOTIFY_MODIFIED
public static final java.lang.String NOTIFY_DELETED
public static final int CACHE_LOAD_SEGMENTS
public static final int CACHE_COMPRESS_SIZE
public static final java.lang.String ENV_DATA_CLASSES_HIGH
public static final java.lang.String ENV_DATA_CLASSES_LOW
public static final java.util.concurrent.atomic.AtomicLong LINKAGE_FUSE
public final long rowId
public static final java.lang.String SLOW_LOAD_LOCATION1
public static final boolean SLOW_LOAD_ALLOWED
public static final java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.FutureTask<LayerData>> LOADING_MAP
@CheckReturnValue @Nonnull public GlobalKeyId getRootDBClassId()
getRootDBClassId
in interface DBDataInterface
public static void simulateSlowLoad(@Nonnegative int milliSecondsPerLoad, @Nullable DBData.SLOW_LOAD_LOCATION slowLocation)
milliSecondsPerLoad
- number of millisecondsslowLocation
- The place to cause the slowness@CheckReturnValue public boolean checkDirty(@Nonnull VirtualDB layer, @Nonnull LayerData layerData, @Nonnegative long transId)
layer
- layerData
- the current data.transId
- the transaction number to check@CheckReturnValue public boolean checkDirty(@Nonnull VirtualDB layer, @Nonnegative long transId)
layer
- the layer.transId
- the transaction number to checkpublic void lock()
@CheckReturnValue public boolean isLocked()
public static void unlockAll(@Nonnull GlobalKeyId rootClassId)
rootClassId
- the class@CheckReturnValue @Nonnull public static long[] listRowsInMemory(@Nonnull GlobalKeyId rootClassId)
rootClassId
- the classpublic void unlock()
@CheckReturnValue public DBClass getRealDBClass(@Nonnull VirtualDB layer, @Nullable Hint hint)
getRealDBClass
in interface DBDataInterface
layer
- The layerhint
- What other rows will be loaded.@CheckReturnValue @Nonnull public DBObject createDBObject(@Nonnull DataSource ds, @Nullable Hint hint) throws NotFoundException
ds
- The DataSource that the object will be created forhint
- The rows that will be loaded.NotFoundException
- The row was not found@CheckReturnValue public GlobalKey getGlobalKey(@Nullable Hint hint)
getGlobalKey
in interface DBDataInterface
hint
- If we need to hit the database, then also get these rows@CheckReturnValue @Nullable public java.lang.Object getRawValue(@Nonnull VirtualDB layer, @Nonnull DBField field, @Nullable Hint hint)
getRawValue
in interface DBDataInterface
layer
- Which layer.field
- The field to gethint
- Which other rows will we be asking for.@CheckReturnValue @Nullable public GlobalKey getGlobalKey(@Nonnull VirtualDB layer, @Nonnull DBField field, @Nullable Hint hint)
getGlobalKey
in interface DBDataInterface
layer
- Which layer.field
- The field to gethint
- Which other rows will we be asking for.@CheckReturnValue public long getLinkedRowId(@Nonnull VirtualDB layer, @Nonnull DBField field, @Nullable Hint hint)
getLinkedRowId
in interface DBDataInterface
layer
- Which layer.field
- The field to gethint
- Which other rows will we be asking for.public static void reloadLayer(@Nonnull VirtualDB layer, @Nonnull DBClass theClass, @Nonnull long[] rowsToReload, @Nonnegative long transNr) throws java.lang.Exception
rowsToReload
- The list of rows to loadtransNr
- The transaction that we need to loadlayer
- Which layertheClass
- The class of the records.java.lang.Exception
- A serious problem occurred.public void reloadLayer(@Nonnull VirtualDB vDB) throws java.lang.Exception
reloadLayer
in interface DBDataInterface
vDB
- For which layerjava.lang.Exception
- A serious problem.@CheckReturnValue public long getRowId()
getRowId
in interface DBDataInterface
@CheckReturnValue public long getTransId(@Nonnull VirtualDB layer, @Nullable Hint hint)
getTransId
in interface DBDataInterface
layer
- Which layerhint
- What other rows.@CheckReturnValue public boolean isDeleted(@Nonnull VirtualDB layer, @Nullable Hint hint)
isDeleted
in interface DBDataInterface
layer
- In which layer ?hint
- What other rows will you be asking about@CheckReturnValue public boolean isLoaded(@Nonnegative int layerID)
layerID
- the layerpublic static void takeSaveLock(@Nonnull MutableDataSource ds, @Nonnull DBObject[] list) throws TimeoutException
ds
- The saving data sourcelist
- The universe of objects to be saved.TimeoutException
public static void removeSaveLock(@Nonnull MutableDataSource ds)
ds
- The datasource to remove all locks for.public void dispose(@Nonnull DBObject theObject)
theObject
- to disposepublic void register(@Nonnull DBObject theObject)
register
in interface DBDataInterface
theObject
- to notify@Nonnull public static DBData load(@Nonnull DBObject obj, @Nonnegative long transId) throws java.lang.Exception
obj
- The object just saved.transId
- The transaction id for which it was saved.java.lang.Exception
- A serious problem@CheckReturnValue public boolean hasLayerDataLoaded(@Nonnull VirtualDB layer)
layer
- The layer@CheckReturnValue @Nullable public LayerData fetchLayerData(@Nonnull VirtualDB layer)
layer
- From which layer@CheckReturnValue @Nonnull public LayerData getLayerData(@Nonnull VirtualDB layer, @Nullable Hint hint)
getLayerData
in interface DBDataInterface
layer
- From which layerhint
- What other records will you be askingpublic void addDependanceListener(@Nonnull DependanceListener dl)
addDependanceListener
in interface DBDataInterface
dl
- The listener@CheckReturnValue public static boolean doesClassListen(@Nullable GlobalId classId)
classId
- Does this class listen ?@CheckReturnValue public static boolean isClassWatched(@Nonnull DBClass rootClass)
rootClass
- the root class@CheckReturnValue public static boolean recordsLoaded(@Nullable GlobalId classId)
classId
- Are records for this class loaded ?@CheckReturnValue public boolean hasRawFieldInLayer(@Nonnull VirtualDB layer, @Nonnull DBField field, @Nullable Hint hint)
hasRawFieldInLayer
in interface DBDataInterface
layer
- From which layer.field
- The fieldhint
- Which other rows.@CheckReturnValue @Nullable public static DBData fetchKey(@Nonnull GlobalKey gk)
gk
- The key to search for.@CheckReturnValue public boolean hasRawRowInLayer(@Nonnull VirtualDB layer, @Nullable Hint hint)
hasRawRowInLayer
in interface DBDataInterface
layer
- From which layerhint
- Which other rows.@CheckReturnValue public boolean isFinal(@Nonnull VirtualDB layer, @Nullable Hint hint)
isFinal
in interface DBDataInterface
layer
- From which layer.hint
- What other rows.@CheckReturnValue @Nullable public static DBData find(long rowId, @Nonnull DBClass requestedClass, boolean create) throws NotFoundException
requestedClass
- The class of the DBData.create
- Should we create the DBData if not found.rowId
- The row id of the record.NotFoundException
- If the row id for this DBClass is not found.@CheckReturnValue @Nonnull public static DBData find(long rowId, @Nonnull DBClass requestedClass) throws NotFoundException
requestedClass
- The class of the DBData.rowId
- The row id of the record.NotFoundException
- If the row id for this DBClass is not found.@CheckReturnValue @Nonnull public static MemoryHandler.Cost getCost(@Nonnull DBClass dbClass)
dbClass
- the class@Nonnull @CheckReturnValue public static DBData find(long rowId, @Nonnull GlobalKeyId rootClassId) throws NotFoundException
rowId
- the rowrootClassId
- the classNotFoundException
- not found@Nullable @CheckReturnValue public static DBData find(long rowId, @Nonnull GlobalKeyId rootClassId, boolean create) throws NotFoundException
rowId
- the rowrootClassId
- the classcreate
- create if not foundNotFoundException
- not found@CheckReturnValue public boolean existedAt(@Nonnull java.util.Date date)
date
- The as of datepublic static void stats(@Nonnull StatsCollector collector)
collector
- the collector@CheckReturnValue public static int getVersion()
@CheckReturnValue public int getBaseLayerId()
getBaseLayerId
in interface DBDataInterface
stSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.