Source Code Cross Referenced for AbstractResultCacheEntry.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » controller » cache » result » entries » 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 JDBC Connection Pool » sequoia 2.10.9 » org.continuent.sequoia.controller.cache.result.entries 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
004:         * Science And Control (INRIA).
005:         * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006:         * Contact: sequoia@continuent.org
007:         * 
008:         * Licensed under the Apache License, Version 2.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * 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:         * Initial developer(s): Emmanuel Cecchet.
021:         * Contributor(s): ______________________________________.
022:         */package org.continuent.sequoia.controller.cache.result.entries;
023:
024:        import org.continuent.sequoia.common.stream.DriverStream;
025:        import org.continuent.sequoia.controller.backend.result.ControllerResultSet;
026:        import org.continuent.sequoia.controller.requests.SelectRequest;
027:
028:        /**
029:         * A <code>CacheEntry</code> represents a SQL select request with its reponse.
030:         * The cache entry can have 3 states:
031:         * <p>
032:         * <ul>
033:         * <li><code>CACHE_VALID</code> when it is valid</li>
034:         * <li><code>CACHE_DIRTY</code> when the result has been marked dirty (may be
035:         * invalid)</li>
036:         * <li><code>CACHE_INVALID</code> when there is no result (request has to be
037:         * re-issued to the database)</li>
038:         * </ul>
039:         * 
040:         * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
041:         * @version 1.0
042:         */
043:        public abstract class AbstractResultCacheEntry {
044:            protected SelectRequest request;
045:            protected ControllerResultSet result;
046:            protected int state;
047:
048:            //Chain for LRU
049:            private AbstractResultCacheEntry next;
050:            private AbstractResultCacheEntry prev;
051:
052:            /** This entry has no deadline */
053:            public static final int NO_DEADLINE = -1;
054:            /** State this entry is valid */
055:            public static final int CACHE_VALID = 0;
056:            /** This entry is dirty */
057:            public static final int CACHE_DIRTY = 1;
058:            /** This entry is no more valid and is not consistent with real data. */
059:            public static final int CACHE_INVALID = 2;
060:
061:            /**
062:             * Creates a new <code>CacheEntry</code> instance.
063:             * 
064:             * @param request a <code>SelectRequest</code> value
065:             * @param result a <code>ControllerResultSet</code> value
066:             */
067:            public AbstractResultCacheEntry(SelectRequest request,
068:                    ControllerResultSet result) {
069:                this .request = request;
070:                this .result = result;
071:                state = CACHE_VALID;
072:                next = null;
073:                prev = null;
074:            }
075:
076:            /**
077:             * Get the type of this entry as a string
078:             * 
079:             * @return NoCache or Eager or Relaxed
080:             */
081:            public abstract String getType();
082:
083:            /**
084:             * Get the state of this entry as a string
085:             * 
086:             * @return Valid or Dirty or Invalid
087:             */
088:            public String getState() {
089:                if (isValid())
090:                    return "Valid";
091:                if (isDirty())
092:                    return "Dirty";
093:                else
094:                    return "Invalid";
095:            }
096:
097:            /**
098:             * Return <code>true</code> if cache entry state is valid (state is
099:             * {@link #CACHE_VALID}).
100:             * 
101:             * @return a <code>boolean</code> value
102:             */
103:            public boolean isValid() {
104:                return state == CACHE_VALID;
105:            }
106:
107:            /**
108:             * Returns <code>true</code> if cache entry state is marked dirty (state is
109:             * {@link #CACHE_DIRTY}).
110:             * 
111:             * @return a <code>boolean</code> value
112:             */
113:            public boolean isDirty() {
114:                return state == CACHE_DIRTY;
115:            }
116:
117:            /**
118:             * Returns the <code>SELECT</code> request of this cache entry.
119:             * 
120:             * @return a <code>SelectRequest</code> value
121:             */
122:            public SelectRequest getRequest() {
123:                return request;
124:            }
125:
126:            /**
127:             * Returns the <code>ControllerResultSet</code> of the cached select request
128:             * 
129:             * @return a <code>ControllerResultSet</code> value
130:             */
131:            public ControllerResultSet getResult() {
132:                return result;
133:            }
134:
135:            /**
136:             * Set a new <code>ControllerResultSet</code> of the cached select request
137:             * (cache update).
138:             * <p>
139:             * The cache state is automatically set to valid ({@link #CACHE_VALID}).
140:             * 
141:             * @param result a <code>ControllerResultSet</code> value
142:             */
143:            public void setResult(ControllerResultSet result) {
144:                this .result = result;
145:                state = CACHE_VALID;
146:            }
147:
148:            /**
149:             * Invalidates this cache entry (removes the <code>ResultSet</code> and turn
150:             * state to {@link #CACHE_INVALID}).
151:             */
152:            public abstract void invalidate();
153:
154:            /**
155:             * Marks this entry dirty (state becomes {@link #CACHE_DIRTY}).
156:             * <p>
157:             * The <code>ResultSet</code> if not affected by this method.
158:             */
159:            public void markDirty() {
160:                state = CACHE_DIRTY;
161:            }
162:
163:            /**
164:             * Marks this entry valid (state becomes {@link #CACHE_VALID}).
165:             */
166:            public void setValid() {
167:                state = CACHE_VALID;
168:            }
169:
170:            /**
171:             * Gets the value of next <code>AbstractResultCacheEntry</code> in LRU.
172:             * 
173:             * @return value of next.
174:             */
175:            public AbstractResultCacheEntry getNext() {
176:                return next;
177:            }
178:
179:            /**
180:             * Sets the value of next <code>AbstractResultCacheEntry</code> in LRU.
181:             * 
182:             * @param next value to assign to next.
183:             */
184:            public void setNext(AbstractResultCacheEntry next) {
185:                this .next = next;
186:            }
187:
188:            /**
189:             * Gets the value of previous <code>AbstractResultCacheEntry</code> in LRU.
190:             * 
191:             * @return value of previous.
192:             */
193:            public AbstractResultCacheEntry getPrev() {
194:                return prev;
195:            }
196:
197:            /**
198:             * Sets the value of previous <code>AbstractResultCacheEntry</code> in LRU.
199:             * 
200:             * @param prev value to assign to prev.
201:             */
202:            public void setPrev(AbstractResultCacheEntry prev) {
203:                this .prev = prev;
204:            }
205:
206:            /**
207:             * Get data about this entry
208:             * 
209:             * @return an array [request,type,status(valid,notvalid,dirty),deadLine]
210:             */
211:            public abstract String[] toStringTable();
212:
213:            /**
214:             * Size of the result in bytes
215:             * 
216:             * @return an integer
217:             */
218:            public int getSizeOfResult() {
219:                try {
220:                    return DriverStream.countBytes(result);
221:                } catch (Exception e) {
222:                    return -1;
223:                }
224:            }
225:
226:        }
w__w_w.__j_a__va__2__s.__co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.