Java Doc for AbstractStore.java in  » Database-DBMS » mckoi » com » mckoi » store » 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 » mckoi » com.mckoi.store 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.mckoi.store.AbstractStore

All known Subclasses:   com.mckoi.store.JournalledFileStore,
AbstractStore
abstract public class AbstractStore implements Store(Code)
Provides an abstract implementation of Store. This implements a bin based best-fit recycling algorithm. The store manages a structure that points to bins of freed space of specific sizes. When an allocation is requested the structure is searched for the first bin that contains an area that best fits the size requested.

Provided the derived class supports safe atomic IO operations, this store is designed for robustness to the level that at no point is the store left in a unworkable (corrupt) state.
author:
   Tobias Downer


Inner Class :static class AreaOutputStream extends OutputStream

Field Summary
final protected static  longBIN_AREA_OFFSET
     The offset into the file that the bin area starts.
final protected static  intBIN_ENTRIES
    
final protected static  longDATA_AREA_OFFSET
     The offset into the file that the data areas start.
final protected static  longFIXED_AREA_OFFSET
     The offset into the file of the 64 byte fixed area.
final protected static  intMAGIC
     The magic value.
protected  long[]free_bin_list
     The free bin list contains 128 entries pointing to the first available block in the bin.
final protected  byte[]header_buf
    
protected  booleanread_only
     True if this is read-only.
protected  longtotal_allocated_space
     The total amount of allocated space within this store since the store was openned.
protected  longwilderness_pointer
     A pointer to the wilderness area (the last deleted area in the store), or -1 if there is no wilderness area.

Constructor Summary
protected  AbstractStore(boolean read_only)
     Constructs the store.

Method Summary
protected  voidcheckPointer(long pointer)
     Checks the pointer is valid.
public synchronized  voidclose()
     Closes the store.
protected  voidcoalescArea(long pointer, long size)
     Coalesc one or more areas into a larger area.
public synchronized  AreaWritercreateArea(long size)
    
public synchronized  voiddeleteArea(long id)
    
abstract protected  longendOfDataAreaPointer()
     Returns a pointer to the end of the current data area.
protected  longexpandDataArea(long minimum_size)
     Expands the data area by at least the minimum size given.
public  ArrayListfindAllocatedAreasNotIn(ArrayList list)
     Scans the area list, and any areas that aren't deleted and aren't found in the given ArrayList are returned as leaked areas.
public  ListgetAllAreas()
     Returns a List of Long objects that contain a complete list of all areas in the store.
public  AreagetArea(long id)
    
protected  voidgetAreaHeader(long pointer, long[] header)
     Sets the 'header' array with information from the header of the given pointer.
public  InputStreamgetAreaInputStream(long id)
    
public  MutableAreagetMutableArea(long id)
    
protected  longgetNextAreaHeader(long pointer, long[] header)
     Sets the 'header' array with information from the next header to the given pointer, and returns a pointer to the next area.
protected  longgetPreviousAreaHeader(long pointer, long[] header)
     Sets the 'header' array with information from the previous header to the given pointer, and returns a pointer to the previous area.
abstract protected  voidinternalClose()
     Internally closes the backing area.
abstract protected  voidinternalOpen(boolean read_only)
     Internally opens the backing area.
protected static  booleanisValidBoundarySize(long size)
     Returns true if the given area size is valid.
public  booleanlastCloseClean()
    
public synchronized  booleanopen()
     Opens the data store.
public synchronized  voidopenScanAndFix(UserTerminal terminal)
     Opens/scans the store looking for any errors with the layout.
protected  voidreadBins()
     Reads the bins from the header information in the file.
abstract protected  intreadByteArrayFrom(long position, byte[] buf, int off, int len)
     Reads a byte array from the given position in the file.
abstract protected  intreadByteFrom(long position)
     Reads a byte from the given position in the file.
protected  voidreboundArea(long pointer, long[] header, boolean write_headers)
     Rebounds the given area with the given header information.
abstract protected  voidsetDataAreaSize(long length)
     Sets the size of the data area.
protected  voidsplitArea(long pointer, long new_boundary)
     Splits an area pointed to by 'pointer' at a new boundary point.
public synchronized  voidstatsScan(HashMap properties)
     Performs an extensive lookup on all the tables in this store and sets a number of properties in the given HashMap (property name(String) -> property description(Object)).
public synchronized  longtotalAllocatedSinceStart()
     Returns the total allocated space since the file was openned.
protected  voidwriteAllBins()
     Updates all bins to the data area header area.
protected  voidwriteBinIndex(int index)
     Updates the given bin index to the data area header area.
abstract protected  voidwriteByteArrayTo(long position, byte[] buf, int off, int len)
     Writes a byte array to the given position in the file.
abstract protected  voidwriteByteTo(long position, int b)
     Writes a byte to the given position in the file.

Field Detail
BIN_AREA_OFFSET
final protected static long BIN_AREA_OFFSET(Code)
The offset into the file that the bin area starts.



BIN_ENTRIES
final protected static int BIN_ENTRIES(Code)



DATA_AREA_OFFSET
final protected static long DATA_AREA_OFFSET(Code)
The offset into the file that the data areas start.



FIXED_AREA_OFFSET
final protected static long FIXED_AREA_OFFSET(Code)
The offset into the file of the 64 byte fixed area.



MAGIC
final protected static int MAGIC(Code)
The magic value.



free_bin_list
protected long[] free_bin_list(Code)
The free bin list contains 128 entries pointing to the first available block in the bin. If the list item contains -1 then there are no free blocks in the bin.



