Source Code Cross Referenced for TempRAFContainer.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » raw » data » 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 » db derby 10.2 » org.apache.derby.impl.store.raw.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.raw.data.TempRAFContainer
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.store.raw.data;
023:
024:        import org.apache.derby.impl.store.raw.data.BaseContainerHandle;
025:        import org.apache.derby.impl.store.raw.data.BasePage;
026:
027:        import org.apache.derby.iapi.services.cache.Cacheable;
028:        import org.apache.derby.iapi.services.sanity.SanityManager;
029:
030:        import org.apache.derby.iapi.error.StandardException;
031:        import org.apache.derby.iapi.store.raw.xact.RawTransaction;
032:        import org.apache.derby.iapi.store.raw.ContainerHandle;
033:        import org.apache.derby.iapi.store.raw.ContainerKey;
034:        import org.apache.derby.iapi.store.raw.Page;
035:        import org.apache.derby.iapi.store.raw.log.LogInstant;
036:        import org.apache.derby.iapi.store.raw.data.RawContainerHandle;
037:
038:        import org.apache.derby.io.StorageFactory;
039:        import org.apache.derby.io.StorageFile;
040:
041:        import java.io.IOException;
042:
043:        /**
044:         needsSync is never true - DONE
045:         An exception never marks the store as corrupt
046:         clean() does not stubbify
047:         preAllocate() does nothing - DONE
048:         getFileName() returns a file in the tmp directory - DONE
049:         flushAll does nothing - DONE
050:         file descriptor is never synced
051:         */
052:        class TempRAFContainer extends RAFContainer {
053:
054:            protected int inUseCount;
055:
056:            TempRAFContainer(BaseDataFileFactory factory) {
057:                super (factory);
058:            }
059:
060:            /**
061:            	@exception StandardException Standard Cloudscape error policy
062:             */
063:            public Cacheable setIdentity(Object key) throws StandardException {
064:
065:                ContainerKey newIdentity = (ContainerKey) key;
066:                if (newIdentity.getSegmentId() != ContainerHandle.TEMPORARY_SEGMENT) {
067:
068:                    RAFContainer realContainer = new RAFContainer(dataFactory);
069:                    return realContainer.setIdent(newIdentity);
070:                }
071:
072:                return super .setIdentity(newIdentity);
073:
074:            }
075:
076:            /**
077:            	@exception StandardException Standard Cloudscape error policy
078:             */
079:            public Cacheable createIdentity(Object key, Object createParameter)
080:                    throws StandardException {
081:
082:                ContainerKey newIdentity = (ContainerKey) key;
083:
084:                if (newIdentity.getSegmentId() != ContainerHandle.TEMPORARY_SEGMENT) {
085:                    RAFContainer realContainer = new RAFContainer(dataFactory);
086:                    return realContainer.createIdentity(newIdentity,
087:                            createParameter);
088:                }
089:
090:                return createIdent(newIdentity, createParameter);
091:            }
092:
093:            /**
094:            	@exception StandardException Standard Cloudscape error policy
095:             */
096:            public void removeContainer(LogInstant instant, boolean leaveStub)
097:                    throws StandardException {
098:                // discard all of my pages in the cache
099:                pageCache.discard(identity);
100:
101:                synchronized (this ) {
102:                    // prevent anybody from looking at this container again
103:                    setDroppedState(true);
104:                    setCommittedDropState(true);
105:                    setDirty(false);
106:                    needsSync = false;
107:
108:                }
109:
110:                removeFile(getFileName(identity, false, false, false));
111:            }
112:
113:            /**
114:            	Preallocate page.  Since we don't sync when we write page anyway, no
115:            	need to preallocate page.
116:             */
117:            protected int preAllocate(long lastPreallocPagenum, int preAllocSize) {
118:                return 0;
119:            }
120:
121:            /**
122:            	Write the page, if it's within range of the current page range of the container.
123:            	If we do write it then don't request that it be synced.
124:
125:            	@exception StandardException Standard Cloudscape error policy
126:             */
127:            protected void writePage(long pageNumber, byte[] pageData,
128:                    boolean syncPage) throws IOException, StandardException {
129:                if (!this .getDroppedState()) {
130:                    super .writePage(pageNumber, pageData, false);
131:                }
132:                needsSync = false;
133:            }
134:
135:            StorageFile getFileName(ContainerKey identity, boolean stub,
136:                    boolean errorOK, boolean tryAlternatePath) {
137:                return privGetFileName(identity, stub, errorOK,
138:                        tryAlternatePath);
139:            }
140:
141:            protected StorageFile privGetFileName(ContainerKey identity,
142:                    boolean stub, boolean errorOK, boolean tryAlternatePath) {
143:                return dataFactory.storageFactory.newStorageFile(
144:                        dataFactory.storageFactory.getTempDir(), "T"
145:                                + identity.getContainerId() + ".tmp");
146:            }
147:
148:            /**
149:            	Add a page without locking the container, only one user will be accessing this
150:            	table at a time.
151:
152:            	@exception StandardException Standard Cloudscape error policy
153:             */
154:            public Page addPage(BaseContainerHandle handle, boolean isOverflow)
155:                    throws StandardException {
156:
157:                BasePage newPage = newPage(handle, (RawTransaction) null,
158:                        handle, isOverflow);
159:
160:                if (SanityManager.DEBUG) {
161:                    SanityManager.ASSERT(newPage.isLatched());
162:                }
163:
164:                return newPage;
165:            }
166:
167:            /**
168:            	@exception StandardException Standard Cloudscape error policy
169:             */
170:            public void truncate(BaseContainerHandle handle)
171:                    throws StandardException {
172:
173:                // stop anyone from writing any of my pages out
174:                synchronized (this ) {
175:                    setDroppedState(true);
176:                    setCommittedDropState(true);
177:                    setDirty(false);
178:                    needsSync = false;
179:                }
180:
181:                // discard all of my pages in the cache
182:                while (pageCache.discard(identity) != true)
183:                    ;
184:
185:                removeFile(getFileName(identity, false, true, false));
186:
187:                createIdent(identity, this );
188:
189:                addPage(handle, false).unlatch();
190:            }
191:
192:            /**
193:            	Lock the container and mark the container as in-use by this container handle.
194:
195:            	@param droppedOK if true, use this container even if it is dropped.,
196:            	@return true if the container can be used, false if it has been dropped
197:            	since the lock was requested and droppedOK is not true.
198:
199:            	@exception StandardException I cannot be opened for update.
200:             */
201:            protected boolean use(BaseContainerHandle handle,
202:                    boolean forUpdate, boolean droppedOK)
203:                    throws StandardException {
204:
205:                if (super .use(handle, forUpdate, droppedOK)) {
206:                    inUseCount++;
207:                    return true;
208:                }
209:
210:                return false;
211:            }
212:
213:            /**
214:            	Discontinue use of this container. Note that the unlockContainer
215:            	call made from this method may not release any locks. The container
216:            	lock may be held until the end of the transaction.
217:
218:             */
219:            protected void letGo(BaseContainerHandle handle) {
220:
221:                inUseCount--;
222:                super .letGo(handle);
223:            }
224:
225:            /**
226:            	Returns true if only a single handle is connected to this container.
227:             */
228:            public boolean isSingleUser() {
229:                return inUseCount == 1;
230:            }
231:        }
w___w_w_.___j_av__a2_s___.___c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.