Java Doc for GarbageCollector.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » Ozone 1.1 » org.ozoneDB.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.ozoneDB.core.ServerComponent
      org.ozoneDB.core.GarbageCollector

GarbageCollector
public class GarbageCollector extends ServerComponent implements Runnable(Code)
Marks reachable objects and sweeps unreachable objects.
This implementation has at least following deficiencies:
  • Method invocation observation is limited to the direct method parameters and the return value. A correct implementation should observe not only method parameters and return values but all objects which are reachable from these objects.
  • Currently, the implementation is not scaleable, because the list GarbageCollector.surelyReachableObjectsWhichHaveToBeMarkedAsSuch may grow to the count of objects. Possible solutions are:
    • Export some contents of this stack to disk. This seems to be highly efficient, because the "hot spot" of the corresponding file always would be the end of the file.
    • Simply forget entries if they are too much. Work through the whole list until it is empty. Once the list is empty, walk through all objects to refill this list and continue. This approach has some appeals, but seems to be element of O(n^2) for large databases because there would be n*c1 walks trough 1/2*n objects each walk.

author:
   Xuân Baldauf (Medium.net

Inner Class :public class GarbageCollectorProxyObjectIdentificationObjectOutputStream extends ObjectOutputStream

Field Summary
final protected static  intPHASE_IDLE
    
final protected static  intPHASE_MARKING
    
final protected static  intPHASE_MARKING2
    
final protected static  intPHASE_READY_TO_START
    
final protected static  intPHASE_RUN_INITIATED
    
final protected static  intPHASE_SWEEPING
    
final protected static  intPHASE_WAITING_FOR_NEW_TRANSACTIONS_TO_COMPLETE
    
final protected static  intPHASE_WAITING_FOR_OLD_TRANSACTIONS_TO_COMPLETE
    
protected  intactionsWithinTransactionCount
     The count of actions which were done within this garbageCollector.
protected  intcurrentGarbageCollectionLevel
     The number which represents the current garbage collection run. This number is the number mentioned in org.ozoneDB.core.wizardStore.WizardObjectContainer.garbageCollectionLevel . There are tree sets of database objects
  • probablyReachable: These objects may or may not be reachable.
protected  intdoneReachableGarbageCollectionLevel
     The garbageCollectionLevel which objects have if they belong to the doneReachable set.
protected  ObjectgarbageCollectionLevelsLock
     This is the lock that everybody has to be synchronized to in order to be able to access any garbageCollectionLevel in any object within this database.
protected  ThreadgarbageCollectionThread
     The thread which actually does the work.
protected  booleankill
     Wether we should stop running as soon as possible.
protected  intphase
     The current phase this GarbageCollector is in.
protected  SimpleArrayListsurelyReachableObjectsWhichHaveToBeMarkedAsSuch
     A stack of ObjectIDs of objects, which are surely reachable, but still were not marked as such.
protected  LinkedListsurelyReachableObjectsWhichShouldHaveBeenProcessedButWereLockContented
     The list of ObjectIDs of objects which are surelyReachable and already were tried to be processed but where locking the objects failed.
protected  Transactiontransaction
     The current transaction of this garbageCollector.
protected  HashSettransactionsRequiredToComplete
     The list of Transaction s, which have to be completed before the GarbageCollector may start.

Constructor Summary
protected  GarbageCollector(Env env)
     Creates a new garbage collector.

Method Summary
protected  voidaddAllNamedObjectsToSurelyReachableSet()
     This method walks through all named objects and adds each of them to the surelyReachable set.
protected  voidaddObjectIDToSurelyReachableObjectsWhichHaveToBeMarkedAsSuch(ObjectID id)
     This method may be called both from transaction threads and from GarbageCollector-Threads.
protected  voidaddRootSetElementsToSurelyReachableSet()
    
public  voidaddTransactionRequiredToComplete(Object ta)
    
protected  voidcheckForEndOfWaitForCurrentTransactionsToCompletePhase()
    
protected  voidcheckForProxyBorderCross(Object o)
     This method checks wether the given object or the object graph reachable from this given object contains OzoneProxys.
protected  voidcheckForProxyBorderCross(OzoneProxy o)
     This method checks wether the given object or the object graph reachable from this given object contains OzoneProxys.
protected  voidcheckForProxyBorderCross(OzoneCompatible o)
     This method checks wether the given object or the object graph reachable from this given object contains OzoneProxys.
protected  voidcompleteTransaction()
     Completes the current transaction and releases it.
protected  voiddeferProcessingOfObjectContainerDueToLockContention(ObjectContainer objectContainer)
     Defers the processing of the given objectContainer because locking was not possible at current time.
protected  voidensureDoneReachable(ObjectContainer objectContainer)
     Ensures that the given object is doneReachable.
protected  voidensureSurelyReachable(ObjectID id)
     Calling this method makes sure that the object which is referenced by the given ID is at least surely reachable.
protected  voidensureSurelyReachable(ObjectContainer objectContainer)
     Calling this method makes sure that the object which is referenced by the given ID is at least surely reachable.
protected  voidincCurrentGarbageCollectorLevel()
    
public  voidinterceptInvocationPost(Transaction transaction, ObjectContainer callee, Object result)
     This method is called by Transactions to indicate that a method of the object callee was called by the transaction.
public  voidinterceptInvocationPre(Transaction transaction, ObjectContainer callee, Object[] args)
     This method is called by Transactions to indicate that a method of the object callee will be called by the transaction.
protected  voidinternalAbortTransaction(Transaction transaction)
    
protected  voidinternalCompleteTransaction(Transaction transaction)
    
protected  voidinternalEnsureDoneReachable(ObjectContainer objectContainer)
     Internally ensures that the given object is doneReachable.
protected  intinternalEnsureSurelyReachable(ObjectContainer objectContainer)
     Internally ensures that the given object is at least surelyReachable. <0 if this object has been updated.
protected  voidinternalFinishTransaction(Transaction transaction)
    
protected  booleanisRunning()
     Returns wether this GarbageCollector is running.
protected  voidnotifyAboutTransactionActionAndRenewTransactionIfRequired()
    
public  voidnotifyDatabaseObjectIsAboutToBeExported(ObjectID id)
     This method is called by DbInvokeClient to notify this garbageCollector that there is a reference which is to be exported to a client.
public  voidnotifyDatabaseObjectIsExported(ObjectID id)
    
protected  voidnotifyEndOfWaitForCurrentTransactionsToCompletePhase()
     Informs this GarbageCollector, the the pre-phase is done, there are no transactions that are older than this garbage collector run.
public  voidnotifyNamedObject(ObjectID id)
     This method is called by StoreManager to indicate that the object with the given id is a named object.
public  voidnotifyNewObjectContainer(ObjectContainer objectContainer)
     This method is called by StoreManager in the event an object is freshly created.
public  voidnotifyNewObjectName(ObjectContainer objectContainer)
     This method is called by StoreManager in the event an unnamed object receives a name.
protected  voidprocessObjectContainerWhichWantsToBeSurelyReachableAndUnpin(Transaction transaction, ObjectContainer objectContainer)
     Processes an ObjectContainer which possibly has not already been registered as surely reachable.
protected  voidprocessReferencesByThisObject(Transaction transaction, ObjectContainer objectContainer)
     Determines all references which are "contained" within the given object, adds them to the list of GarbageCollector.surelyReachableObjectsWhichHaveToBeMarkedAsSuch and then marks the given object as doneReachable.
protected  voidprocessSurelyReachableObjectsWhichHaveToBeMarkedAsSuch()
     This is the "main()" method of the mark phase.
public  voidremoveTransactionRequiredToComplete(Transaction ta)
    
protected  voidrenewTransactionIfRequired()
     Checks wether the current transaction has to be committed (because it accumulated too much changes) and if so, commits it and closes it.
public  voidrun()
     The main method for garbage collection.
public  voidsave()
    
protected  voidsetCurrentGarbageCollectionLevel(int to)
    
protected synchronized  voidsetPhase(int to)
    
public  voidshutdown()
    
public  voidstart()
     Starts the garbage collection process.
protected  voidstartFilterDatabaseObjectReferencesAtExternalDatabaseGates()
    
public  voidstartup()
    
protected  voidsweepUnreachableObjects()
     Sweeps all objects which are considered unreachable.
protected synchronized  voidwaitForPhase(int newPhase)
    

Field Detail
PHASE_IDLE
final protected static int PHASE_IDLE(Code)
Doing nothing



PHASE_MARKING
final protected static int PHASE_MARKING(Code)
We are started, we are marking all reachable objects



PHASE_MARKING2
final protected static int PHASE_MARKING2(Code)
We are started, we are marking all reachable objects



PHASE_READY_TO_START
final protected static int PHASE_READY_TO_START(Code)
We may start, all old transactions are complete



PHASE_RUN_INITIATED
final protected static int PHASE_RUN_INITIATED(Code)
A run has been initiated



PHASE_SWEEPING
final protected static int PHASE_SWEEPING(Code)
We are started, we are sweeping all unreachable objects



PHASE_WAITING_FOR_NEW_TRANSACTIONS_TO_COMPLETE
final protected static int PHASE_WAITING_FOR_NEW_TRANSACTIONS_TO_COMPLETE(Code)
Waiting for the old transactions to complete



PHASE_WAITING_FOR_OLD_TRANSACTIONS_TO_COMPLETE
final protected static int PHASE_WAITING_FOR_OLD_TRANSACTIONS_TO_COMPLETE(Code)
Waiting for the old transactions to complete



actionsWithinTransactionCount
protected int actionsWithinTransactionCount(Code)
The count of actions which were done within this garbageCollector.



currentGarbageCollectionLevel
protected int currentGarbageCollectionLevel(Code)
The number which represents the current garbage collection run. This number is the number mentioned in org.ozoneDB.core.wizardStore.WizardObjectContainer.garbageCollectionLevel . There are tree sets of database objects
  • probablyReachable: These objects may or may not be reachable. Their garbageCollectionLevel is below the currentGarbageCollectionLevel
  • surelyReachable: These objects have been reached during the walk. Their garbageCollectionLevel is currentGarbageCollectionLevel
  • doneReachable: These object have been processed for members. All their members are surelyReachable or better. Their garbageCollectionLevel is currentGarbageCollectionLevel+1



doneReachableGarbageCollectionLevel
protected int doneReachableGarbageCollectionLevel(Code)
The garbageCollectionLevel which objects have if they belong to the doneReachable set. This is GarbageCollector.currentGarbageCollectionLevel +1



garbageCollectionLevelsLock
protected Object garbageCollectionLevelsLock(Code)
This is the lock that everybody has to be synchronized to in order to be able to access any garbageCollectionLevel in any object within this database.



garbageCollectionThread
protected Thread garbageCollectionThread(Code)
The thread which actually does the work.



kill
protected boolean kill(Code)
Wether we should stop running as soon as possible. Synchronization is not required, because it does not matter wether we receive this signal soon or later.



phase
protected int phase(Code)
The current phase this GarbageCollector is in. Access only within synchronization to this object.



surelyReachableObjectsWhichHaveToBeMarkedAsSuch
protected SimpleArrayList surelyReachableObjectsWhichHaveToBeMarkedAsSuch(Code)
A stack of ObjectIDs of objects, which are surely reachable, but still were not marked as such. Access only during synchronization on it.



surelyReachableObjectsWhichShouldHaveBeenProcessedButWereLockContented
protected LinkedList surelyReachableObjectsWhichShouldHaveBeenProcessedButWereLockContented(Code)
The list of ObjectIDs of objects which are surelyReachable and already were tried to be processed but where locking the objects failed. The processing the contents of this list should be retried some times later. To minimize overhead, access is only allowed during synchronization to GarbageCollector.surelyReachableObjectsWhichHaveToBeMarkedAsSuch



transaction
protected Transaction transaction(Code)
The current transaction of this garbageCollector.



transactionsRequiredToComplete
protected HashSet transactionsRequiredToComplete(Code)
The list of Transaction s, which have to be completed before the GarbageCollector may start. It may not start earlier because the rollback of those transaction may make objects live which were believed to be dead.




Constructor Detail
GarbageCollector
protected GarbageCollector(Env env)(Code)
Creates a new garbage collector.




Method Detail
addAllNamedObjectsToSurelyReachableSet
protected void addAllNamedObjectsToSurelyReachableSet()(Code)
This method walks through all named objects and adds each of them to the surelyReachable set.



addObjectIDToSurelyReachableObjectsWhichHaveToBeMarkedAsSuch
protected void addObjectIDToSurelyReachableObjectsWhichHaveToBeMarkedAsSuch(ObjectID id)(Code)
This method may be called both from transaction threads and from GarbageCollector-Threads.



addRootSetElementsToSurelyReachableSet
protected void addRootSetElementsToSurelyReachableSet()(Code)



addTransactionRequiredToComplete
public void addTransactionRequiredToComplete(Object ta)(Code)



checkForEndOfWaitForCurrentTransactionsToCompletePhase
protected void checkForEndOfWaitForCurrentTransactionsToCompletePhase()(Code)



checkForProxyBorderCross
protected void checkForProxyBorderCross(Object o)(Code)
This method checks wether the given object or the object graph reachable from this given object contains OzoneProxys. If so, the database objects referenced by these proxies are considered surelyReachable.



checkForProxyBorderCross
protected void checkForProxyBorderCross(OzoneProxy o)(Code)
This method checks wether the given object or the object graph reachable from this given object contains OzoneProxys. If so, the database objects referenced by these proxies are considered surelyReachable.



checkForProxyBorderCross
protected void checkForProxyBorderCross(OzoneCompatible o)(Code)
This method checks wether the given object or the object graph reachable from this given object contains OzoneProxys. If so, the database objects referenced by these proxies are considered surelyReachable.



completeTransaction
protected void completeTransaction() throws IOException, ClassNotFoundException(Code)
Completes the current transaction and releases it.



deferProcessingOfObjectContainerDueToLockContention
protected void deferProcessingOfObjectContainerDueToLockContention(ObjectContainer objectContainer)(Code)
Defers the processing of the given objectContainer because locking was not possible at current time. Because objectContainers may be modified in the meantime (in the case they are unloaded and loaded again, we would hold an old copy of objectContainer which does not reflect the changes made to the new objectContainer), it's not wise to queue the ObjectContainer. Instead, we have to queue the ObjectID of that ObjectContainer.



ensureDoneReachable
protected void ensureDoneReachable(ObjectContainer objectContainer)(Code)
Ensures that the given object is doneReachable.



ensureSurelyReachable
protected void ensureSurelyReachable(ObjectID id)(Code)
Calling this method makes sure that the object which is referenced by the given ID is at least surely reachable.



ensureSurelyReachable
protected void ensureSurelyReachable(ObjectContainer objectContainer)(Code)
Calling this method makes sure that the object which is referenced by the given ID is at least surely reachable. This method is called by non-GarbageCollector-Threads.



incCurrentGarbageCollectorLevel
protected void incCurrentGarbageCollectorLevel()(Code)



interceptInvocationPost
public void interceptInvocationPost(Transaction transaction, ObjectContainer callee, Object result)(Code)
This method is called by Transactions to indicate that a method of the object callee was called by the transaction. This method will always be called, even if the GarbageCollector is not startet.



interceptInvocationPre
public void interceptInvocationPre(Transaction transaction, ObjectContainer callee, Object[] args)(Code)
This method is called by Transactions to indicate that a method of the object callee will be called by the transaction. This method will always be called, even if the GarbageCollector is not startet.



internalAbortTransaction
protected void internalAbortTransaction(Transaction transaction) throws IOException, ClassNotFoundException(Code)



internalCompleteTransaction
protected void internalCompleteTransaction(Transaction transaction) throws IOException, ClassNotFoundException(Code)



internalEnsureDoneReachable
protected void internalEnsureDoneReachable(ObjectContainer objectContainer)(Code)
Internally ensures that the given object is doneReachable.



internalEnsureSurelyReachable
protected int internalEnsureSurelyReachable(ObjectContainer objectContainer)(Code)
Internally ensures that the given object is at least surelyReachable. <0 if this object has been updated. If this is the case, this object has to join a transaction which will complete successfully.=0 if this object has not been updated, it is surelyReachable>0 if this object has not been updated, it is processedReachable



internalFinishTransaction
protected void internalFinishTransaction(Transaction transaction) throws IOException, ClassNotFoundException(Code)



isRunning
protected boolean isRunning()(Code)
Returns wether this GarbageCollector is running. This method must be called during synchronization on this GarbageCollector.



notifyAboutTransactionActionAndRenewTransactionIfRequired
protected void notifyAboutTransactionActionAndRenewTransactionIfRequired() throws IOException, ClassNotFoundException, TransactionExc(Code)



notifyDatabaseObjectIsAboutToBeExported
public void notifyDatabaseObjectIsAboutToBeExported(ObjectID id)(Code)
This method is called by DbInvokeClient to notify this garbageCollector that there is a reference which is to be exported to a client.



notifyDatabaseObjectIsExported
public void notifyDatabaseObjectIsExported(ObjectID id)(Code)



notifyEndOfWaitForCurrentTransactionsToCompletePhase
protected void notifyEndOfWaitForCurrentTransactionsToCompletePhase()(Code)
Informs this GarbageCollector, the the pre-phase is done, there are no transactions that are older than this garbage collector run.



notifyNamedObject
public void notifyNamedObject(ObjectID id)(Code)
This method is called by StoreManager to indicate that the object with the given id is a named object.



notifyNewObjectContainer
public void notifyNewObjectContainer(ObjectContainer objectContainer)(Code)
This method is called by StoreManager in the event an object is freshly created.



notifyNewObjectName
public void notifyNewObjectName(ObjectContainer objectContainer)(Code)
This method is called by StoreManager in the event an unnamed object receives a name. This is the case if an object which was formerly unnamed gets a name.



processObjectContainerWhichWantsToBeSurelyReachableAndUnpin
protected void processObjectContainerWhichWantsToBeSurelyReachableAndUnpin(Transaction transaction, ObjectContainer objectContainer)(Code)
Processes an ObjectContainer which possibly has not already been registered as surely reachable. // This method may be called by any CommandThread. This method may be called only by the garbage collector thread.



processReferencesByThisObject
protected void processReferencesByThisObject(Transaction transaction, ObjectContainer objectContainer)(Code)
Determines all references which are "contained" within the given object, adds them to the list of GarbageCollector.surelyReachableObjectsWhichHaveToBeMarkedAsSuch and then marks the given object as doneReachable. This method may be called by any CommandThread.



processSurelyReachableObjectsWhichHaveToBeMarkedAsSuch
protected void processSurelyReachableObjectsWhichHaveToBeMarkedAsSuch()(Code)
This is the "main()" method of the mark phase.



removeTransactionRequiredToComplete
public void removeTransactionRequiredToComplete(Transaction ta)(Code)



renewTransactionIfRequired
protected void renewTransactionIfRequired() throws IOException, ClassNotFoundException, TransactionExc(Code)
Checks wether the current transaction has to be committed (because it accumulated too much changes) and if so, commits it and closes it. Afterwards (or if there has not been a current transaction already), it creates a new current transaction.



run
public void run()(Code)
The main method for garbage collection.



save
public void save()(Code)



setCurrentGarbageCollectionLevel
protected void setCurrentGarbageCollectionLevel(int to)(Code)



setPhase
protected synchronized void setPhase(int to)(Code)



shutdown
public void shutdown()(Code)



start
public void start()(Code)
Starts the garbage collection process.



startFilterDatabaseObjectReferencesAtExternalDatabaseGates
protected void startFilterDatabaseObjectReferencesAtExternalDatabaseGates()(Code)



startup
public void startup()(Code)



sweepUnreachableObjects
protected void sweepUnreachableObjects()(Code)
Sweeps all objects which are considered unreachable.



waitForPhase
protected synchronized void waitForPhase(int newPhase) throws InterruptedException(Code)



Fields inherited from org.ozoneDB.core.ServerComponent
protected transient Env env(Code)(Java Doc)

Methods inherited from org.ozoneDB.core.ServerComponent
public synchronized void clearChanged()(Code)(Java Doc)
public boolean hasChanged()(Code)(Java Doc)
abstract public void save() throws Exception(Code)(Java Doc)
public synchronized void setChanged()(Code)(Java Doc)
abstract public void shutdown() throws Exception(Code)(Java Doc)
abstract public void startup() throws Exception(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.