Source Code Cross Referenced for SR10553Test.java in  » JMX » je » com » sleepycat » je » cleaner » 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 » JMX » je » com.sleepycat.je.cleaner 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: SR10553Test.java,v 1.10.2.3 2008/01/07 15:14:25 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je.cleaner;
010:
011:        import java.io.File;
012:        import java.io.IOException;
013:
014:        import junit.framework.TestCase;
015:
016:        import com.sleepycat.je.CheckpointConfig;
017:        import com.sleepycat.je.Cursor;
018:        import com.sleepycat.je.Database;
019:        import com.sleepycat.je.DatabaseConfig;
020:        import com.sleepycat.je.DatabaseEntry;
021:        import com.sleepycat.je.DatabaseException;
022:        import com.sleepycat.je.DbInternal;
023:        import com.sleepycat.je.Environment;
024:        import com.sleepycat.je.EnvironmentConfig;
025:        import com.sleepycat.je.OperationStatus;
026:        import com.sleepycat.je.config.EnvironmentParams;
027:        import com.sleepycat.je.log.FileManager;
028:        import com.sleepycat.je.util.TestUtils;
029:
030:        public class SR10553Test extends TestCase {
031:
032:            private static final String DB_NAME = "foo";
033:
034:            private static final CheckpointConfig forceConfig = new CheckpointConfig();
035:            static {
036:                forceConfig.setForce(true);
037:            }
038:
039:            private File envHome;
040:            private Environment env;
041:            private Database db;
042:
043:            public SR10553Test() {
044:                envHome = new File(System.getProperty(TestUtils.DEST_DIR));
045:            }
046:
047:            public void setUp() throws IOException, DatabaseException {
048:
049:                TestUtils.removeLogFiles("Setup", envHome, false);
050:                TestUtils.removeFiles("Setup", envHome, FileManager.DEL_SUFFIX);
051:            }
052:
053:            public void tearDown() throws IOException, DatabaseException {
054:
055:                try {
056:                    if (env != null) {
057:                        env.close();
058:                    }
059:                } catch (Throwable e) {
060:                    System.out.println("tearDown: " + e);
061:                }
062:
063:                try {
064:                    TestUtils.removeLogFiles("tearDown", envHome, true);
065:                    TestUtils.removeFiles("tearDown", envHome,
066:                            FileManager.DEL_SUFFIX);
067:                } catch (Throwable e) {
068:                    System.out.println("tearDown: " + e);
069:                }
070:
071:                db = null;
072:                env = null;
073:                envHome = null;
074:            }
075:
076:            /**
077:             * Opens the environment and database.
078:             */
079:            private void openEnv() throws DatabaseException {
080:
081:                EnvironmentConfig config = TestUtils.initEnvConfig();
082:                DbInternal.disableParameterValidation(config);
083:                config.setAllowCreate(true);
084:                /* Do not run the daemons. */
085:                config.setConfigParam(EnvironmentParams.ENV_RUN_CLEANER
086:                        .getName(), "false");
087:                config.setConfigParam(EnvironmentParams.ENV_RUN_EVICTOR
088:                        .getName(), "false");
089:                config.setConfigParam(EnvironmentParams.ENV_RUN_CHECKPOINTER
090:                        .getName(), "false");
091:                config.setConfigParam(EnvironmentParams.ENV_RUN_INCOMPRESSOR
092:                        .getName(), "false");
093:                /* Use a small log file size to make cleaning more frequent. */
094:                config.setConfigParam(EnvironmentParams.LOG_FILE_MAX.getName(),
095:                        Integer.toString(1024));
096:                /* Use a small memory size to force eviction. */
097:                config.setConfigParam(EnvironmentParams.MAX_MEMORY.getName(),
098:                        Integer.toString(1024 * 96));
099:                /* Don't track detail with a tiny cache size. */
100:                config.setConfigParam(EnvironmentParams.CLEANER_TRACK_DETAIL
101:                        .getName(), "false");
102:                config.setConfigParam(EnvironmentParams.NUM_LOG_BUFFERS
103:                        .getName(), Integer.toString(2));
104:                /* Set log buffers large enough for trace messages. */
105:                config.setConfigParam(EnvironmentParams.LOG_MEM_SIZE.getName(),
106:                        Integer.toString(7000));
107:
108:                env = new Environment(envHome, config);
109:
110:                openDb();
111:            }
112:
113:            /**
114:             * Opens that database.
115:             */
116:            private void openDb() throws DatabaseException {
117:
118:                DatabaseConfig dbConfig = new DatabaseConfig();
119:                dbConfig.setAllowCreate(true);
120:                dbConfig.setSortedDuplicates(true);
121:                db = env.openDatabase(null, DB_NAME, dbConfig);
122:            }
123:
124:            /**
125:             * Closes the environment and database.
126:             */
127:            private void closeEnv() throws DatabaseException {
128:
129:                if (db != null) {
130:                    db.close();
131:                    db = null;
132:                }
133:                if (env != null) {
134:                    env.close();
135:                    env = null;
136:                }
137:            }
138:
139:            /**
140:             */
141:            public void testSR10553() throws DatabaseException {
142:
143:                openEnv();
144:
145:                /* Put some duplicates, enough to fill a log file. */
146:                final int COUNT = 10;
147:                DatabaseEntry key = new DatabaseEntry(TestUtils.getTestArray(0));
148:                DatabaseEntry data = new DatabaseEntry();
149:                for (int i = 0; i < COUNT; i += 1) {
150:                    data.setData(TestUtils.getTestArray(i));
151:                    db.put(null, key, data);
152:                }
153:                Cursor cursor = db.openCursor(null, null);
154:                assertEquals(OperationStatus.SUCCESS, cursor.getSearchKey(key,
155:                        data, null));
156:                assertEquals(COUNT, cursor.count());
157:                cursor.close();
158:
159:                /* Delete everything.  Do not compress. */
160:                db.delete(null, key);
161:
162:                /* Checkpoint and clean. */
163:                env.checkpoint(forceConfig);
164:                int cleaned = env.cleanLog();
165:                assertTrue("cleaned=" + cleaned, cleaned > 0);
166:
167:                /* Force eviction. */
168:                env.evictMemory();
169:
170:                /* Scan all values. */
171:                cursor = db.openCursor(null, null);
172:                for (OperationStatus status = cursor.getFirst(key, data, null); status == OperationStatus.SUCCESS; status = cursor
173:                        .getNext(key, data, null)) {
174:                }
175:                cursor.close();
176:
177:                /*
178:                 * Before the fix to 10553, while scanning over deleted records, a
179:                 * LogFileNotFoundException would occur when faulting in a deleted
180:                 * record, if the log file had been cleaned.  This was because the
181:                 * cleaner was not setting knownDeleted for deleted records.
182:                 */
183:                closeEnv();
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.