header_buf
final protected byte[] header_buf(Code)



read_only
protected boolean read_only(Code)
True if this is read-only.



total_allocated_space
protected long total_allocated_space(Code)
The total amount of allocated space within this store since the store was openned. Note that this could be a negative amount if more space was freed than allocated.



wilderness_pointer
protected long wilderness_pointer(Code)
A pointer to the wilderness area (the last deleted area in the store), or -1 if there is no wilderness area.




Constructor Detail
AbstractStore
protected AbstractStore(boolean read_only)(Code)
Constructs the store.




Method Detail
checkPointer
protected void checkPointer(long pointer) throws IOException(Code)
Checks the pointer is valid.



close
public synchronized void close() throws IOException(Code)
Closes the store.



coalescArea
protected void coalescArea(long pointer, long size) throws IOException(Code)
Coalesc one or more areas into a larger area. This alters the boundary of the area to encompass the given size.



createArea
public synchronized AreaWriter createArea(long size) throws IOException(Code)



deleteArea
public synchronized void deleteArea(long id) throws IOException(Code)



endOfDataAreaPointer
abstract protected long endOfDataAreaPointer() throws IOException(Code)
Returns a pointer to the end of the current data area.



expandDataArea
protected long expandDataArea(long minimum_size) throws IOException(Code)
Expands the data area by at least the minimum size given. Returns the actual size the data area was expanded by.



findAllocatedAreasNotIn
public ArrayList findAllocatedAreasNotIn(ArrayList list) throws IOException(Code)
Scans the area list, and any areas that aren't deleted and aren't found in the given ArrayList are returned as leaked areas. This is a useful method for finding any leaks in the store.



getAllAreas
public List getAllAreas() throws IOException(Code)
Returns a List of Long objects that contain a complete list of all areas in the store. This is useful for checking if a given pointer is valid or not. The returned list is sorted from start area to end area.



getArea
public Area getArea(long id) throws IOException(Code)



getAreaHeader
protected void getAreaHeader(long pointer, long[] header) throws IOException(Code)
Sets the 'header' array with information from the header of the given pointer.



getAreaInputStream
public InputStream getAreaInputStream(long id) throws IOException(Code)



getMutableArea
public MutableArea getMutableArea(long id) throws IOException(Code)



getNextAreaHeader
protected long getNextAreaHeader(long pointer, long[] header) throws IOException(Code)
Sets the 'header' array with information from the next header to the given pointer, and returns a pointer to the next area.



getPreviousAreaHeader
protected long getPreviousAreaHeader(long pointer, long[] header) throws IOException(Code)
Sets the 'header' array with information from the previous header to the given pointer, and returns a pointer to the previous area.



internalClose
abstract protected void internalClose() throws IOException(Code)
Internally closes the backing area.



internalOpen
abstract protected void internalOpen(boolean read_only) throws IOException(Code)
Internally opens the backing area. If 'read_only' is true then the store is openned in read only mode.



isValidBoundarySize
protected static boolean isValidBoundarySize(long size)(Code)
Returns true if the given area size is valid. Currently the criteria for a valid boundary size is (size >= 24) and (size % 8 == 0) and (size < 200 gigabytes)



lastCloseClean
public boolean lastCloseClean()(Code)



open
public synchronized boolean open() throws IOException(Code)
Opens the data store. Returns true if the store did not close cleanly.



openScanAndFix
public synchronized void openScanAndFix(UserTerminal terminal) throws IOException(Code)
Opens/scans the store looking for any errors with the layout. If a problem with the store is detected, it attempts to fix it.



readBins
protected void readBins() throws IOException(Code)
Reads the bins from the header information in the file.



readByteArrayFrom
abstract protected int readByteArrayFrom(long position, byte[] buf, int off, int len) throws IOException(Code)
Reads a byte array from the given position in the file. Returns the number of bytes read.



readByteFrom
abstract protected int readByteFrom(long position) throws IOException(Code)
Reads a byte from the given position in the file.



reboundArea
protected void reboundArea(long pointer, long[] header, boolean write_headers) throws IOException(Code)
Rebounds the given area with the given header information. If 'write_headers' is true, the header (header[0]) is changed. Note that this shouldn't be used to change the size of a chunk.



setDataAreaSize
abstract protected void setDataAreaSize(long length) throws IOException(Code)
Sets the size of the data area.



splitArea
protected void splitArea(long pointer, long new_boundary) throws IOException(Code)
Splits an area pointed to by 'pointer' at a new boundary point.



statsScan
public synchronized void statsScan(HashMap properties) throws IOException(Code)
Performs an extensive lookup on all the tables in this store and sets a number of properties in the given HashMap (property name(String) -> property description(Object)). This should be used for store diagnostics.

Assume the store is open.




totalAllocatedSinceStart
public synchronized long totalAllocatedSinceStart()(Code)
Returns the total allocated space since the file was openned.



writeAllBins
protected void writeAllBins() throws IOException(Code)
Updates all bins to the data area header area.



writeBinIndex
protected void writeBinIndex(int index) throws IOException(Code)
Updates the given bin index to the data area header area.



writeByteArrayTo
abstract protected void writeByteArrayTo(long position, byte[] buf, int off, int len) throws IOException(Code)
Writes a byte array to the given position in the file.



writeByteTo
abstract protected void writeByteTo(long position, int b) throws IOException(Code)
Writes a byte to the given position in the file.



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.