diff -Nru libdb-je-java-3.3.62/ant/internal.xml libdb-je-java-3.3.98/ant/internal.xml --- libdb-je-java-3.3.62/ant/internal.xml 2008-01-17 05:41:40.000000000 +0000 +++ libdb-je-java-3.3.98/ant/internal.xml 2009-07-28 20:32:24.000000000 +0000 @@ -415,4 +415,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru libdb-je-java-3.3.62/build.properties libdb-je-java-3.3.98/build.properties --- libdb-je-java-3.3.62/build.properties 2007-10-24 11:47:30.000000000 +0000 +++ libdb-je-java-3.3.98/build.properties 2008-06-11 03:25:20.000000000 +0000 @@ -46,3 +46,9 @@ # when doing a full clover run of all tests. ########################################################################## #clover.ignorefailure=true + +########################################################################## +# Set logging.config.file to a configuration file which can change the +# default logging configuration for all logging operations. +########################################################################## +#logging.config.file=rep.properties diff -Nru libdb-je-java-3.3.62/build.xml libdb-je-java-3.3.98/build.xml --- libdb-je-java-3.3.62/build.xml 2008-06-04 03:10:26.000000000 +0000 +++ libdb-je-java-3.3.98/build.xml 2010-01-22 00:29:56.000000000 +0000 @@ -805,6 +805,7 @@ errorProperty="unittest.failed" failureProperty="unittest.failed" haltOnFailure="false" + showoutput="true" fork="yes"> + diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/collections/StoredMap.java libdb-je-java-3.3.98/src/com/sleepycat/collections/StoredMap.java --- libdb-je-java-3.3.62/src/com/sleepycat/collections/StoredMap.java 2008-05-29 03:17:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/collections/StoredMap.java 2008-07-15 19:08:42.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: StoredMap.java,v 1.55 2008/05/29 03:17:27 linda Exp $ + * $Id: StoredMap.java,v 1.55.2.1 2008/07/15 19:08:41 mark Exp $ */ package com.sleepycat.collections; @@ -35,7 +35,8 @@ * * @author Mark Hayes */ -public class StoredMap extends StoredContainer implements Map { +public class StoredMap extends StoredContainer + implements ConcurrentMap { private StoredKeySet keySet; private StoredEntrySet entrySet; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/APILockedException.java libdb-je-java-3.3.98/src/com/sleepycat/je/APILockedException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/APILockedException.java 2008-05-20 17:52:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/APILockedException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: APILockedException.java,v 1.5 2008/05/20 17:52:34 linda Exp $ + * $Id: APILockedException.java,v 1.5.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/BtreeStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/BtreeStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/BtreeStats.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/BtreeStats.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BtreeStats.java,v 1.15 2008/01/24 14:59:27 linda Exp $ + * $Id: BtreeStats.java,v 1.15.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/CacheMode.java libdb-je-java-3.3.98/src/com/sleepycat/je/CacheMode.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/CacheMode.java 2008-05-29 03:17:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/CacheMode.java 2010-03-26 13:23:54.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CacheMode.java,v 1.2 2008/05/29 03:17:28 linda Exp $ + * $Id: CacheMode.java,v 1.2.2.4 2010/03/26 13:23:54 mark Exp $ */ package com.sleepycat.je; @@ -77,10 +77,39 @@ *

The record will have the same hotness as other records accessed with * this cache mode. Its relative hotness will not be reduced over time as * other records are accessed. It can only become colder over time if it - * is subsequently accessed with the {@code DEFAULT} cache mode.

+ * is subsequently accessed with the {@code DEFAULT} or {@code MAKE_COLD} + * cache mode.

* *

This cache mode is normally used when the application intends to * access this record again soon.

*/ - KEEP_HOT + KEEP_HOT, + + /** + * The record is assigned "maximum coldness" by the operation where this + * cache mode is specified. + * + *

The record will have the same hotness as other records accessed with + * this cache mode. It is very likely that this record will be evicted + * from the cache if space is needed. It can only become warmer over time + * if it is subsequently accessed with the {@code DEFAULT} or + * {@code KEEP_HOT} cache mode.

+ * + *

This cache mode is normally used when the application does not intend + * to access this record again soon.

+ */ + MAKE_COLD, + + /** + * The record (leaf node) is evicted as soon as possible after the + * operation where this cache mode is specified. If the record cannot be + * evicted immediately, it is assigned "maximum coldness" as if {@code + * MAKE_COLD} were used. + * + *

This cache mode is normally used when the application prefers to read + * the record from the log file when it is accessed again, rather than have + * it take up space in the JE cache and potentially cause expensive Java + * GC.

+ */ + EVICT_LN } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/CheckpointConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/CheckpointConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/CheckpointConfig.java 2008-05-29 03:38:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/CheckpointConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CheckpointConfig.java,v 1.19 2008/05/29 03:38:23 linda Exp $ + * $Id: CheckpointConfig.java,v 1.20.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -121,4 +121,18 @@ public boolean getMinimizeRecoveryTime() { return minimizeRecoveryTime; } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "minutes=" + minutes + + "\nkBytes=" + kbytes + + "\nforce=" + force + + "\nminimizeRecoveryTime=" + minimizeRecoveryTime + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/BaseLocalUtilizationTracker.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/BaseLocalUtilizationTracker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/BaseLocalUtilizationTracker.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/BaseLocalUtilizationTracker.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BaseLocalUtilizationTracker.java,v 1.8 2008/05/15 01:52:40 linda Exp $ + * $Id: BaseLocalUtilizationTracker.java,v 1.8.2.4 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -91,12 +91,16 @@ fileEntries.next(); Long fileNum = fileEntry.getKey(); - DbFileSummary localSummary = fileEntry.getValue(); DbFileSummary dbFileSummary = db.getDbFileSummary(fileNum, true /*willModify*/); - dbFileSummary.add(localSummary); + if (dbFileSummary != null) { + DbFileSummary localSummary = fileEntry.getValue(); + dbFileSummary.add(localSummary); + } } } + /* Ensure that DbTree.releaseDb is called. [#16329] */ + releaseDatabaseImpl(db); /* This object is being discarded, subtract it from the budget. */ fileMap.subtractFromMemoryBudget(); } @@ -104,30 +108,43 @@ /** * Returns the DatabaseImpl from the database key, which is either the - * DatabaseId or DatabaseImpl. + * DatabaseId or DatabaseImpl. The releaseDatabaseImpl must be called + * with the DatabaseImpl returned by this method. */ abstract DatabaseImpl databaseKeyToDatabaseImpl(Object databaseKey) throws DatabaseException; /** + * Must be called after calling databaseKeyToDatabaseImpl. The db + * parameter may be null, in which case no action is taken. + * + * If DbTree.getDb is called by the implementation of + * databaseKeyToDatabaseImpl, then DbTree.releaseDb must be called by the + * implementation of this method. + */ + abstract void releaseDatabaseImpl(DatabaseImpl db); + + /** * Allocates DbFileSummary information locally in this object rather than * in the DatabaseImpl. * * @param databaseKey is either a DatabaseId or DatabaseImpl depending on * whether called from the RecoveryUtilizationTracker or * LocalUtilizationTracker, respectively. + * + * @return the summary, or null if the databaseKey param is null. */ DbFileSummary getDbFileSummary(Object databaseKey, long fileNum) { if (databaseKey != null) { - DbFileSummaryMap fileMap = - dbMap.get(databaseKey); + DbFileSummaryMap fileMap = dbMap.get(databaseKey); if (fileMap == null) { fileMap = new DbFileSummaryMap(true /* countParentMapEntry */); fileMap.init(env); dbMap.put(databaseKey, fileMap); } return fileMap.get - (Long.valueOf(fileNum), true /* adjustMemBudget */); + (Long.valueOf(fileNum), true /*adjustMemBudget*/, + true /*checkResurrected*/, env.getFileManager()); } else { return null; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/BaseUtilizationTracker.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/BaseUtilizationTracker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/BaseUtilizationTracker.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/BaseUtilizationTracker.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BaseUtilizationTracker.java,v 1.10 2008/05/15 01:52:40 linda Exp $ + * $Id: BaseUtilizationTracker.java,v 1.10.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -105,13 +105,17 @@ if (isLNType(type)) { fileSummary.totalLNCount += 1; fileSummary.totalLNSize += size; - dbFileSummary.totalLNCount += 1; - dbFileSummary.totalLNSize += size; + if (dbFileSummary != null) { + dbFileSummary.totalLNCount += 1; + dbFileSummary.totalLNSize += size; + } } else { fileSummary.totalINCount += 1; fileSummary.totalINSize += size; - dbFileSummary.totalINCount += 1; - dbFileSummary.totalINSize += size; + if (dbFileSummary != null) { + dbFileSummary.totalINCount += 1; + dbFileSummary.totalINSize += size; + } } } /* Increment bytes and indicate whether to wakeup the cleaner. */ @@ -163,17 +167,19 @@ " type: " + type; DbFileSummary dbFileSummary = getDbFileSummary(databaseKey, fileNum); - if (isLN) { - dbFileSummary.obsoleteLNCount += 1; - /* The size is optional when tracking obsolete LNs. */ - if (size > 0) { - dbFileSummary.obsoleteLNSize += size; - dbFileSummary.obsoleteLNSizeCounted += 1; + if (dbFileSummary != null) { + if (isLN) { + dbFileSummary.obsoleteLNCount += 1; + /* The size is optional when tracking obsolete LNs. */ + if (size > 0) { + dbFileSummary.obsoleteLNSize += size; + dbFileSummary.obsoleteLNSizeCounted += 1; + } + } else { + dbFileSummary.obsoleteINCount += 1; + /* The size is not allowed when tracking obsolete INs. */ + assert size == 0; } - } else { - dbFileSummary.obsoleteINCount += 1; - /* The size is not allowed when tracking obsolete INs. */ - assert size == 0; } } } @@ -250,6 +256,9 @@ * databaseKey as either the DatabaseImpl or a DatabaseId.

* *

For the global tracker, must be called under the log write latch.

+ * + * @return the summary, or null if the DB should not be tracked because + * the file has been deleted. */ abstract DbFileSummary getDbFileSummary(Object databaseKey, long fileNum); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/Cleaner.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/Cleaner.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/Cleaner.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/Cleaner.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Cleaner.java,v 1.213 2008/05/15 01:52:40 linda Exp $ + * $Id: Cleaner.java,v 1.213.2.5 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -22,6 +22,7 @@ import com.sleepycat.je.EnvironmentMutableConfig; import com.sleepycat.je.EnvironmentStats; import com.sleepycat.je.ExceptionListener; +import com.sleepycat.je.RunRecoveryException; import com.sleepycat.je.StatsConfig; import com.sleepycat.je.cleaner.FileSelector.CheckpointStartCleanerState; import com.sleepycat.je.config.EnvironmentParams; @@ -100,7 +101,6 @@ * This could produce errors in counting, but avoids contention around stat * updates. */ - int nBacklogFiles = 0; long nCleanerRuns = 0; long nCleanerDeletions = 0; long nINsObsolete = 0; @@ -141,11 +141,10 @@ boolean lazyMigration; /** - * All files that are to-be-cleaning or being-cleaned. Used to perform - * proactive migration. Is read-only after assignment, so no - * synchronization is needed. + * All files that are to-be-cleaned. Used to perform proactive migration. + * Is read-only after assignment, so no synchronization is needed. */ - private Set mustBeCleanedFiles = Collections.emptySet(); + private Set toBeCleanedFiles = Collections.emptySet(); /** * All files that are below the minUtilization threshold. Used to perform @@ -291,6 +290,11 @@ return profile; } + /** For unit testing. */ + FileSelector getFileSelector() { + return fileSelector; + } + public boolean getFetchObsoleteSize() { return fetchObsoleteSize; } @@ -393,7 +397,7 @@ public void loadStats(StatsConfig config, EnvironmentStats stat) throws DatabaseException { - stat.setCleanerBacklog(nBacklogFiles); + stat.setCleanerBacklog(getBacklog()); stat.setNCleanerRuns(nCleanerRuns); stat.setNCleanerDeletions(nCleanerDeletions); stat.setNINsObsolete(nINsObsolete); @@ -443,13 +447,6 @@ } /** - * For unit testing. - */ - void injectFileForCleaning(Long fileNum) { - fileSelector.putBackFileForCleaning(fileNum); - } - - /** * Deletes all files that are safe-to-delete, if there are no read/only * processes and concurrent backups. * @@ -594,13 +591,17 @@ } } - private void traceFileNotDeleted(Exception e, long fileNum) { - Tracer.trace - (env, "Cleaner", "deleteSafeToDeleteFiles", + private void traceFileNotDeleted(Throwable e, long fileNum) + throws DatabaseException { + + String msg = "Cleaner deleteSafeToDeleteFiles" + "Log file 0x" + Long.toHexString(fileNum) + " could not be " + (expunge ? "deleted" : "renamed") + - ". This operation will be retried at the next checkpoint.", - e); + ". This operation will be retried at the next checkpoint." + + e.toString() + + " FileSelector: " + fileSelector; + Tracer.trace + (env, "Cleaner", "deleteSafeToDeleteFiles", msg, e); } /** @@ -632,13 +633,16 @@ } /** - * Update the lowUtilizationFiles and mustBeCleanedFiles fields with new - * read-only collections, and update the backlog file count. + * Update the lowUtilizationFiles and toBeCleanedFiles fields with new + * read-only collections. */ public void updateReadOnlyFileCollections() { - mustBeCleanedFiles = fileSelector.getMustBeCleanedFiles(); + toBeCleanedFiles = fileSelector.getToBeCleanedFiles(); lowUtilizationFiles = fileSelector.getLowUtilizationFiles(); - nBacklogFiles = fileSelector.getBacklog(); + } + + final int getBacklog() { + return toBeCleanedFiles.size(); } /** @@ -861,7 +865,7 @@ Long fileNum = Long.valueOf(DbLsn.getFileNumber(lsn)); if ((PROACTIVE_MIGRATION || isResident) && - mustBeCleanedFiles.contains(fileNum)) { + toBeCleanedFiles.contains(fileNum)) { return false; } @@ -1065,7 +1069,7 @@ Long fileNum = Long.valueOf(DbLsn.getFileNumber(childLsn)); if ((PROACTIVE_MIGRATION || isResident) && - mustBeCleanedFiles.contains(fileNum)) { + toBeCleanedFiles.contains(fileNum)) { /* Migrate because it will be cleaned soon. */ doMigration = true; @@ -1533,5 +1537,6 @@ public void close() { profile.close(); tracker.close(); + fileSelector.close(env.getMemoryBudget()); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/DbFileSummary.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/DbFileSummary.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/DbFileSummary.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/DbFileSummary.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbFileSummary.java,v 1.4 2008/01/07 14:28:47 cwl Exp $ + * $Id: DbFileSummary.java,v 1.5.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -222,6 +222,7 @@ return false; } + @Override public String toString() { StringBuffer buf = new StringBuffer(); dumpLog(buf, true); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/DbFileSummaryMap.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/DbFileSummaryMap.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/DbFileSummaryMap.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/DbFileSummaryMap.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,19 +1,22 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbFileSummaryMap.java,v 1.5 2008/05/15 01:52:40 linda Exp $ + * $Id: DbFileSummaryMap.java,v 1.6.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je.cleaner; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Set; import com.sleepycat.je.dbi.EnvironmentImpl; import com.sleepycat.je.dbi.MemoryBudget; +import com.sleepycat.je.log.FileManager; public class DbFileSummaryMap { @@ -64,18 +67,52 @@ * necessary. * *

Must be called under the log write latch.

+ * + * @param fileNum the file identifying the summary. + * + * @param adjustMemBudget see init(). + * + * @param checkResurrected is true if this method should check fileNum and + * return null if the file does not exist. + * + * @param fileManager is used to check for resurrected files and may be null + * if checkResurrected is false. */ - public DbFileSummary get(Long fileNum, boolean adjustMemBudget) { + public DbFileSummary get(Long fileNum, + boolean adjustMemBudget, + boolean checkResurrected, + FileManager fileManager) { assert adjustMemBudget == (budget != null); + /* + * Note that both calls below to isFileValid (which calls File.exists) + * only occur if the file number is less than the last file in the log, + * and the file is not already present in the map. When the file is + * not the last file, we are recording obsoleteness and the file should + * already be in the map. So we only incur the overhead of File.exists + * when resurrecting a file, which should be pretty rare. + */ DbFileSummary summary = map.get(fileNum); if (summary == null) { - summary = new DbFileSummary(); - map.put(fileNum, summary); - memSize += FILE_ENTRY_OVERHEAD; - if (adjustMemBudget) { - budget.updateTreeAdminMemoryUsage(FILE_ENTRY_OVERHEAD); + if (checkResurrected && + fileNum < fileManager.getCurrentFileNum() && + !fileManager.isFileValid(fileNum)) { + /* Will return null. */ + } else { + summary = new DbFileSummary(); + Object oldVal = map.put(fileNum, summary); + assert oldVal == null; + memSize += FILE_ENTRY_OVERHEAD; + if (adjustMemBudget) { + budget.updateTreeAdminMemoryUsage(FILE_ENTRY_OVERHEAD); + } + /* Double-check that we never add a deleted file. */ + assert fileManager == null || + fileNum == fileManager.getCurrentFileNum() || + fileManager.isFileValid(fileNum) : + "Resurrected file: 0x" + Long.toHexString(fileNum); + } } return summary; @@ -126,7 +163,25 @@ return map.size(); } + @Override public String toString() { return map.toString(); } + + /** + * Removes entries for deleted files that were created by JE 3.3.74 and + * earlier. [#16610] + */ + public void repair(EnvironmentImpl env) { + Long[] existingFiles = env.getFileManager().getAllFileNumbers(); + Iterator iter = map.keySet().iterator(); + while (iter.hasNext()) { + Long fileNum = iter.next(); + if (Arrays.binarySearch(existingFiles, fileNum) < 0) { + iter.remove(); + budget.updateTreeAdminMemoryUsage(0 - FILE_ENTRY_OVERHEAD); + memSize -= FILE_ENTRY_OVERHEAD; + } + } + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/FileProcessor.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/FileProcessor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/FileProcessor.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/FileProcessor.java 2010-01-30 01:10:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileProcessor.java,v 1.42 2008/05/15 01:52:40 linda Exp $ + * $Id: FileProcessor.java,v 1.44.2.5 2010/01/30 01:10:55 mark Exp $ */ package com.sleepycat.je.cleaner; @@ -121,6 +121,7 @@ /** * Return the number of retries when a deadlock exception occurs. */ + @Override protected long nDeadlockRetries() throws DatabaseException { @@ -221,7 +222,7 @@ String traceMsg = "CleanerRun " + runId + " on file 0x" + Long.toHexString(fileNumValue) + - " begins backlog=" + cleaner.nBacklogFiles; + " begins backlog=" + cleaner.getBacklog(); Tracer.trace(Level.INFO, env, traceMsg); if (DEBUG_TRACING) { System.out.println("\n" + traceMsg); @@ -241,14 +242,14 @@ /* * File was deleted. Although it is possible that the file was * deleted externally it is much more likely that the file was - * deleted normally after being cleaned earlier (this was - * observed prior to JE 3.2.29), and that we are mistakedly - * processing the file repeatedly. Since the file does not - * exist, ignore the error so that the cleaner will continue. - * The tracing below will indicate that the file was deleted. - * Remove the file completely from the FileSelector and - * UtilizationProfile so that we don't repeatedly attempt to - * process it. [#15528] + * deleted normally after being cleaned earlier. This can + * occur when tracked obsolete information is collected and + * processed after the file has been cleaned and deleted. + * Since the file does not exist, ignore the error so that the + * cleaner will continue. The tracing below will indicate that + * the file was deleted. Remove the file completely from the + * FileSelector and UtilizationProfile so that we don't + * repeatedly attempt to process it. [#15528] */ fileDeleted = true; profile.removeFile(fileNum, null /*databases*/); @@ -368,7 +369,8 @@ * releaseDb after getDb with the dbCache, since the entire dbCache * will be released at the end of thie method. */ - Map dbCache = new HashMap(); + Map dbCache = + new HashMap(); DbTree dbMapTree = env.getDbTree(); try { @@ -556,6 +558,27 @@ } /** + * Unit testing. Simulates processing of a single LN. + */ + void testProcessLN(LN targetLN, + long logLsn, + byte[] key, + byte[] dupKey, + DatabaseId dbId, + Map dbCache) + throws DatabaseException { + + LookAheadCache lookAheadCache = new LookAheadCache(1); + + lookAheadCache.add + (Long.valueOf(DbLsn.getFileOffset(logLsn)), + new LNInfo(targetLN, dbId, key, dupKey)); + + processLN(DbLsn.getFileNumber(logLsn), new TreeLocation(), + lookAheadCache, dbCache); + } + + /** * Processes the first LN in the look ahead cache and removes it from the * cache. While the BIN is latched, look through the BIN for other LNs in * the cache; if any match, process them to avoid a tree search later. @@ -894,6 +917,11 @@ * the tree and log LSNs are equal. We will always restore the * LN to the BIN slot here, and always log the dirty LN when * logging the BIN. + * + * Also for temporary databases, make both the target LN and + * the BIN or IN parent dirty. Otherwise, when the BIN or IN is + * evicted in the future, it will be written to disk without + * flushing its dirty, migrated LNs. [#18227] */ if (isDupCountLN) { ChildReference dclRef = parentDIN.getDupCountLNRef(); @@ -905,6 +933,7 @@ if (isTemporary) { ((LN) dclRef.getTarget()).setDirty(); dclRef.setLsn(DbLsn.NULL_LSN); + parentDIN.setDirty(true); } else if (cleaner.lazyMigration) { dclRef.setMigrate(true); parentDIN.setDirty(true); @@ -934,6 +963,7 @@ if (isTemporary) { ((LN) bin.getTarget(index)).setDirty(); bin.clearLsn(index); + bin.setDirty(true); } else if (cleaner.lazyMigration) { bin.setMigrate(index, true); bin.setDirty(true); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/FileSelector.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/FileSelector.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/FileSelector.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/FileSelector.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,13 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileSelector.java,v 1.24 2008/05/15 01:52:40 linda Exp $ + * $Id: FileSelector.java,v 1.24.2.10 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je.cleaner; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -20,6 +21,8 @@ import com.sleepycat.je.dbi.DatabaseId; import com.sleepycat.je.dbi.MemoryBudget; import com.sleepycat.je.tree.LN; +import com.sleepycat.je.utilint.TestHook; +import com.sleepycat.je.utilint.TestHookExecute; /** * Keeps track of the status of files for which cleaning is in progres. @@ -131,6 +134,9 @@ */ private Set lowUtilizationFiles; + /* For unit tests */ + private TestHook fileChosenHook; + FileSelector() { toBeCleanedFiles = new TreeSet(); cleanedFiles = new HashSet(); @@ -144,10 +150,14 @@ beingCleanedFiles = new HashSet(); } + /* For unit testing only. */ + public void setFileChosenHook(TestHook hook) { + fileChosenHook = hook; + } + /** * Returns the best file that qualifies for cleaning, or null if no file - * qualifies. This method is not thread safe and should only be called - * from the cleaner thread. + * qualifies. * * @param forceCleaning is true to always select a file, even if its * utilization is above the minimum utilization threshold. @@ -166,6 +176,15 @@ int maxBatchFiles) throws DatabaseException { + /* + * Note that because it calls UtilizationProfile methods, this method + * itself cannot be synchronized. Synchronization is done elsewhere in + * the order [UtilizationProfile, FileSelector], so this method can't + * synchronize first on FileSelector and then call a UtilizationProfile + * method without causing a deadlock. However, it must synchronize + * while accessing private fields. Retries are performed when + * necessary to work around the lack of synchronization. See below. + */ Set newLowUtilizationFiles = calcLowUtilizationFiles ? (new HashSet()) : null; @@ -192,8 +211,23 @@ break; } + assert TestHookExecute.doHookIfSet(fileChosenHook); + + /* + * Because we don't synchronize on the FileSelector while calling + * UtilizationProfile.getBestFileForCleaning, another thread may + * have selected this file. Add the file only if not already being + * cleaned. [#17079] + * + * There is also a possibility that another thread will have + * already cleaned and deleted the file. In that case, we will + * return it and attempt to clean it again, but + * FileProcessor.doClean will detect this situation and recover. + */ synchronized (this) { - toBeCleanedFiles.add(fileNum); + if (!isFileCleaningInProgress(fileNum)) { + toBeCleanedFiles.add(fileNum); + } } } @@ -204,21 +238,32 @@ /* * Select the cheapest file to clean from a copy of the to-be-cleaned - * set. Then move the file from the to-be-cleaned set to the + * set. Move the selected file from the to-be-cleaned set to the * being-cleaned set. + * + * Because we don't synchronize on the FileSelector while calling + * UtilizationProfile.getCheapestFileToClean, another thread may have + * selected this file. Select the file only if it is waiting to be + * cleaned. [#17079] */ SortedSet availableFiles; synchronized (this) { availableFiles = new TreeSet(toBeCleanedFiles); } - Long file = profile.getCheapestFileToClean(availableFiles); - if (file != null) { + while (availableFiles.size() > 0) { + Long fileNum = profile.getCheapestFileToClean(availableFiles); + if (fileNum == null) { + return null; + } synchronized (this) { - toBeCleanedFiles.remove(file); - beingCleanedFiles.add(file); + if (toBeCleanedFiles.remove(fileNum)) { + beingCleanedFiles.add(fileNum); + return fileNum; + } + availableFiles.remove(fileNum); } } - return file; + return null; } /** @@ -233,6 +278,15 @@ safeToDeleteFiles.contains(file); } + private boolean isFileCleaningInProgress(Collection files) { + for (Long file : files) { + if (isFileCleaningInProgress(file)) { + return true; + } + } + return false; + } + /** * Removes all references to a file. */ @@ -252,8 +306,18 @@ * set to the to-be-cleaned set. */ synchronized void putBackFileForCleaning(Long fileNum) { - toBeCleanedFiles.add(fileNum); beingCleanedFiles.remove(fileNum); + assert !isFileCleaningInProgress(fileNum); + toBeCleanedFiles.add(fileNum); + } + + /** + * For unit testing. + */ + synchronized void injectFileForCleaning(Long fileNum) { + if (!isFileCleaningInProgress(fileNum)) { + toBeCleanedFiles.add(fileNum); + } } /** @@ -263,11 +327,12 @@ synchronized void addCleanedFile(Long fileNum, Set databases, MemoryBudget budget) { + beingCleanedFiles.remove(fileNum); + assert !isFileCleaningInProgress(fileNum); cleanedFiles.add(fileNum); Set oldDatabases = cleanedFilesDatabases.put(fileNum, databases); adjustMemoryBudget(budget, oldDatabases, databases); - beingCleanedFiles.remove(fileNum); } /** @@ -280,20 +345,11 @@ } /** - * Returns a read-only copy of to-be-cleaned and being-cleaned files that - * can be accessed without synchronization. - */ - synchronized Set getMustBeCleanedFiles() { - Set set = new HashSet(toBeCleanedFiles); - set.addAll(beingCleanedFiles); - return set; - } - - /** - * Returns the number of files waiting to-be-cleaned. + * Returns a read-only copy of to-be-cleaned files that can be accessed + * without synchronization. */ - synchronized int getBacklog() { - return toBeCleanedFiles.size(); + synchronized Set getToBeCleanedFiles() { + return new HashSet(toBeCleanedFiles); } /** @@ -314,26 +370,30 @@ * When a checkpoint is complete, move the previously cleaned and * fully-processed files to the checkpointed and safe-to-delete sets. */ - synchronized void updateFilesAtCheckpointEnd( - CheckpointStartCleanerState info) { + synchronized void + updateFilesAtCheckpointEnd(CheckpointStartCleanerState info) { if (!info.isEmpty()) { Set previouslyCleanedFiles = info.getCleanedFiles(); if (previouslyCleanedFiles != null) { + cleanedFiles.removeAll(previouslyCleanedFiles); + assert !isFileCleaningInProgress(previouslyCleanedFiles) : + toString(); if (anyPendingDuringCheckpoint) { checkpointedFiles.addAll(previouslyCleanedFiles); } else { safeToDeleteFiles.addAll(previouslyCleanedFiles); } - cleanedFiles.removeAll(previouslyCleanedFiles); } Set previouslyProcessedFiles = info.getFullyProcessedFiles(); if (previouslyProcessedFiles != null) { - safeToDeleteFiles.addAll(previouslyProcessedFiles); fullyProcessedFiles.removeAll(previouslyProcessedFiles); + assert !isFileCleaningInProgress(previouslyProcessedFiles) : + toString(); + safeToDeleteFiles.addAll(previouslyProcessedFiles); } updateProcessedFiles(); @@ -343,8 +403,10 @@ /** * Adds the given LN info to the pending LN set. */ - synchronized boolean addPendingLN(LN ln, DatabaseId dbId, - byte[] key, byte[] dupKey) { + synchronized boolean addPendingLN(LN ln, + DatabaseId dbId, + byte[] key, + byte[] dupKey) { assert ln != null; boolean added = pendingLNs.put @@ -437,9 +499,18 @@ * finally been deleted. */ synchronized void removeDeletedFile(Long fileNum, MemoryBudget budget) { - safeToDeleteFiles.remove(fileNum); - Set oldDatabases = cleanedFilesDatabases.remove(fileNum); - adjustMemoryBudget(budget, oldDatabases, null /*newDatabases*/); + /* Ensure that no remnants of a deleted file remain. [#17752] */ + removeAllFileReferences(fileNum, budget); + } + + /** + * Update memory budgets when the environment is closed and will never be + * accessed again. + */ + synchronized void close(MemoryBudget budget) { + for (Set oldDatabases : cleanedFilesDatabases.values()) { + adjustMemoryBudget(budget, oldDatabases, null /*newDatabases*/); + } } /** @@ -516,4 +587,19 @@ return fullyProcessedFiles; } } + + @Override + public String toString() { + return "toBeCleanedFiles = " + toBeCleanedFiles + + " beingCleanedFiles = " + beingCleanedFiles + + " cleanedFiles = " + cleanedFiles + + " cleanedFilesDatabases = " + cleanedFilesDatabases + + " checkpointedFiles = " + checkpointedFiles + + " fullyProcessedFiles = " + fullyProcessedFiles + + " safeToDeleteFiles = " + safeToDeleteFiles + + " pendingLNs = " + pendingLNs + + " pendingDBs = " + pendingDBs + + " anyPendingDuringCheckpoint = " + anyPendingDuringCheckpoint + + " lowUtilizationFiles = " + lowUtilizationFiles; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/FileSummary.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/FileSummary.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/FileSummary.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/FileSummary.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileSummary.java,v 1.24 2008/01/07 14:28:47 cwl Exp $ + * $Id: FileSummary.java,v 1.25.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -278,6 +278,7 @@ return false; } + @Override public String toString() { StringBuffer buf = new StringBuffer(); dumpLog(buf, true); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/LNInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/LNInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/LNInfo.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/LNInfo.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LNInfo.java,v 1.7 2008/01/07 14:28:47 cwl Exp $ + * $Id: LNInfo.java,v 1.7.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/LocalUtilizationTracker.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/LocalUtilizationTracker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/LocalUtilizationTracker.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/LocalUtilizationTracker.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LocalUtilizationTracker.java,v 1.4 2008/05/15 01:52:40 linda Exp $ + * $Id: LocalUtilizationTracker.java,v 1.4.2.3 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -107,4 +107,11 @@ return (DatabaseImpl) databaseKey; } + + /** + * Do nothing, since DbTree.getDb was not called by + * databaseKeyToDatabaseImpl. + */ + void releaseDatabaseImpl(DatabaseImpl db) { + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/OffsetList.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/OffsetList.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/OffsetList.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/OffsetList.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: OffsetList.java,v 1.14 2008/01/07 14:28:47 cwl Exp $ + * $Id: OffsetList.java,v 1.14.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/PackedOffsets.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/PackedOffsets.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/PackedOffsets.java 2008-01-17 17:22:12.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/PackedOffsets.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PackedOffsets.java,v 1.15 2008/01/17 17:22:11 cwl Exp $ + * $Id: PackedOffsets.java,v 1.16.2.3 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -32,6 +32,12 @@ * Creates an empty object. */ public PackedOffsets() { + + /* + * Verify assumption in FileSummaryLN that a new PackedOffsets instance + * has no extra extra memory that must be budgeted. + */ + assert getExtraMemorySize() == 0; } /** @@ -223,6 +229,7 @@ return false; } + @Override public String toString() { StringBuffer buf = new StringBuffer(); dumpLog(buf, true); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/RecoveryUtilizationTracker.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/RecoveryUtilizationTracker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/RecoveryUtilizationTracker.java 2008-05-27 15:30:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/RecoveryUtilizationTracker.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryUtilizationTracker.java,v 1.8 2008/05/27 15:30:35 mark Exp $ + * $Id: RecoveryUtilizationTracker.java,v 1.9.2.3 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -134,6 +134,7 @@ * Overrides this method for recovery and returns whether the FileSummaryLN * for the given file is prior to the given LSN. */ + @Override boolean isFileUncounted(Long fileNum, long lsn) { long fsLsn = DbLsn.longToLsn(fileSummaryLsns.get(fileNum)); int cmpFsLsnToNewLsn = (fsLsn != DbLsn.NULL_LSN) ? @@ -173,10 +174,20 @@ * Returns the DatabaseImpl from the database key, which in this case is * the DatabaseId. */ + @Override DatabaseImpl databaseKeyToDatabaseImpl(Object databaseKey) throws DatabaseException { DatabaseId dbId = (DatabaseId) databaseKey; return env.getDbTree().getDb(dbId); } + + /** + * Must release the database, since DbTree.getDb was called by + * databaseKeyToDatabaseImpl. + */ + @Override + void releaseDatabaseImpl(DatabaseImpl db) { + env.getDbTree().releaseDb(db); + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/TrackedFileSummary.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/TrackedFileSummary.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/TrackedFileSummary.java 2008-03-25 03:26:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/TrackedFileSummary.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TrackedFileSummary.java,v 1.16 2008/03/25 02:26:35 linda Exp $ + * $Id: TrackedFileSummary.java,v 1.17.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -79,6 +79,7 @@ * *

Must be called under the log write latch.

*/ + @Override public void reset() { obsoleteOffsets = null; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/UtilizationProfile.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/UtilizationProfile.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/UtilizationProfile.java 2008-05-15 01:52:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/UtilizationProfile.java 2010-01-22 00:29:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: UtilizationProfile.java,v 1.84 2008/05/15 01:52:40 linda Exp $ + * $Id: UtilizationProfile.java,v 1.84.2.5 2010/01/22 00:29:56 mark Exp $ */ package com.sleepycat.je.cleaner; @@ -218,21 +218,24 @@ Long bestFile = null; int bestCost = Integer.MAX_VALUE; + final SortedMap currentFileSummaryMap = + getFileSummaryMap(true /*includeTrackedFiles*/); + for (Iterator iter = files.iterator(); iter.hasNext();) { Long file = iter.next(); + FileSummary summary = currentFileSummaryMap.get(file); /* - * Ignore files in the given set that are not in the profile. This - * can occur with multiple cleaner threads because we don't hold a - * synchronized lock during the entire execution of the - * FileSelector.selectFileForCleaning method. [#14431] + * Return a file in the given set if it does not exist. Deleted + * files should be selected ASAP to remove them from the backlog. + * [#18179] For details, see where FileProcessor.doClean handles + * LogFileNotFoundException. */ - if (!fileSummaryMap.containsKey(file)) { - continue; + if (summary == null) { + return file; } /* Calculate this file's cost to clean. */ - FileSummary summary = getFileSummary(file); int thisCost = summary.getNonObsoleteCount(); /* Select this file if it has the lowest cost so far. */ @@ -701,6 +704,7 @@ /* Now delete all FileSummaryLNs. */ Locker locker = null; CursorImpl cursor = null; + boolean clearedTrackedFile = false; try { locker = BasicLocker.createBasicLocker(env, false /*noWait*/, true /*noAPIReadLock*/); @@ -713,13 +717,15 @@ long fileNumVal = fileNum.longValue(); /* Search by file number. */ - if (!getFirstFSLN + OperationStatus status = OperationStatus.SUCCESS; + if (getFirstFSLN (cursor, fileNumVal, keyEntry, dataEntry, LockType.WRITE)) { - return; + status = OperationStatus.SUCCESS; + } else { + status = OperationStatus.NOTFOUND; } /* Delete all LNs for this file number. */ - OperationStatus status = OperationStatus.SUCCESS; while (status == OperationStatus.SUCCESS) { /* Perform eviction once per operation. */ @@ -739,6 +745,7 @@ /* Associate the tracked summary so it will be cleared. */ if (tfs != null) { ln.setTrackedSummary(tfs); + clearedTrackedFile = true; } /* @@ -763,6 +770,21 @@ locker.operationEnd(); } } + + /* + * If LN.setTrackedSummary was not called above, the file will not be + * removed from the UtilizationTracker. This can happen if a file is + * resurrected in the tracker after being cleaned, deleted and removed + * from the profile. We'll end up here because FileProcessor.doClean + * calls removeFile when it gets a LogFileNotFoundException. For this + * case we explicitly remove the file from the tracker below. [#16928] + */ + if (!clearedTrackedFile) { + TrackedFileSummary tfs = tracker.getTrackedFile(fileNum); + if (tfs != null) { + env.getLogManager().removeTrackedFile(tfs); + } + } } /** @@ -1247,10 +1269,12 @@ /** * Insert the given LN with the given key values. This method is * synchronized and may not perform eviction. + * + * Is public only for unit testing. */ - private synchronized void insertFileSummary(FileSummaryLN ln, - long fileNum, - int sequence) + public synchronized boolean insertFileSummary(FileSummaryLN ln, + long fileNum, + int sequence) throws DatabaseException { byte[] keyBytes = FileSummaryLN.makeFullKey(fileNum, sequence); @@ -1275,10 +1299,17 @@ "Cleaner duplicate key sequence file=0x" + Long.toHexString(fileNum) + " sequence=0x" + Long.toHexString(sequence)); + return false; } + /* Account for FileSummaryLN's extra marshaled memory. [#17462] */ + BIN bin = cursor.latchBIN(); + ln.addExtraMarshaledMemorySize(bin); + cursor.releaseBIN(); + /* Always evict after using a file summary LN. */ cursor.evict(); + return true; } finally { if (cursor != null) { cursor.close(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/UtilizationTracker.java libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/UtilizationTracker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/cleaner/UtilizationTracker.java 2008-05-13 01:44:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/cleaner/UtilizationTracker.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: UtilizationTracker.java,v 1.26 2008/05/13 01:44:49 cwl Exp $ + * $Id: UtilizationTracker.java,v 1.27.2.3 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -50,6 +50,7 @@ super(env, cleaner); } + @Override public EnvironmentImpl getEnvironment() { return env; } @@ -185,6 +186,9 @@ * database key. * *

Must be called under the log write latch.

+ * + * @return the summary, or null if the DB should not be tracked because + * the file has been deleted, or null if the databaseKey param is null. */ DbFileSummary getDbFileSummary(Object databaseKey, long fileNum) { DatabaseImpl db = (DatabaseImpl) databaseKey; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/BooleanConfigParam.java libdb-je-java-3.3.98/src/com/sleepycat/je/config/BooleanConfigParam.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/BooleanConfigParam.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/BooleanConfigParam.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BooleanConfigParam.java,v 1.30 2008/05/30 19:07:40 mark Exp $ + * $Id: BooleanConfigParam.java,v 1.31.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.config; @@ -36,6 +36,7 @@ /** * Make sure that value is a valid string for booleans. */ + @Override public void validateValue(String value) throws IllegalArgumentException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/ConfigParam.java libdb-je-java-3.3.98/src/com/sleepycat/je/config/ConfigParam.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/ConfigParam.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/ConfigParam.java 2008-06-10 02:52:10.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: ConfigParam.java,v 1.31 2008/05/30 19:07:40 mark Exp $ + * $Id: ConfigParam.java,v 1.32 2008/06/10 02:52:09 cwl Exp $ */ package com.sleepycat.je.config; @@ -141,6 +141,7 @@ } + @Override public String toString() { return name; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/EnvironmentParams.java libdb-je-java-3.3.98/src/com/sleepycat/je/config/EnvironmentParams.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/EnvironmentParams.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/EnvironmentParams.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,26 +1,20 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentParams.java,v 1.106 2008/05/30 19:07:40 mark Exp $ + * $Id: EnvironmentParams.java,v 1.108.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.config; -import java.io.File; -import java.io.FileWriter; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.TreeSet; import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.dbi.EnvironmentImpl; /** - * Javadoc for this public class is generated - * via the doc templates in the doc_src directory. */ public class EnvironmentParams { @@ -33,7 +27,8 @@ new HashMap(); /* - * Environment + * Only environment parameters that are part of the public API are + * represented by String constants in EnvironmentConfig. */ public static final LongConfigParam MAX_MEMORY = new LongConfigParam(EnvironmentConfig.MAX_MEMORY, @@ -82,7 +77,7 @@ false); // forReplication /** - * @deprecated As of 2.0, eviction is performed in-line. + * As of 2.0, eviction is performed in-line. * * If true, starts up the evictor. This parameter is false by default. */ @@ -173,7 +168,7 @@ false); // forReplication /** - * @deprecated As of 3.3, is true by default. + * Not part of the public API. As of 3.3, is true by default. * * If true (the default), use shared latches for Btree Internal Nodes (INs) * to improve concurrency. @@ -481,7 +476,7 @@ false); // forReplication /** - * @deprecated As of 2.0, eviction is performed in-line. + * Not part of public API. As of 2.0, eviction is performed in-line. * * At this percentage over the allotted cache, critical eviction will * start. @@ -692,7 +687,7 @@ false); // forReplication /** - * @deprecated as of 3.3, never intended for public use + * Not part of public API. * * If true, the cleaner tracks and stores detailed information that is used * to decrease the cost of cleaning. @@ -712,7 +707,7 @@ false); // forReplication /** - * @deprecated as of 3.0, since it applies to a very old bug. + * Not part of public API, since it applies to a very old bug. * * If true, detail information is discarded that was added by earlier * versions of JE (specifically 2.0.42 and 2.0.54) if it may be invalid. diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/IntConfigParam.java libdb-je-java-3.3.98/src/com/sleepycat/je/config/IntConfigParam.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/IntConfigParam.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/IntConfigParam.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: IntConfigParam.java,v 1.30 2008/05/30 19:07:40 mark Exp $ + * $Id: IntConfigParam.java,v 1.31.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.config; @@ -62,6 +62,7 @@ } } + @Override public void validateValue(String value) throws IllegalArgumentException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/LongConfigParam.java libdb-je-java-3.3.98/src/com/sleepycat/je/config/LongConfigParam.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/LongConfigParam.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/LongConfigParam.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LongConfigParam.java,v 1.28 2008/05/30 19:07:40 mark Exp $ + * $Id: LongConfigParam.java,v 1.29.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.config; @@ -63,6 +63,7 @@ } } + @Override public void validateValue(String value) throws IllegalArgumentException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/package.html libdb-je-java-3.3.98/src/com/sleepycat/je/config/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/package.html 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/package.html 2010-01-04 15:30:28.000000000 +0000 @@ -5,9 +5,9 @@ See the file LICENSE for redistribution information. - Copyright (c) 2002,2008 Oracle. All rights reserved. + Copyright (c) 2002,2010 Oracle. All rights reserved. - $Id: package.html,v 1.11 2008/01/07 14:28:47 cwl Exp $ + $Id: package.html,v 1.11.2.2 2010/01/04 15:30:28 cwl Exp $ --> diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/config/ShortConfigParam.java libdb-je-java-3.3.98/src/com/sleepycat/je/config/ShortConfigParam.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/config/ShortConfigParam.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/config/ShortConfigParam.java 2008-06-10 02:52:10.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2002,2006 Oracle. All rights reserved. * - * $Id: ShortConfigParam.java,v 1.25 2008/05/30 19:07:40 mark Exp $ + * $Id: ShortConfigParam.java,v 1.26 2008/06/10 02:52:09 cwl Exp $ */ package com.sleepycat.je.config; @@ -61,6 +61,7 @@ } } + @Override public void validateValue(String value) throws IllegalArgumentException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/CursorConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/CursorConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/CursorConfig.java 2008-04-07 22:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/CursorConfig.java 2010-03-22 21:53:34.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CursorConfig.java,v 1.24 2008/04/07 22:28:29 mark Exp $ + * $Id: CursorConfig.java,v 1.25.2.4 2010/03/22 21:53:33 mark Exp $ */ package com.sleepycat.je; @@ -115,11 +115,14 @@ } /** - * Configures read operations performed by the cursor to return modified - * but not yet committed data. + * Configures read operations performed by the cursor to obey read + * committed isolation. Read committed isolation provides for cursor + * stability but not repeatable reads. Data items which have been + * previously read by this transaction may be deleted or modified by other + * transactions before the cursor is closed or the transaction completes. * * @param readCommitted If true, configure read operations performed by - * the cursor to return modified but not yet committed data. + * the cursor to obey read commited isolation. * * @see LockMode#READ_COMMITTED */ @@ -129,10 +132,10 @@ /** * Returns true if read operations performed by the cursor are configured - * to return modified but not yet committed data. + * to obey read committed isolation. * * @return true if read operations performed by the cursor are configured - * to return modified but not yet committed data. + * to obey read committed isolation.w * * @see LockMode#READ_COMMITTED */ @@ -151,4 +154,16 @@ return null; } } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "readUncommitted=" + readUncommitted + + "\nreadCommitted=" + readCommitted + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/Cursor.java libdb-je-java-3.3.98/src/com/sleepycat/je/Cursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/Cursor.java 2008-05-29 03:17:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/Cursor.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Cursor.java,v 1.215 2008/05/29 03:17:28 linda Exp $ + * $Id: Cursor.java,v 1.216.2.5 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -186,8 +186,8 @@ assert locker != null; - DatabaseImpl dbImpl = dbHandle.getDatabaseImpl(); - cursorImpl = new CursorImpl(dbImpl, locker, retainNonTxnLocks); + DatabaseImpl databaseImpl = dbHandle.getDatabaseImpl(); + cursorImpl = new CursorImpl(databaseImpl, locker, retainNonTxnLocks); /* Perform eviction for user cursors. */ cursorImpl.setAllowEviction(true); @@ -200,14 +200,14 @@ cursorImpl.getLocker().isSerializableIsolation(); updateOperationsProhibited = - (dbImpl.isTransactional() && !locker.isTransactional()) || + (databaseImpl.isTransactional() && !locker.isTransactional()) || !dbHandle.isWritable(); - this.dbImpl = dbImpl; + this.dbImpl = databaseImpl; this.dbHandle = dbHandle; dbHandle.addCursor(this); this.config = cursorConfig; - this.logger = dbImpl.getDbEnvironment().getLogger(); + this.logger = databaseImpl.getDbEnvironment().getLogger(); } /** @@ -427,7 +427,7 @@ *

If the key already appears in the database and duplicates are * supported, the new data value is inserted at the correct sorted * location. If the key already appears in the database and duplicates are - * not supported, the existing key/data pair will be replaced.

+ * not supported, the data associated with the key will be replaced.

* * @param key the key {@link com.sleepycat.je.DatabaseEntry * DatabaseEntry} operated on. @@ -637,7 +637,7 @@ } /** - * Moves the cursor to the first key/data pair of the database, and return + * Moves the cursor to the first key/data pair of the database, and returns * that pair. If the first key has duplicate values, the first data item * in the set of duplicates is returned. * @@ -681,7 +681,7 @@ } /** - * Moves the cursor to the last key/data pair of the database, and return + * Moves the cursor to the last key/data pair of the database, and returns * that pair. If the last key has duplicate values, the last data item in * the set of duplicates is returned. * @@ -725,9 +725,7 @@ } /** - * Moves the cursor to the next key/data pair and return that pair. If the - * matching key has duplicate values, the first data item in the set of - * duplicates is returned. + * Moves the cursor to the next key/data pair and returns that pair. * *

If the cursor is not yet initialized, move the cursor to the first * key/data pair of the database, and return that pair. Otherwise, the @@ -781,7 +779,7 @@ /** * If the next key/data pair of the database is a duplicate data record for * the current key/data pair, moves the cursor to the next key/data pair of - * the database and return that pair. + * the database and returns that pair. * *

If this method fails for any reason, the position of the cursor will * be unchanged.

@@ -823,9 +821,9 @@ } /** - * Moves the cursor to the next non-duplicate key/data pair and return that - * pair. If the matching key has duplicate values, the first data item in - * the set of duplicates is returned. + * Moves the cursor to the next non-duplicate key/data pair and returns + * that pair. If the matching key has duplicate values, the first data + * item in the set of duplicates is returned. * *

If the cursor is not yet initialized, move the cursor to the first * key/data pair of the database, and return that pair. Otherwise, the @@ -876,9 +874,7 @@ } /** - * Moves the cursor to the previous key/data pair and return that pair. If - * the matching key has duplicate values, the last data item in the set of - * duplicates is returned. + * Moves the cursor to the previous key/data pair and returns that pair. * *

If the cursor is not yet initialized, move the cursor to the last * key/data pair of the database, and return that pair. Otherwise, the @@ -932,7 +928,7 @@ /** * If the previous key/data pair of the database is a duplicate data record * for the current key/data pair, moves the cursor to the previous key/data - * pair of the database and return that pair. + * pair of the database and returns that pair. * *

If this method fails for any reason, the position of the cursor will * be unchanged.

@@ -974,7 +970,7 @@ } /** - * Moves the cursor to the previous non-duplicate key/data pair and return + * Moves the cursor to the previous non-duplicate key/data pair and returns * that pair. If the matching key has duplicate values, the last data item * in the set of duplicates is returned. * @@ -1027,7 +1023,7 @@ } /** - * Moves the cursor to the given key of the database, and return the datum + * Moves the cursor to the given key of the database, and returns the datum * associated with the given key. If the matching key has duplicate * values, the first data item in the set of duplicates is returned. * @@ -1072,10 +1068,10 @@ } /** - * Moves the cursor to the closest matching key of the database, and return - * the data item associated with the matching key. If the matching key has - * duplicate values, the first data item in the set of duplicates is - * returned. + * Moves the cursor to the closest matching key of the database, and + * returns the data item associated with the matching key. If the matching + * key has duplicate values, the first data item in the set of duplicates + * is returned. * *

The returned key/data pair is for the smallest key greater than or * equal to the specified key (as determined by the key comparison @@ -1698,7 +1694,6 @@ SearchMode.SET_RANGE : SearchMode.BOTH_RANGE; KeyChangeStatus result = null; - boolean noNextKeyFound; CursorImpl dup = beginRead(false /* searchAndPosition will add cursor */); @@ -1714,9 +1709,6 @@ (dup, key, data, searchLockType, advanceLockType, searchMode, true /*advanceAfterRangeSearch*/); - /* The keyChange value is independent of the status value. */ - noNextKeyFound = !result.keyChange; - /* If the key changed, then we do not have an exact match. */ if (result.keyChange && result.status == OperationStatus.SUCCESS) { result.status = OperationStatus.NOTFOUND; @@ -1726,8 +1718,11 @@ result.status == OperationStatus.SUCCESS); } - /* Lock the EOF node if no more records, whether or not more dups. */ - if (noNextKeyFound) { + /* + * Lock the EOF node if there was no exact match and we did not + * range-lock the next record. + */ + if (result.status != OperationStatus.SUCCESS && !result.keyChange) { cursorImpl.lockEofNode(LockType.RANGE_READ); } @@ -1928,7 +1923,7 @@ /* * If we did not match the key (exactly) for - * BOTH_RANGE, and advanceAfterSearchRangeBoth is + * BOTH_RANGE, and advanceAfterRangeSearch is * false, then return NOTFOUND. */ status = OperationStatus.NOTFOUND; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseConfig.java 2008-05-29 03:38:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseConfig.java,v 1.47 2008/05/29 03:38:23 linda Exp $ + * $Id: DatabaseConfig.java,v 1.48.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -877,7 +877,7 @@ boolean dwMatch, boolean btCmpMatch, boolean dtCmpMatch) { - StringBuffer ret = new StringBuffer + StringBuilder ret = new StringBuilder ("The following DatabaseConfig parameters for the\n" + "cached Database do not match the parameters for the\n" + "requested Database:\n"); @@ -1030,4 +1030,22 @@ return true; } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "allowCreate=" + allowCreate + + "\nexclusiveCreate=" + exclusiveCreate + + "\ntransactional=" + transactional + + "\nreadOnly=" + readOnly + + "\nduplicatesAllowed=" + duplicatesAllowed + + "\ndeferredWrite=" + deferredWrite + + "\ntemporary=" + temporary + + "\nkeyPrefixingEnabled=" + keyPrefixingEnabled + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseEntry.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseEntry.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseEntry.java,v 1.47 2008/01/24 14:59:27 linda Exp $ + * $Id: DatabaseEntry.java,v 1.48.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -104,7 +104,7 @@ /* FindBugs - ignore not "final" since a user can set this. */ /** @hidden - * The maximum number of bytes to show when toString() is called. + * The maximum number of bytes to show when toString() is called. */ public static int MAX_DUMP_BYTES = 100; @@ -115,12 +115,16 @@ * defaults to 100. MAX_DUMP_BYTES may be changed by an application if it * wishes to cause more bytes to be formatted. */ + @Override public String toString() { StringBuffer sb = new StringBuffer(" MAX_DUMP_BYTES) { @@ -426,6 +430,7 @@ * equal both entries must have the same partial properties: partial, * partialOffset and partialLength. */ + @Override public boolean equals(Object o) { if (!(o instanceof DatabaseEntry)) { return false; @@ -458,6 +463,7 @@ /** * Returns a hash code based on the data value. */ + @Override public int hashCode() { int hash = 0; if (data != null) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseException.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseException.java 2008-05-29 03:38:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseException.java,v 1.26 2008/05/29 03:38:23 linda Exp $ + * $Id: DatabaseException.java,v 1.26.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/Database.java libdb-je-java-3.3.98/src/com/sleepycat/je/Database.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/Database.java 2008-05-30 14:04:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/Database.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Database.java,v 1.241 2008/05/30 14:04:15 mark Exp $ + * $Id: Database.java,v 1.242.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -61,6 +61,7 @@ this.stateName = stateName; } + @Override public String toString() { return "DbState." + stateName; } @@ -844,9 +845,10 @@ * Stores the key/data pair into the database. * *

If the key already appears in the database and duplicates are not - * configured, the existing key/data pair will be replaced. If the key - * already appears in the database and sorted duplicates are configured, - * the new data value is inserted at the correct sorted location.

+ * configured, the data associated with the key will be replaced. If the + * key already appears in the database and sorted duplicates are + * configured, the new data value is inserted at the correct sorted + * location.

* * @param txn For a transactional database, an explicit transaction may be * specified, or null may be specified to use auto-commit. For a diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseNotFoundException.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseNotFoundException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseNotFoundException.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseNotFoundException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseNotFoundException.java,v 1.9 2008/01/07 14:28:46 cwl Exp $ + * $Id: DatabaseNotFoundException.java,v 1.9.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseStats.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseStats.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseStats.java,v 1.24 2008/01/07 14:28:46 cwl Exp $ + * $Id: DatabaseStats.java,v 1.24.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseTrigger.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseTrigger.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseTrigger.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseTrigger.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseTrigger.java,v 1.11 2008/01/07 14:28:46 cwl Exp $ + * $Id: DatabaseTrigger.java,v 1.11.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseUtil.java libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseUtil.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DatabaseUtil.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DatabaseUtil.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseUtil.java,v 1.36 2008/01/07 14:28:46 cwl Exp $ + * $Id: DatabaseUtil.java,v 1.36.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/CursorImpl.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/CursorImpl.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/CursorImpl.java 2008-05-20 03:27:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/CursorImpl.java 2010-03-26 13:23:56.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CursorImpl.java,v 1.348 2008/05/20 03:27:34 linda Exp $ + * $Id: CursorImpl.java,v 1.348.2.5 2010/03/26 13:23:55 mark Exp $ */ package com.sleepycat.je.dbi; @@ -115,8 +115,7 @@ */ private static long lastAllocatedId = 0; - private ThreadLocal - treeStatsAccumulatorTL = new ThreadLocal(); + private ThreadLocal treeStatsAccumulatorTL; /* * Allocate a new hashCode id. Doesn't need to be synchronized since it's @@ -130,8 +129,16 @@ return thisId; } + private void maybeInitTreeStatsAccumulator() { + if (treeStatsAccumulatorTL == null) { + treeStatsAccumulatorTL = + new ThreadLocal(); + } + } + private TreeWalkerStatsAccumulator getTreeStatsAccumulator() { if (EnvironmentImpl.getThreadLocalReferenceCount() > 0) { + maybeInitTreeStatsAccumulator(); return treeStatsAccumulatorTL.get(); } else { return null; @@ -416,6 +423,7 @@ } public void setTreeStatsAccumulator(TreeWalkerStatsAccumulator tSA) { + maybeInitTreeStatsAccumulator(); treeStatsAccumulatorTL.set(tSA); } @@ -697,6 +705,10 @@ assert assertCursorState(false) : dumpToString(true); + if (cacheMode == CacheMode.EVICT_LN) { + evict(); + } + removeCursor(); locker.unRegisterCursor(this); @@ -1084,7 +1096,7 @@ } /** - * Insert the replicated LN. TODO: very similar to put(), refactor for + * Insert the replicated LN. TODO: very similar to put(), refactor for * HA release. */ public OperationStatus putReplicatedLN(LNLogEntry lnEntry, @@ -1116,7 +1128,7 @@ } /** - * Delete the replicated LN. + * Delete the replicated LN. */ public OperationStatus deleteReplicatedLN(LNLogEntry lnEntry, ReplicationContext repContext) @@ -1855,8 +1867,9 @@ } /** - * Position the cursor at the first or last record of the databaseImpl. It's - * okay if this record is deleted. Returns with the target BIN latched. + * Position the cursor at the first or last record of the databaseImpl. + * It's okay if this record is deleted. Returns with the target BIN + * latched. * * @return true if a first or last position is found, false if the * tree being searched is empty. @@ -1949,7 +1962,7 @@ * An IN was found. Even if it's empty, let Cursor handle * moving to the first non-deleted entry. */ - /* + /* * assert (in instanceof DBIN); * Will always be true since Tree.getFirst/LastNode always * returns a DBIN. @@ -2226,7 +2239,6 @@ * is still the correct LN, but our cursor is now down in a * duplicate tree. [#14230]. */ - ln = lockResult.getLN(); if (ln == null) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DatabaseId.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DatabaseId.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DatabaseId.java 2008-05-06 18:23:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DatabaseId.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseId.java,v 1.42 2008/05/06 18:23:48 linda Exp $ + * $Id: DatabaseId.java,v 1.42.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DatabaseImpl.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DatabaseImpl.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DatabaseImpl.java 2008-05-19 17:52:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DatabaseImpl.java 2010-03-23 15:02:08.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseImpl.java,v 1.204 2008/05/19 17:52:17 linda Exp $ + * $Id: DatabaseImpl.java,v 1.205.2.7 2010/03/23 15:02:07 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -111,6 +111,8 @@ private static final byte IS_REPLICATED_BIT = 0x4; // isReplicated() private static final byte NOT_REPLICATED_BIT = 0x8;// notReplicated() private static final byte PREFIXING_ENABLED = 0x10;// getKeyPrefixing() + /* getUtilizationRepairDone() */ + private static final byte UTILIZATION_REPAIR_DONE = 0x20; private DatabaseId id; // unique id private Tree tree; @@ -168,7 +170,7 @@ /* For unit tests */ private TestHook pendingDeletedHook; - /* + /* * For debugging -- this gives the ability to force all non-internal * databases to use key prefixing. * @@ -230,6 +232,12 @@ createdAtLogVersion = LogEntryType.LOG_VERSION; + /* + * New DB records do not need utilization repair. Set this before + * calling initWithEnvironment to avoid repair overhead. + */ + setUtilizationRepairDone(); + commonInit(); initWithEnvironment(); @@ -332,6 +340,19 @@ /* Budgets memory for the utilization info. */ dbFileSummaries.init(envImpl); + + /* + * Repair utilization info if necessary. The repair flag will not be + * set for MapLNs written by JE 3.3.74 and earlier, and will be set for + * all MapLNs written thereafter. Make the utilization dirty to force + * the MapLN to be flushed. Even if no repair is performed, we want to + * write the updated flag. [#16610] + */ + if (!getUtilizationRepairDone()) { + dbFileSummaries.repair(envImpl); + setDirtyUtilization(); + setUtilizationRepairDone(); + } } /** @@ -508,6 +529,24 @@ flags |= NOT_REPLICATED_BIT; } + /** + * Is public for unit testing. + */ + public boolean getUtilizationRepairDone() { + return (flags & UTILIZATION_REPAIR_DONE) != 0; + } + + private void setUtilizationRepairDone() { + flags |= UTILIZATION_REPAIR_DONE; + } + + /** + * Is public for unit testing. + */ + public void clearUtilizationRepairDone() { + flags &= ~UTILIZATION_REPAIR_DONE; + } + public int getNodeMaxEntries() { return maxMainTreeEntriesPerNode; } @@ -543,7 +582,7 @@ val += 2 * MemoryBudget.byteArraySize (duplicateComparatorBytes.length); } - + return val; } @@ -729,9 +768,9 @@ * garbage collected, due to eviction or recovery. */ public void releaseTreeAdminMemory() { - /* + /* * There's no need to account for INs which belong to this database, - * because those are closed by the EnvironmentImpl when clearing + * because those are closed by the EnvironmentImpl when clearing * the INList. Do adjust memory budget for utilization info. */ dbFileSummaries.subtractFromMemoryBudget(); @@ -860,7 +899,9 @@ dirtyUtilization = true; } assert dbFileSummaries != null; - return dbFileSummaries.get(fileNum, true /* adjustMemBudget */); + return dbFileSummaries.get(fileNum, true /*adjustMemBudget*/, + true /*checkResurrected*/, + envImpl.getFileManager()); } /** @@ -1249,14 +1290,15 @@ new StatsAccumulator(out, config.getShowProgressInterval(), emptyStats) { - void verifyNode(Node node) { + @Override + void verifyNode(Node node) { - try { - node.verify(null); - } catch (DatabaseException INE) { - progressStream.println(INE); - } + try { + node.verify(null); + } catch (DatabaseException INE) { + progressStream.println(INE); } + } }; boolean ok = walkDatabaseTree(statsAcc, out, config.getPrintInfo()); statsAcc.copyToStats(emptyStats); @@ -1304,6 +1346,11 @@ } boolean done = false; while (!done) { + + /* Perform eviction before each cursor operation. */ + envImpl.getEvictor().doCriticalEviction + (false /*backgroundIO*/); + try { status = cursor.getNext (key, foundData, LockType.NONE, true /*forward*/, @@ -1405,7 +1452,7 @@ binsSeenByLevel = new long[MAX_LEVELS]; dinsSeenByLevel = new long[MAX_LEVELS]; dbinsSeenByLevel = new long[MAX_LEVELS]; - + this.useStats = useStats; } @@ -1613,8 +1660,6 @@ byte[] ignore2) throws DatabaseException { - assert childLsn != DbLsn.NULL_LSN; - /* * Check if we've exceeded either the max time or max bytes * allowed for this preload() call. @@ -1733,7 +1778,7 @@ protected void releaseRootIN(IN root) throws DatabaseException { - root.releaseLatch(); + root.releaseLatch(); } /* @@ -1811,20 +1856,20 @@ cacheBudget + " bytes."); } - PreloadStats stats = new PreloadStats(); + PreloadStats pstats = new PreloadStats(); PreloadProcessor callback = - new PreloadProcessor(envImpl, maxBytes, targetTime, stats); + new PreloadProcessor(envImpl, maxBytes, targetTime, pstats); SortedLSNTreeWalker walker = new PreloadLSNTreeWalker(this, callback, config); walker.setPassNullLSNNodes(true); try { walker.walk(); } catch (HaltPreloadException HPE) { - stats.setStatus(HPE.getStatus()); + pstats.setStatus(HPE.getStatus()); } assert LatchSupport.countLatchesHeld() == 0; - return stats; + return pstats; } catch (Error E) { envImpl.invalidate(E); throw E; @@ -1902,9 +1947,9 @@ throws DatabaseException { try { - PreloadStats stats = new PreloadStats(); + PreloadStats pstats = new PreloadStats(); - CountProcessor callback = new CountProcessor(envImpl, stats); + CountProcessor callback = new CountProcessor(envImpl, pstats); ExceptionPredicate excPredicate = new CountExceptionPredicate(); SortedLSNTreeWalker walker = new SortedLSNTreeWalker(this, false /* setDbState */, @@ -1912,13 +1957,11 @@ excPredicate); /* Don't descend down into the dup tree. Use the DupCountLN. */ walker.setProcessDupTree(false); - if (isDurableDeferredWrite()) { - walker.setPassNullLSNNodes(true); - } + walker.setPassNullLSNNodes(true); walker.walk(); assert LatchSupport.countLatchesHeld() == 0; - return stats.getNLNsLoaded(); + return pstats.getNLNsLoaded(); } catch (Error E) { envImpl.invalidate(E); throw E; @@ -1958,7 +2001,7 @@ } sb.append(">"); if (dbFileSummaries != null) { - Iterator> entries = + Iterator> entries = (Iterator>) dbFileSummaries.entrySet().iterator(); while (entries.hasNext()) { @@ -2000,7 +2043,8 @@ 1; // createdAtLogVersion size += LogUtils.getPackedIntLogSize(dbFileSummaries.size()); - Iterator> i = + + Iterator> i = (Iterator>) dbFileSummaries.entrySet().iterator(); while (i.hasNext()) { @@ -2027,7 +2071,7 @@ LogUtils.writePackedInt(logBuffer, maxDupTreeEntriesPerNode); logBuffer.put(createdAtLogVersion); LogUtils.writePackedInt(logBuffer, dbFileSummaries.size()); - Iterator> i = + Iterator> i = (Iterator>) dbFileSummaries.entrySet().iterator(); @@ -2095,8 +2139,8 @@ if (obj instanceof String) { String className = (String)obj; - Class> cls = - (Class>) + Class> cls = + (Class>) Class.forName(className); btreeComparator = instantiateComparator(cls, "Btree"); @@ -2116,8 +2160,8 @@ (duplicateComparatorBytes, "Duplicate"); if (obj instanceof String) { - Class> cls = - (Class>) + Class> cls = + (Class>) Class.forName((String) obj); duplicateComparator = @@ -2152,7 +2196,8 @@ for (int i = 0; i < nFiles; i += 1) { long fileNum = LogUtils.readPackedLong(itemBuffer); DbFileSummary summary = dbFileSummaries.get - (Long.valueOf(fileNum), false /* adjustMemBudget */); + (Long.valueOf(fileNum), false /*adjustMemBudget*/, + false /*checkResurrected*/, null /*fileManager*/); summary.readFromLog(itemBuffer, entryVersion); } } @@ -2173,8 +2218,8 @@ id.dumpLog(sb, verbose); tree.dumpLog(sb, verbose); if (dbFileSummaries != null) { - Iterator> entries = - (Iterator>) + Iterator> entries = + (Iterator>) dbFileSummaries.entrySet().iterator(); while (entries.hasNext()) { @@ -2193,7 +2238,7 @@ static void dumpFlags(StringBuffer sb, boolean verbose, byte flags) { sb.append(" dupsort=\"").append((flags & DUPS_ALLOWED_BIT) != 0); sb.append("\" replicated=\"").append((flags & IS_REPLICATED_BIT) != 0); - sb.append("\" temp=\"").append((flags & TEMPORARY_BIT) + sb.append("\" temp=\"").append((flags & TEMPORARY_BIT) != 0).append("\" "); } @@ -2215,7 +2260,7 @@ /** * Used for log dumping. */ - private static String + private static String getComparatorClassName(Comparator comparator) { if (comparator != null) { @@ -2229,8 +2274,8 @@ * Used both to read from the log and to validate a comparator when set in * DatabaseConfig. */ - public static Comparator - instantiateComparator(Class> + public static Comparator + instantiateComparator(Class> comparatorClass, String comparatorType) throws LogException { @@ -2255,7 +2300,7 @@ /** * Used to validate a comparator when set in DatabaseConfig. */ - public static Comparator + public static Comparator instantiateComparator(Comparator comparator, String comparatorType) throws DatabaseException { @@ -2348,7 +2393,7 @@ Object obj = bytesToObject(comparatorBytes, comparatorType); if (obj instanceof String) { String className = (String)obj; - Class> cls = + Class> cls = (Class>) Class.forName(className); comparator = instantiateComparator(cls, comparatorType); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbConfigException.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbConfigException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbConfigException.java 2008-05-20 17:52:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbConfigException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbConfigException.java,v 1.18 2008/05/20 17:52:34 linda Exp $ + * $Id: DbConfigException.java,v 1.18.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbConfigManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbConfigManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbConfigManager.java 2008-05-30 19:07:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbConfigManager.java 2008-06-30 20:54:46.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: DbConfigManager.java,v 1.47 2008/05/30 19:07:41 mark Exp $ + * $Id: DbConfigManager.java,v 1.48 2008/06/30 20:54:46 linda Exp $ */ package com.sleepycat.je.dbi; @@ -192,7 +192,10 @@ /** * Validate a collection of configurations at Environment and Replicator * startup time. Check for valid configuration names and values. + * SuppressWarnings here because Enumeration doesn't work well with + * Properties in Java 1.5 */ + @SuppressWarnings("unchecked") public static void validateProperties(Properties props, boolean forReplication, String configClassName, @@ -253,7 +256,8 @@ * Apply the configurations specified in the je.properties file to override * the programatically set configuration values held in the property bag. */ - public static void applyFileConfig(File envHome, + @SuppressWarnings("unchecked") + public static void applyFileConfig(File envHome, Properties props, boolean forReplication, String errorClassName) diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbEnvState.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbEnvState.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbEnvState.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbEnvState.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbEnvState.java,v 1.21 2008/01/07 14:28:48 cwl Exp $ + * $Id: DbEnvState.java,v 1.22.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -34,6 +34,7 @@ this.name = name; } + @Override public String toString() { return name; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbTree.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbTree.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/DbTree.java 2008-05-21 14:49:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/DbTree.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbTree.java,v 1.205 2008/05/21 14:49:14 cwl Exp $ + * $Id: DbTree.java,v 1.206.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -1624,6 +1624,7 @@ return self.toString(); } + @Override public String toString() { return dumpString(0); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/EnvironmentImpl.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/EnvironmentImpl.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/EnvironmentImpl.java 2008-05-30 19:07:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/EnvironmentImpl.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentImpl.java,v 1.301 2008/05/30 19:07:41 mark Exp $ + * $Id: EnvironmentImpl.java,v 1.301.2.8 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -222,6 +222,13 @@ IS_DALVIK = "Dalvik".equals(System.getProperty("java.vm.name")); } + public static final boolean IS_WINDOWS_7; + + static { + String osName = System.getProperty("os.name"); + IS_WINDOWS_7 = (osName != null && osName.startsWith("Windows 7")); + } + /* * Timeout for waiting for API lockout to finish. */ @@ -300,8 +307,7 @@ } } - directNIO = - configManager.getBoolean(EnvironmentParams.LOG_DIRECT_NIO); + directNIO = false; fairLatches = configManager.getBoolean(EnvironmentParams.ENV_FAIR_LATCHES); isReadOnly = @@ -351,7 +357,7 @@ /* * The node sequence transient ids, but not the node ids, must be * created before the DbTree is created because the transient node - * id sequence is used during the creation of the dbtree. + * id sequence is used during the creation of the dbtree. */ nodeSequence = new NodeSequence(); nodeSequence.initTransientNodeId(); @@ -359,7 +365,7 @@ /* * Instantiate a new, blank dbtree. If the environment already * exists, recovery will recreate the dbMapTree from the log and - * overwrite this instance. + * overwrite this instance. */ dbMapTree = new DbTree(this, replicationIntended); @@ -501,9 +507,10 @@ * exists, recovery will recreate the dbMapTree from the log and * overwrite this instance. */ - if (dbMapTree != null) { - dbMapTree.close(); - } + if (dbMapTree != null) { + dbMapTree.close(); + } + dbMapTree = new DbTree(this, replicationIntended); mapTreeRootLsn = DbLsn.NULL_LSN; referenceCount = 0; @@ -835,7 +842,7 @@ false, null); LockGrantType grant = lr.getLockGrant(); - + if (grant == LockGrantType.DENIED) { throw new APILockedException("API Lock timeout"); } @@ -1446,7 +1453,7 @@ errors.println(); } - /* + /* * Close the memory budgets on these components before the * INList is forcibly released and the treeAdmin budget is * cleared. @@ -1537,11 +1544,11 @@ return threadLocalReferenceCount; } - public static synchronized void incThreadLocalReferenceCount() { + static synchronized void incThreadLocalReferenceCount() { threadLocalReferenceCount++; } - public static synchronized void decThreadLocalReferenceCount() { + static synchronized void decThreadLocalReferenceCount() { threadLocalReferenceCount--; } @@ -1594,9 +1601,17 @@ } long memoryUsage = memoryBudget.getVariableCacheUsage(); - if (memoryUsage!= 0) { + if (memoryUsage != 0) { clean = false; System.err.println("Local Cache Usage = " + memoryUsage); + System.err.println("Tree Memory Usage = " + + memoryBudget.getTreeMemoryUsage()); + System.err.println("Admin Memory Usage = " + + memoryBudget.getAdminMemoryUsage()); + System.err.println("Tree Admin Memory Usage = " + + memoryBudget.getTreeAdminMemoryUsage()); + System.err.println("Lock Memory Usage = " + + memoryBudget.getLockMemoryUsage()); EnvironmentStats memoryStats = new EnvironmentStats(); memoryBudget.loadStats(new StatsConfig(), memoryStats); @@ -1666,6 +1681,11 @@ public int invokeCleaner() throws DatabaseException { + if (isReadOnly || isMemOnly) { + throw new IllegalStateException + ("Log cleaning not allowed in a read-only or memory-only " + + "environment"); + } if (cleaner != null) { return cleaner.doClean(true, // cleanMultipleFiles false); // forceCleaning @@ -1840,7 +1860,7 @@ return isMemOnly; } - /* + /* * FUTURE: change this to be non-static. It's static now just to avoid * passing down parameters in various places. */ @@ -1859,10 +1879,6 @@ return dbEviction; } - public boolean useDirectNIO() { - return directNIO; - } - public static int getAdler32ChunkSize() { return adler32ChunkSize; } @@ -1916,7 +1932,7 @@ public NodeSequence getNodeSequence() { return nodeSequence; } - + /** * Clones the current configuration. */ diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/GetMode.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/GetMode.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/GetMode.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/GetMode.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: GetMode.java,v 1.10 2008/01/07 14:28:48 cwl Exp $ + * $Id: GetMode.java,v 1.11.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -32,6 +32,7 @@ return forward; } + @Override public String toString() { return name; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/INList.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/INList.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/INList.java 2008-05-06 18:01:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/INList.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INList.java,v 1.59 2008/05/06 18:01:32 linda Exp $ + * $Id: INList.java,v 1.59.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/MemoryBudget.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/MemoryBudget.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/MemoryBudget.java 2008-05-29 13:50:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/MemoryBudget.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MemoryBudget.java,v 1.85 2008/05/29 13:50:07 cwl Exp $ + * $Id: MemoryBudget.java,v 1.86.2.4 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -54,6 +54,7 @@ * * _32 values are the same on Windows and Solaris. * _64 values are from 1.5.0_05 on Solaris. + * _Dalvik values are from running the Sizeof test on Android. * * Specifically: * @@ -69,71 +70,90 @@ // 7 private final static int LONG_OVERHEAD_32 = 16; private final static int LONG_OVERHEAD_64 = 24; + private final static int LONG_OVERHEAD_DALVIK = 24; // 8 private final static int ARRAY_OVERHEAD_32 = 16; private final static int ARRAY_OVERHEAD_64 = 24; + private final static int ARRAY_OVERHEAD_DALVIK = 24; private final static int ARRAY_SIZE_INCLUDED_32 = 4; private final static int ARRAY_SIZE_INCLUDED_64 = 0; + private final static int ARRAY_SIZE_INCLUDED_DALVIK = 4; // 2 private final static int OBJECT_OVERHEAD_32 = 8; private final static int OBJECT_OVERHEAD_64 = 16; + private final static int OBJECT_OVERHEAD_DALVIK = 16; // (4 - ARRAY_OVERHEAD) / 256 // 64b: 4 is 2072 + // Dalvik; 4 is 1048 private final static int OBJECT_ARRAY_ITEM_OVERHEAD_32 = 4; private final static int OBJECT_ARRAY_ITEM_OVERHEAD_64 = 8; + private final static int OBJECT_ARRAY_ITEM_OVERHEAD_DALVIK = 4; // 20 private final static int HASHMAP_OVERHEAD_32 = 120; private final static int HASHMAP_OVERHEAD_64_15 = 216; private final static int HASHMAP_OVERHEAD_64_16 = 218; + private final static int HASHMAP_OVERHEAD_DALVIK = 128; // 21 - OBJECT_OVERHEAD - HASHMAP_OVERHEAD // 64b: 21 is max(280,...,287) on Linux/Solaris 1.5/1.6 + // Dalvik: 21 is 176 private final static int HASHMAP_ENTRY_OVERHEAD_32 = 24; private final static int HASHMAP_ENTRY_OVERHEAD_64 = 55; + private final static int HASHMAP_ENTRY_OVERHEAD_DALVIK = 32; // 22 private final static int HASHSET_OVERHEAD_32 = 136; private final static int HASHSET_OVERHEAD_64 = 240; + private final static int HASHSET_OVERHEAD_DALVIK = 144; // 23 - OBJECT_OVERHEAD - HASHSET_OVERHEAD // 64b: 23 is max(304,...,311) on Linux/Solaris + // Dalvik: 23 is 192 private final static int HASHSET_ENTRY_OVERHEAD_32 = 24; private final static int HASHSET_ENTRY_OVERHEAD_64 = 55; + private final static int HASHSET_ENTRY_OVERHEAD_DALVIK = 32; // HASHMAP_OVERHEAD * 2 private final static int TWOHASHMAPS_OVERHEAD_32 = 240; private final static int TWOHASHMAPS_OVERHEAD_64_15 = 432; private final static int TWOHASHMAPS_OVERHEAD_64_16 = 436; + private final static int TWOHASHMAPS_OVERHEAD_DALVIK = 256; // 34 private final static int TREEMAP_OVERHEAD_32_15 = 40; private final static int TREEMAP_OVERHEAD_32_16 = 48; private final static int TREEMAP_OVERHEAD_64_15 = 64; private final static int TREEMAP_OVERHEAD_64_16 = 80; + private final static int TREEMAP_OVERHEAD_DALVIK = 40; // 35 - OBJECT_OVERHEAD - TREEMAP_OVERHEAD // 64b: 35 is 144 on 1.5 and 160 on 1.6, result is 64 for both + // Dalvik: 35 is 96 private final static int TREEMAP_ENTRY_OVERHEAD_32 = 32; private final static int TREEMAP_ENTRY_OVERHEAD_64 = 64; + private final static int TREEMAP_ENTRY_OVERHEAD_DALVIK = 40; // 36 private final static int MAPLN_OVERHEAD_32_15 = 640; private final static int MAPLN_OVERHEAD_32_16 = 664; private final static int MAPLN_OVERHEAD_64_15 = 1096; private final static int MAPLN_OVERHEAD_64_16 = 1136; + private final static int MAPLN_OVERHEAD_DALVIK = 744; // 9 private final static int LN_OVERHEAD_32 = 24; private final static int LN_OVERHEAD_64 = 40; + private final static int LN_OVERHEAD_DALVIK = 32; // 19 private final static int DUPCOUNTLN_OVERHEAD_32 = 24; private final static int DUPCOUNTLN_OVERHEAD_64 = 48; + private final static int DUPCOUNTLN_OVERHEAD_DALVIK = 32; // 12 // 64b: 12 is max(536, 539) on Linux/Solaris on 1.5 @@ -141,43 +161,52 @@ private final static int BIN_FIXED_OVERHEAD_32 = 370; // 344 in 1.5 private final static int BIN_FIXED_OVERHEAD_64_15 = 544; private final static int BIN_FIXED_OVERHEAD_64_16 = 584; + private final static int BIN_FIXED_OVERHEAD_DALVIK = 458; // 18 private final static int DIN_FIXED_OVERHEAD_32 = 377; // 352 in 1.5 private final static int DIN_FIXED_OVERHEAD_64_15 = 552; private final static int DIN_FIXED_OVERHEAD_64_16 = 596; + private final static int DIN_FIXED_OVERHEAD_DALVIK = 451; // 17 // 64b: 17 is max(592,593) on Linux/Solaris on 1.6 private final static int DBIN_FIXED_OVERHEAD_32 = 377; // 352 in 1.5 private final static int DBIN_FIXED_OVERHEAD_64_15 = 560; private final static int DBIN_FIXED_OVERHEAD_64_16 = 600; + private final static int DBIN_FIXED_OVERHEAD_DALVIK = 458; // 13 // 339 is max(312,339) on Solaris 1.5 vs 1.6 private final static int IN_FIXED_OVERHEAD_32 = 339; // 312 in 1.5 private final static int IN_FIXED_OVERHEAD_64_15 = 488; private final static int IN_FIXED_OVERHEAD_64_16 = 528; + private final static int IN_FIXED_OVERHEAD_DALVIK = 402; // 6 private final static int KEY_OVERHEAD_32 = 16; private final static int KEY_OVERHEAD_64 = 24; + private final static int KEY_OVERHEAD_DALVIK = 16; // 24 private final static int LOCKIMPL_OVERHEAD_32 = 24; private final static int LOCKIMPL_OVERHEAD_64 = 48; + private final static int LOCKIMPL_OVERHEAD_DALVIK = 32; // 42 private final static int THINLOCKIMPL_OVERHEAD_32 = 16; private final static int THINLOCKIMPL_OVERHEAD_64 = 32; + private final static int THINLOCKIMPL_OVERHEAD_DALVIK = 24; // 25 private final static int LOCKINFO_OVERHEAD_32 = 16; private final static int LOCKINFO_OVERHEAD_64 = 32; + private final static int LOCKINFO_OVERHEAD_DALVIK = 24; // 37 private final static int WRITE_LOCKINFO_OVERHEAD_32 = 32; private final static int WRITE_LOCKINFO_OVERHEAD_64 = 40; + private final static int WRITE_LOCKINFO_OVERHEAD_DALVIK = 40; /* * Txn memory is the size for the Txn + a hashmap entry @@ -186,58 +215,56 @@ // 15 private final static int TXN_OVERHEAD_32 = 186; private final static int TXN_OVERHEAD_64 = 281; + private final static int TXN_OVERHEAD_DALVIK = 218; // 26 private final static int CHECKPOINT_REFERENCE_SIZE_32 = 40 + HASHSET_ENTRY_OVERHEAD_32; private final static int CHECKPOINT_REFERENCE_SIZE_64 = 56 + HASHSET_ENTRY_OVERHEAD_64; + private final static int CHECKPOINT_REFERENCE_SIZE_DALVIK = 40; /* The per-log-file bytes used in UtilizationProfile. */ // 29 / 10 private final static int UTILIZATION_PROFILE_ENTRY_32 = 101; private final static int UTILIZATION_PROFILE_ENTRY_64 = 153; + private final static int UTILIZATION_PROFILE_ENTRY_DALVIK = 124; // 38 private final static int DBFILESUMMARY_OVERHEAD_32 = 40; private final static int DBFILESUMMARY_OVERHEAD_64 = 48; + private final static int DBFILESUMMARY_OVERHEAD_DALVIK = 48; /* Tracked File Summary overheads. */ // 31 private final static int TFS_LIST_INITIAL_OVERHEAD_32 = 464; private final static int TFS_LIST_INITIAL_OVERHEAD_64 = 504; + private final static int TFS_LIST_INITIAL_OVERHEAD_DALVIK = 472; // 30 // 64b: 30 is max(464,464,464,465) on Linux/Solaris on 1.5/1.6 private final static int TFS_LIST_SEGMENT_OVERHEAD_32 = 440; private final static int TFS_LIST_SEGMENT_OVERHEAD_64 = 465; + private final static int TFS_LIST_SEGMENT_OVERHEAD_DALVIK = 448; // 33 private final static int LN_INFO_OVERHEAD_32 = 24; private final static int LN_INFO_OVERHEAD_64 = 48; + private final static int LN_INFO_OVERHEAD_DALVIK = 32; // 43 private final static int FILESUMMARYLN_OVERHEAD_32 = 112; private final static int FILESUMMARYLN_OVERHEAD_64 = 168; + private final static int FILESUMMARYLN_OVERHEAD_DALVIK = 136; /* Approximate element size in an ArrayList of Long. */ // (28 - 27) / 10 // 32b: 28 and 27 are 240 and 40, resp. // 64b: 28 and 27 are 384 and 64, resp. + // Dalvik: 28 and 27 are 336 and 32, resp. private final static int LONG_LIST_PER_ITEM_OVERHEAD_32 = 20; private final static int LONG_LIST_PER_ITEM_OVERHEAD_64 = 32; - - // 43 - private final static int INCOMING_CONNECTION_HANDLER_OVERHEAD_32 = 24; - private final static int INCOMING_CONNECTION_HANDLER_OVERHEAD_64 = 48; - - // 44 - private final static int RECEIVE_MESSAGE_HANDLER_OVERHEAD_32 = 40; - private final static int RECEIVE_MESSAGE_HANDLER_OVERHEAD_64 = 80; - - // 45 - private final static int SEND_MESSAGE_HANDLER_OVERHEAD_32 = 56; - private final static int SEND_MESSAGE_HANDLER_OVERHEAD_64 = 96; + private final static int LONG_LIST_PER_ITEM_OVERHEAD_DALVIK = 30; public final static int LONG_OVERHEAD; public final static int ARRAY_OVERHEAD; @@ -280,109 +307,150 @@ private final static String FORCE_JVM_ARCH = "je.forceJVMArch"; static { - String javaVersion = System.getProperty("java.version"); - boolean isJVM15 = javaVersion != null && - javaVersion.startsWith("1.5."); - - boolean is64 = false; - String overrideArch = System.getProperty(FORCE_JVM_ARCH); - try { - if (overrideArch == null) { - String arch = System.getProperty(JVM_ARCH_PROPERTY); - if (arch != null) { - is64 = Integer.parseInt(arch) == 64; + + /* + * On the Dalvik VM (Android), there is no difference in sizes between + * any platforms. + */ + if (EnvironmentImpl.IS_DALVIK) { + LONG_OVERHEAD = LONG_OVERHEAD_DALVIK; + ARRAY_OVERHEAD = ARRAY_OVERHEAD_DALVIK; + ARRAY_SIZE_INCLUDED = ARRAY_SIZE_INCLUDED_DALVIK; + OBJECT_OVERHEAD = OBJECT_OVERHEAD_DALVIK; + OBJECT_ARRAY_ITEM_OVERHEAD = OBJECT_ARRAY_ITEM_OVERHEAD_DALVIK; + HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_DALVIK; + HASHMAP_ENTRY_OVERHEAD = HASHMAP_ENTRY_OVERHEAD_DALVIK; + HASHSET_OVERHEAD = HASHSET_OVERHEAD_DALVIK; + HASHSET_ENTRY_OVERHEAD = HASHSET_ENTRY_OVERHEAD_DALVIK; + TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_DALVIK; + TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_DALVIK; + TREEMAP_ENTRY_OVERHEAD = TREEMAP_ENTRY_OVERHEAD_DALVIK; + MAPLN_OVERHEAD = MAPLN_OVERHEAD_DALVIK; + LN_OVERHEAD = LN_OVERHEAD_DALVIK; + DUPCOUNTLN_OVERHEAD = DUPCOUNTLN_OVERHEAD_DALVIK; + BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_DALVIK; + DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_DALVIK; + DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_DALVIK; + IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_DALVIK; + KEY_OVERHEAD = KEY_OVERHEAD_DALVIK; + LOCKIMPL_OVERHEAD = LOCKIMPL_OVERHEAD_DALVIK; + THINLOCKIMPL_OVERHEAD = THINLOCKIMPL_OVERHEAD_DALVIK; + LOCKINFO_OVERHEAD = LOCKINFO_OVERHEAD_DALVIK; + WRITE_LOCKINFO_OVERHEAD = WRITE_LOCKINFO_OVERHEAD_DALVIK; + TXN_OVERHEAD = TXN_OVERHEAD_DALVIK; + CHECKPOINT_REFERENCE_SIZE = CHECKPOINT_REFERENCE_SIZE_DALVIK; + UTILIZATION_PROFILE_ENTRY = UTILIZATION_PROFILE_ENTRY_DALVIK; + DBFILESUMMARY_OVERHEAD = DBFILESUMMARY_OVERHEAD_DALVIK; + TFS_LIST_INITIAL_OVERHEAD = TFS_LIST_INITIAL_OVERHEAD_DALVIK; + TFS_LIST_SEGMENT_OVERHEAD = TFS_LIST_SEGMENT_OVERHEAD_DALVIK; + LN_INFO_OVERHEAD = LN_INFO_OVERHEAD_DALVIK; + FILESUMMARYLN_OVERHEAD = FILESUMMARYLN_OVERHEAD_DALVIK; + LONG_LIST_PER_ITEM_OVERHEAD = LONG_LIST_PER_ITEM_OVERHEAD_DALVIK; + } else { + String javaVersion = System.getProperty("java.version"); + boolean isJVM15 = javaVersion != null && + javaVersion.startsWith("1.5."); + + boolean is64 = false; + String overrideArch = System.getProperty(FORCE_JVM_ARCH); + try { + if (overrideArch == null) { + String arch = System.getProperty(JVM_ARCH_PROPERTY); + if (arch != null) { + is64 = Integer.parseInt(arch) == 64; + } + } else { + is64 = Integer.parseInt(overrideArch) == 64; } - } else { - is64 = Integer.parseInt(overrideArch) == 64; + } catch (NumberFormatException NFE) { + NFE.printStackTrace(System.err); } - } catch (NumberFormatException NFE) { - NFE.printStackTrace(System.err); - } - if (is64) { - LONG_OVERHEAD = LONG_OVERHEAD_64; - ARRAY_OVERHEAD = ARRAY_OVERHEAD_64; - ARRAY_SIZE_INCLUDED = ARRAY_SIZE_INCLUDED_64; - OBJECT_OVERHEAD = OBJECT_OVERHEAD_64; - OBJECT_ARRAY_ITEM_OVERHEAD = OBJECT_ARRAY_ITEM_OVERHEAD_64; - HASHMAP_ENTRY_OVERHEAD = HASHMAP_ENTRY_OVERHEAD_64; - HASHSET_OVERHEAD = HASHSET_OVERHEAD_64; - HASHSET_ENTRY_OVERHEAD = HASHSET_ENTRY_OVERHEAD_64; - if (isJVM15) { - TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_64_15; - MAPLN_OVERHEAD = MAPLN_OVERHEAD_64_15; - BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_64_15; - DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_64_15; - DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_64_15; - IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_64_15; - HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_64_15; - TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_64_15; - } else { - TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_64_16; - MAPLN_OVERHEAD = MAPLN_OVERHEAD_64_16; - BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_64_16; - DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_64_16; - DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_64_16; - IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_64_16; - HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_64_16; - TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_64_16; - } - TREEMAP_ENTRY_OVERHEAD = TREEMAP_ENTRY_OVERHEAD_64; - LN_OVERHEAD = LN_OVERHEAD_64; - DUPCOUNTLN_OVERHEAD = DUPCOUNTLN_OVERHEAD_64; - TXN_OVERHEAD = TXN_OVERHEAD_64; - CHECKPOINT_REFERENCE_SIZE = CHECKPOINT_REFERENCE_SIZE_64; - KEY_OVERHEAD = KEY_OVERHEAD_64; - LOCKIMPL_OVERHEAD = LOCKIMPL_OVERHEAD_64; - THINLOCKIMPL_OVERHEAD = THINLOCKIMPL_OVERHEAD_64; - LOCKINFO_OVERHEAD = LOCKINFO_OVERHEAD_64; - WRITE_LOCKINFO_OVERHEAD = WRITE_LOCKINFO_OVERHEAD_64; - UTILIZATION_PROFILE_ENTRY = UTILIZATION_PROFILE_ENTRY_64; - DBFILESUMMARY_OVERHEAD = DBFILESUMMARY_OVERHEAD_64; - TFS_LIST_INITIAL_OVERHEAD = TFS_LIST_INITIAL_OVERHEAD_64; - TFS_LIST_SEGMENT_OVERHEAD = TFS_LIST_SEGMENT_OVERHEAD_64; - LN_INFO_OVERHEAD = LN_INFO_OVERHEAD_64; - FILESUMMARYLN_OVERHEAD = FILESUMMARYLN_OVERHEAD_64; - LONG_LIST_PER_ITEM_OVERHEAD = LONG_LIST_PER_ITEM_OVERHEAD_64; - } else { - LONG_OVERHEAD = LONG_OVERHEAD_32; - ARRAY_OVERHEAD = ARRAY_OVERHEAD_32; - ARRAY_SIZE_INCLUDED = ARRAY_SIZE_INCLUDED_32; - OBJECT_OVERHEAD = OBJECT_OVERHEAD_32; - OBJECT_ARRAY_ITEM_OVERHEAD = OBJECT_ARRAY_ITEM_OVERHEAD_32; - HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_32; - HASHMAP_ENTRY_OVERHEAD = HASHMAP_ENTRY_OVERHEAD_32; - HASHSET_OVERHEAD = HASHSET_OVERHEAD_32; - HASHSET_ENTRY_OVERHEAD = HASHSET_ENTRY_OVERHEAD_32; - TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_32; - if (isJVM15) { - TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_32_15; - MAPLN_OVERHEAD = MAPLN_OVERHEAD_32_15; + if (is64) { + LONG_OVERHEAD = LONG_OVERHEAD_64; + ARRAY_OVERHEAD = ARRAY_OVERHEAD_64; + ARRAY_SIZE_INCLUDED = ARRAY_SIZE_INCLUDED_64; + OBJECT_OVERHEAD = OBJECT_OVERHEAD_64; + OBJECT_ARRAY_ITEM_OVERHEAD = OBJECT_ARRAY_ITEM_OVERHEAD_64; + HASHMAP_ENTRY_OVERHEAD = HASHMAP_ENTRY_OVERHEAD_64; + HASHSET_OVERHEAD = HASHSET_OVERHEAD_64; + HASHSET_ENTRY_OVERHEAD = HASHSET_ENTRY_OVERHEAD_64; + if (isJVM15) { + TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_64_15; + MAPLN_OVERHEAD = MAPLN_OVERHEAD_64_15; + BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_64_15; + DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_64_15; + DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_64_15; + IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_64_15; + HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_64_15; + TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_64_15; + } else { + TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_64_16; + MAPLN_OVERHEAD = MAPLN_OVERHEAD_64_16; + BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_64_16; + DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_64_16; + DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_64_16; + IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_64_16; + HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_64_16; + TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_64_16; + } + TREEMAP_ENTRY_OVERHEAD = TREEMAP_ENTRY_OVERHEAD_64; + LN_OVERHEAD = LN_OVERHEAD_64; + DUPCOUNTLN_OVERHEAD = DUPCOUNTLN_OVERHEAD_64; + TXN_OVERHEAD = TXN_OVERHEAD_64; + CHECKPOINT_REFERENCE_SIZE = CHECKPOINT_REFERENCE_SIZE_64; + KEY_OVERHEAD = KEY_OVERHEAD_64; + LOCKIMPL_OVERHEAD = LOCKIMPL_OVERHEAD_64; + THINLOCKIMPL_OVERHEAD = THINLOCKIMPL_OVERHEAD_64; + LOCKINFO_OVERHEAD = LOCKINFO_OVERHEAD_64; + WRITE_LOCKINFO_OVERHEAD = WRITE_LOCKINFO_OVERHEAD_64; + UTILIZATION_PROFILE_ENTRY = UTILIZATION_PROFILE_ENTRY_64; + DBFILESUMMARY_OVERHEAD = DBFILESUMMARY_OVERHEAD_64; + TFS_LIST_INITIAL_OVERHEAD = TFS_LIST_INITIAL_OVERHEAD_64; + TFS_LIST_SEGMENT_OVERHEAD = TFS_LIST_SEGMENT_OVERHEAD_64; + LN_INFO_OVERHEAD = LN_INFO_OVERHEAD_64; + FILESUMMARYLN_OVERHEAD = FILESUMMARYLN_OVERHEAD_64; + LONG_LIST_PER_ITEM_OVERHEAD = LONG_LIST_PER_ITEM_OVERHEAD_64; } else { - TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_32_16; - MAPLN_OVERHEAD = MAPLN_OVERHEAD_32_16; + LONG_OVERHEAD = LONG_OVERHEAD_32; + ARRAY_OVERHEAD = ARRAY_OVERHEAD_32; + ARRAY_SIZE_INCLUDED = ARRAY_SIZE_INCLUDED_32; + OBJECT_OVERHEAD = OBJECT_OVERHEAD_32; + OBJECT_ARRAY_ITEM_OVERHEAD = OBJECT_ARRAY_ITEM_OVERHEAD_32; + HASHMAP_OVERHEAD = HASHMAP_OVERHEAD_32; + HASHMAP_ENTRY_OVERHEAD = HASHMAP_ENTRY_OVERHEAD_32; + HASHSET_OVERHEAD = HASHSET_OVERHEAD_32; + HASHSET_ENTRY_OVERHEAD = HASHSET_ENTRY_OVERHEAD_32; + TWOHASHMAPS_OVERHEAD = TWOHASHMAPS_OVERHEAD_32; + if (isJVM15) { + TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_32_15; + MAPLN_OVERHEAD = MAPLN_OVERHEAD_32_15; + } else { + TREEMAP_OVERHEAD = TREEMAP_OVERHEAD_32_16; + MAPLN_OVERHEAD = MAPLN_OVERHEAD_32_16; + } + TREEMAP_ENTRY_OVERHEAD = TREEMAP_ENTRY_OVERHEAD_32; + LN_OVERHEAD = LN_OVERHEAD_32; + DUPCOUNTLN_OVERHEAD = DUPCOUNTLN_OVERHEAD_32; + BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_32; + DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_32; + DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_32; + IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_32; + TXN_OVERHEAD = TXN_OVERHEAD_32; + CHECKPOINT_REFERENCE_SIZE = CHECKPOINT_REFERENCE_SIZE_32; + KEY_OVERHEAD = KEY_OVERHEAD_32; + LOCKIMPL_OVERHEAD = LOCKIMPL_OVERHEAD_32; + THINLOCKIMPL_OVERHEAD = THINLOCKIMPL_OVERHEAD_32; + LOCKINFO_OVERHEAD = LOCKINFO_OVERHEAD_32; + WRITE_LOCKINFO_OVERHEAD = WRITE_LOCKINFO_OVERHEAD_32; + UTILIZATION_PROFILE_ENTRY = UTILIZATION_PROFILE_ENTRY_32; + DBFILESUMMARY_OVERHEAD = DBFILESUMMARY_OVERHEAD_32; + TFS_LIST_INITIAL_OVERHEAD = TFS_LIST_INITIAL_OVERHEAD_32; + TFS_LIST_SEGMENT_OVERHEAD = TFS_LIST_SEGMENT_OVERHEAD_32; + LN_INFO_OVERHEAD = LN_INFO_OVERHEAD_32; + FILESUMMARYLN_OVERHEAD = FILESUMMARYLN_OVERHEAD_32; + LONG_LIST_PER_ITEM_OVERHEAD = LONG_LIST_PER_ITEM_OVERHEAD_32; } - TREEMAP_ENTRY_OVERHEAD = TREEMAP_ENTRY_OVERHEAD_32; - LN_OVERHEAD = LN_OVERHEAD_32; - DUPCOUNTLN_OVERHEAD = DUPCOUNTLN_OVERHEAD_32; - BIN_FIXED_OVERHEAD = BIN_FIXED_OVERHEAD_32; - DIN_FIXED_OVERHEAD = DIN_FIXED_OVERHEAD_32; - DBIN_FIXED_OVERHEAD = DBIN_FIXED_OVERHEAD_32; - IN_FIXED_OVERHEAD = IN_FIXED_OVERHEAD_32; - TXN_OVERHEAD = TXN_OVERHEAD_32; - CHECKPOINT_REFERENCE_SIZE = CHECKPOINT_REFERENCE_SIZE_32; - KEY_OVERHEAD = KEY_OVERHEAD_32; - LOCKIMPL_OVERHEAD = LOCKIMPL_OVERHEAD_32; - THINLOCKIMPL_OVERHEAD = THINLOCKIMPL_OVERHEAD_32; - LOCKINFO_OVERHEAD = LOCKINFO_OVERHEAD_32; - WRITE_LOCKINFO_OVERHEAD = WRITE_LOCKINFO_OVERHEAD_32; - UTILIZATION_PROFILE_ENTRY = UTILIZATION_PROFILE_ENTRY_32; - DBFILESUMMARY_OVERHEAD = DBFILESUMMARY_OVERHEAD_32; - TFS_LIST_INITIAL_OVERHEAD = TFS_LIST_INITIAL_OVERHEAD_32; - TFS_LIST_SEGMENT_OVERHEAD = TFS_LIST_SEGMENT_OVERHEAD_32; - LN_INFO_OVERHEAD = LN_INFO_OVERHEAD_32; - FILESUMMARYLN_OVERHEAD = FILESUMMARYLN_OVERHEAD_32; - LONG_LIST_PER_ITEM_OVERHEAD = LONG_LIST_PER_ITEM_OVERHEAD_32; } } @@ -390,7 +458,7 @@ public final static long MIN_MAX_MEMORY_SIZE = 96 * 1024; public final static String MIN_MAX_MEMORY_SIZE_STRING = Long.toString(MIN_MAX_MEMORY_SIZE); - + /* This value prevents cache churn for apps with a high write rate. */ @SuppressWarnings("unused") private final static int DEFAULT_MIN_BTREE_CACHE_SIZE = 500 * 1024; @@ -440,7 +508,7 @@ * Amount of memory cached for locks. Protected by the * LockManager.lockTableLatches[lockTableIndex]. */ - private long[] lockMemoryUsage; + private AtomicLong[] lockMemoryUsage; /* * Memory available to JE, based on je.maxMemory and the memory available @@ -453,11 +521,11 @@ /* Maximum allowed use of the admin budget by the UtilizationTracker. */ private long trackerBudget; - + /* Mininum to prevent cache churn. */ private long minTreeMemoryUsage; - - /* + + /* * Overheads that are a function of node capacity. */ private long inOverhead; @@ -631,7 +699,7 @@ * reduce the log buffer budget again. */ long newLogBufferBudget = - configManager.getLong(EnvironmentParams.LOG_MEM_SIZE); + configManager.getLong(EnvironmentParams.LOG_MEM_SIZE); if (newLogBufferBudget == 0) { if (EnvironmentImpl.IS_DALVIK) { /* If Dalvik JVM, use 1/128th instead of 1/16th of cache. */ @@ -674,9 +742,9 @@ long newMinTreeMemoryUsage = Math.min (configManager.getLong(EnvironmentParams.MIN_TREE_MEMORY), - myCachePortion - newLogBufferBudget); + myCachePortion - newLogBufferBudget); - /* + /* * If all has gone well, update the budget fields. Once the log buffer * budget is determined, the remainder of the memory is left for tree * nodes. @@ -687,7 +755,10 @@ if (lockMemoryUsage == null) { nLockTables = configManager.getInt(EnvironmentParams.N_LOCK_TABLES); - lockMemoryUsage = new long[nLockTables]; + lockMemoryUsage = new AtomicLong[nLockTables]; + for (int i = 0; i < nLockTables; i++) { + lockMemoryUsage[i] = new AtomicLong(0); + } } minTreeMemoryUsage = newMinTreeMemoryUsage; @@ -728,7 +799,7 @@ * and txns yet, and the items in the admin category are cleaner items and * aren't affected by the recovery splicing process. */ - void initCacheMemoryUsage(long dbTreeAdminMemory) + void initCacheMemoryUsage(long dbTreeAdminMemory) throws DatabaseException { long totalTree = 0; @@ -816,17 +887,17 @@ * @param increment note that increment may be negative. */ public void updateTreeAdminMemoryUsage(long increment) { - updateCounter(increment, treeAdminMemoryUsage, "treeAdmin", - DEBUG_TREEADMIN); + updateCounter(increment, treeAdminMemoryUsage, "treeAdmin", + DEBUG_TREEADMIN); } - private void updateCounter(long increment, + private void updateCounter(long increment, AtomicLong counter, String debugName, boolean debug) { if (increment != 0) { long newSize = counter.addAndGet(increment); - + assert (sizeNotNegative(newSize)) : makeErrorMessage(debugName, newSize, increment); @@ -857,22 +928,22 @@ public void updateLockMemoryUsage(long increment, int lockTableIndex) { if (increment != 0) { - lockMemoryUsage[lockTableIndex] += increment; + lockMemoryUsage[lockTableIndex].addAndGet(increment); - assert lockMemoryUsage[lockTableIndex] >= 0: + assert lockMemoryUsage[lockTableIndex].get() >= 0: makeErrorMessage("lockMem", - lockMemoryUsage[lockTableIndex], - increment); + lockMemoryUsage[lockTableIndex].get(), + increment); if (DEBUG_LOCK) { if (increment > 0) { System.err.println("INC-------- =" + increment + - " lock[" + - lockTableIndex + "] " + - lockMemoryUsage[lockTableIndex]); + " lock[" + + lockTableIndex + "] " + + lockMemoryUsage[lockTableIndex].get()); } else { System.err.println("-------DEC=" + increment + - " lock[" + lockTableIndex + "] " + - lockMemoryUsage[lockTableIndex]); + " lock[" + lockTableIndex + "] " + + lockMemoryUsage[lockTableIndex].get()); } } @@ -915,10 +986,10 @@ public long getLockMemoryUsage() { long accLockMemoryUsage = txnMemoryUsage.get(); if (nLockTables == 1) { - accLockMemoryUsage += lockMemoryUsage[0]; + accLockMemoryUsage += lockMemoryUsage[0].get(); } else { for (int i = 0; i < nLockTables; i++) { - accLockMemoryUsage += lockMemoryUsage[i]; + accLockMemoryUsage += lockMemoryUsage[i].get(); } } @@ -950,7 +1021,7 @@ public long getAdminMemoryUsage() { return adminMemoryUsage.get(); } - + /* * For unit testing */ @@ -1027,7 +1098,7 @@ stats.setLockBytes(getLockMemoryUsage()); } - @Override + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("treeUsage = ").append(treeMemoryUsage.get()); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/NodeSequence.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/NodeSequence.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/NodeSequence.java 2008-05-06 18:01:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/NodeSequence.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,134 +1,134 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 2002,2008 Oracle. All rights reserved. - * - * $Id: NodeSequence.java,v 1.1 2008/05/06 18:01:32 linda Exp $ - */ - -package com.sleepycat.je.dbi; - -import java.util.concurrent.atomic.AtomicLong; - -/** - * NodeSequence encapsulates the generation and maintenance of a sequence for - * generating node ids. - */ -public class NodeSequence { - - /* - * Node Ids: We need to ensure that local and replicated nodes use - * different number spaces for their ids, so there can't be any possible - * conflicts. Local, non replicated nodes use positive values, replicated - * nodes use negative values. On top of that, there is the notion of - * transient node ids, which are used for cases like the eof node used for - * Serializable isolation and the lock used for api lockout. Transient node - * ids are used to provide unique locks, and are only used during the life - * of an environment, for non-persistent objects. We use the descending - * sequence of positive values, starting from Long.MAX_VALUE. - * - * The transient node sequence must be initialized before the DbTree - * uber-tree is created, because they are used at DatabaseImpl - * construction. The local and replicated node id sequences are - * initialized by the first pass of recovery, after the log has been - * scanned for the latest used node id. - */ - private AtomicLong lastAllocatedLocalNodeId = null; - private AtomicLong lastAllocatedReplicatedNodeId = null; - private AtomicLong lastAllocatedTransientNodeId = null; - - /** - * Initialize the counters in these methods rather than a constructor - * so we can control the initialization more precisely. - */ - void initTransientNodeId() { - lastAllocatedTransientNodeId = new AtomicLong(Long.MAX_VALUE); - } - - /** - * Initialize the counters in these methods rather than a constructor - * so we can control the initialization more precisely. - */ - void initRealNodeId() { - lastAllocatedLocalNodeId = new AtomicLong(0); - lastAllocatedReplicatedNodeId = new AtomicLong(0); - } - - /** - * The last allocated local and replicated node ids are used for ckpts. - */ - public long getLastLocalNodeId() { - return lastAllocatedLocalNodeId.get(); - } - - public long getLastReplicatedNodeId() { - return lastAllocatedReplicatedNodeId.get(); - } - - /** - * We get a new node id of the appropriate kind when creating a new node. - */ - public long getNextLocalNodeId() { - return lastAllocatedLocalNodeId.incrementAndGet(); - } - - public long getNextReplicatedNodeId() { - return lastAllocatedReplicatedNodeId.decrementAndGet(); - } - - public long getNextTransientNodeId() { - /* Assert that the two sequences haven't overlapped. */ - assert (noOverlap()) : "transient=" + - lastAllocatedTransientNodeId.get(); - return lastAllocatedTransientNodeId.decrementAndGet(); - } - - private boolean noOverlap() { - if (lastAllocatedLocalNodeId != null) { - return (lastAllocatedTransientNodeId.get() - 1) > - lastAllocatedLocalNodeId.get(); - } else { - return true; - } - } - - /** - * Initialize the node ids, from recovery. No need to initialize - * the transient node ids, since those can be reused each time the - * environment is recreated. - */ - public void setLastNodeId(long lastReplicatedNodeId, - long lastLocalNodeId) { - lastAllocatedReplicatedNodeId.set(lastReplicatedNodeId); - lastAllocatedLocalNodeId.set(lastLocalNodeId); - } - - /* - * Only set the replicated node id if the replayNodeId represents a - * newer, later value in the replication stream. If the replayNodeId is - * earlier than this node's lastAllocatedReplicateNodeId, don't bother - * updating the sequence; - */ - public void updateFromReplay(long replayNodeId) { - - assert replayNodeId < 0 : - "replay node id is unexpectedly positive " + replayNodeId; - - while (true) { - long currentVal = lastAllocatedReplicatedNodeId.get(); - if (replayNodeId < currentVal) { - /* - * This replayNodeId is newer than any other replicatedNodeId - * known by this node. - */ - boolean ok = lastAllocatedReplicatedNodeId.weakCompareAndSet - (currentVal, replayNodeId); - if (ok) { - break; - } - } else { - break; - } - } - } -} +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002,2010 Oracle. All rights reserved. + * + * $Id: NodeSequence.java,v 1.1.2.2 2010/01/04 15:30:28 cwl Exp $ + */ + +package com.sleepycat.je.dbi; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * NodeSequence encapsulates the generation and maintenance of a sequence for + * generating node ids. + */ +public class NodeSequence { + + /* + * Node Ids: We need to ensure that local and replicated nodes use + * different number spaces for their ids, so there can't be any possible + * conflicts. Local, non replicated nodes use positive values, replicated + * nodes use negative values. On top of that, there is the notion of + * transient node ids, which are used for cases like the eof node used for + * Serializable isolation and the lock used for api lockout. Transient node + * ids are used to provide unique locks, and are only used during the life + * of an environment, for non-persistent objects. We use the descending + * sequence of positive values, starting from Long.MAX_VALUE. + * + * The transient node sequence must be initialized before the DbTree + * uber-tree is created, because they are used at DatabaseImpl + * construction. The local and replicated node id sequences are + * initialized by the first pass of recovery, after the log has been + * scanned for the latest used node id. + */ + private AtomicLong lastAllocatedLocalNodeId = null; + private AtomicLong lastAllocatedReplicatedNodeId = null; + private AtomicLong lastAllocatedTransientNodeId = null; + + /** + * Initialize the counters in these methods rather than a constructor + * so we can control the initialization more precisely. + */ + void initTransientNodeId() { + lastAllocatedTransientNodeId = new AtomicLong(Long.MAX_VALUE); + } + + /** + * Initialize the counters in these methods rather than a constructor + * so we can control the initialization more precisely. + */ + void initRealNodeId() { + lastAllocatedLocalNodeId = new AtomicLong(0); + lastAllocatedReplicatedNodeId = new AtomicLong(0); + } + + /** + * The last allocated local and replicated node ids are used for ckpts. + */ + public long getLastLocalNodeId() { + return lastAllocatedLocalNodeId.get(); + } + + public long getLastReplicatedNodeId() { + return lastAllocatedReplicatedNodeId.get(); + } + + /** + * We get a new node id of the appropriate kind when creating a new node. + */ + public long getNextLocalNodeId() { + return lastAllocatedLocalNodeId.incrementAndGet(); + } + + public long getNextReplicatedNodeId() { + return lastAllocatedReplicatedNodeId.decrementAndGet(); + } + + public long getNextTransientNodeId() { + /* Assert that the two sequences haven't overlapped. */ + assert (noOverlap()) : "transient=" + + lastAllocatedTransientNodeId.get(); + return lastAllocatedTransientNodeId.decrementAndGet(); + } + + private boolean noOverlap() { + if (lastAllocatedLocalNodeId != null) { + return (lastAllocatedTransientNodeId.get() - 1) > + lastAllocatedLocalNodeId.get(); + } else { + return true; + } + } + + /** + * Initialize the node ids, from recovery. No need to initialize + * the transient node ids, since those can be reused each time the + * environment is recreated. + */ + public void setLastNodeId(long lastReplicatedNodeId, + long lastLocalNodeId) { + lastAllocatedReplicatedNodeId.set(lastReplicatedNodeId); + lastAllocatedLocalNodeId.set(lastLocalNodeId); + } + + /* + * Only set the replicated node id if the replayNodeId represents a + * newer, later value in the replication stream. If the replayNodeId is + * earlier than this node's lastAllocatedReplicateNodeId, don't bother + * updating the sequence; + */ + public void updateFromReplay(long replayNodeId) { + + assert replayNodeId < 0 : + "replay node id is unexpectedly positive " + replayNodeId; + + while (true) { + long currentVal = lastAllocatedReplicatedNodeId.get(); + if (replayNodeId < currentVal) { + /* + * This replayNodeId is newer than any other replicatedNodeId + * known by this node. + */ + boolean ok = lastAllocatedReplicatedNodeId.weakCompareAndSet + (currentVal, replayNodeId); + if (ok) { + break; + } + } else { + break; + } + } + } +} diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/Operation.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/Operation.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/Operation.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/Operation.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Operation.java,v 1.9 2008/01/07 14:28:48 cwl Exp $ + * $Id: Operation.java,v 1.10.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -64,6 +64,7 @@ } } + @Override public String toString() { return name; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/PutMode.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/PutMode.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/PutMode.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/PutMode.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PutMode.java,v 1.9 2008/01/07 14:28:48 cwl Exp $ + * $Id: PutMode.java,v 1.9.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/RangeRestartException.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/RangeRestartException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/RangeRestartException.java 2008-05-06 18:01:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/RangeRestartException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RangeRestartException.java,v 1.8 2008/05/06 18:01:32 linda Exp $ + * $Id: RangeRestartException.java,v 1.8.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/ReplicatedDatabaseConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/ReplicatedDatabaseConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/ReplicatedDatabaseConfig.java 2008-05-19 17:52:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/ReplicatedDatabaseConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReplicatedDatabaseConfig.java,v 1.8 2008/05/19 17:52:17 linda Exp $ + * $Id: ReplicatedDatabaseConfig.java,v 1.8.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/ReplicatorInstance.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/ReplicatorInstance.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/ReplicatorInstance.java 2008-05-13 20:03:12.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/ReplicatorInstance.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReplicatorInstance.java,v 1.21 2008/05/13 20:03:11 sam Exp $ + * $Id: ReplicatorInstance.java,v 1.21.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/SortedLSNTreeWalker.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/SortedLSNTreeWalker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/SortedLSNTreeWalker.java 2008-05-13 17:09:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/SortedLSNTreeWalker.java 2010-03-23 15:02:08.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SortedLSNTreeWalker.java,v 1.37 2008/05/13 17:09:00 mark Exp $ + * $Id: SortedLSNTreeWalker.java,v 1.37.2.4 2010/03/23 15:02:07 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -219,8 +219,11 @@ root = getRootIN(rootLsn); } if (root != null) { - accumulateLSNs(root); - releaseRootIN(root); + try { + accumulateLSNs(root); + } finally { + releaseRootIN(root); + } } if (setDbState) { @@ -231,7 +234,6 @@ maybeGetMoreINs(); if (currentLSNs != null && currentLSNIdx < currentLSNs.length) { - didSomeMore = true; fetchAndProcessLSN(currentLSNs[currentLSNIdx++]); } else { break; @@ -239,8 +241,6 @@ } } - public boolean didSomeMore = false; - private void maybeGetMoreINs() { if ((currentLSNs != null && diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/TruncateResult.java libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/TruncateResult.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/dbi/TruncateResult.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/dbi/TruncateResult.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TruncateResult.java,v 1.7 2008/01/07 14:28:48 cwl Exp $ + * $Id: TruncateResult.java,v 1.7.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DbInternal.java libdb-je-java-3.3.98/src/com/sleepycat/je/DbInternal.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DbInternal.java 2008-03-18 16:53:04.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DbInternal.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbInternal.java,v 1.56 2008/03/18 15:53:04 mark Exp $ + * $Id: DbInternal.java,v 1.57.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -16,6 +16,7 @@ import com.sleepycat.je.dbi.EnvironmentImpl; import com.sleepycat.je.dbi.GetMode; import com.sleepycat.je.txn.Locker; +import com.sleepycat.je.txn.Txn; /** * @hidden @@ -311,4 +312,8 @@ return new Environment(envHome, config, replicationIntended); } + + public static Txn getTxn(Transaction transaction) { + return transaction.getTxn(); + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/DeadlockException.java libdb-je-java-3.3.98/src/com/sleepycat/je/DeadlockException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/DeadlockException.java 2008-02-27 15:03:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/DeadlockException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DeadlockException.java,v 1.18 2008/02/27 15:03:51 mark Exp $ + * $Id: DeadlockException.java,v 1.18.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/Durability.java libdb-je-java-3.3.98/src/com/sleepycat/je/Durability.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/Durability.java 2008-05-13 20:03:10.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/Durability.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,14 +1,13 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Durability.java,v 1.1 2008/05/13 20:03:09 sam Exp $ + * $Id: Durability.java,v 1.5.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; - /** * @hidden * @@ -16,8 +15,8 @@ * transaction. When operating on a local environment the durability of a * transaction is completely determined by the local SyncPolicy that is in * effect. In a replicated environment, the overall durability is additionally - * a function of the ReplicaAclPolicy used by the master and the SyncPolicy - * in effect at each Replica. + * a function of the ReplicaAclPolicy used by the master and the SyncPolicy in + * effect at each Replica. */ public class Durability { @@ -40,12 +39,12 @@ * Do not write or synchronously flush the log on transaction commit. * Transactions exhibit the ACI (atomicity, consistency, and isolation) * properties, but not D (durability); that is, database integrity will - * be maintained, but if the application or system fails, it is possible - * some number of the most recently committed transactions may be undone - * during recovery. The number of transactions at risk is governed by - * how many log updates can fit into the log buffer, how often the - * operating system flushes dirty buffers to disk, and how often the log - * is checkpointed. + * be maintained, but if the application or system fails, it is + * possible some number of the most recently committed transactions may + * be undone during recovery. The number of transactions at risk is + * governed by how many log updates can fit into the log buffer, how + * often the operating system flushes dirty buffers to disk, and how + * often the log is checkpointed. */ NO_SYNC, @@ -53,44 +52,44 @@ * Write but do not synchronously flush the log on transaction commit. * Transactions exhibit the ACI (atomicity, consistency, and isolation) * properties, but not D (durability); that is, database integrity will - * be maintained, but if the operating system fails, it is possible some - * number of the most recently committed transactions may be undone - * during recovery. The number of transactions at risk is governed by - * how often the operating system flushes dirty buffers to disk, and how - * often the log is checkpointed. + * be maintained, but if the operating system fails, it is possible + * some number of the most recently committed transactions may be + * undone during recovery. The number of transactions at risk is + * governed by how often the operating system flushes dirty buffers to + * disk, and how often the log is checkpointed. */ WRITE_NO_SYNC }; /** - * A replicated environment makes it possible to increase an application's - * transaction commit guarantees by committing changes to its replicas on the - * network. ReplicaAckPolicy defines the policy for how such network - * commits are handled. - * - * The choice of a ReplicaAckPolicy must be consistent across all the - * replicas in a replication group, to ensure that the policy is consistently - * enforced in the event of an election. - */ - public enum ReplicaAckPolicy { + * A replicated environment makes it possible to increase an application's + * transaction commit guarantees by committing changes to its replicas on + * the network. ReplicaAckPolicy defines the policy for how such network + * commits are handled. + * + * The choice of a ReplicaAckPolicy must be consistent across all the + * replicas in a replication group, to ensure that the policy is + * consistently enforced in the event of an election. + */ + public enum ReplicaAckPolicy { - /** + /** * All replicas must acknowledge that they have committed the * transaction. This policy should be selected only if your replication * group has a small number of replicas, and those replicas are on * extremely reliable networks and servers. */ - ALL, + ALL, - /** - * No transaction commit acknowledgments are required and the master will - * never wait for replica acknowledgments. In this case, transaction - * durability is determined entirely by the type of commit that is being - * performed on the master. - */ - NONE, + /** + * No transaction commit acknowledgments are required and the master + * will never wait for replica acknowledgments. In this case, + * transaction durability is determined entirely by the type of commit + * that is being performed on the master. + */ + NONE, - /** + /** * A quorum of replicas must acknowledge that they have committed the * transaction. A quorum is reached when acknowledgments are received * from the minimum number of environments needed to ensure that the @@ -101,34 +100,36 @@ * * This is the default. */ - QUORUM; + QUORUM; - /** - * Returns the minimum number of replication nodes required to implement - * the ReplicaAckPolicy for a given group size. + /** + * Returns the minimum number of replication nodes required to + * implement the ReplicaAckPolicy for a given group size. * * @param groupSize the size of the replication group. * * @return the number of nodes that are needed */ - public int requiredNodes(int groupSize) { - switch (this) { - case ALL: - return groupSize; - case NONE: - return 1; - case QUORUM: - return (groupSize <= 2) ? 1 : (groupSize/2+1); - } - assert false : "unreachable"; - return Integer.MAX_VALUE; - } - } + public int requiredNodes(int groupSize) { + switch (this) { + case ALL: + return groupSize; + case NONE: + return 1; + case QUORUM: + return (groupSize <= 2) ? 1 : (groupSize / 2 + 1); + } + assert false : "unreachable"; + return Integer.MAX_VALUE; + } + } /* The sync policy in effect on the local node. */ final private SyncPolicy localSync; + /* The sync policy in effect on a replica. */ final private SyncPolicy replicaSync; + /* The replica acknowledgment policy to be used. */ final private ReplicaAckPolicy replicaAck; @@ -173,6 +174,4 @@ public ReplicaAckPolicy getReplicaAck() { return replicaAck; } - - } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentConfig.java 2008-06-02 16:31:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentConfig.java,v 1.50 2008/06/02 16:31:43 linda Exp $ + * $Id: EnvironmentConfig.java,v 1.52.2.4 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -710,6 +710,8 @@ * false * *

+ * @deprecated NIO is no longer used by JE and this parameter has no + * effect. */ public static final String LOG_USE_NIO = "je.log.useNIO"; @@ -726,6 +728,8 @@ * false * *

+ * @deprecated NIO is no longer used by JE and this parameter has no + * effect. */ public static final String LOG_DIRECT_NIO = "je.log.directNIO"; @@ -745,6 +749,8 @@ * 67108864 (64M) * *

+ * @deprecated NIO is no longer used by JE and this parameter has no + * effect. */ public static final String LOG_CHUNKED_NIO = "je.log.chunkedNIO"; @@ -907,8 +913,8 @@ "je.compressor.lockTimeout"; /** - * If true, when the compressor encounters an empty tree, the root node of - * the tree is deleted. + * If true, when the compressor encounters an empty database, the root node + * of the Btree is deleted. * *

* @@ -919,6 +925,10 @@ * * *
NameTypeMutableDefault
false

+ * + * @deprecated as of 3.3.87. Compression of the root node no longer has + * any benefit and this feature has been removed. This parameter has no + * effect. */ public static final String COMPRESSOR_PURGE_ROOT = "je.compressor.purgeRoot"; @@ -1762,7 +1772,7 @@ * @param timeout The lock timeout, in microseconds. A value of 0 turns off * lock timeouts. * - * @throws IllegalArgumentException If the value of timeout is negative + * @throws IllegalArgumentException If the value of timeout is negative * @see Transaction#setLockTimeout */ public void setLockTimeout(long timeout) @@ -1901,7 +1911,7 @@ * @param timeout The transaction timeout, in microseconds. A value of 0 * turns off transaction timeouts. * - * @throws IllegalArgumentException If the value of timeout is negative + * @throws IllegalArgumentException If the value of timeout is negative * * @see Transaction#setTxnTimeout */ @@ -2026,6 +2036,7 @@ } /* Documentation inherited from EnvironmentMutableConfig.setConfigParam. */ + @Override public void setConfigParam(String paramName, String value) throws IllegalArgumentException { @@ -2082,6 +2093,7 @@ /** * Display configuration values. */ + @Override public String toString() { return ("allowCreate=" + allowCreate + "\n" + super.toString()); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/Environment.java libdb-je-java-3.3.98/src/com/sleepycat/je/Environment.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/Environment.java 2008-05-30 19:07:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/Environment.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Environment.java,v 1.217 2008/05/30 19:07:40 mark Exp $ + * $Id: Environment.java,v 1.217.2.4 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -139,9 +139,13 @@ * @throws IllegalArgumentException if an invalid parameter was specified. * * @throws DatabaseException if a failure occurs. + * + * @throws EnvironmentLockedException when an environment cannot be opened + * for write access because another process has the same environment open + * for write access. */ public Environment(File envHome, EnvironmentConfig configuration) - throws DatabaseException { + throws DatabaseException, EnvironmentLockedException { this(envHome, configuration, true /*openIfNeeded*/, false /*replicationIntended*/); @@ -1551,6 +1555,8 @@ } /** + * For internal use only. + * @hidden * Scans raw log entries in the JE log between two given points, passing * all records for a given set of databases to the scanRecord method of the * given LogScanner object. diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentLockedException.java libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentLockedException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentLockedException.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentLockedException.java 2010-01-04 15:30:28.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002,2010 Oracle. All rights reserved. + * + * $Id: EnvironmentLockedException.java,v 1.1.2.3 2010/01/04 15:30:27 cwl Exp $ + */ + +package com.sleepycat.je; + +/** + * Thrown by the Environment constructor when an environment cannot be + * opened for write access because another process has the same environment + * open for write access. + */ +public class EnvironmentLockedException extends DatabaseException { + + private static final long serialVersionUID = 629594964L; + + public EnvironmentLockedException() { + super(); + } + + public EnvironmentLockedException(Throwable t) { + super(t); + } + + public EnvironmentLockedException(String message) { + super(message); + } + + public EnvironmentLockedException(String message, Throwable t) { + super(message, t); + } +} diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentMutableConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentMutableConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentMutableConfig.java 2008-05-19 17:52:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentMutableConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentMutableConfig.java,v 1.41 2008/05/19 17:52:16 linda Exp $ + * $Id: EnvironmentMutableConfig.java,v 1.44.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -295,9 +295,6 @@ * calling setCacheSize() with a non-zero value overrides the percentage * based calculation and sets the cache size explicitly.

* - *

Note that the cache does not include transient objects created by the - * JE library, such as cursors, locks and transactions.

- * *

Note that the log buffer cache may be cleared if the cache size is * changed after the environment has been opened.

* @@ -497,6 +494,7 @@ * Overrides Object.clone() to clone all properties, used by this class and * EnvironmentConfig. */ + @Override protected Object clone() throws CloneNotSupportedException { @@ -534,8 +532,11 @@ /** * Copies all mutable props to the given config object. + * Unchecked suppress here because Properties don't play well with + * generics in Java 1.5 */ - void copyMutablePropsTo(EnvironmentMutableConfig toConfig) { + @SuppressWarnings("unchecked") + void copyMutablePropsTo(EnvironmentMutableConfig toConfig) { Properties toProps = toConfig.props; Enumeration propNames = props.propertyNames(); @@ -560,9 +561,12 @@ cacheSize = envImpl.getMemoryBudget().getMaxMemory(); } - /** - * Removes all immutable props. - */ + /** + * Removes all immutable props. + * Unchecked suppress here because Properties don't play well with + * generics in Java 1.5 + */ + @SuppressWarnings("unchecked") private void clearImmutableProps() { Enumeration propNames = props.propertyNames(); while (propNames.hasMoreElements()) { @@ -604,10 +608,11 @@ /** * Display configuration values. */ + @Override public String toString() { return ("cacheSize=" + cacheSize + "\n" + "txnNoSync=" + txnNoSync + "\n" + "txnWriteNoSync=" + txnWriteNoSync + "\n" + - props.toString()); + props.toString() + "\n"); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/EnvironmentStats.java 2008-05-07 17:12:26.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/EnvironmentStats.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentStats.java,v 1.57 2008/05/07 17:12:25 mark Exp $ + * $Id: EnvironmentStats.java,v 1.58.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -1542,6 +1542,7 @@ * Returns a String representation of the stats in the form of * <stat>=<value> */ + @Override public String toString() { DecimalFormat f = new DecimalFormat("###,###,###,###,###,###,###"); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/Evictor.java libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/Evictor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/Evictor.java 2008-05-20 03:27:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/Evictor.java 2010-01-30 01:10:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Evictor.java,v 1.114 2008/05/20 03:27:35 linda Exp $ + * $Id: Evictor.java,v 1.115.2.6 2010/01/30 01:10:55 mark Exp $ */ package com.sleepycat.je.evictor; @@ -41,6 +41,7 @@ import com.sleepycat.je.utilint.DbLsn; import com.sleepycat.je.utilint.TestHook; import com.sleepycat.je.utilint.Tracer; +import com.sleepycat.je.utilint.TestHookExecute; /** * The Evictor looks through the INList for IN's and BIN's that are worthy of @@ -117,6 +118,7 @@ /* Debugging and unit test support. */ EvictProfile evictProfile; private TestHook runnableHook; + private TestHook preEvictINHook; Evictor(EnvironmentImpl envImpl, String name) throws DatabaseException { @@ -172,6 +174,7 @@ /** * Return the number of retries when a deadlock exception occurs. */ + @Override protected long nDeadlockRetries() throws DatabaseException { @@ -514,13 +517,10 @@ } /* - * If this is a read only database and we have at least one - * target, skip any dirty INs (recovery dirties INs even in a - * read-only environment). We take at least one target so we - * don't loop endlessly if everything is dirty. + * If this is a read-only environment, skip any dirty INs (recovery + * dirties INs even in a read-only environment). */ if (db.getDbEnvironment().isReadOnly() && - target != null && in.getDirty()) { continue; } @@ -648,12 +648,14 @@ rootIN.latch(CacheMode.UNCHANGED); try { /* Re-check that all conditions still hold. */ + boolean isDirty = rootIN.getDirty(); if (rootIN == target && rootIN.isDbRoot() && - rootIN.isEvictable()) { + rootIN.isEvictable() && + !(envImpl.isReadOnly() && isDirty)) { /* Flush if dirty. */ - if (!envImpl.isReadOnly() && rootIN.getDirty()) { + if (isDirty) { long newLsn = rootIN.log (envImpl.getLogManager(), false, // allowDeltas @@ -774,6 +776,14 @@ /* Regular eviction. */ Tree tree = db.getTree(); + /* + * Unit testing. The target is latched and we are about to + * release that latch and search for the parent. Make sure + * that other operations, such as dirtying an LN in the + * target BIN, can occur safely in this window. [#18227] + */ + assert TestHookExecute.doHookIfSet(preEvictINHook); + /* getParentINForChildIN unlatches target. */ targetIsLatched = false; SearchResult result = @@ -806,8 +816,7 @@ } /** - * Evict an IN. Dirty nodes are logged before they're evicted. inlist is - * latched with the major latch by the caller. + * Evict an IN. Dirty nodes are logged before they're evicted. */ private long evictIN(IN child, IN parent, int index, boolean backgroundIO) throws DatabaseException { @@ -827,7 +836,7 @@ /* * See the evictIN() method in this class for an explanation for - * calling latchNoWait(false). + * calling latchNoWait(). */ if ((renewedChild != null) && (renewedChild.getGeneration() <= oldGenerationCount) && @@ -946,6 +955,11 @@ runnableHook = hook; } + /* For unit testing only. */ + public void setPreEvictINHook(TestHook hook) { + preEvictINHook = hook; + } + /** * Standard daemon method to set envImpl to null. */ @@ -969,7 +983,7 @@ /** * Only supported by SharedEvictor. */ - public abstract boolean checkEnvs(Set envs); + public abstract boolean checkEnvs(Set envs); abstract Logger getLogger(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/package.html libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/package.html 2008-01-24 14:59:30.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/package.html 2010-01-04 15:30:28.000000000 +0000 @@ -5,10 +5,10 @@ See the file LICENSE for redistribution information. - Copyright (c) 2002,2008 Oracle. All rights reserved. + Copyright (c) 2002,2010 Oracle. All rights reserved. - $Id: package.html,v 1.9 2008/01/24 14:59:29 linda Exp $ + $Id: package.html,v 1.9.2.2 2010/01/04 15:30:28 cwl Exp $ --> diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/PrivateEvictor.java libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/PrivateEvictor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/PrivateEvictor.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/PrivateEvictor.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrivateEvictor.java,v 1.4 2008/01/07 14:28:48 cwl Exp $ + * $Id: PrivateEvictor.java,v 1.4.2.2 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.evictor; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/SharedEvictor.java libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/SharedEvictor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/evictor/SharedEvictor.java 2008-01-07 14:28:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/evictor/SharedEvictor.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SharedEvictor.java,v 1.4 2008/01/07 14:28:48 cwl Exp $ + * $Id: SharedEvictor.java,v 1.4.2.3 2010/01/04 15:30:28 cwl Exp $ */ package com.sleepycat.je.evictor; @@ -221,11 +221,12 @@ * by reinitializing the Subject.remaining fields. */ IN getNextIN() { - int initialIndex = rotationIndex; int nSubjects = subjects.size(); if (nSubjects == 0) { - return null; // No environments are sharing the cache + /* No environments are sharing the cache. */ + return null; } + int nSubjectsExamined = 0; while (true) { if (rotationIndex >= nSubjects) { rotationIndex = 0; @@ -238,13 +239,16 @@ subject.iter = subject.ins.iterator(); } if (subject.iter.hasNext()) { - return subject.iter.next(); // Found an IN to return + /* Found an IN to return. */ + return subject.iter.next(); } else { - subject.remaining = -1; // This INList is empty + /* This INList is empty. */ + subject.remaining = -1; } } - if (rotationIndex == initialIndex) { - /* All Subject.remaining fields are <= 0. Start a new round. */ + nSubjectsExamined += 1; + if (nSubjectsExamined >= nSubjects) { + /* All Subject.remaining fields are <= 0. */ boolean foundAny = false; for (int i = 0; i < nSubjects; i += 1) { Subject sub = subjects.get(i); @@ -256,8 +260,11 @@ } } if (!foundAny) { - return null; // All INLists are empty + /* All INLists are empty or not evictable. */ + return null; } + /* Start a new round. */ + nSubjectsExamined = 0; } } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/ExceptionEvent.java libdb-je-java-3.3.98/src/com/sleepycat/je/ExceptionEvent.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/ExceptionEvent.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/ExceptionEvent.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ExceptionEvent.java,v 1.9 2008/01/07 14:28:46 cwl Exp $ + * $Id: ExceptionEvent.java,v 1.10.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -43,6 +43,7 @@ return threadName; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(" diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/JEVersion.java libdb-je-java-3.3.98/src/com/sleepycat/je/JEVersion.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/JEVersion.java 2008-06-04 18:46:48.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/JEVersion.java 2010-03-23 15:01:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JEVersion.java,v 1.109 2008/06/04 18:46:47 cwl Exp $ + * $Id: JEVersion.java,v 1.111.2.33 2010/03/23 15:01:50 cwl Exp $ */ package com.sleepycat.je; @@ -21,7 +21,7 @@ * Release version. */ public static final JEVersion CURRENT_VERSION = - new JEVersion(3, 3, 62, null); + new JEVersion(3, 3, 98, null); private int majorNum; private int minorNum; @@ -35,6 +35,7 @@ this.name = name; } + @Override public String toString() { return getVersionString(); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/jmx/JEMBeanHelper.java libdb-je-java-3.3.98/src/com/sleepycat/je/jmx/JEMBeanHelper.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/jmx/JEMBeanHelper.java 2008-05-19 17:52:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/jmx/JEMBeanHelper.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JEMBeanHelper.java,v 1.16 2008/05/19 17:52:18 linda Exp $ + * $Id: JEMBeanHelper.java,v 1.16.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.jmx; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/jmx/JEMonitor.java libdb-je-java-3.3.98/src/com/sleepycat/je/jmx/JEMonitor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/jmx/JEMonitor.java 2008-05-19 17:52:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/jmx/JEMonitor.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JEMonitor.java,v 1.10 2008/05/19 17:52:18 linda Exp $ + * $Id: JEMonitor.java,v 1.10.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.jmx; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/JoinConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/JoinConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/JoinConfig.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/JoinConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JoinConfig.java,v 1.11 2008/01/24 14:59:27 linda Exp $ + * $Id: JoinConfig.java,v 1.12.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -95,4 +95,15 @@ return null; } } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "noSort=" + noSort + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/JoinCursor.java libdb-je-java-3.3.98/src/com/sleepycat/je/JoinCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/JoinCursor.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/JoinCursor.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JoinCursor.java,v 1.20 2008/01/07 14:28:46 cwl Exp $ + * $Id: JoinCursor.java,v 1.20.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchException.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchException.java 2008-01-07 14:28:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchException.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchException.java,v 1.20 2008/01/07 14:28:50 cwl Exp $ + * $Id: LatchException.java,v 1.20.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/Latch.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/Latch.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/Latch.java 2008-05-30 14:04:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/Latch.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Latch.java,v 1.91 2008/05/30 14:04:15 mark Exp $ + * $Id: Latch.java,v 1.92.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; @@ -26,6 +26,7 @@ super(fair); } + @Override protected Thread getOwner() { return super.getOwner(); } @@ -202,6 +203,7 @@ /** * Formats a latch owner and waiters. */ + @Override public String toString() { return lock.toString(); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchNotHeldException.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchNotHeldException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchNotHeldException.java 2008-01-07 14:28:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchNotHeldException.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchNotHeldException.java,v 1.18 2008/01/07 14:28:50 cwl Exp $ + * $Id: LatchNotHeldException.java,v 1.18.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchStats.java 2008-01-07 14:28:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchStats.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchStats.java,v 1.25 2008/01/07 14:28:50 cwl Exp $ + * $Id: LatchStats.java,v 1.26.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; @@ -57,6 +57,7 @@ */ public int nReleases = 0; + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("nAcquiresNoWaiters="). @@ -76,6 +77,7 @@ return sb.toString(); } + @Override public Object clone() throws CloneNotSupportedException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchSupport.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchSupport.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchSupport.java 2008-05-13 01:44:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchSupport.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchSupport.java,v 1.14 2008/05/13 01:44:51 cwl Exp $ + * $Id: LatchSupport.java,v 1.14.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchTable.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchTable.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/LatchTable.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/LatchTable.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchTable.java,v 1.17 2008/05/15 01:52:41 linda Exp $ + * $Id: LatchTable.java,v 1.17.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/package.html libdb-je-java-3.3.98/src/com/sleepycat/je/latch/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/package.html 2008-01-07 14:28:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/package.html 2010-01-04 15:30:30.000000000 +0000 @@ -5,10 +5,10 @@ See the file LICENSE for redistribution information. - Copyright (c) 2002,2008 Oracle. All rights reserved. + Copyright (c) 2002,2010 Oracle. All rights reserved. - $Id: package.html,v 1.10 2008/01/07 14:28:50 cwl Exp $ + $Id: package.html,v 1.10.2.2 2010/01/04 15:30:29 cwl Exp $ --> diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/latch/SharedLatch.java libdb-je-java-3.3.98/src/com/sleepycat/je/latch/SharedLatch.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/latch/SharedLatch.java 2008-05-20 17:52:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/latch/SharedLatch.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SharedLatch.java,v 1.24 2008/05/20 17:52:35 linda Exp $ + * $Id: SharedLatch.java,v 1.24.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.latch; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/LockMode.java libdb-je-java-3.3.98/src/com/sleepycat/je/LockMode.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/LockMode.java 2008-04-07 22:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/LockMode.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockMode.java,v 1.25 2008/04/07 22:28:29 mark Exp $ + * $Id: LockMode.java,v 1.25.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/LockNotGrantedException.java libdb-je-java-3.3.98/src/com/sleepycat/je/LockNotGrantedException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/LockNotGrantedException.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/LockNotGrantedException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockNotGrantedException.java,v 1.10 2008/01/07 14:28:46 cwl Exp $ + * $Id: LockNotGrantedException.java,v 1.10.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/LockStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/LockStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/LockStats.java 2008-03-19 16:04:04.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/LockStats.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockStats.java,v 1.30 2008/03/19 15:04:03 mark Exp $ + * $Id: LockStats.java,v 1.31.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -209,6 +209,7 @@ * For convenience, the LockStats class has a toString method that lists * all the data fields. */ + @Override public String toString() { StringBuffer sb = new StringBuffer(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/CheckpointFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/CheckpointFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/CheckpointFileReader.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/CheckpointFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CheckpointFileReader.java,v 1.31 2008/01/07 14:28:51 cwl Exp $ + * $Id: CheckpointFileReader.java,v 1.32.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -41,6 +41,7 @@ /** * @return true if this is a targetted entry. */ + @Override protected boolean isTargetEntry() { byte logEntryTypeNumber = currentEntryHeader.getType(); boolean isTarget = false; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/ChecksumValidator.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/ChecksumValidator.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/ChecksumValidator.java 2008-01-17 17:36:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/ChecksumValidator.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ChecksumValidator.java,v 1.36 2008/01/17 17:36:20 cwl Exp $ + * $Id: ChecksumValidator.java,v 1.36.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/CleanerFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/CleanerFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/CleanerFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/CleanerFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CleanerFileReader.java,v 1.42 2008/05/15 01:52:41 linda Exp $ + * $Id: CleanerFileReader.java,v 1.43.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -90,6 +90,7 @@ * Helper for determining the starting position and opening * up a file at the desired location. */ + @Override protected void initStartingPosition(long endOfFileLsn, Long fileNum) throws IOException, DatabaseException { @@ -114,6 +115,7 @@ /** * @return true if this is a type we're interested in. */ + @Override protected boolean isTargetEntry() { LogEntryType fromLogType = diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/DbChecksumException.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/DbChecksumException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/DbChecksumException.java 2008-05-13 01:44:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/DbChecksumException.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbChecksumException.java,v 1.23 2008/05/13 01:44:52 cwl Exp $ + * $Id: DbChecksumException.java,v 1.24.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -42,6 +42,7 @@ } } + @Override public String toString() { if (extraInfo == null) { return super.toString(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/DbOpReplicationContext.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/DbOpReplicationContext.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/DbOpReplicationContext.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/DbOpReplicationContext.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbOpReplicationContext.java,v 1.5 2008/01/07 14:28:51 cwl Exp $ + * $Id: DbOpReplicationContext.java,v 1.5.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/DumpFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/DumpFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/DumpFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/DumpFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DumpFileReader.java,v 1.49 2008/05/15 01:52:41 linda Exp $ + * $Id: DumpFileReader.java,v 1.50.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -76,6 +76,7 @@ * @return true if this reader should process this entry, or just * skip over it. */ + @Override protected boolean isTargetEntry() { if (targetEntryTypes.size() == 0) { /* We want to dump all entry types. */ diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/BaseEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/BaseEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/BaseEntry.java 2008-03-10 20:59:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/BaseEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BaseEntry.java,v 1.8 2008/03/10 19:59:19 linda Exp $ + * $Id: BaseEntry.java,v 1.9.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; @@ -92,6 +92,7 @@ public abstract StringBuffer dumpEntry(StringBuffer sb, boolean verbose); + @Override public String toString() { StringBuffer sb = new StringBuffer(); dumpEntry(sb, true); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/BINDeltaLogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/BINDeltaLogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/BINDeltaLogEntry.java 2008-03-10 20:59:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/BINDeltaLogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BINDeltaLogEntry.java,v 1.27 2008/03/10 19:59:19 linda Exp $ + * $Id: BINDeltaLogEntry.java,v 1.27.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/DbOperationType.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/DbOperationType.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/DbOperationType.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/DbOperationType.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbOperationType.java,v 1.3 2008/01/07 14:28:51 cwl Exp $ + * $Id: DbOperationType.java,v 1.3.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/DeletedDupLNLogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/DeletedDupLNLogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/DeletedDupLNLogEntry.java 2008-01-17 17:22:12.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/DeletedDupLNLogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DeletedDupLNLogEntry.java,v 1.32 2008/01/17 17:22:12 cwl Exp $ + * $Id: DeletedDupLNLogEntry.java,v 1.33.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; @@ -60,6 +60,7 @@ * Extends its super class to read in the extra dup key. * @see LNLogEntry#readEntry */ + @Override public void readEntry(LogEntryHeader header, ByteBuffer entryBuffer, boolean readFullItem) @@ -81,6 +82,7 @@ * Extends super class to dump out extra key. * @see LNLogEntry#dumpEntry */ + @Override public StringBuffer dumpEntry(StringBuffer sb, boolean verbose) { super.dumpEntry(sb, verbose); sb.append(Key.dumpString(dataAsKey, 0)); @@ -95,6 +97,7 @@ * Extend super class to add in extra key. * @see LNLogEntry#getSize */ + @Override public int getSize() { return super.getSize() + LogUtils.getByteArrayLogSize(dataAsKey); @@ -103,6 +106,7 @@ /** * @see LogEntry#writeToLog */ + @Override public void writeEntry(LogEntryHeader header, ByteBuffer destBuffer) { super.writeEntry(header, destBuffer); @@ -116,6 +120,7 @@ /** * Get the data-as-key out of the entry. */ + @Override public byte[] getDupKey() { return dataAsKey; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/INContainingEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/INContainingEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/INContainingEntry.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/INContainingEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INContainingEntry.java,v 1.19 2008/01/07 14:28:51 cwl Exp $ + * $Id: INContainingEntry.java,v 1.19.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/INLogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/INLogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/INLogEntry.java 2008-03-10 20:59:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/INLogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INLogEntry.java,v 1.49 2008/03/10 19:59:19 linda Exp $ + * $Id: INLogEntry.java,v 1.50.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; @@ -169,6 +169,7 @@ return in; } + @Override public Object clone() throws CloneNotSupportedException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/LNLogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/LNLogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/LNLogEntry.java 2008-05-13 01:44:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/LNLogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LNLogEntry.java,v 1.54 2008/05/13 01:44:52 cwl Exp $ + * $Id: LNLogEntry.java,v 1.56.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; @@ -289,6 +289,7 @@ /** * Returns the last logged size, saved by readEntry and writeEntry. */ + @Override public int getLastLoggedSize() { return ln.getLastLoggedSize(); } @@ -330,6 +331,7 @@ * Returns true for a deleted LN to count it immediately as obsolete. * @see LogEntry#countAsObsoleteWhenLogged */ + @Override public boolean countAsObsoleteWhenLogged() { return ln.isDeleted(); } @@ -341,6 +343,7 @@ * * @see LogEntry#postLogWork */ + @Override public void postLogWork(long justLoggedLsn) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/LogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/LogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/LogEntry.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/LogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogEntry.java,v 1.27 2008/01/07 14:28:51 cwl Exp $ + * $Id: LogEntry.java,v 1.27.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/NameLNLogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/NameLNLogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/NameLNLogEntry.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/NameLNLogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NameLNLogEntry.java,v 1.5 2008/01/07 14:28:51 cwl Exp $ + * $Id: NameLNLogEntry.java,v 1.5.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/NodeLogEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/NodeLogEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/NodeLogEntry.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/NodeLogEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NodeLogEntry.java,v 1.8 2008/01/07 14:28:51 cwl Exp $ + * $Id: NodeLogEntry.java,v 1.8.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/SingleItemEntry.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/SingleItemEntry.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/entry/SingleItemEntry.java 2008-03-10 20:59:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/entry/SingleItemEntry.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SingleItemEntry.java,v 1.8 2008/03/10 19:59:19 linda Exp $ + * $Id: SingleItemEntry.java,v 1.9.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.log.entry; @@ -82,6 +82,7 @@ /** * @see LogEntry#clone */ + @Override public Object clone() throws CloneNotSupportedException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileHandle.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileHandle.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileHandle.java 2008-05-07 17:12:26.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileHandle.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileHandle.java,v 1.27 2008/05/07 17:12:25 mark Exp $ + * $Id: FileHandle.java,v 1.27.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileHandleSource.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileHandleSource.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileHandleSource.java 2008-03-19 12:56:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileHandleSource.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileHandleSource.java,v 1.16 2008/03/19 11:56:55 cwl Exp $ + * $Id: FileHandleSource.java,v 1.17.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -28,6 +28,7 @@ /** * @see LogSource#release */ + @Override public void release() throws DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileHeader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileHeader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileHeader.java 2008-02-26 18:52:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileHeader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileHeader.java,v 1.47 2008/02/26 18:52:35 mark Exp $ + * $Id: FileHeader.java,v 1.48.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -162,6 +162,7 @@ /** * Print in xml format */ + @Override public String toString() { StringBuffer sb = new StringBuffer(); dumpLog(sb, true); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileManager.java 2008-05-22 20:21:04.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileManager.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileManager.java,v 1.193 2008/05/22 20:21:04 linda Exp $ + * $Id: FileManager.java,v 1.194.2.9 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -28,6 +28,7 @@ import com.sleepycat.je.DatabaseException; import com.sleepycat.je.EnvironmentStats; +import com.sleepycat.je.EnvironmentLockedException; import com.sleepycat.je.RunRecoveryException; import com.sleepycat.je.StatsConfig; import com.sleepycat.je.config.EnvironmentParams; @@ -163,14 +164,6 @@ */ private Map perFileLastUsedLsn; - /* Whether to use NIO for file I/O. */ - private boolean useNIO; - - /* - * If non-0, do NIO in chunks of this size. - */ - private long chunkedNIOSize = 0; - /* * Use O_DSYNC to open JE log files. */ @@ -230,27 +223,11 @@ DbConfigManager configManager = envImpl.getConfigManager(); maxFileSize = configManager.getLong(EnvironmentParams.LOG_FILE_MAX); - useNIO = - configManager.getBoolean(EnvironmentParams.LOG_USE_NIO); - chunkedNIOSize = - configManager.getLong(EnvironmentParams.LOG_CHUNKED_NIO); useODSYNC = configManager.getBoolean(EnvironmentParams.LOG_USE_ODSYNC); - boolean directNIO = - configManager.getBoolean(EnvironmentParams.LOG_DIRECT_NIO); VERIFY_CHECKSUMS = configManager.getBoolean(EnvironmentParams.LOG_VERIFY_CHECKSUMS); - if (!useNIO && (chunkedNIOSize > 0 || directNIO)) { - throw new IllegalArgumentException - (EnvironmentParams.LOG_USE_NIO.getName() + - " is false and therefore " + - EnvironmentParams.LOG_DIRECT_NIO.getName() + - " or " + - EnvironmentParams.LOG_CHUNKED_NIO.getName() + - " may not be used."); - } - if (!envImpl.isMemOnly()) { if (!dbEnvHome.exists()) { throw new LogException("Environment home " + dbEnvHome + @@ -372,7 +349,9 @@ } /** - * For unit tests. + * Returns the highest (current) file number. Because a long value cannot + * be read atomically without synchronization, this method should be called + * while holding the log write latch. */ public long getCurrentFileNum() { return currentFileNum; @@ -862,7 +841,13 @@ fileName = fileNames[i]; try { newFile = - new RandomAccessFile(fileName, mode.getModeValue()); + new RandomAccessFile(fileName, mode.getModeValue()) { + public synchronized long length() + throws IOException { + + return super.length(); + } + }; break; } catch (FileNotFoundException e) { /* Save the first exception thrown. */ @@ -1160,6 +1145,11 @@ endOfLog.getWritableFile(DbLsn.getFileNumber(firstLsn)); ByteBuffer data = fullBuffer.getDataBuffer(); + if (VERIFY_CHECKSUMS) { + verifyChecksums(data, DbLsn.getFileOffset(firstLsn), + "pre-write"); + } + try { /* @@ -1215,7 +1205,7 @@ * it to disk on the write, then rewriting should allow * them to be rewritten. See [11271]. * - * Rewriting committed transactions in replication is + * Rewriting committed transactions in replication is * highly problematic, and can lead to divergence between * the replica and master. If this path is re-enabled, we * must assess its impact in replication. @@ -1240,7 +1230,7 @@ } /** - * Write a buffer to a file at a given offset, using NIO if so configured. + * Write a buffer to a file at a given offset. */ private int writeToFile(RandomAccessFile file, ByteBuffer data, @@ -1249,95 +1239,46 @@ throws IOException, DatabaseException { int totalBytesWritten = 0; - if (useNIO) { - FileChannel channel = file.getChannel(); - if (chunkedNIOSize > 0) { + bumpWriteCount("write"); - /* - * We can't change the limit without impacting readers that - * might find this buffer in the buffer pool. Duplicate the - * buffer so we can set the limit independently. - */ - ByteBuffer useData = data.duplicate(); + /* + * Perform a RandomAccessFile write and update the buffer position. + * ByteBuffer.array() is safe to use since all non-direct ByteBuffers + * have a backing array. Synchronization on the file object is needed + * because two threads may call seek() on the same file object. + */ + synchronized (file) { + assert data.hasArray(); - /* - * Write small chunks of data by manipulating the position and - * limit properties of the buffer, and submitting it for - * writing repeatedly. - * - * For each chunk, the limit is set to the position + - * chunkedNIOSize, capped by the original limit of the buffer. - * - * Preconditions: data to be written is betweek data.position() - * and data.limit() - - * Postconditions: data.limit() has not changed, - * data.position() == data.limit(), offset of the channel has - * not been modified. - */ - int originalLimit = useData.limit(); - useData.limit(useData.position()); - while (useData.limit() < originalLimit) { - bumpWriteCount("nio write"); - - useData.limit((int) - (Math.min(useData.limit() + chunkedNIOSize, - originalLimit))); - int bytesWritten = channel.write(useData, destOffset); - destOffset += bytesWritten; - totalBytesWritten += bytesWritten; - } - } else { + int pos = data.position(); + int size = data.limit() - pos; - /* - * Perform a single write using NIO. - */ - totalBytesWritten = channel.write(data, destOffset); + if (lastFileNumberTouched == fileNum && + (Math.abs(destOffset - lastFileTouchedOffset) < + ADJACENT_TRACK_SEEK_DELTA)) { + nSequentialWrites++; + nSequentialWriteBytes += size; + } else { + nRandomWrites++; + nRandomWriteBytes += size; } - } else { - - bumpWriteCount("write"); - - /* - * Perform a RandomAccessFile write and update the buffer position. - * ByteBuffer.array() is safe to use since all non-direct - * ByteBuffers have a backing array. Synchronization on the file - * object is needed because two threads may call seek() on the same - * file object. - */ - synchronized (file) { - assert data.hasArray(); - int pos = data.position(); - int size = data.limit() - pos; - - if (lastFileNumberTouched == fileNum && - (Math.abs(destOffset - lastFileTouchedOffset) < - ADJACENT_TRACK_SEEK_DELTA)) { - nSequentialWrites++; - nSequentialWriteBytes += size; - } else { - nRandomWrites++; - nRandomWriteBytes += size; - } - - if (VERIFY_CHECKSUMS) { - verifyChecksums(data, destOffset, "pre-write"); - } + if (VERIFY_CHECKSUMS) { + verifyChecksums(data, destOffset, "pre-write"); + } + file.seek(destOffset); + file.write(data.array(), pos + data.arrayOffset(), size); + if (VERIFY_CHECKSUMS) { file.seek(destOffset); - file.write(data.array(), pos + data.arrayOffset(), size); - if (VERIFY_CHECKSUMS) { - file.seek(destOffset); - file.read(data.array(), pos + data.arrayOffset(), size); - verifyChecksums(data, destOffset, "post-write"); - } - data.position(pos + size); - totalBytesWritten = size; - - lastFileNumberTouched = fileNum; - lastFileTouchedOffset = destOffset + size; + file.read(data.array(), pos + data.arrayOffset(), size); + verifyChecksums(data, destOffset, "post-write"); } + data.position(pos + size); + totalBytesWritten = size; + + lastFileNumberTouched = fileNum; + lastFileTouchedOffset = destOffset + size; } return totalBytesWritten; } @@ -1362,7 +1303,7 @@ } /** - * Read a buffer from a file at a given offset, using NIO if so configured. + * Read a buffer from a file at a given offset. */ void readFromFile(RandomAccessFile file, ByteBuffer readBuffer, @@ -1387,82 +1328,41 @@ long fileNum) throws DatabaseException, IOException { - if (useNIO) { - FileChannel channel = file.getChannel(); - - if (chunkedNIOSize > 0) { - - /* - * Read a chunk at a time to prevent large direct memory - * allocations by NIO. - */ - int readLength = readBuffer.limit(); - long currentPosition = offset; - while (readBuffer.position() < readLength) { - readBuffer.limit((int) - (Math.min(readBuffer.limit() + - chunkedNIOSize, - readLength))); - if (IO_EXCEPTION_TESTING_ON_READ) { - throw new IOException("generated for testing (read)"); - } - int bytesRead = channel.read(readBuffer, currentPosition); + /* + * Perform a RandomAccessFile read and update the buffer position. + * ByteBuffer.array() is safe to use since all non-direct ByteBuffers + * have a backing array. Synchronization on the file object is needed + * because two threads may call seek() on the same file object. + */ + synchronized (file) { + assert readBuffer.hasArray(); - if (bytesRead < 1) - break; + int pos = readBuffer.position(); + int size = readBuffer.limit() - pos; - currentPosition += bytesRead; - } + if (lastFileNumberTouched == fileNum && + (Math.abs(offset - lastFileTouchedOffset) < + ADJACENT_TRACK_SEEK_DELTA)) { + nSequentialReads++; + nSequentialReadBytes += size; } else { - - if (IO_EXCEPTION_TESTING_ON_READ) { - throw new IOException("generated for testing (read)"); - } - - /* - * Perform a single read using NIO. - */ - channel.read(readBuffer, offset); + nRandomReads++; + nRandomReadBytes += size; } - } else { - /* - * Perform a RandomAccessFile read and update the buffer position. - * ByteBuffer.array() is safe to use since all non-direct - * ByteBuffers have a backing array. Synchronization on the file - * object is needed because two threads may call seek() on the same - * file object. - */ - synchronized (file) { - assert readBuffer.hasArray(); - - int pos = readBuffer.position(); - int size = readBuffer.limit() - pos; - - if (lastFileNumberTouched == fileNum && - (Math.abs(offset - lastFileTouchedOffset) < - ADJACENT_TRACK_SEEK_DELTA)) { - nSequentialReads++; - nSequentialReadBytes += size; - } else { - nRandomReads++; - nRandomReadBytes += size; - } - - file.seek(offset); - if (IO_EXCEPTION_TESTING_ON_READ) { - throw new IOException("generated for testing (read)"); - } - int bytesRead = file.read(readBuffer.array(), - pos + readBuffer.arrayOffset(), - size); - if (bytesRead > 0) { - readBuffer.position(pos + bytesRead); - } - - lastFileNumberTouched = fileNum; - lastFileTouchedOffset = offset + bytesRead; + file.seek(offset); + if (IO_EXCEPTION_TESTING_ON_READ) { + throw new IOException("generated for testing (read)"); } + int bytesRead = file.read(readBuffer.array(), + pos + readBuffer.arrayOffset(), + size); + if (bytesRead > 0) { + readBuffer.position(pos + bytesRead); + } + + lastFileNumberTouched = fileNum; + lastFileTouchedOffset = offset + bytesRead; } } @@ -1711,7 +1611,8 @@ throwIt = true; } if (throwIt) { - throw new LogException + close(); + throw new EnvironmentLockedException ("A " + LOCK_FILE + " file exists in " + dbEnvHome.getAbsolutePath() + " The environment can not be locked for " + @@ -2129,7 +2030,24 @@ * file has flipped to a new file since the fsync was issued. */ synchronized (fsyncFileSynchronizer) { - RandomAccessFile file = endOfLogSyncFile; + + /* + * In [#17865] a user reported file corruption when using + * Windows 7. This SR includes a test program (JETester) which + * readily demonstrates the problem. We are reasonably sure + * that the problem is caused by concurrent write() and fsync() + * calls on the same file, and in particular, if two different + * file descriptors are used concurrently. The code below is a + * workaround for this problem since it does not happen when we + * use the same RAF for the write() and fsync(). In fact, the + * test program has slightly better performance on the write + * phase with the change below. This problem is not present + * in 4.0 because of the write queue code in that release. + */ + boolean isWin7 = EnvironmentImpl.IS_WINDOWS_7; + RandomAccessFile file = + (isWin7 ? endOfLogRWFile : endOfLogSyncFile); + if (file != null) { bumpWriteCount("fsync"); FileChannel channel = file.getChannel(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileReader.java 2008-05-20 17:52:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileReader.java,v 1.119 2008/05/20 17:52:35 linda Exp $ + * $Id: FileReader.java,v 1.119.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileSource.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileSource.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FileSource.java 2008-03-19 12:56:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FileSource.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileSource.java,v 1.37 2008/03/19 11:56:55 cwl Exp $ + * $Id: FileSource.java,v 1.37.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/FSyncManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/FSyncManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/FSyncManager.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/FSyncManager.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FSyncManager.java,v 1.22 2008/01/07 14:28:51 cwl Exp $ + * $Id: FSyncManager.java,v 1.22.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/INFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/INFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/INFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/INFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INFileReader.java,v 1.70 2008/05/15 01:52:41 linda Exp $ + * $Id: INFileReader.java,v 1.72.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -215,6 +215,7 @@ * log entries. If not, we only want to see IN entries. * @return true if this is an IN entry. */ + @Override protected boolean isTargetEntry() throws DatabaseException { @@ -372,7 +373,7 @@ fileMappers.put(fileNumber, mapper); } mapper.putLSN(vlsn.getSequence(), lsn, - LogEntryType.isSyncPoint(currentEntryHeader.getType())); + LogEntryType.findType(currentEntryHeader.getType())); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/JEFileFilter.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/JEFileFilter.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/JEFileFilter.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/JEFileFilter.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JEFileFilter.java,v 1.21 2008/01/07 14:28:51 cwl Exp $ + * $Id: JEFileFilter.java,v 1.21.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LastFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LastFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LastFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LastFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LastFileReader.java,v 1.54 2008/05/15 01:52:41 linda Exp $ + * $Id: LastFileReader.java,v 1.55.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -84,6 +84,7 @@ /** * Override so that we always start at the last file. */ + @Override protected void initStartingPosition(long endOfFileLsn, Long singleFileNum) throws IOException, DatabaseException { @@ -237,6 +238,7 @@ * readNextEntry will stop at a bad entry. * @return true if an element has been read. */ + @Override public boolean readNextEntry() throws DatabaseException, IOException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LatchedLogManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LatchedLogManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LatchedLogManager.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LatchedLogManager.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchedLogManager.java,v 1.28 2008/05/15 01:52:41 linda Exp $ + * $Id: LatchedLogManager.java,v 1.28.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LNFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LNFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LNFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LNFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LNFileReader.java,v 1.70 2008/05/15 01:52:41 linda Exp $ + * $Id: LNFileReader.java,v 1.71.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -84,6 +84,7 @@ /** * @return true if this is a transactional LN or Locker Commit entry. */ + @Override protected boolean isTargetEntry() { if (currentEntryHeader.getProvisional().isProvisional diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogBuffer.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogBuffer.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogBuffer.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogBuffer.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogBuffer.java,v 1.47 2008/01/07 14:28:51 cwl Exp $ + * $Id: LogBuffer.java,v 1.47.2.3 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -40,11 +40,7 @@ LogBuffer(int capacity, EnvironmentImpl env) throws DatabaseException { - if (env.useDirectNIO()) { - buffer = ByteBuffer.allocateDirect(capacity); - } else { - buffer = ByteBuffer.allocate(capacity); - } + buffer = ByteBuffer.allocate(capacity); readLatch = new Latch(DEBUG_NAME); reinit(); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogBufferPool.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogBufferPool.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogBufferPool.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogBufferPool.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogBufferPool.java,v 1.77 2008/05/15 01:52:41 linda Exp $ + * $Id: LogBufferPool.java,v 1.77.2.3 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -29,7 +29,7 @@ private EnvironmentImpl envImpl = null; private int logBufferSize; // size of each log buffer - private LinkedList bufferPool; + private LinkedList bufferPool; /* Buffer that holds the current log end. All writes go to this buffer. */ private LogBuffer currentWriteBuffer; @@ -192,7 +192,7 @@ currentWriteBuffer.latchForWrite(); LogBuffer latchedBuffer = currentWriteBuffer; try { - ByteBuffer currentByteBuffer = currentWriteBuffer.getDataBuffer(); + ByteBuffer currentByteBuffer = latchedBuffer.getDataBuffer(); int savePosition = currentByteBuffer.position(); int saveLimit = currentByteBuffer.limit(); currentByteBuffer.flip(); @@ -214,10 +214,10 @@ * write this buffer to disk and find a new buffer to use. */ try { - fileManager.writeLogBuffer(currentWriteBuffer); + fileManager.writeLogBuffer(latchedBuffer); /* Rewind so readers can see this. */ - currentWriteBuffer.getDataBuffer().rewind(); + latchedBuffer.getDataBuffer().rewind(); /* We're done with the current buffer. */ latchedBuffer.release(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogContext.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogContext.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogContext.java 2008-04-18 22:57:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogContext.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogContext.java,v 1.1 2008/04/18 22:57:36 mark Exp $ + * $Id: LogContext.java,v 1.1.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogEntryHeader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogEntryHeader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogEntryHeader.java 2008-05-12 15:35:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogEntryHeader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogEntryHeader.java,v 1.24 2008/05/12 15:35:31 linda Exp $ + * $Id: LogEntryHeader.java,v 1.26.2.2 2010/01/04 15:30:29 cwl Exp $ */ package com.sleepycat.je.log; @@ -311,7 +311,7 @@ * @param verbose if true, dump the full, verbose version */ public void dumpLog(StringBuffer sb, boolean verbose) { - sb.append("
"); } @@ -329,11 +329,11 @@ sb.append("type=\"").append(lastEntryType.toStringNoVersion()). append("/").append((int) entryVersion); if (provisional != Provisional.NO) { - sb.append("\" provisional=\""); + sb.append("\" prov=\""); sb.append(provisional); } if (replicated) { - sb.append("\" replicated=\"true"); + sb.append("\" rep=\"true"); } if (vlsn != null) { sb.append("\" "); @@ -381,6 +381,7 @@ LogUtils.writeUnsignedInt(entryBuffer, checksumVal); } + @Override public String toString() { StringBuffer sb = new StringBuffer(); dumpLog(sb, true /* verbose */); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogEntryType.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogEntryType.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogEntryType.java 2008-05-27 15:30:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogEntryType.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogEntryType.java,v 1.99 2008/05/27 15:30:35 mark Exp $ + * $Id: LogEntryType.java,v 1.99.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogException.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogException.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogException.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogException.java,v 1.16 2008/01/07 14:28:51 cwl Exp $ + * $Id: LogException.java,v 1.16.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogFileNotFoundException.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogFileNotFoundException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogFileNotFoundException.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogFileNotFoundException.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogFileNotFoundException.java,v 1.13 2008/01/07 14:28:51 cwl Exp $ + * $Id: LogFileNotFoundException.java,v 1.13.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/Loggable.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/Loggable.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/Loggable.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/Loggable.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Loggable.java,v 1.8 2008/01/07 14:28:51 cwl Exp $ + * $Id: Loggable.java,v 1.8.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogItem.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogItem.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogItem.java 2008-04-18 22:57:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogItem.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogItem.java,v 1.1 2008/04/18 22:57:36 mark Exp $ + * $Id: LogItem.java,v 1.1.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogManager.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogManager.java 2010-02-08 17:19:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogManager.java,v 1.201 2008/05/15 01:52:41 linda Exp $ + * $Id: LogManager.java,v 1.203.2.4 2010/02/08 17:19:42 cwl Exp $ */ package com.sleepycat.je.log; @@ -362,8 +362,8 @@ * of writing this mapping to disk. */ if (item.repContext.inReplicationStream()) { - assert (item.header.getVLSN() != null) : - "Unexpected null vlsn: " + item.header + " " + + assert (item.header.getVLSN() != null) : + "Unexpected null VLSN: " + item.header + " " + item.repContext; envImpl.getReplicator().registerVLSN(item.newLsn, item.header); } @@ -504,7 +504,7 @@ LogBuffer useLogBuffer = logBufferPool.getWriteBuffer(entrySize, flippedFile); - /* Add checksum, prev offset, vlsn to entry. */ + /* Add checksum, prev offset, and VLSN to the entry. */ item.buffer = item.header.addPostMarshallingInfo (envImpl, item.buffer, fileManager.getPrevEntryOffset(), item.repContext); @@ -595,7 +595,7 @@ * Serialize a loggable object into this buffer. (public for * unit tests. */ - public ByteBuffer marshallIntoBuffer(LogEntryHeader header, LogEntry entry) + private ByteBuffer marshallIntoBuffer(LogEntryHeader header, LogEntry entry) throws DatabaseException { int entrySize = header.getSize() + header.getItemSize(); @@ -623,6 +623,9 @@ LogEntryHeader header = new LogEntryHeader (entry, Provisional.NO, ReplicationContext.NO_REPLICATE); + /* Assert that we're not in a situation demanding Txn mutex. */ + assert entry.getLogType() != LogEntryType.LOG_LN_TRANSACTIONAL; + ByteBuffer destBuffer = marshallIntoBuffer(header, entry); return header.addPostMarshallingInfo(envImpl, @@ -1028,7 +1031,7 @@ /** * Counts the given obsolete IN LSNs under the log write latch. */ - public abstract void countObsoleteINs(List lsnList, + public abstract void countObsoleteINs(List lsnList, DatabaseImpl nodeDb) throws DatabaseException; @@ -1067,7 +1070,7 @@ void loadEndOfLogStatInternal(EnvironmentStats stats) { stats.setEndOfLog(fileManager.getLastUsedLsn()); - } + } /* For unit testing only. */ public void setReadHook(TestHook hook) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogSource.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogSource.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogSource.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogSource.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogSource.java,v 1.26 2008/01/07 14:28:51 cwl Exp $ + * $Id: LogSource.java,v 1.26.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogUtils.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogUtils.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/LogUtils.java 2008-05-13 01:44:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/LogUtils.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogUtils.java,v 1.61 2008/05/13 01:44:52 cwl Exp $ + * $Id: LogUtils.java,v 1.62.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; @@ -560,6 +560,7 @@ return bqual; } + @Override public boolean equals(Object o) { if (!(o instanceof XidImpl)) { return false; @@ -577,6 +578,7 @@ return false; } + @Override public int hashCode() { int code = formatId; if (gid != null) { @@ -611,6 +613,7 @@ return true; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(" diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/PrintFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/PrintFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/PrintFileReader.java 2008-05-13 01:44:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/PrintFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrintFileReader.java,v 1.22 2008/05/13 01:44:52 cwl Exp $ + * $Id: PrintFileReader.java,v 1.22.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/Provisional.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/Provisional.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/Provisional.java 2008-04-22 15:44:10.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/Provisional.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Provisional.java,v 1.2 2008/04/22 15:44:10 mark Exp $ + * $Id: Provisional.java,v 1.2.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/ReplicationContext.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/ReplicationContext.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/ReplicationContext.java 2008-05-13 01:44:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/ReplicationContext.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReplicationContext.java,v 1.9 2008/05/13 01:44:52 cwl Exp $ + * $Id: ReplicationContext.java,v 1.9.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/ScavengerFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/ScavengerFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/ScavengerFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/ScavengerFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ScavengerFileReader.java,v 1.22 2008/05/15 01:52:41 linda Exp $ + * $Id: ScavengerFileReader.java,v 1.23.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; @@ -110,6 +110,7 @@ * to find the other side of the corrupted area and try to re-read this * file. */ + @Override public boolean readNextEntry() throws DatabaseException, IOException { @@ -129,6 +130,7 @@ * and read forward until the lower side of the corrupted area has been * found. */ + @Override protected boolean resyncReader(long nextGoodRecordPostCorruption, boolean showCorruptedBounds) throws DatabaseException, IOException { @@ -195,6 +197,7 @@ * @return true if this reader should process this entry, or just skip * over it. */ + @Override protected boolean isTargetEntry() { if (targetEntryTypes.size() == 0) { /* We want to dump all entry types. */ diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/SearchFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/SearchFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/SearchFileReader.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/SearchFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SearchFileReader.java,v 1.46 2008/01/07 14:28:51 cwl Exp $ + * $Id: SearchFileReader.java,v 1.47.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; @@ -45,6 +45,7 @@ /** * @return true if this is a targetted entry. */ + @Override protected boolean isTargetEntry() { return (targetType.equalsType(currentEntryHeader.getType())); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/StatsFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/StatsFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/StatsFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/StatsFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: StatsFileReader.java,v 1.24 2008/05/15 01:52:41 linda Exp $ + * $Id: StatsFileReader.java,v 1.25.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; @@ -128,6 +128,7 @@ return true; } + @Override public void summarize() { System.out.println("Log statistics:"); Iterator> iter = @@ -303,17 +304,17 @@ c.endCkptLsn; long endToEndDistance = 0; - FileManager fileManager = envImpl.getFileManager(); + FileManager fileMgr = envImpl.getFileManager(); if (prevCounter == null) { endToEndDistance = DbLsn.getWithCleaningDistance(end, - fileManager, + fileMgr, firstLsnRead, logFileMax); } else { endToEndDistance = DbLsn.getWithCleaningDistance(end, - fileManager, + fileMgr, prevCounter.endCkptLsn, logFileMax); } @@ -330,13 +331,13 @@ if (prevCounter == null) { endToStartDistance = DbLsn.getWithCleaningDistance(start, - fileManager, + fileMgr, firstLsnRead, logFileMax); } else { endToStartDistance = DbLsn.getWithCleaningDistance(start, - fileManager, + fileMgr, prevCounter.endCkptLsn, logFileMax); } @@ -350,7 +351,7 @@ (c.endCkptLsn != DbLsn.NULL_LSN)) { startToEndDistance = DbLsn.getWithCleaningDistance(c.endCkptLsn, - fileManager, + fileMgr, c.startCkptLsn, logFileMax); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/SyncedLogManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/SyncedLogManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/SyncedLogManager.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/SyncedLogManager.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SyncedLogManager.java,v 1.28 2008/05/15 01:52:41 linda Exp $ + * $Id: SyncedLogManager.java,v 1.28.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/TraceLogHandler.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/TraceLogHandler.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/TraceLogHandler.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/TraceLogHandler.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TraceLogHandler.java,v 1.34 2008/01/07 14:28:51 cwl Exp $ + * $Id: TraceLogHandler.java,v 1.34.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/log/UtilizationFileReader.java libdb-je-java-3.3.98/src/com/sleepycat/je/log/UtilizationFileReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/log/UtilizationFileReader.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/log/UtilizationFileReader.java 2010-01-04 15:30:30.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: UtilizationFileReader.java,v 1.18 2008/05/15 01:52:41 linda Exp $ + * $Id: UtilizationFileReader.java,v 1.19.2.2 2010/01/04 15:30:30 cwl Exp $ */ package com.sleepycat.je.log; @@ -71,6 +71,7 @@ twoEntryList.add(null); } + @Override protected boolean isTargetEntry() { /* UtilizationTracker does not count the file header. */ return currentEntryHeader.getType() != @@ -270,6 +271,7 @@ * Overrides the LN size calculation to return the recalculated number * of obsolete LN bytes. */ + @Override public int getObsoleteLNSize() { return recalcObsoleteLNSize; } @@ -278,6 +280,7 @@ * Overrides the IN size calculation to return the recalculated number * of obsolete IN bytes. */ + @Override public int getObsoleteINSize() { return recalcObsoleteINSize; } @@ -285,6 +288,7 @@ /** * Overrides to add the extended data fields. */ + @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append(super.toString()); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/LogScanConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/LogScanConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/LogScanConfig.java 2008-05-13 17:41:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/LogScanConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,14 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogScanConfig.java,v 1.6 2008/05/13 17:41:43 cwl Exp $ + * $Id: LogScanConfig.java,v 1.7.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; /** + * For internal use only. + * @hidden * Specify the attributes of a log scan. */ public class LogScanConfig { @@ -39,4 +41,15 @@ public boolean getForwards() { return forwards; } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "forwards=" + forwards + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/LogScanner.java libdb-je-java-3.3.98/src/com/sleepycat/je/LogScanner.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/LogScanner.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/LogScanner.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,14 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogScanner.java,v 1.3 2008/01/24 14:59:27 linda Exp $ + * $Id: LogScanner.java,v 1.3.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; /** + * For internal use only. + * @hidden * Used with Environment.scanLog to scan raw log entries. An instance of a * class that implements this interface should be passed to * Environment.scanLog. diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/OperationStatus.java libdb-je-java-3.3.98/src/com/sleepycat/je/OperationStatus.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/OperationStatus.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/OperationStatus.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: OperationStatus.java,v 1.14 2008/01/07 14:28:46 cwl Exp $ + * $Id: OperationStatus.java,v 1.15.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -47,6 +47,7 @@ } /** {@inheritDoc} */ + @Override public String toString() { return "OperationStatus." + statusName; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/package.html libdb-je-java-3.3.98/src/com/sleepycat/je/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/je/package.html 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/package.html 2010-01-04 15:30:28.000000000 +0000 @@ -5,9 +5,9 @@ See the file LICENSE for redistribution information. - Copyright (c) 2002,2008 Oracle. All rights reserved. + Copyright (c) 2002,2010 Oracle. All rights reserved. - $Id: package.html,v 1.16 2008/01/07 14:28:46 cwl Exp $ + $Id: package.html,v 1.16.2.2 2010/01/04 15:30:27 cwl Exp $ --> diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/PreloadConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/PreloadConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/PreloadConfig.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/PreloadConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PreloadConfig.java,v 1.8 2008/01/24 14:59:27 linda Exp $ + * $Id: PreloadConfig.java,v 1.9.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -104,4 +104,17 @@ return null; } } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "maxBytes=" + maxBytes + + "\nmaxMillisecs=" + maxMillisecs + + "\nloadLNs=" + loadLNs + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/PreloadStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/PreloadStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/PreloadStats.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/PreloadStats.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PreloadStats.java,v 1.9 2008/01/24 14:59:27 linda Exp $ + * $Id: PreloadStats.java,v 1.10.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -212,6 +212,7 @@ * Returns a String representation of the stats in the form of * <stat>=<value> */ + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("status=").append(status).append('\n'); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/PreloadStatus.java libdb-je-java-3.3.98/src/com/sleepycat/je/PreloadStatus.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/PreloadStatus.java 2008-05-20 17:52:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/PreloadStatus.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PreloadStatus.java,v 1.10 2008/05/20 17:52:34 linda Exp $ + * $Id: PreloadStatus.java,v 1.11.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -23,6 +23,7 @@ this.statusName = statusName; } + @Override public String toString() { return "PreloadStatus." + statusName; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/CheckpointEnd.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/CheckpointEnd.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/CheckpointEnd.java 2008-02-06 02:04:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/CheckpointEnd.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CheckpointEnd.java,v 1.37 2008/02/06 02:04:18 cwl Exp $ + * $Id: CheckpointEnd.java,v 1.38.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; @@ -228,6 +228,7 @@ return false; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("time=").append(endTime); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/Checkpointer.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/Checkpointer.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/Checkpointer.java 2008-05-23 18:50:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/Checkpointer.java 2010-03-26 01:52:08.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Checkpointer.java,v 1.169 2008/05/23 18:50:49 mark Exp $ + * $Id: Checkpointer.java,v 1.170.2.5 2010/03/26 01:52:07 mark Exp $ */ package com.sleepycat.je.recovery; @@ -74,6 +74,8 @@ */ public static TestHook maxFlushLevelHook = null; + public static TestHook beforeFlushHook = null; + private EnvironmentImpl envImpl; /* Checkpoint sequence, initialized at recovery. */ @@ -234,6 +236,7 @@ /** * Return the number of retries when a deadlock exception occurs. */ + @Override protected long nDeadlockRetries() throws DatabaseException { @@ -468,6 +471,9 @@ */ dirtyMap.addCostToMemoryBudget(); + /* Call hook after dirty map creation and before flushing. */ + TestHookExecute.doHookIfSet(beforeFlushHook); + /* Flush IN nodes. */ boolean allowDeltas = !config.getMinimizeRecoveryTime(); flushDirtyNodes(envImpl, dirtyMap, highestFlushLevels, allowDeltas, @@ -616,6 +622,11 @@ maxFlushLevelHook = hook; } + /* For unit testing only. */ + public static void setBeforeFlushHook(TestHook hook) { + beforeFlushHook = hook; + } + /** * Flush the nodes in order, from the lowest level to highest level. As a * flush dirties its parent, add it to the dirty map, thereby cascading the @@ -759,22 +770,22 @@ * * If this is a high priority checkpoint, we'll hold the INb latch across * the time it takes to flush all three children. In flushIN(BINd), we - * walk through INa, create a local map of all the siblings that can be + * walk through INb, create a local map of all the siblings that can be * found in the dirty map, and then call logSiblings with that local map. - * Then we'll write out INa. + * Then we'll write out INb. * * If high priority is false, we will not hold the INb latch across * multiple IOs. Instead, we * - write BINd out, using logSiblings - * - while still holding the INa latch, we create a local map of dirty + * - while still holding the INb latch, we create a local map of dirty * siblings - * - release the INa latch + * - release the INb latch * - call flushIN() recursively on each entry in the local sibling map, * which will result in a search and write of each sibling. These * recursive calls to flushIN are called with the allowLogSubtree * parameter of false to halt the recursion and prevent a repeat of the * sibling examination. - * - write INa + * - write INb */ private static void flushIN(EnvironmentImpl envImpl, DatabaseImpl db, @@ -862,6 +873,7 @@ */ if (result.parent != null) { IN parent = result.parent; + int parentLevel = parent.getLevel(); boolean mustLogParent = false; /* @@ -874,17 +886,25 @@ * tree DB. */ boolean bottomLevelTarget = db.getSortedDuplicates() ? - (parent.getLevel() == 2) : - ((parent.getLevel() & IN.LEVEL_MASK) == 2); + (parentLevel == 2) : + ((parentLevel & IN.LEVEL_MASK) == 2); /* * INs at the max flush level are always non-provisional and * INs at the bottom level (when this is not also the max flush * level) are always provisional. In between INs are * provisional BEFORE_CKPT_END (see Provisional). + * + * Note that to determine whether this IN is at the + * maxFlushLevel, we check (parentLevel > maxFlushLevel) + * instead of (currentLevel >= maxFlushLevel). This handles + * the case where this IN is a DIN root, and the parent is a + * BIN that will not be flushed because the maxFlushLevel is + * less than IN.MAIN_LEVEL (0x10000). For example, this IN is + * a DIN root at level 2 and the maxFlushLevel is 3. [#16712] */ Provisional provisional; - if (currentLevel >= maxFlushLevel) { + if (parentLevel > maxFlushLevel) { provisional = Provisional.NO; } else if (bottomLevelTarget) { provisional = Provisional.YES; @@ -969,7 +989,7 @@ * the non-exact search does not find a sibling * rather than a parent. [#11555] */ - if (parent.getLevel() > currentLevel) { + if (parentLevel > currentLevel) { mustLogParent |= true; } /* nAlreadyEvictedThisRun++; -- for future. */ @@ -984,6 +1004,11 @@ * does not contain targetRef (the sibling we're * processing) because it was removed before calling * this method, but it is added to the map below. + * + * A TreeMap (sorted map) is used so that siblings are + * latched in node ID order. A deterministic order is + * needed to avoid deadlocks, if siblings are latched + * in multiple threads in the future. */ siblingsToLog = new TreeMap(); for (int index = 0; @@ -1037,8 +1062,13 @@ dumpParentChildInfo(result, parent, targetRef.nodeId, currentLevel, tree); - dirtyMap.addDirtyIN - (parent, true /* updateMemoryBudget */); + /* + * Add the parent IN to the dirty map unconditionally, + * even if not dirty, to cause changes to propogate + * upward even when a node has been evicted and + * refetched and is no longer dirty. [#16523] + */ + dirtyMap.addIN(parent, true /*updateMemoryBudget*/); } } finally { parent.releaseLatch(); @@ -1075,13 +1105,13 @@ * latch above, since we must search and acquire the * grandparent latch. */ - if (logSubtree && parent.getLevel() <= maxFlushLevel) { + if (logSubtree && parentLevel <= maxFlushLevel) { CheckpointReference parentRef = dirtyMap.removeNode - (parent.getLevel(), parent.getNodeId()); + (parentLevel, parent.getNodeId()); if (parentRef != null) { flushIN (envImpl, db, logManager, parentRef, dirtyMap, - parent.getLevel(), maxFlushLevel, allowDeltas, + parentLevel, maxFlushLevel, allowDeltas, checkpointStart, highPriority, fstats, localTracker, false /*allowLogSubtree*/); } @@ -1185,9 +1215,13 @@ /* Remove it from dirty map if it is present. */ dirtyMap.removeNode(child.getLevel(), child.getNodeId()); - /* Latch and add item so we will release the latch below. */ + /* + * Latch and add item with valid parentIndex, so we will + * release the latch in the finally statement. + */ child.latch(CacheMode.UNCHANGED); INLogItem item = new INLogItem(); + item.parentIndex = index; itemList.add(item); /* @@ -1222,7 +1256,6 @@ item.provisional = provisional; item.repContext = ReplicationContext.NO_REPLICATE; item.parent = parent; - item.parentIndex = index; /* * Allow child to perform "before log" processing. Note @@ -1408,6 +1441,7 @@ this.dupTreeKey = dupTreeKey; } + @Override public boolean equals(Object o) { if (!(o instanceof CheckpointReference)) { return false; @@ -1417,6 +1451,7 @@ return nodeId == other.nodeId; } + @Override public int hashCode() { return (int) nodeId; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/CheckpointStart.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/CheckpointStart.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/CheckpointStart.java 2008-01-17 17:22:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/CheckpointStart.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CheckpointStart.java,v 1.34 2008/01/17 17:22:13 cwl Exp $ + * $Id: CheckpointStart.java,v 1.34.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/DirtyINMap.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/DirtyINMap.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/DirtyINMap.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/DirtyINMap.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DirtyINMap.java,v 1.17 2008/05/15 01:52:42 linda Exp $ + * $Id: DirtyINMap.java,v 1.17.2.3 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; @@ -86,8 +86,8 @@ continue; } - Integer level = addDirtyIN - (in, false /* updateMemoryBudget */); + Integer level = + addDirtyIN(in, false /*updateMemoryBudget*/); if (level != null) { /* @@ -172,7 +172,7 @@ if (in.getDatabaseId().equals(dbId)) { in.latch(CacheMode.UNCHANGED); try { - addDirtyIN(in, false /* updateMemoryBudget */); + addDirtyIN(in, false /*updateMemoryBudget*/); } finally { in.releaseLatch(); } @@ -208,49 +208,57 @@ } /** - * Add a node to the dirty map. The dirty map is keyed by level (Integers) - * and holds sets of IN references. + * Adds the IN if dirty, otherwise returns null. See addIN. + */ + private Integer addDirtyIN(IN in, boolean updateMemoryBudget) { + + if (in.getDirty()) { + return addIN(in, updateMemoryBudget); + } else { + return null; + } + } + + + /** + * Add a node unconditionally to the dirty map. The dirty map is keyed by + * level (Integers) and holds sets of IN references. * * @param updateMemoryBudget if true then update the memory budget as the * map is changed; if false then addCostToMemoryBudget must be called * later. * - * @return level of IN added to the dirty map, or null if the IN was not - * added to the dirty map. The level is returned rather than a boolean - * simply to avoid allocating another Integer in the caller. + * @return level of IN added to the dirty map. The level is returned + * rather than a boolean simply to avoid allocating another Integer in the + * caller. */ - Integer addDirtyIN(IN in, boolean updateMemoryBudget) { + Integer addIN(IN in, boolean updateMemoryBudget) { - if (in.getDirty()) { - - Integer level = Integer.valueOf(in.getLevel()); - Map nodeMap; - if (levelMap.containsKey(level)) { - nodeMap = levelMap.get(level); - } else { - nodeMap = new HashMap(); - levelMap.put(level, nodeMap); - } - - nodeMap.put(in.getNodeId(), - new CheckpointReference(in.getDatabase().getId(), - in.getNodeId(), - in.containsDuplicates(), - in.isDbRoot(), - in.getMainTreeKey(), - in.getDupTreeKey())); - numEntries++; - - if (updateMemoryBudget) { - MemoryBudget mb = envImpl.getMemoryBudget(); - mb.updateAdminMemoryUsage - (MemoryBudget.CHECKPOINT_REFERENCE_SIZE); - } - - return level; + Integer level = Integer.valueOf(in.getLevel()); + Map nodeMap; + if (levelMap.containsKey(level)) { + nodeMap = levelMap.get(level); } else { - return null; + nodeMap = new HashMap(); + levelMap.put(level, nodeMap); } + + nodeMap.put(in.getNodeId(), + new CheckpointReference(in.getDatabase().getId(), + in.getNodeId(), + in.containsDuplicates(), + in.isDbRoot(), + in.getMainTreeKey(), + in.getDupTreeKey())); + numEntries++; + + if (updateMemoryBudget) { + MemoryBudget mb = envImpl.getMemoryBudget(); + mb.updateAdminMemoryUsage + (MemoryBudget.CHECKPOINT_REFERENCE_SIZE); + } + + return level; } /** diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/LevelRecorder.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/LevelRecorder.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/LevelRecorder.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/LevelRecorder.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LevelRecorder.java,v 1.7 2008/05/15 01:52:42 linda Exp $ + * $Id: LevelRecorder.java,v 1.7.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/NoRootException.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/NoRootException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/NoRootException.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/NoRootException.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NoRootException.java,v 1.3 2008/01/07 14:28:52 cwl Exp $ + * $Id: NoRootException.java,v 1.3.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/RecoveryException.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/RecoveryException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/RecoveryException.java 2008-05-20 17:52:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/RecoveryException.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryException.java,v 1.19 2008/05/20 17:52:36 linda Exp $ + * $Id: RecoveryException.java,v 1.19.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/RecoveryInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/RecoveryInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/RecoveryInfo.java 2008-01-07 14:28:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/RecoveryInfo.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryInfo.java,v 1.30 2008/01/07 14:28:52 cwl Exp $ + * $Id: RecoveryInfo.java,v 1.31.2.2 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; @@ -63,6 +63,7 @@ /* VLSN mappings seen during recovery processing, for replication. */ public Collection fileMappers = new HashSet(); + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Recovery Info"); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/RecoveryManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/RecoveryManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/recovery/RecoveryManager.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/recovery/RecoveryManager.java 2010-01-04 15:30:32.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryManager.java,v 1.241 2008/05/15 01:52:42 linda Exp $ + * $Id: RecoveryManager.java,v 1.242.2.5 2010/01/04 15:30:32 cwl Exp $ */ package com.sleepycat.je.recovery; @@ -52,6 +52,7 @@ import com.sleepycat.je.tree.TreeLocation; import com.sleepycat.je.tree.WithRootLatched; import com.sleepycat.je.txn.BasicLocker; +import com.sleepycat.je.txn.LockResult; import com.sleepycat.je.txn.LockType; import com.sleepycat.je.txn.PreparedTxn; import com.sleepycat.je.txn.Txn; @@ -1195,9 +1196,12 @@ * there was a write lock on this LN since * it exists in the log under this txnId. */ - preparedTxn.lock + LockResult lockResult = preparedTxn.lock (ln.getNodeId(), LockType.WRITE, false /*noWait*/, db); + lockResult.setAbortLsn + (reader.getAbortLsn(), + reader.getAbortKnownDeleted()); } treeLsn = redo(db, @@ -1236,21 +1240,22 @@ mapLN.getDatabase().countObsoleteDb (tracker, logLsn); } - } - /* Redo utilization info. */ - TxnNodeId txnNodeId = null; - if (txnId != null) { - txnNodeId = new TxnNodeId(reader.getNodeId(), - txnId.longValue()); + /* Redo utilization info. */ + TxnNodeId txnNodeId = null; + if (txnId != null) { + txnNodeId = new TxnNodeId + (reader.getNodeId(), + txnId.longValue()); + } + redoUtilizationInfo + (logLsn, treeLsn, commitLsn, + reader.getAbortLsn(), + reader.getAbortKnownDeleted(), + reader.getLastEntrySize(), + reader.getKey(), + ln, db, txnNodeId, countedAbortLsnNodes); } - redoUtilizationInfo(logLsn, treeLsn, commitLsn, - reader.getAbortLsn(), - reader.getAbortKnownDeleted(), - reader.getLastEntrySize(), - reader.getKey(), - ln, db, txnNodeId, - countedAbortLsnNodes); } finally { dbMapTree.releaseDb(db); } @@ -1307,6 +1312,7 @@ /** * Compare two TxnNodeId objects */ + @Override public boolean equals(Object obj) { if (this == obj) { return true; @@ -1320,6 +1326,7 @@ (((TxnNodeId) obj).nodeId == nodeId)); } + @Override public int hashCode() { return (int) (txnId + nodeId); } @@ -2269,11 +2276,14 @@ /* * If the LN is marked deleted and its LSN follows the FileSummaryLN * for its file, count it as obsolete. + * + * Inexact counting is used to save resources because the cleaner knows + * that all deleted LNs are obsolete. */ if (ln.isDeleted()) { tracker.countObsoleteIfUncounted (logLsn, logLsn, null, logEntrySize, db.getId(), - true /*countExact*/); + false /*countExact*/); } /* Was the LN found in the tree? */ @@ -2284,6 +2294,12 @@ * If the oldLsn and newLsn differ and the newLsn follows the * FileSummaryLN for the file of the oldLsn, count the oldLsn as * obsolete. + * + * Use exact counting only if the transaction is committed. A + * prepared or resurrected transaction may be committed or aborted + * later on. We perform obsolete counting as if a commit will + * occur to ensure cleaning will occur, but we count inexact to + * prevent LogFileNotFound in case an abort occurs. [#17022] */ if (cmpLogLsnToTreeLsn != 0) { long newLsn = (cmpLogLsnToTreeLsn < 0) ? treeLsn : logLsn; @@ -2292,7 +2308,7 @@ tracker.countObsoleteIfUncounted (oldLsn, newLsn, null, tracker.fetchLNSize(oldSize, oldLsn), db.getId(), - true /*countExact*/); + commitLsn != DbLsn.NULL_LSN /*countExact*/); } /* @@ -2314,13 +2330,17 @@ * The abortLsn is only an approximation of the prior LSN, so * use inexact counting. Since this is relatively rare, a zero * entry size (use average size) is acceptable. + * + * Note that commitLsn may be null if this is a prepared or + * resurrected HA Txn. [#16375] */ - assert commitLsn != DbLsn.NULL_LSN; - tracker.countObsoleteIfUncounted - (abortLsn, commitLsn, null, 0, db.getId(), - false /*countExact*/); - /* Don't count this abortLsn (this node) again. */ - countedAbortLsnNodes.add(txnNodeId); + if (commitLsn != DbLsn.NULL_LSN) { + tracker.countObsoleteIfUncounted + (abortLsn, commitLsn, null, 0, db.getId(), + false /*countExact*/); + /* Don't count this abortLsn (this node) again. */ + countedAbortLsnNodes.add(txnNodeId); + } } } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/ReplicaConsistencyPolicy.java libdb-je-java-3.3.98/src/com/sleepycat/je/ReplicaConsistencyPolicy.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/ReplicaConsistencyPolicy.java 2008-05-13 20:03:10.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/ReplicaConsistencyPolicy.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,13 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReplicaConsistencyPolicy.java,v 1.1 2008/05/13 20:03:09 sam Exp $ + * $Id: ReplicaConsistencyPolicy.java,v 1.3.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; +import com.sleepycat.je.dbi.ReplicatorInstance; + /** * @hidden * Feature not yet available. @@ -19,4 +21,11 @@ */ public interface ReplicaConsistencyPolicy { + /** + * Ensures that the replica is within the constraints specified by this + * policy. If it isn't the method waits until the constraint is satisfied + * by the replica. + */ + public void ensureConsistency(ReplicatorInstance repInstance) + throws InterruptedException, DatabaseException; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/RunRecoveryException.java libdb-je-java-3.3.98/src/com/sleepycat/je/RunRecoveryException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/RunRecoveryException.java 2008-05-29 03:38:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/RunRecoveryException.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RunRecoveryException.java,v 1.24 2008/05/29 03:38:23 linda Exp $ + * $Id: RunRecoveryException.java,v 1.25.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -62,6 +62,7 @@ this.alreadyThrown = alreadyThrown; } + @Override public String toString() { if (alreadyThrown) { return "Environment invalid because of previous exception: " + diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryConfig.java 2008-02-08 03:22:38.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryConfig.java,v 1.23 2008/02/08 03:22:38 mark Exp $ + * $Id: SecondaryConfig.java,v 1.25.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -374,6 +374,7 @@ /* * For JCA Database handle caching. */ + @Override void validate(DatabaseConfig configArg) throws DatabaseException { @@ -464,4 +465,22 @@ return ret.toString(); } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "keyCreator=" + keyCreator + + "\nmultiKeyCreator=" + multiKeyCreator + + "\nallowPopulate=" + allowPopulate + + "\nforeignKeyDatabase=" + foreignKeyDatabase + + "\nforeignKeyDeleteAction=" + foreignKeyDeleteAction + + "\nforeignKeyNullifier=" + foreignKeyNullifier + + "\nforeignMultiKeyNullifier=" + foreignMultiKeyNullifier + + "\nimmutableSecondaryKey=" + immutableSecondaryKey + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryCursor.java libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryCursor.java 2008-05-19 17:52:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryCursor.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryCursor.java,v 1.44 2008/05/19 17:52:16 linda Exp $ + * $Id: SecondaryCursor.java,v 1.45.2.3 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -113,10 +113,11 @@ * Returns a new SecondaryCursor for the same transaction as * the original cursor. */ + @Override public Cursor dup(boolean samePosition) throws DatabaseException { - checkState(true); + checkState(false); return new SecondaryCursor(this, samePosition); } @@ -146,6 +147,7 @@ * cursor functions expecting the cursor to refer to an existing key will * fail. */ + @Override public OperationStatus delete() throws DatabaseException { @@ -176,6 +178,7 @@ * UnsupportedOperationException} will always be thrown by this method. * The corresponding method on the primary database should be used instead. */ + @Override public OperationStatus put(DatabaseEntry key, DatabaseEntry data) throws DatabaseException { @@ -187,6 +190,7 @@ * UnsupportedOperationException} will always be thrown by this method. * The corresponding method on the primary database should be used instead. */ + @Override public OperationStatus putNoOverwrite(DatabaseEntry key, DatabaseEntry data) throws DatabaseException { @@ -199,6 +203,7 @@ * UnsupportedOperationException} will always be thrown by this method. * The corresponding method on the primary database should be used instead. */ + @Override public OperationStatus putNoDupData(DatabaseEntry key, DatabaseEntry data) throws DatabaseException { @@ -210,6 +215,7 @@ * UnsupportedOperationException} will always be thrown by this method. * The corresponding method on the primary database should be used instead. */ + @Override public OperationStatus putCurrent(DatabaseEntry data) throws DatabaseException { @@ -246,6 +252,7 @@ * deleted; otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getCurrent(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -329,6 +336,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getFirst(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -417,6 +425,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getLast(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -511,6 +520,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getNext(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -609,6 +619,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getNextDup(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -702,6 +713,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getNextNoDup(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -807,6 +819,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getPrev(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -905,6 +918,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getPrevDup(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -998,6 +1012,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getPrevNoDup(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -1096,6 +1111,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getSearchKey(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -1192,6 +1208,7 @@ * otherwise, {@link com.sleepycat.je.OperationStatus#SUCCESS * OperationStatus.SUCCESS}. */ + @Override public OperationStatus getSearchKeyRange(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -1262,6 +1279,7 @@ * The corresponding method with the pKey parameter should be * used instead. */ + @Override public OperationStatus getSearchBoth(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -1326,6 +1344,7 @@ * The corresponding method with the pKey parameter should be * used instead. */ + @Override public OperationStatus getSearchBothRange(DatabaseEntry key, DatabaseEntry data, LockMode lockMode) @@ -1570,7 +1589,7 @@ * secondary key. If it has been, return KEYEMPTY. */ if (readUncommitted) { - SecondaryConfig config = + SecondaryConfig conf = secondaryDb.getPrivateSecondaryConfig(); /* @@ -1578,28 +1597,28 @@ * null (the database is read only), then we can skip this * check. */ - if (config.getImmutableSecondaryKey()) { + if (conf.getImmutableSecondaryKey()) { /* Do nothing. */ - } else if (config.getKeyCreator() != null) { + } else if (conf.getKeyCreator() != null) { /* * Check that the key we're using is equal to the key * returned by the key creator. */ DatabaseEntry secKey = new DatabaseEntry(); - if (!config.getKeyCreator().createSecondaryKey + if (!conf.getKeyCreator().createSecondaryKey (secondaryDb, pKey, data, secKey) || !secKey.equals(key)) { return OperationStatus.KEYEMPTY; } - } else if (config.getMultiKeyCreator() != null) { + } else if (conf.getMultiKeyCreator() != null) { /* * Check that the key we're using is in the set returned by * the key creator. */ Set results = new HashSet(); - config.getMultiKeyCreator().createSecondaryKeys + conf.getMultiKeyCreator().createSecondaryKeys (secondaryDb, pKey, data, results); if (!results.contains(key)) { return OperationStatus.KEYEMPTY; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryDatabase.java libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryDatabase.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryDatabase.java 2008-03-18 16:53:04.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryDatabase.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryDatabase.java,v 1.61 2008/03/18 15:53:04 mark Exp $ + * $Id: SecondaryDatabase.java,v 1.62.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -161,6 +161,7 @@ /** * Create a database, called by Environment */ + @Override void initNew(Environment env, Locker locker, String databaseName, @@ -174,6 +175,7 @@ /** * Open a database, called by Environment */ + @Override void initExisting(Environment env, Locker locker, DatabaseImpl database, @@ -357,6 +359,7 @@ /** * Overrides Database method. */ + @Override Cursor newDbcInstance(Transaction txn, CursorConfig cursorConfig) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryKeyCreator.java libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryKeyCreator.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryKeyCreator.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryKeyCreator.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryKeyCreator.java,v 1.13 2008/01/07 14:28:46 cwl Exp $ + * $Id: SecondaryKeyCreator.java,v 1.13.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryMultiKeyCreator.java libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryMultiKeyCreator.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryMultiKeyCreator.java 2008-05-27 15:30:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryMultiKeyCreator.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryMultiKeyCreator.java,v 1.9 2008/05/27 15:30:34 mark Exp $ + * $Id: SecondaryMultiKeyCreator.java,v 1.9.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryTrigger.java libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryTrigger.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SecondaryTrigger.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SecondaryTrigger.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryTrigger.java,v 1.14 2008/01/07 14:28:46 cwl Exp $ + * $Id: SecondaryTrigger.java,v 1.14.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SequenceConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/SequenceConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SequenceConfig.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SequenceConfig.java 2008-06-10 00:21:30.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2005,2008 Oracle. All rights reserved. * - * $Id: SequenceConfig.java,v 1.10 2008/01/07 14:28:46 cwl Exp $ + * $Id: SequenceConfig.java,v 1.11 2008/06/10 00:21:30 cwl Exp $ */ package com.sleepycat.je; @@ -271,4 +271,23 @@ public boolean getWrap() { return wrap; } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "allowCreate=" + allowCreate + + "\ncacheSize=" + cacheSize + + "\ndecrement=" + decrement + + "\nexclusiveCreate=" + exclusiveCreate + + "\ninitialValue=" + initialValue + + "\nautoCommitNoSync=" + autoCommitNoSync + + "\nrangeMin=" + rangeMin + + "\nrangeMax=" + rangeMax + + "\nwrap=" + wrap + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/SequenceStats.java libdb-je-java-3.3.98/src/com/sleepycat/je/SequenceStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/SequenceStats.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/SequenceStats.java 2008-06-10 02:52:08.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2005,2008 Oracle. All rights reserved. * - * $Id: SequenceStats.java,v 1.8 2008/01/07 14:28:46 cwl Exp $ + * $Id: SequenceStats.java,v 1.9 2008/06/10 02:52:08 cwl Exp $ */ package com.sleepycat.je; @@ -115,6 +115,7 @@ return cacheSize; } + @Override public String toString() { return "nGets=" + nGets + "\nnCachedGets=" + nCachedGets diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/StatsConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/StatsConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/StatsConfig.java 2008-01-24 14:59:28.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/StatsConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: StatsConfig.java,v 1.18 2008/01/24 14:59:27 linda Exp $ + * $Id: StatsConfig.java,v 1.19.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -113,4 +113,18 @@ public int getShowProgressInterval() { return showProgressInterval; } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "fast=" + fast + + "\nclear=" + clear + + "\nshowProgressStream=" + showProgressStream + + "\nshowProgressInterval=" + showProgressInterval + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/TransactionConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/TransactionConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/TransactionConfig.java 2008-05-28 14:46:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/TransactionConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TransactionConfig.java,v 1.23 2008/05/28 14:46:42 linda Exp $ + * $Id: TransactionConfig.java,v 1.24.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -33,8 +33,6 @@ private boolean readCommitted = false; private boolean serializableIsolation = false; - - /* Convenience constants for local (non-replicated) use. */ /** @@ -454,4 +452,23 @@ " supported"); } } + + /** + * Returns the values for each configuration attribute. + * + * @return the values for each configuration attribute. + */ + @Override + public String toString() { + return "sync=" + sync + + "\nnoSync=" + noSync + + "\nwriteNoSync=" + writeNoSync + + "\ndurability=" + durability + + "\nconsistencyPolicy=" + consistencyPolicy + + "\nnoWait=" + noWait + + "\nreadUncommitted=" + readUncommitted + + "\nreadCommitted=" + readCommitted + + "\nSerializableIsolation=" + serializableIsolation + + "\n"; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/Transaction.java libdb-je-java-3.3.98/src/com/sleepycat/je/Transaction.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/Transaction.java 2008-05-29 03:38:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/Transaction.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Transaction.java,v 1.59 2008/05/29 03:38:23 linda Exp $ + * $Id: Transaction.java,v 1.60.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -168,6 +168,7 @@ */ public void commit(Durability durability) throws DatabaseException { + doCommit(durability, false /* explicitSync */); } @@ -387,6 +388,7 @@ * @hidden * For internal use. */ + @Override public int hashCode() { return (int) id; } @@ -395,6 +397,7 @@ * @hidden * For internal use. */ + @Override public boolean equals(Object o) { if (o == null) { return false; @@ -411,6 +414,7 @@ return false; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(" getKeyComparator() { return getDatabase().getBtreeComparator(); } + @Override public String beginTag() { return BEGIN_TAG; } + @Override public String endTag() { return END_TAG; } @@ -1080,6 +1126,7 @@ /** * @see IN.logDirtyChildren(); */ + @Override public void logDirtyChildren() throws DatabaseException { @@ -1118,10 +1165,12 @@ /** * @see Node#getLogType */ + @Override public LogEntryType getLogType() { return LogEntryType.LOG_BIN; } + @Override public String shortClassName() { return "BIN"; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/BINReference.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/BINReference.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/BINReference.java 2008-05-15 01:52:42.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/BINReference.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BINReference.java,v 1.22 2008/05/15 01:52:42 linda Exp $ + * $Id: BINReference.java,v 1.23.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -95,6 +95,7 @@ /** * Compare two BINReferences. */ + @Override public boolean equals(Object obj) { if (this == obj) { return true; @@ -107,10 +108,12 @@ return ((BINReference) obj).nodeId == nodeId; } + @Override public int hashCode() { return (int) nodeId; } + @Override public String toString() { return "idKey=" + Key.getNoFormatString(idKey) + " nodeId = " + nodeId + diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/ChildReference.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/ChildReference.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/ChildReference.java 2008-01-17 17:22:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/ChildReference.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ChildReference.java,v 1.109 2008/01/17 17:22:13 cwl Exp $ + * $Id: ChildReference.java,v 1.110.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -364,6 +364,7 @@ return sb.toString(); } + @Override public String toString() { return dumpString(0, false); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/CursorsExistException.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/CursorsExistException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/CursorsExistException.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/CursorsExistException.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CursorsExistException.java,v 1.9 2008/01/07 14:28:56 cwl Exp $ + * $Id: CursorsExistException.java,v 1.9.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DBIN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DBIN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DBIN.java 2008-05-20 14:51:50.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DBIN.java 2010-03-26 13:23:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DBIN.java,v 1.81 2008/05/20 14:51:49 cwl Exp $ + * $Id: DBIN.java,v 1.82.2.3 2010/03/26 13:23:55 mark Exp $ */ package com.sleepycat.je.tree; @@ -52,6 +52,7 @@ * Create a new DBIN. Need this because we can't call newInstance() * without getting a 0 node. */ + @Override protected IN createNewInstance(byte[] identifierKey, int maxEntries, int level) { @@ -67,11 +68,18 @@ * "always exclusive" variety. Presently, only IN's are actually latched * shared. BINs, DINs, and DBINs are all latched exclusive only. */ + @Override boolean isAlwaysLatchedExclusively() { return true; } + @Override + boolean isBottomMostNode() { + return true; + } + /* Duplicates have no mask on their levels. */ + @Override protected int generateLevel(DatabaseId dbId, int newLevel) { return newLevel; } @@ -80,6 +88,7 @@ * Return the comparator function to be used for DBINs. This is * the user defined duplicate comparison function, if defined. */ + @Override public final Comparator getKeyComparator() { return getDatabase().getDuplicateComparator(); } @@ -87,6 +96,7 @@ /** * Return the key for this duplicate set. */ + @Override public byte[] getDupKey() { return dupKey; } @@ -95,6 +105,7 @@ * Get the key (dupe or identifier) in child that is used to locate * it in 'this' node. */ + @Override public byte[] getChildKey(IN child) throws DatabaseException { @@ -104,6 +115,7 @@ /* * A DBIN uses the dupTree key in its searches. */ + @Override public byte[] selectKey(byte[] mainTreeKey, byte[] dupTreeKey) { return dupTreeKey; } @@ -111,6 +123,7 @@ /** * Return the key for navigating through the duplicate tree. */ + @Override public byte[] getDupTreeKey() { return getIdentifierKey(); } @@ -118,6 +131,7 @@ /** * Return the key for navigating through the main tree. */ + @Override public byte[] getMainTreeKey() { return dupKey; } @@ -126,6 +140,7 @@ * @return true if this node is a duplicate-bearing node type, false * if otherwise. */ + @Override public boolean containsDuplicates() { return true; } @@ -133,10 +148,12 @@ /** * @return the log entry type to use for bin delta log entries. */ + @Override LogEntryType getBINDeltaType() { return LogEntryType.LOG_DUP_BIN_DELTA; } + @Override public BINReference createReference() { return new DBINReference(getNodeId(), getDatabase().getId(), getIdentifierKey(), dupKey); @@ -145,6 +162,7 @@ /** * Count up the memory usage attributable to this node alone. */ + @Override protected long computeMemorySize() { long size = super.computeMemorySize(); return size; @@ -162,6 +180,7 @@ IN.computeArraysOverhead(configManager); } + @Override protected long getMemoryOverhead(MemoryBudget mb) { return mb.getDBINOverhead(); } @@ -169,6 +188,7 @@ /* * A DBIN cannot be the ancestor of any IN. */ + @Override protected boolean canBeAncestor(boolean targetContainsDuplicates) { return false; } @@ -190,22 +210,27 @@ * used. For DBIN's, the CursorImpl.dupIndex and CursorImpl.dupBin * fields should be used. */ + @Override BIN getCursorBIN(CursorImpl cursor) { return cursor.getDupBIN(); } + @Override BIN getCursorBINToBeRemoved(CursorImpl cursor) { return cursor.getDupBINToBeRemoved(); } + @Override int getCursorIndex(CursorImpl cursor) { return cursor.getDupIndex(); } + @Override void setCursorBIN(CursorImpl cursor, BIN bin) { cursor.setDupBIN((DBIN) bin); } + @Override void setCursorIndex(CursorImpl cursor, int index) { cursor.setDupIndex(index); } @@ -217,6 +242,7 @@ * * No latching is performed. */ + @Override boolean matchLNByNodeId(TreeLocation location, long nodeId, CacheMode cacheMode) @@ -246,14 +272,17 @@ /* * DbStat support. */ + @Override void accumulateStats(TreeWalkerStatsAccumulator acc) { acc.processDBIN(this, Long.valueOf(getNodeId()), getLevel()); } + @Override public String beginTag() { return BEGIN_TAG; } + @Override public String endTag() { return END_TAG; } @@ -262,6 +291,7 @@ * For unit test support: * @return a string that dumps information about this IN, without */ + @Override public String dumpString(int nSpaces, boolean dumpTags) { StringBuffer sb = new StringBuffer(); sb.append(TreeUtils.indent(nSpaces)); @@ -284,6 +314,7 @@ /** * @see Node#getLogType() */ + @Override public LogEntryType getLogType() { return LogEntryType.LOG_DBIN; } @@ -295,6 +326,7 @@ /** * @see Loggable#getLogSize */ + @Override public int getLogSize() { int size = super.getLogSize(); // ancestors size += LogUtils.getByteArrayLogSize(dupKey); // identifier key @@ -304,6 +336,7 @@ /** * @see Loggable#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { super.writeToLog(logBuffer); @@ -313,6 +346,7 @@ /** * @see BIN#readFromLog */ + @Override public void readFromLog(ByteBuffer itemBuffer, byte entryVersion) throws LogException { @@ -323,11 +357,13 @@ /** * DBINS need to dump their dup key */ + @Override protected void dumpLogAdditional(StringBuffer sb) { super.dumpLogAdditional(sb); sb.append(Key.dumpString(dupKey, 0)); } + @Override public String shortClassName() { return "DBIN"; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DBINReference.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DBINReference.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DBINReference.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DBINReference.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DBINReference.java,v 1.18 2008/05/13 01:44:53 cwl Exp $ + * $Id: DBINReference.java,v 1.19.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -25,14 +25,17 @@ this.dupKey = dupKey; } + @Override public byte[] getKey() { return dupKey; } + @Override public byte[] getData() { return idKey; } + @Override public String toString() { return super.toString() + " dupKey=" + Key.dumpString(dupKey, 0); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DeltaInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DeltaInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DeltaInfo.java 2008-01-17 17:22:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DeltaInfo.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DeltaInfo.java,v 1.27 2008/01/17 17:22:13 cwl Exp $ + * $Id: DeltaInfo.java,v 1.27.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DIN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DIN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DIN.java 2008-05-20 14:52:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DIN.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DIN.java,v 1.99 2008/05/20 14:52:00 cwl Exp $ + * $Id: DIN.java,v 1.100.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -72,6 +72,7 @@ } /* Duplicates have no mask on their levels. */ + @Override protected int generateLevel(DatabaseId dbId, int newLevel) { return newLevel; } @@ -80,6 +81,7 @@ * Create a new DIN. Need this because we can't call newInstance() * without getting a 0 node. */ + @Override protected IN createNewInstance(byte[] identifierKey, int maxEntries, int level) { @@ -96,6 +98,7 @@ * "always exclusive" variety. Presently, only IN's are actually latched * shared. BINs, DINs, and DBINs are all latched exclusive only. */ + @Override boolean isAlwaysLatchedExclusively() { return true; } @@ -103,6 +106,7 @@ /** * Return the key for this duplicate set. */ + @Override public byte[] getDupKey() { return dupKey; } @@ -111,6 +115,7 @@ * Get the key (dupe or identifier) in child that is used to locate * it in 'this' node. */ + @Override public byte[] getChildKey(IN child) throws DatabaseException { @@ -120,6 +125,7 @@ /* * A DIN uses the dupTree key in its searches. */ + @Override public byte[] selectKey(byte[] mainTreeKey, byte[] dupTreeKey) { return dupTreeKey; } @@ -127,6 +133,7 @@ /** * Return the key for navigating through the duplicate tree. */ + @Override public byte[] getDupTreeKey() { return getIdentifierKey(); } @@ -134,6 +141,7 @@ /** * Return the key for navigating through the main tree. */ + @Override public byte[] getMainTreeKey() { return dupKey; } @@ -202,11 +210,13 @@ * @return true if this node is a duplicate-bearing node type, false * if otherwise. */ + @Override public boolean containsDuplicates() { return true; } /* Never true for a DIN. */ + @Override public boolean isDbRoot() { return false; } @@ -215,6 +225,7 @@ * Return the comparator function to be used for DINs. This is * the user defined duplicate comparison function, if defined. */ + @Override public final Comparator getKeyComparator() { return getDatabase().getDuplicateComparator(); } @@ -254,6 +265,7 @@ * are counted by their BIN/DIN parents, but INs are not counted by * their parents because they are resident on the IN list. */ + @Override protected long computeMemorySize() { long size = super.computeMemorySize(); if (dupCountLNRef != null) { @@ -275,6 +287,7 @@ IN.computeArraysOverhead(configManager); } + @Override protected long getMemoryOverhead(MemoryBudget mb) { return mb.getDINOverhead(); } @@ -286,6 +299,7 @@ * * No latching is performed. */ + @Override boolean matchLNByNodeId(TreeLocation location, long nodeId, CacheMode cacheMode) @@ -313,6 +327,7 @@ /* * DbStat support. */ + @Override void accumulateStats(TreeWalkerStatsAccumulator acc) { acc.processDIN(this, Long.valueOf(getNodeId()), getLevel()); } @@ -324,6 +339,7 @@ /** * @see Node#getLogType */ + @Override public LogEntryType getLogType() { return LogEntryType.LOG_DIN; } @@ -370,6 +386,7 @@ /** * @see IN#getLogSize */ + @Override public int getLogSize() { int size = super.getLogSize(); // ancestors size += LogUtils.getByteArrayLogSize(dupKey);// identifier key @@ -383,6 +400,7 @@ /** * @see IN#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { // ancestors @@ -403,6 +421,7 @@ /** * @see IN#readFromLog */ + @Override public void readFromLog(ByteBuffer itemBuffer, byte entryVersion) throws LogException { @@ -424,6 +443,7 @@ /** * DINS need to dump their dup key */ + @Override protected void dumpLogAdditional(StringBuffer sb) { super.dumpLogAdditional(sb); sb.append(Key.dumpString(dupKey, 0)); @@ -436,10 +456,12 @@ * Dumping */ + @Override public String beginTag() { return BEGIN_TAG; } + @Override public String endTag() { return END_TAG; } @@ -448,6 +470,7 @@ * For unit test support: * @return a string that dumps information about this DIN, without */ + @Override public String dumpString(int nSpaces, boolean dumpTags) { StringBuffer sb = new StringBuffer(); if (dumpTags) { @@ -478,10 +501,12 @@ return sb.toString(); } + @Override public String toString() { return dumpString(0, true); } + @Override public String shortClassName() { return "DIN"; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DupCountLN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DupCountLN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DupCountLN.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DupCountLN.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DupCountLN.java,v 1.40 2008/05/13 01:44:53 cwl Exp $ + * $Id: DupCountLN.java,v 1.40.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DuplicateEntryException.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DuplicateEntryException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/DuplicateEntryException.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/DuplicateEntryException.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DuplicateEntryException.java,v 1.15 2008/01/07 14:28:56 cwl Exp $ + * $Id: DuplicateEntryException.java,v 1.15.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/FileSummaryLN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/FileSummaryLN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/FileSummaryLN.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/FileSummaryLN.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileSummaryLN.java,v 1.33 2008/01/07 14:28:56 cwl Exp $ + * $Id: FileSummaryLN.java,v 1.34.2.3 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -76,7 +76,7 @@ private static final String BEGIN_TAG = ""; private static final String END_TAG = ""; - private MemoryBudget memBudget; + private int extraMarshaledMemorySize; private FileSummary baseSummary; private TrackedFileSummary trackedSummary; private PackedOffsets obsoleteOffsets; @@ -91,7 +91,6 @@ super(new byte[0], envImpl, // envImpl false); // replicate - memBudget = envImpl.getMemoryBudget(); assert baseSummary != null; this.baseSummary = baseSummary; obsoleteOffsets = new PackedOffsets(); @@ -238,13 +237,12 @@ * contains version 1 offsets that can be incorrect when RMW was used, and * if je.cleaner.rmwFix is enabled, discard the offsets. [#13158] */ + @Override public void postFetchInit(DatabaseImpl db, long sourceLsn) throws DatabaseException { super.postFetchInit(db, sourceLsn); - memBudget = db.getDbEnvironment().getMemoryBudget(); - if (entryVersion == 1 && db.getDbEnvironment().getUtilizationProfile().isRMWFixEnabled()) { obsoleteOffsets = new PackedOffsets(); @@ -255,18 +253,22 @@ * Dumping */ + @Override public String toString() { return dumpString(0, true); } + @Override public String beginTag() { return BEGIN_TAG; } + @Override public String endTag() { return END_TAG; } + @Override public String dumpString(int nSpaces, boolean dumpTags) { StringBuffer sb = new StringBuffer(); sb.append(super.dumpString(nSpaces, dumpTags)); @@ -282,6 +284,7 @@ * Dump additional fields. Done this way so the additional info can * be within the XML tags defining the dumped log entry. */ + @Override protected void dumpLogAdditional(StringBuffer sb, boolean verbose) { if (!isDeleted()) { baseSummary.dumpLog(sb, true); @@ -298,6 +301,7 @@ /** * Log type for transactional entries. */ + @Override protected LogEntryType getTransactionalLogType() { assert false : "Txnl access to UP db not allowed"; return LogEntryType.LOG_FILESUMMARYLN; @@ -306,6 +310,7 @@ /** * @see Node#getLogType */ + @Override public LogEntryType getLogType() { return LogEntryType.LOG_FILESUMMARYLN; } @@ -318,6 +323,7 @@ * * @see LN#getLogSize */ + @Override public int getLogSize() { int size = super.getLogSize(); if (!isDeleted()) { @@ -331,6 +337,7 @@ /** * @see LN#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { /* @@ -361,6 +368,7 @@ /** * @see LN#readFromLog */ + @Override public void readFromLog(ByteBuffer itemBuffer, byte entryVersion) throws LogException { @@ -391,13 +399,14 @@ * written to the log. */ private void getOffsets() { + assert !isDeleted(); if (needOffsets) { long[] offsets = trackedSummary.getObsoleteOffsets(); if (offsets != null) { int oldSize = obsoleteOffsets.getExtraMemorySize(); obsoleteOffsets.pack(offsets); int newSize = obsoleteOffsets.getExtraMemorySize(); - memBudget.updateTreeMemoryUsage(newSize - oldSize); + extraMarshaledMemorySize = newSize - oldSize; } needOffsets = false; } @@ -422,4 +431,30 @@ super.makeDeleted(); obsoleteOffsets = new PackedOffsets(); } + + /** + * Adds the extra memory used by obsoleteOffsets to the parent BIN memory + * size. Must be called after LN is inserted into the BIN and logged, + * while the cursor is still positioned on the inserted LN. The BIN must + * be latched. [#17462] + * + *

The obsoleteOffsets memory size is not intially budgeted in the usual + * way because PackedOffsets.pack (which changes the memory size) is called + * during marshalling (see getOffset). This amount is not counted in the + * parent IN size in the usual way, because LN logging / marshalling occurs + * after the LN is inserted in the BIN and its memory size has been counted + * (see Tree.insert).

+ * + *

Note that the tree memory usage cannot be updated directly in + * getOffsets because the tree memory usage must always be the sum of all + * IN sizes, and it is reset to this sum each checkpoint.

+ */ + public void addExtraMarshaledMemorySize(BIN parentBIN) { + if (extraMarshaledMemorySize != 0) { + assert trackedSummary != null; /* Must be set during the insert. */ + assert parentBIN.isLatchOwnerForWrite(); + parentBIN.updateMemorySize(0, extraMarshaledMemorySize); + extraMarshaledMemorySize = 0; + } + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Generation.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Generation.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Generation.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Generation.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Generation.java,v 1.14 2008/01/07 14:28:56 cwl Exp $ + * $Id: Generation.java,v 1.14.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/InconsistentNodeException.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/InconsistentNodeException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/InconsistentNodeException.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/InconsistentNodeException.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: InconsistentNodeException.java,v 1.16 2008/01/07 14:28:56 cwl Exp $ + * $Id: InconsistentNodeException.java,v 1.16.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INDeleteInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INDeleteInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INDeleteInfo.java 2008-01-17 17:22:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INDeleteInfo.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INDeleteInfo.java,v 1.40 2008/01/17 17:22:14 cwl Exp $ + * $Id: INDeleteInfo.java,v 1.40.2.3 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -24,6 +24,10 @@ /** * INDeleteInfo encapsulates the information logged about the removal of a * child from an IN during IN compression. + * + * As of JE 3.3.87, INDelete is no longer logged becaue the root compression + * feature has been disabled. However, INDelete must still be processed in log + * files created with 3.3.87 and earlier. [#17546] */ public class INDeleteInfo implements Loggable { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INDupDeleteInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INDupDeleteInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INDupDeleteInfo.java 2008-01-17 17:22:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INDupDeleteInfo.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INDupDeleteInfo.java,v 1.21 2008/01/17 17:22:14 cwl Exp $ + * $Id: INDupDeleteInfo.java,v 1.21.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/IN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/IN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/IN.java 2008-05-30 14:04:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/IN.java 2010-03-26 13:23:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: IN.java,v 1.344 2008/05/30 14:04:16 mark Exp $ + * $Id: IN.java,v 1.346.2.7 2010/03/26 13:23:55 mark Exp $ */ package com.sleepycat.je.tree; @@ -228,6 +228,7 @@ inMemorySize = computeMemorySize(); } + @Override public boolean equals(Object obj) { if (!(obj instanceof IN)) { return false; @@ -245,6 +246,7 @@ * different container in the future that does not re-hash the return * value, we should probably implement the Wang-Jenkins hash function here. */ + @Override public int hashCode() { return (int) ~getNodeId(); } @@ -287,6 +289,7 @@ /** * Initialize a node that has been read in from the log. */ + @Override public void postFetchInit(DatabaseImpl db, long sourceLsn) throws DatabaseException { @@ -389,6 +392,7 @@ /** * Release the latch on this node. */ + @Override public void releaseLatch() throws LatchNotHeldException { @@ -432,6 +436,13 @@ generation = Long.MAX_VALUE; break; + case MAKE_COLD: + case EVICT_LN: + if (isBottomMostNode()) { + generation = 0L; + } + break; + default: throw new RuntimeException("unknown cacheMode: " + cacheMode); } @@ -441,10 +452,19 @@ generation = newGeneration; } + @Override public int getLevel() { return level; } + /** + * @return true if this node cannot contain contain children INs, i.e., if + * this is a DBIN, or this is a BIN in a non-duplicates DB. + */ + boolean isBottomMostNode() { + return false; + } + protected int generateLevel(DatabaseId dbId, int newLevel) { if (dbId.equals(DbTree.ID_DB_ID)) { return newLevel | DBMAP_LEVEL; @@ -661,7 +681,7 @@ return setKeyAndPrefix(idx, keyVal); } - /* + /* * Set the key at idx and adjust the key prefix if necessary. Return true * if the prefixes and suffixes were adjusted to indicate that memory * recalculation can occur. @@ -747,7 +767,7 @@ return true; } - /* + /* * Computes a key prefix based on all the keys in 'this'. Return null if * the IN is empty or prefixing is not enabled or there is no common * prefix for the keys. @@ -1591,7 +1611,7 @@ public long getBudgetedMemorySize() { return inMemorySize - accumulatedDelta; } - + /** * Returns the treeAdmin memory in objects referenced by this IN. * Specifically, this refers to the DbFileSummaryMap held by @@ -1632,7 +1652,7 @@ * Count up the memory usage attributable to this node alone. LNs children * are counted by their BIN/DIN parents, but INs are not counted by their * parents because they are resident on the IN list. The identifierKey is - * "intentionally" not kept track of in the memory budget. + * "intentionally" not kept track of in the memory budget. */ protected long computeMemorySize() { MemoryBudget mb = databaseImpl.getDbEnvironment().getMemoryBudget(); @@ -2438,6 +2458,7 @@ * maxKey, if non-null specifies that all keys in this node must be less * than maxKey. */ + @Override public void verify(byte[] maxKey) throws DatabaseException { @@ -2577,7 +2598,7 @@ * Determine if 'this' is the parent of a child (targetNodeId). If not, * find a child of 'this' that may be the parent and return it. If there * are no possibilities, then return null. Note that the keys of the - * target are passed in as args to we don't have to latch the target to + * target are passed in as args so we don't have to latch the target to * look at them. Also, 'this' is latched upon entry. * * @param doFetch If true, fetch the child in the pursuit of this search. @@ -3163,8 +3184,9 @@ INLogContext context) throws DatabaseException { - item.oldLsn = (item.provisional == Provisional.YES) ? - DbLsn.NULL_LSN : lastFullVersion; + item.oldLsn = countObsoleteDuringLogging(item.provisional) ? + lastFullVersion : + DbLsn.NULL_LSN; item.entry = new INLogEntry(this); } @@ -3184,13 +3206,13 @@ INLogContext context) throws DatabaseException { - if (item.provisional == Provisional.YES) { + if (countObsoleteDuringLogging(item.provisional)) { + flushProvisionalObsolete(logManager); + } else { if (item.parent != null) { item.parent.trackProvisionalObsolete (this, lastFullVersion, DbLsn.NULL_LSN); } - } else { - flushProvisionalObsolete(logManager); } setLastFullLsn(item.newLsn); @@ -3198,6 +3220,24 @@ } /** + * Returns whether to count the prior version of an IN (as well as + * accumulated provisionally obsolete LSNs for child nodes) obsolete when + * logging the new version. + * + * True is returned if we are logging the IN non-provisionally, since the + * non-provisional version durably replaces the prior version and causes + * all provisional children to also become durable. + * + * True is also returned if the database is temporary. Since we never use a + * temporary DB past recovery, prior versions of an IN are never used. + * [#16928] + */ + private boolean countObsoleteDuringLogging(Provisional provisional) { + return provisional != Provisional.YES || + databaseImpl.isTemporary(); + } + + /** * Adds the given obsolete LSNs and any tracked obsolete LSNs for the given * child IN to this IN's tracking list. This method is called to track * obsolete LSNs when a child IN is logged provisionally. Such LSNs cannot @@ -3258,7 +3298,7 @@ if (provisionalObsolete != null) { int memDelta = provisionalObsolete.size() * - MemoryBudget.LONG_LIST_PER_ITEM_OVERHEAD; + MemoryBudget.LONG_LIST_PER_ITEM_OVERHEAD; logManager.countObsoleteINs(provisionalObsolete, getDatabase()); provisionalObsolete = null; @@ -3277,6 +3317,7 @@ /** * @see Loggable#getLogSize */ + @Override public int getLogSize() { int size = super.getLogSize(); // ancestors size += LogUtils.getByteArrayLogSize(identifierKey); // identifier key @@ -3305,6 +3346,7 @@ /** * @see Loggable#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { super.writeToLog(logBuffer); @@ -3374,6 +3416,7 @@ /** * @see Loggable#readFromLog */ + @Override public void readFromLog(ByteBuffer itemBuffer, byte entryVersion) throws LogException { @@ -3450,6 +3493,7 @@ /** * @see Loggable#dumpLog */ + @Override public void dumpLog(StringBuffer sb, boolean verbose) { sb.append(beginTag()); @@ -3540,6 +3584,7 @@ * For unit test support: * @return a string that dumps information about this IN, without */ + @Override public String dumpString(int nSpaces, boolean dumpTags) { StringBuffer sb = new StringBuffer(); if (dumpTags) { @@ -3636,6 +3681,7 @@ sb.append(isStatePendingDeleted(state)).append("\"/>"); } + @Override public String toString() { return dumpString(0, true); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INLogContext.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INLogContext.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INLogContext.java 2008-04-18 22:57:38.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INLogContext.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INLogContext.java,v 1.1 2008/04/18 22:57:37 mark Exp $ + * $Id: INLogContext.java,v 1.1.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INLogItem.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INLogItem.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/INLogItem.java 2008-04-18 22:57:38.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/INLogItem.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INLogItem.java,v 1.1 2008/04/18 22:57:37 mark Exp $ + * $Id: INLogItem.java,v 1.1.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Key.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Key.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Key.java 2008-05-19 17:52:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Key.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Key.java,v 1.70 2008/05/19 17:52:18 linda Exp $ + * $Id: Key.java,v 1.71.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -136,6 +136,7 @@ /** * Support Set of Key in BINReference. */ + @Override public boolean equals(Object o) { return (o instanceof Key) && (compareTo((Key)o) == 0); } @@ -143,6 +144,7 @@ /** * Support HashSet of Key in BINReference. */ + @Override public int hashCode() { int code = 0; for (int i = 0; i < key.length; i += 1) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/LN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/LN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/LN.java 2008-03-25 03:26:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/LN.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LN.java,v 1.151 2008/03/25 02:26:36 linda Exp $ + * $Id: LN.java,v 1.152.2.5 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -78,17 +78,18 @@ */ public LN(DatabaseEntry dbt, EnvironmentImpl envImpl, boolean replicated) { super(envImpl, replicated); - byte[] data = dbt.getData(); - if (data == null) { - this.data = null; + + byte[] dat = dbt.getData(); + if (dat == null) { + data = null; } else if (dbt.getPartial()) { - init(data, + init(dat, dbt.getOffset(), dbt.getPartialOffset() + dbt.getSize(), dbt.getPartialOffset(), dbt.getSize()); } else { - init(data, dbt.getOffset(), dbt.getSize()); + init(dat, dbt.getOffset(), dbt.getSize()); } setDirty(); } @@ -463,8 +464,9 @@ boolean logAbortKnownDeleted; Txn logTxn; if (locker != null && locker.isTransactional()) { - entryType = isDelDup ? LogEntryType.LOG_DEL_DUPLN_TRANSACTIONAL - : getTransactionalLogType(); + entryType = isDelDup ? + LogEntryType.LOG_DEL_DUPLN_TRANSACTIONAL : + getTransactionalLogType(); WriteLockInfo info = locker.getWriteLockInfo(getNodeId()); logAbortLsn = info.getAbortLsn(); logAbortKnownDeleted = info.getAbortKnownDeleted(); @@ -474,8 +476,7 @@ info.setAbortInfo(dbImpl, getLastLoggedSize()); } } else { - entryType = isDelDup ? LogEntryType.LOG_DEL_DUPLN - : getLogType(); + entryType = isDelDup ? LogEntryType.LOG_DEL_DUPLN : getLogType(); logAbortLsn = DbLsn.NULL_LSN; logAbortKnownDeleted = false; logTxn = null; @@ -507,16 +508,32 @@ long lsn = DbLsn.NULL_LSN; try { - lsn = env.getLogManager().log(logEntry, isProvisional, - backgroundIO, oldLsn, dbImpl, - repContext); + if (logTxn != null) { + + /* + * Writing an LN_TX entry requires looking at the Txn's + * lastLoggedLsn. The Txn may be used by multiple threads so + * ensure that the view we get is consistent. [#17204] + */ + synchronized (logTxn) { + lsn = env.getLogManager().log(logEntry, isProvisional, + backgroundIO, oldLsn, dbImpl, + repContext); + } + } else { + lsn = env.getLogManager().log(logEntry, isProvisional, + backgroundIO, oldLsn, dbImpl, + repContext); + } } catch (DatabaseException DE) { /* * If any exception happens during logging, then force this txn * to onlyAbortable. [#15768] */ - locker.setOnlyAbortable(); + if (locker != null) { + locker.setOnlyAbortable(); + } throw DE; } clearDirty(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/MapLN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/MapLN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/MapLN.java 2008-03-25 03:26:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/MapLN.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MapLN.java,v 1.86 2008/03/25 02:26:36 linda Exp $ + * $Id: MapLN.java,v 1.87.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -129,10 +129,12 @@ databaseImpl = new DatabaseImpl(); } + @Override public boolean isDeleted() { return deleted; } + @Override void makeDeleted() { deleted = true; @@ -206,6 +208,7 @@ /** * Initialize a node that has been faulted in from the log. */ + @Override public void postFetchInit(DatabaseImpl db, long sourceLsn) throws DatabaseException { @@ -234,18 +237,22 @@ * Dumping */ + @Override public String toString() { return dumpString(0, true); } + @Override public String beginTag() { return BEGIN_TAG; } + @Override public String endTag() { return END_TAG; } + @Override public String dumpString(int nSpaces, boolean dumpTags) { StringBuffer sb = new StringBuffer(); sb.append(super.dumpString(nSpaces, dumpTags)); @@ -265,6 +272,7 @@ /** * Log type for transactional entries. */ + @Override protected LogEntryType getTransactionalLogType() { return LogEntryType.LOG_MAPLN_TRANSACTIONAL; } @@ -272,6 +280,7 @@ /** * @see Node#getLogType */ + @Override public LogEntryType getLogType() { return LogEntryType.LOG_MAPLN; } @@ -279,6 +288,7 @@ /** * @see LN#getLogSize */ + @Override public int getLogSize() { return super.getLogSize() + databaseImpl.getLogSize() + @@ -288,6 +298,7 @@ /** * @see LN#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { /* Ask ancestors to write to log. */ super.writeToLog(logBuffer); @@ -299,6 +310,7 @@ /** * @see LN#readFromLog */ + @Override public void readFromLog(ByteBuffer itemBuffer, byte entryVersion) throws LogException { @@ -322,6 +334,7 @@ * Dump additional fields. Done this way so the additional info can be * within the XML tags defining the dumped log entry. */ + @Override protected void dumpLogAdditional(StringBuffer sb, boolean verbose) { databaseImpl.dumpLog(sb, true); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/NameLN.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/NameLN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/NameLN.java 2008-02-06 19:48:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/NameLN.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NameLN.java,v 1.28 2008/02/06 19:48:01 linda Exp $ + * $Id: NameLN.java,v 1.29.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -51,10 +51,12 @@ id = new DatabaseId(); } + @Override public boolean isDeleted() { return deleted; } + @Override void makeDeleted() { deleted = true; } @@ -71,18 +73,22 @@ * Dumping */ + @Override public String toString() { return dumpString(0, true); } + @Override public String beginTag() { return BEGIN_TAG; } + @Override public String endTag() { return END_TAG; } + @Override public String dumpString(int nSpaces, boolean dumpTags) { StringBuffer sb = new StringBuffer(); sb.append(super.dumpString(nSpaces, dumpTags)); @@ -105,6 +111,7 @@ /** * Log type for transactional entries. */ + @Override protected LogEntryType getTransactionalLogType() { return LogEntryType.LOG_NAMELN_TRANSACTIONAL; } @@ -112,6 +119,7 @@ /** * @see Node#getLogType */ + @Override public LogEntryType getLogType() { return LogEntryType.LOG_NAMELN; } @@ -119,6 +127,7 @@ /** * @see LN#getLogSize */ + @Override public int getLogSize() { return super.getLogSize() + // superclass @@ -129,6 +138,7 @@ /** * @see LN#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { /* Ask ancestors to write to log. */ super.writeToLog(logBuffer); // super class @@ -140,6 +150,7 @@ /** * @see LN#readFromLog */ + @Override public void readFromLog(ByteBuffer itemBuffer, byte entryVersion) throws LogException { @@ -176,6 +187,7 @@ * Dump additional fields. Done this way so the additional info can be * within the XML tags defining the dumped log entry. */ + @Override protected void dumpLogAdditional(StringBuffer sb, boolean verbose) { id.dumpLog(sb, true); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Node.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Node.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Node.java 2008-05-06 18:01:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Node.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Node.java,v 1.107 2008/05/06 18:01:34 linda Exp $ + * $Id: Node.java,v 1.108.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -171,6 +171,7 @@ /** * Default toString method at the root of the tree. */ + @Override public String toString() { return this.dumpString(0, true); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/NodeNotEmptyException.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/NodeNotEmptyException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/NodeNotEmptyException.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/NodeNotEmptyException.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NodeNotEmptyException.java,v 1.17 2008/01/07 14:28:56 cwl Exp $ + * $Id: NodeNotEmptyException.java,v 1.17.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/SearchResult.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/SearchResult.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/SearchResult.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/SearchResult.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SearchResult.java,v 1.16 2008/01/07 14:28:56 cwl Exp $: + * $Id: SearchResult.java,v 1.17.2.2 2010/01/04 15:30:36 cwl Exp $: */ package com.sleepycat.je.tree; @@ -31,6 +31,7 @@ childNotResident = false; } + @Override public String toString() { return "exactParentFound="+ exactParentFound + diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/SplitRequiredException.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/SplitRequiredException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/SplitRequiredException.java 2008-05-20 17:52:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/SplitRequiredException.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SplitRequiredException.java,v 1.8 2008/05/20 17:52:36 linda Exp $ + * $Id: SplitRequiredException.java,v 1.8.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/TrackingInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/TrackingInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/TrackingInfo.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/TrackingInfo.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TrackingInfo.java,v 1.14 2008/01/07 14:28:56 cwl Exp $ + * $Id: TrackingInfo.java,v 1.15.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -22,6 +22,7 @@ this.nodeId = nodeId; } + @Override public String toString() { return "lsn=" + DbLsn.getNoFormatString(lsn) + " node=" + nodeId; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Tree.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Tree.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/Tree.java 2008-05-30 14:04:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/Tree.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Tree.java,v 1.456 2008/05/30 14:04:16 mark Exp $ + * $Id: Tree.java,v 1.458.2.5 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -169,8 +169,24 @@ maxDupTreeEntriesPerNode = database.getNodeMaxDupTreeEntries(); DbConfigManager configManager = database.getDbEnvironment().getConfigManager(); - purgeRoot = configManager.getBoolean - (EnvironmentParams.COMPRESSOR_PURGE_ROOT); + + /* + * Root compression is no longer supported. Root compression has no + * impact on memory usage now that we evict the root IN. It reduces + * log space taken by INs for empty (but not removed) databases, yet + * requires logging an INDelete and MapLN; this provides very little + * benefit, if any. Because it requires extensive testing (which has + * not been done), this minor benefit is not worth the cost. And by + * removing it we no longer log INDelete, which reduces complexity + * going forward. + * + * In JE 3.3 we have made the minimal change (setting purgeRoot to + * false below) to disable this feature, while in 4.0 and later the + * supporting code will be removed. + * + * [#17546] + */ + purgeRoot = false; } /** @@ -243,14 +259,6 @@ super(target, key, lsn); } - /* Not used. */ - private RootChildReference(Node target, - byte[] key, - long lsn, - byte existingState) { - super(target, key, lsn, existingState); - } - /* Caller is responsible for releasing rootLatch. */ @Override public Node fetchTarget(DatabaseImpl database, IN in) @@ -891,10 +899,6 @@ * child. Used by the checkpointer to avoid conflicting with work done * by the evictor. * - * @param child The child node for which to find the parent. This node is - * latched by the caller and is released by this function before returning - * to the caller. - * * @return a SearchResult object. If the parent has been found, * result.foundExactMatch is true. If any parent, exact or potential has * been found, result.parent refers to that node. @@ -1695,6 +1699,7 @@ */ @SuppressWarnings("serial") private static class RelatchRequiredException extends DatabaseException { + @Override public synchronized Throwable fillInStackTrace() { return this; } @@ -3149,8 +3154,7 @@ int startingCount = (locker.createdNode(nodeId) || existingLNIsDeleted || - locker.getWriteLockInfo(nodeId).getAbortKnownDeleted()) ? - 0 : 1; + (locker.getWriteLockInfo(nodeId).getAbortKnownDeleted()) ? 0 : 1); DupCountLN dupCountLN = new DupCountLN(database.getDbEnvironment(), startingCount); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/tree/TreeLocation.java libdb-je-java-3.3.98/src/com/sleepycat/je/tree/TreeLocation.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/tree/TreeLocation.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/tree/TreeLocation.java 2010-01-04 15:30:36.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TreeLocation.java,v 1.16 2008/01/07 14:28:56 cwl Exp $ + * $Id: TreeLocation.java,v 1.17.2.2 2010/01/04 15:30:36 cwl Exp $ */ package com.sleepycat.je.tree; @@ -27,6 +27,7 @@ childLsn = DbLsn.NULL_LSN; } + @Override public String toString() { StringBuffer sb = new StringBuffer(" releaseAndFindNotifyTargets(long nodeId, Locker locker) + protected Set releaseAndFindNotifyTargets(long nodeId, + Locker locker) throws DatabaseException { - return null; + if (locker.isTransactional()) { + return superiorLockManager. + releaseAndFindNotifyTargets(nodeId, locker); + } else { + return null; + } } /** @@ -84,6 +115,12 @@ boolean demoteToRead) throws DatabaseException { + if (owningLocker.isTransactional()) { + superiorLockManager.transfer + (nodeId, owningLocker, destLocker, demoteToRead); + } else { + return; + } } /** @@ -94,6 +131,12 @@ Locker[] destLockers) throws DatabaseException { + if (owningLocker.isTransactional()) { + superiorLockManager.transferMultiple + (nodeId, owningLocker, destLockers); + } else { + return; + } } /** @@ -102,46 +145,56 @@ void demote(long nodeId, Locker locker) throws DatabaseException { + if (locker.isTransactional()) { + superiorLockManager.demote(nodeId, locker); + } else { + return; + } } /** * @see LockManager#isLocked */ - boolean isLocked(Long nodeId) { + boolean isLocked(Long nodeId) + throws DatabaseException { - return false; + return superiorLockManager.isLocked(nodeId); } /** * @see LockManager#isOwner */ - boolean isOwner(Long nodeId, Locker locker, LockType type) { + boolean isOwner(Long nodeId, Locker locker, LockType type) + throws DatabaseException { - return false; + return superiorLockManager.isOwner(nodeId, locker, type); } /** * @see LockManager#isWaiter */ - boolean isWaiter(Long nodeId, Locker locker) { + boolean isWaiter(Long nodeId, Locker locker) + throws DatabaseException { - return false; + return superiorLockManager.isWaiter(nodeId, locker); } /** * @see LockManager#nWaiters */ - int nWaiters(Long nodeId) { + int nWaiters(Long nodeId) + throws DatabaseException { - return 0; + return superiorLockManager.nWaiters(nodeId); } /** * @see LockManager#nOwners */ - int nOwners(Long nodeId) { + int nOwners(Long nodeId) + throws DatabaseException { - return 0; + return superiorLockManager.nOwners(nodeId); } /** @@ -150,7 +203,7 @@ Locker getWriteOwnerLocker(Long nodeId) throws DatabaseException { - return null; + return superiorLockManager.getWriteOwnerLocker(nodeId); } /** @@ -163,7 +216,12 @@ MemoryBudget mb) throws DatabaseException { - return true; + if (locker.isTransactional()) { + return superiorLockManager.validateOwnership + (nodeId, locker, type, flushFromWaiters, mb); + } else { + return true; + } } /** @@ -172,5 +230,6 @@ protected void dumpLockTable(LockStats stats) throws DatabaseException { + superiorLockManager.dumpLockTable(stats); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LatchedLockManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LatchedLockManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LatchedLockManager.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LatchedLockManager.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchedLockManager.java,v 1.20 2008/05/15 01:52:43 linda Exp $ + * $Id: LatchedLockManager.java,v 1.20.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockAttemptResult.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockAttemptResult.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockAttemptResult.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockAttemptResult.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockAttemptResult.java,v 1.2 2008/01/07 14:28:56 cwl Exp $ + * $Id: LockAttemptResult.java,v 1.2.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockConflict.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockConflict.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockConflict.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockConflict.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockConflict.java,v 1.7 2008/01/07 14:28:56 cwl Exp $ + * $Id: LockConflict.java,v 1.7.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockerFactory.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockerFactory.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockerFactory.java 2008-05-13 20:03:10.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockerFactory.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockerFactory.java,v 1.18 2008/05/13 20:03:10 sam Exp $ + * $Id: LockerFactory.java,v 1.18.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/Locker.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/Locker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/Locker.java 2008-05-22 20:25:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/Locker.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Locker.java,v 1.121 2008/05/22 20:25:35 cwl Exp $ + * $Id: Locker.java,v 1.122.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -801,6 +801,7 @@ /* * Helpers */ + @Override public String toString() { String className = getClass().getName(); className = className.substring(className.lastIndexOf('.') + 1); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockGrantType.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockGrantType.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockGrantType.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockGrantType.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockGrantType.java,v 1.20 2008/01/07 14:28:56 cwl Exp $ + * $Id: LockGrantType.java,v 1.21.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -37,6 +37,7 @@ this.name = name; } + @Override public String toString() { return name; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockImpl.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockImpl.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockImpl.java 2008-05-19 17:52:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockImpl.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockImpl.java,v 1.7 2008/05/19 17:52:19 linda Exp $ + * $Id: LockImpl.java,v 1.8.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -975,6 +975,7 @@ /** * Debug dumper. */ + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(" LockAddr:").append(System.identityHashCode(this)); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockInfo.java 2008-05-30 14:04:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockInfo.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockInfo.java,v 1.35 2008/05/30 14:04:17 mark Exp $ + * $Id: LockInfo.java,v 1.36.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -85,6 +85,7 @@ return lockType; } + @Override public Object clone() throws CloneNotSupportedException { @@ -98,6 +99,7 @@ System.out.println(this); } + @Override public String toString() { StringBuffer buf = new StringBuffer(500); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/Lock.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/Lock.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/Lock.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/Lock.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Lock.java,v 1.71 2008/05/15 01:52:43 linda Exp $ + * $Id: Lock.java,v 1.73.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockManager.java 2008-06-03 16:25:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockManager.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockManager.java,v 1.141 2008/06/03 16:25:43 cwl Exp $ + * $Id: LockManager.java,v 1.142.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -82,6 +82,12 @@ new RangeRestartException(); private static boolean lockTableDump = false; + /* + * @SuppressWarnings is used to stifle a type safety complaint about the + * assignment of lockTables = new Map[nLockTables]. There's no way to + * specify the type of the array. + */ + @SuppressWarnings("unchecked") public LockManager(EnvironmentImpl envImpl) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockResult.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockResult.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockResult.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockResult.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockResult.java,v 1.18 2008/01/07 14:28:56 cwl Exp $ + * $Id: LockResult.java,v 1.18.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockType.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockType.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockType.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockType.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockType.java,v 1.22 2008/01/07 14:28:56 cwl Exp $ + * $Id: LockType.java,v 1.23.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -199,6 +199,7 @@ return upgrade; } + @Override public String toString() { return name; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockUpgrade.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockUpgrade.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/LockUpgrade.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/LockUpgrade.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockUpgrade.java,v 1.7 2008/01/07 14:28:56 cwl Exp $ + * $Id: LockUpgrade.java,v 1.7.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/package.html libdb-je-java-3.3.98/src/com/sleepycat/je/txn/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/package.html 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/package.html 2010-01-04 15:30:38.000000000 +0000 @@ -5,10 +5,10 @@ See the file LICENSE for redistribution information. - Copyright (c) 2002,2008 Oracle. All rights reserved. + Copyright (c) 2002,2010 Oracle. All rights reserved. - $Id: package.html,v 1.8 2008/01/07 14:28:56 cwl Exp $ + $Id: package.html,v 1.8.2.2 2010/01/04 15:30:37 cwl Exp $ --> diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/PreparedTxn.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/PreparedTxn.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/PreparedTxn.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/PreparedTxn.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PreparedTxn.java,v 1.6 2008/01/07 14:28:56 cwl Exp $ + * $Id: PreparedTxn.java,v 1.6.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/ReadCommittedLocker.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/ReadCommittedLocker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/ReadCommittedLocker.java 2008-03-18 16:53:06.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/ReadCommittedLocker.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReadCommittedLocker.java,v 1.13 2008/03/18 15:53:05 mark Exp $ + * $Id: ReadCommittedLocker.java,v 1.13.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/SyncedLockManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/SyncedLockManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/SyncedLockManager.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/SyncedLockManager.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SyncedLockManager.java,v 1.18 2008/05/15 01:52:43 linda Exp $ + * $Id: SyncedLockManager.java,v 1.18.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/ThinLockImpl.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/ThinLockImpl.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/ThinLockImpl.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/ThinLockImpl.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ThinLockImpl.java,v 1.5 2008/05/15 01:52:43 linda Exp $ + * $Id: ThinLockImpl.java,v 1.6.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -197,6 +197,7 @@ return true; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/ThreadLocker.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/ThreadLocker.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/ThreadLocker.java 2008-03-18 16:53:06.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/ThreadLocker.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ThreadLocker.java,v 1.20 2008/03/18 15:53:05 mark Exp $ + * $Id: ThreadLocker.java,v 1.20.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnAbort.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnAbort.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnAbort.java 2008-05-13 01:57:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnAbort.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnAbort.java,v 1.25 2008/05/13 01:57:01 linda Exp $ + * $Id: TxnAbort.java,v 1.26.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -41,6 +41,9 @@ if (!(other instanceof TxnAbort)) return false; - return (id == ((TxnAbort) other).id); + TxnAbort otherAbort = (TxnAbort) other; + + return ((id == otherAbort.id) && + (repMasterNodeId == otherAbort.repMasterNodeId)); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnCommit.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnCommit.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnCommit.java 2008-05-13 01:57:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnCommit.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnCommit.java,v 1.27 2008/05/13 01:57:01 linda Exp $ + * $Id: TxnCommit.java,v 1.28.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -41,6 +41,9 @@ if (!(other instanceof TxnCommit)) return false; - return (id == ((TxnCommit) other).id); + TxnCommit otherCommit = (TxnCommit) other; + + return ((id == otherCommit.id) && + (repMasterNodeId == otherCommit.repMasterNodeId)); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnEnd.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnEnd.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnEnd.java 2008-05-21 18:50:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnEnd.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnEnd.java,v 1.40 2008/05/21 18:50:02 sam Exp $ + * $Id: TxnEnd.java,v 1.41.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -25,7 +25,7 @@ private long lastLsn; /* For replication - master node which wrote this record. */ - private int repMasterNodeId; + int repMasterNodeId; TxnEnd(long id, long lastLsn, int repMasterNodeId) { this.id = id; @@ -56,7 +56,7 @@ return lastLsn; } - int getMasterNodeId() { + public int getMasterNodeId() { return repMasterNodeId; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/Txn.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/Txn.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/Txn.java 2008-05-28 15:40:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/Txn.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Txn.java,v 1.194 2008/05/28 15:39:59 sam Exp $ + * $Id: Txn.java,v 1.198.2.5 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -80,7 +80,7 @@ * write lock collections is done by synchronizing on the txn. */ private Set readLocks; // Set (nodeIds) - private Map writeInfo; // key=nodeid + private Map writeInfo; // key=nodeid private final int READ_LOCK_OVERHEAD = MemoryBudget.HASHSET_ENTRY_OVERHEAD; private final int WRITE_LOCK_OVERHEAD = @@ -101,7 +101,7 @@ * the mapping tree. (The normal code paths want to take locks, add * cursors, etc. */ - protected Map undoDatabases; + protected Map undoDatabases; /* Last LSN logged for this transaction. */ protected long lastLoggedLsn = DbLsn.NULL_LSN; @@ -110,7 +110,7 @@ * First LSN logged for this transaction -- used for keeping track of the * first active LSN point, for checkpointing. This field is not persistent. */ - private long firstLoggedLsn = DbLsn.NULL_LSN; + protected long firstLoggedLsn = DbLsn.NULL_LSN; /* The configured durability at the time the transaction was created. */ private Durability defaultDurability; @@ -279,11 +279,11 @@ Txn ret = null; try { ret = envImpl.isReplicated() ? - envImpl.getReplicator().createRepTxn(envImpl, - config, - noAPIReadLock, - 0 /* mandatedId */) : - new Txn(envImpl, config, noAPIReadLock, 0 /* mandatedId */); + envImpl.getReplicator().createRepTxn(envImpl, + config, + noAPIReadLock, + 0 /* mandatedId */) : + new Txn(envImpl, config, noAPIReadLock, 0 /* mandatedId */); ret.isAutoCommit = true; ret.setRepContext(repContext); ret.initApiReadLock(); @@ -541,10 +541,10 @@ /* Transfer handle locks to their owning handles. */ if (handleLockToHandleMap != null) { - Iterator>> handleLockIter = + Iterator>> handleLockIter = handleLockToHandleMap.entrySet().iterator(); while (handleLockIter.hasNext()) { - Map.Entry> entry = + Map.Entry> entry = handleLockIter.next(); Long nodeId = entry.getKey(); if (writeInfo != null) { @@ -557,8 +557,8 @@ transferredWriteLockInfo.add(info); } } - transferHandleLockToHandleSet - (nodeId, entry.getValue()); + transferHandleLockToHandleSet(nodeId, + entry.getValue()); } } @@ -569,33 +569,50 @@ int numReadLocks = clearReadLocks(); /* - * Log the commit if we ever held any write locks. Note that - * with dbhandle write locks, we may have held the write lock - * but then had it transferred away. + * Log the commit if we ever logged any modifications for this + * txn. Refraining from logging empty commits is more efficient + * and makes for fewer edge cases for HA. Note that this is not + * the same as the question of whether we have held any write + * locks. Various scenarios, like RMW txns and + * Cursor.putNoOverwrite can take write locks without having + * actually made any modifications. + * + * If we have outstanding write locks, we must release them + * even if we haven't logged a commit. With dbhandle write + * locks, we may have held the write lock but then had it + * transferred away. */ int numWriteLocks = 0; if (writeInfo != null) { numWriteLocks = writeInfo.size(); - try { - preLogCommitHook(); - } catch (DatabaseException preCommitException) { - repAbortException = preCommitException; - throw preCommitException; - } + /* + * If nothing was written to log for this txn, no need to + * log a commit. + */ + if (firstLoggedLsn != DbLsn.NULL_LSN) { - try { - commitLsn = logCommitEntry(durability.getLocalSync()); - } catch (Exception e) { - /* Cleanup and propagate the exception. */ - postLogAbortHook(); - throw e; - } + try { + preLogCommitHook(); + } catch (DatabaseException preCommitException) { + repAbortException = preCommitException; + throw preCommitException; + } - try { - postLogCommitHook(); - } catch (DatabaseException postCommitException) { - repNoAbortException = postCommitException; + try { + commitLsn = + logCommitEntry(durability.getLocalSync()); + } catch (Exception e) { + /* Cleanup and propagate the exception. */ + postLogAbortHook(); + throw e; + } + + try { + postLogCommitHook(); + } catch (DatabaseException postCommitException) { + repNoAbortException = postCommitException; + } } /* @@ -613,10 +630,10 @@ Set alreadyCountedLsnSet = new HashSet(); /* Release all write locks, clear lock collection. */ - Iterator> iter = + Iterator> iter = writeInfo.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = iter.next(); + Map.Entry entry = iter.next(); Long nodeId = entry.getKey(); lockManager.release(nodeId, this); /* Count obsolete LSNs for released write locks. */ @@ -743,7 +760,7 @@ SingleItemEntry commitEntry = new SingleItemEntry(LogEntryType.LOG_TXN_COMMIT, new TxnCommit(id, lastLoggedLsn, - 0 /* masterNodeId */)); + getReplicatorNodeId())); switch (flushSyncBehavior) { @@ -756,6 +773,7 @@ return logManager.logForceFlush(commitEntry, false, // fsyncRequired repContext); + default: return logManager.log(commitEntry, repContext); } @@ -810,8 +828,6 @@ throws DatabaseException { try { - int numReadLocks; - int numWriteLocks; long abortLsn; synchronized (this) { @@ -825,7 +841,7 @@ SingleItemEntry abortEntry = new SingleItemEntry (LogEntryType.LOG_TXN_ABORT, new TxnAbort(id, lastLoggedLsn, - 0 /* masterNodeId */)); + getReplicatorNodeId())); if (forceFlush) { abortLsn = envImpl.getLogManager(). logForceFlush(abortEntry, @@ -841,29 +857,6 @@ /* Undo the changes. */ undo(); - - /* - * Release all read locks after the undo (since the undo - * may need to read in mapLNs). - */ - numReadLocks = (readLocks == null) ? 0 : clearReadLocks(); - - /* - * Set database state for deletes before releasing any - * write locks. - */ - setDeletedDatabaseState(false); - - /* Throw away write lock collection. */ - numWriteLocks = - (writeInfo == null) ? 0 : clearWriteLocks(); - - /* - * Let the delete related info (binreferences and dbs) get - * gc'ed. Don't explicitly iterate and clear -- that's far - * less efficient, gives GC wrong input. - */ - deleteInfo = null; } } @@ -879,8 +872,6 @@ Tracer.trace(Level.FINE, envImpl, "Abort:id = " + id + - " numWriteLocks= " + numWriteLocks + - " numReadLocks= " + numReadLocks + " openCursors= " + openCursors); if (openCursors) { throw new DatabaseException @@ -912,7 +903,7 @@ /** * Rollback the changes to this txn's write locked nodes. */ - private void undo() + protected void undo() throws DatabaseException { Long nodeId = null; @@ -974,6 +965,29 @@ DbLsn.getNoFormatString(undoLsn), e); throw e; } + + /* + * Release all read locks after the undo (since the undo may need to + * read in mapLNs). + */ + if (readLocks != null) { + clearReadLocks(); + } + + /* Set database state for deletes before releasing any write locks. */ + setDeletedDatabaseState(false); + + /* Throw away write lock collection. */ + if (writeInfo != null) { + clearWriteLocks(); + } + + /* + * Let the delete related info (binreferences and dbs) get gc'ed. Don't + * explicitly iterate and clear -- that's far less efficient, gives GC + * wrong input. + */ + deleteInfo = null; } private int clearWriteLocks() @@ -981,10 +995,10 @@ int numWriteLocks = writeInfo.size(); /* Release all write locks, clear lock collection. */ - Iterator> iter = + Iterator> iter = writeInfo.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = iter.next(); + Map.Entry entry = iter.next(); Long nodeId = entry.getKey(); lockManager.release(nodeId, this); } @@ -1018,11 +1032,11 @@ public void addLogInfo(long lastLsn) throws DatabaseException { - /* Save the last LSN for maintaining the transaction LSN chain. */ - lastLoggedLsn = lastLsn; - - /* Save handle to LSN for aborts. */ synchronized (this) { + /* Save the last LSN for maintaining the transaction LSN chain. */ + lastLoggedLsn = lastLsn; + + /* Save handle to LSN for aborts. */ /* * If this is the first LSN, save it for calculating the first LSN @@ -1101,7 +1115,7 @@ * that latch, needs to synchronize on individual txns, so we must avoid a * latching hiearchy conflict. */ - private void cleanupDatabaseImpls(boolean isCommit) + protected void cleanupDatabaseImpls(boolean isCommit) throws DatabaseException { if (deletedDatabases != null) { @@ -1136,8 +1150,8 @@ int delta = 0; if (type.isWriteLock()) { if (writeInfo == null) { - writeInfo = new HashMap(); - undoDatabases = new HashMap(); + writeInfo = new HashMap(); + undoDatabases = new HashMap(); delta += MemoryBudget.TWOHASHMAPS_OVERHEAD; } @@ -1278,14 +1292,18 @@ public WriteLockInfo getWriteLockInfo(long nodeId) throws DatabaseException { - WriteLockInfo info = WriteLockInfo.basicWriteLockInfo; + WriteLockInfo wli = null; synchronized (this) { if (writeInfo != null) { - info = writeInfo.get(nodeId); + wli = writeInfo.get(nodeId); } } - return info; + if (wli == null) { + throw new UnsupportedOperationException + ("writeInfo is null in Txn.getWriteLockInfo"); + } + return wli; } /** @@ -1614,6 +1632,15 @@ close(); } + public boolean isClosed() { + return ((txnState & CLOSED) != 0); + } + + /* Non replicated txns don't use a node id. */ + protected int getReplicatorNodeId() { + return 0; + } + /* * Log support */ diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnManager.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnManager.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnManager.java 2008-05-15 09:44:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnManager.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnManager.java,v 1.81 2008/05/15 09:44:34 chao Exp $ + * $Id: TxnManager.java,v 1.81.2.4 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -14,6 +14,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; import javax.transaction.xa.Xid; @@ -74,17 +75,17 @@ if (EnvironmentImpl.getFairLatches()) { lockManager = new LatchedLockManager(envImpl); } else { - if (envImpl.isNoLocking()) { - lockManager = new DummyLockManager(envImpl); - } else { - lockManager = new SyncedLockManager(envImpl); - } + lockManager = new SyncedLockManager(envImpl); + } + + if (envImpl.isNoLocking()) { + lockManager = new DummyLockManager(envImpl, lockManager); } this.envImpl = envImpl; allTxns = new HashSet(); allXATxns = Collections.synchronizedMap(new HashMap()); - thread2Txn = Collections.synchronizedMap(new HashMap()); + thread2Txn = new ConcurrentHashMap(); numBegins = 0; numCommits = 0; @@ -237,7 +238,7 @@ /** * Called when XATransaction is prepared. */ - public void notePrepare() { + public void notePrepare() { numXAPrepares++; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnPrepare.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnPrepare.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/TxnPrepare.java 2008-05-13 01:53:34.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/TxnPrepare.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnPrepare.java,v 1.16 2008/05/13 01:53:34 linda Exp $ + * $Id: TxnPrepare.java,v 1.17.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; @@ -50,6 +50,7 @@ /** * @see Loggable#getLogSize */ + @Override public int getLogSize() { return LogUtils.getPackedLongLogSize(id) + LogUtils.getTimestampLogSize(time) + @@ -59,6 +60,7 @@ /** * @see Loggable#writeToLog */ + @Override public void writeToLog(ByteBuffer logBuffer) { LogUtils.writePackedLong(logBuffer, id); LogUtils.writeTimestamp(logBuffer, time); @@ -68,6 +70,7 @@ /** * @see Loggable#readFromLog */ + @Override public void readFromLog(ByteBuffer logBuffer, byte entryVersion) { boolean unpacked = (entryVersion < 6); id = LogUtils.readLong(logBuffer, unpacked); @@ -78,6 +81,7 @@ /** * @see Loggable#dumpLog */ + @Override public void dumpLog(StringBuffer sb, boolean verbose) { sb.append("<").append(getTagName()); sb.append(" id=\"").append(id); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/txn/WriteLockInfo.java libdb-je-java-3.3.98/src/com/sleepycat/je/txn/WriteLockInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/txn/WriteLockInfo.java 2008-01-07 14:28:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/txn/WriteLockInfo.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: WriteLockInfo.java,v 1.19 2008/01/07 14:28:56 cwl Exp $ + * $Id: WriteLockInfo.java,v 1.19.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbBackup.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbBackup.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbBackup.java 2008-01-24 14:59:30.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbBackup.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbBackup.java,v 1.14 2008/01/24 14:59:29 linda Exp $ + * $Id: DbBackup.java,v 1.15.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; @@ -15,7 +15,6 @@ import com.sleepycat.je.log.FileManager; import com.sleepycat.je.utilint.DbLsn; - /** * DbBackup is a helper class for stopping and restarting JE background * activity in an open environment in order to simplify backup operations. It diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbDump.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbDump.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbDump.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbDump.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbDump.java,v 1.55 2008/05/15 01:52:43 linda Exp $ + * $Id: DbDump.java,v 1.56.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; @@ -28,7 +28,6 @@ import com.sleepycat.je.LockMode; import com.sleepycat.je.OperationStatus; import com.sleepycat.je.config.EnvironmentParams; -import com.sleepycat.je.util.DbScavenger; import com.sleepycat.je.utilint.CmdUtil; import com.sleepycat.je.utilint.Tracer; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbLoad.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbLoad.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbLoad.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbLoad.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbLoad.java,v 1.52 2008/05/13 01:44:54 cwl Exp $ + * $Id: DbLoad.java,v 1.52.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbPrintLog.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbPrintLog.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbPrintLog.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbPrintLog.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbPrintLog.java,v 1.46 2008/01/07 14:28:57 cwl Exp $ + * $Id: DbPrintLog.java,v 1.46.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbRecover.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbRecover.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbRecover.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbRecover.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbRecover.java,v 1.17 2008/01/07 14:28:57 cwl Exp $ + * $Id: DbRecover.java,v 1.17.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbRunAction.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbRunAction.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbRunAction.java 2008-05-30 14:04:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbRunAction.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbRunAction.java,v 1.45 2008/05/30 14:04:17 mark Exp $ + * $Id: DbRunAction.java,v 1.46.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; @@ -364,6 +364,7 @@ this.env = env; } + @Override public void run() { StatsConfig clearConfig = new StatsConfig(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbScavenger.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbScavenger.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbScavenger.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbScavenger.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbScavenger.java,v 1.23 2008/05/15 01:52:43 linda Exp $ + * $Id: DbScavenger.java,v 1.24.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; @@ -126,6 +126,7 @@ /** * Start the scavenger run. */ + @Override public void dump() throws IOException, DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbSpace.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbSpace.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbSpace.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbSpace.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbSpace.java,v 1.32 2008/05/15 01:52:43 linda Exp $ + * $Id: DbSpace.java,v 1.32.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbStat.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbStat.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbStat.java 2008-05-13 20:33:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbStat.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbStat.java,v 1.27 2008/05/13 20:33:43 linda Exp $ + * $Id: DbStat.java,v 1.27.2.2 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbVerify.java libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbVerify.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/DbVerify.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/DbVerify.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbVerify.java,v 1.50 2008/05/15 01:52:43 linda Exp $ + * $Id: DbVerify.java,v 1.50.2.4 2010/01/04 15:30:37 cwl Exp $ */ package com.sleepycat.je.util; @@ -315,7 +315,7 @@ } if (doClose) { - closeEnv(); + closeEnv(); } } catch (DatabaseException DE) { ret = false; @@ -345,39 +345,44 @@ out.println("Verifying database " + name); } - /* - * First check the tree. Use DatabaseImpl.verify so we can get a status - * return. - */ - if (verifyConfig.getPrintInfo()) { - out.println("Checking tree for " + name); - } - DatabaseStats stats = dbImpl.getEmptyStats(); - status = dbImpl.verify(verifyConfig, stats); - if (verifyConfig.getPrintInfo()) { + if (checkLsns) { + /* Check the obsolete lsns */ + if (verifyConfig.getPrintInfo()) { + out.println("Checking obsolete offsets for " + name); + } + try { + VerifyUtils.checkLsns(dbImpl, out); + } catch (DatabaseException e) { + if (verifyConfig.getPrintInfo()) { + out.println("Problem from checkLsns:" + e); + } + status = false; + } + } else { /* - * Intentionally use print, not println, because stats.toString() - * puts in a newline too. + * Check the tree. Use DatabaseImpl.verify so we can get a status + * return. */ - out.print(stats); - } - - /* Then check the obsolete lsns */ - if (verifyConfig.getPrintInfo()) { - out.println("Checking obsolete offsets for " + name); - } - try { - VerifyUtils.checkLsns(dbImpl, out); - } catch (DatabaseException e) { if (verifyConfig.getPrintInfo()) { - out.println("Problem from checkLsns:" + e); + out.println("Checking tree for " + name); + } + DatabaseStats stats = dbImpl.getEmptyStats(); + status = dbImpl.verify(verifyConfig, stats); + if (verifyConfig.getPrintInfo()) { + + /* + * Intentionally use print, not println, because + * stats.toString() puts in a newline too. + */ + out.print(stats); } - status = false; } + if (verifyConfig.getPrintInfo()) { out.println(); } + return status; } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/util/package.html libdb-je-java-3.3.98/src/com/sleepycat/je/util/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/je/util/package.html 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/util/package.html 2010-01-04 15:30:38.000000000 +0000 @@ -5,9 +5,9 @@ See the file LICENSE for redistribution information. - Copyright (c) 2002,2008 Oracle. All rights reserved. + Copyright (c) 2002,2010 Oracle. All rights reserved. - $Id: package.html,v 1.13 2008/01/07 14:28:57 cwl Exp $ + $Id: package.html,v 1.13.2.2 2010/01/04 15:30:37 cwl Exp $ --> diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/Adler32.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/Adler32.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/Adler32.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/Adler32.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Adler32.java,v 1.14 2008/01/07 14:28:57 cwl Exp $ + * $Id: Adler32.java,v 1.16.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -61,6 +61,7 @@ this.adler32ChunkSize = adler32ChunkSize; } + @Override public void update(byte[] b, int off, int len) { if (len < adler32ChunkSize) { super.update(b, off, len); @@ -79,8 +80,7 @@ } public static Checksum makeChecksum() { - if (!EnvironmentImpl.IS_DALVIK && - EnvironmentImpl.USE_JAVA5_ADLER32) { + if (EnvironmentImpl.USE_JAVA5_ADLER32) { int adler32ChunkSize = EnvironmentImpl.getAdler32ChunkSize(); if (adler32ChunkSize > 0) { return new ChunkingAdler32(adler32ChunkSize); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/BitMap.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/BitMap.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/BitMap.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/BitMap.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BitMap.java,v 1.10 2008/05/15 01:52:44 linda Exp $ + * $Id: BitMap.java,v 1.10.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/CmdUtil.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/CmdUtil.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/CmdUtil.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/CmdUtil.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CmdUtil.java,v 1.28 2008/05/15 01:52:44 linda Exp $ + * $Id: CmdUtil.java,v 1.28.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DaemonRunner.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DaemonRunner.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DaemonRunner.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DaemonRunner.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DaemonRunner.java,v 1.8 2008/01/07 14:28:57 cwl Exp $ + * $Id: DaemonRunner.java,v 1.8.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DaemonThread.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DaemonThread.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DaemonThread.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DaemonThread.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DaemonThread.java,v 1.63 2008/05/13 01:44:54 cwl Exp $ + * $Id: DaemonThread.java,v 1.64.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -111,6 +111,7 @@ } } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(""); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DatabaseUtil.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DatabaseUtil.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DatabaseUtil.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DatabaseUtil.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseUtil.java,v 1.4 2008/01/07 14:28:57 cwl Exp $ + * $Id: DatabaseUtil.java,v 1.4.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DbLsn.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DbLsn.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/DbLsn.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/DbLsn.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbLsn.java,v 1.56 2008/05/13 01:44:54 cwl Exp $ + * $Id: DbLsn.java,v 1.56.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/EventTrace.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/EventTrace.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/EventTrace.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/EventTrace.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EventTrace.java,v 1.15 2008/01/07 14:28:57 cwl Exp $ + * $Id: EventTrace.java,v 1.16.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -36,6 +36,7 @@ comment = null; } + @Override public String toString() { return comment; } @@ -99,6 +100,7 @@ event = new Exception(); } + @Override public String toString() { return Tracer.getStackTrace(event); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/FileMapper.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/FileMapper.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/FileMapper.java 2008-05-20 03:27:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/FileMapper.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileMapper.java,v 1.8 2008/05/20 03:27:36 linda Exp $ + * $Id: FileMapper.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -20,6 +20,7 @@ import com.sleepycat.je.DatabaseEntry; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.OperationStatus; +import com.sleepycat.je.log.LogEntryType; /** * A FileMapper instance represents the VLSN->LSN mappings for a single log @@ -45,6 +46,14 @@ private VLSN lastSyncVLSN; /* + * The last VLSN in this file which is a replicated commit record. Akin + * to lastSyncVLSN, but used specifically to determine if a syncup is + * rolling back past a committed txn, and therefore whether the syncup + * needs to be a hard recovery, or can just be a soft partial rollback. + */ + private VLSN lastCommitVLSN; + + /* * The file offset is really an unsigned int on disk, but must be * represented as a long in Java. */ @@ -60,6 +69,7 @@ this.fileNumber = fileNumber; this.vlsnToFileOffsetMap = new HashMap(); lastSyncVLSN = VLSN.NULL_VLSN; + lastCommitVLSN = VLSN.NULL_VLSN; } /* For reading from disk */ @@ -78,6 +88,10 @@ return lastSyncVLSN; } + public VLSN getLastCommitVLSN() { + return lastCommitVLSN; + } + public void writeToDatabase(Database fileMapperDb) throws DatabaseException { @@ -111,24 +125,33 @@ } /** Record the LSN location for this VLSN. */ - public void putLSN(long vlsn, long lsn, boolean isSyncPoint) { + public void putLSN(long vlsn, + long lsn, + LogEntryType entryType) { assert DbLsn.getFileNumber(lsn) == fileNumber: "unexpected lsn file num=" + DbLsn.getFileNumber(lsn) + " while file mapper file number=" + fileNumber; vlsnToFileOffsetMap.put(vlsn, DbLsn.getFileOffset(lsn)); - if (isSyncPoint) { - + if (entryType.isSyncPoint()) { VLSN thisVLSN = new VLSN(vlsn); if (lastSyncVLSN.compareTo(thisVLSN) < 0) { lastSyncVLSN = thisVLSN; } } + + if (LogEntryType.LOG_TXN_COMMIT.equals(entryType)) { + VLSN thisVLSN = new VLSN(vlsn); + if (lastCommitVLSN.compareTo(thisVLSN) < 0) { + lastCommitVLSN = thisVLSN; + } + } + dirty = true; } - /* + /** * Put all the VLSN->LSN mappings in the file mapper parameter into this * one. */ @@ -141,6 +164,10 @@ lastSyncVLSN = other.lastSyncVLSN; } + if (lastCommitVLSN.compareTo(other.lastCommitVLSN) < 0) { + lastCommitVLSN = other.lastCommitVLSN; + } + dirty = true; } @@ -169,7 +196,8 @@ public String toString() { StringBuilder sb = new StringBuilder(""); return sb.toString(); @@ -180,11 +208,13 @@ * Doesn't persist the file number, because that's the key of the database. * TODO: use packed numbers for the map in HA release. */ - private static class FileMapperBinding extends TupleBinding { + private static class FileMapperBinding extends TupleBinding { - public Object entryToObject(TupleInput ti) { + public FileMapper entryToObject(TupleInput ti) { FileMapper mapper = new FileMapper(); mapper.lastSyncVLSN = new VLSN(ti.readPackedLong()); + mapper.lastCommitVLSN = new VLSN(ti.readPackedLong()); + mapper.vlsnToFileOffsetMap = new HashMap(); int nEntries = ti.readInt(); for (int i = 0; i < nEntries; i++) { @@ -195,9 +225,10 @@ return mapper; } - public void objectToEntry(Object object, TupleOutput to) { - FileMapper mapper = (FileMapper) object; + public void objectToEntry(FileMapper mapper, TupleOutput to) { to.writePackedLong(mapper.lastSyncVLSN.getSequence()); + to.writePackedLong(mapper.lastCommitVLSN.getSequence()); + int nEntries = mapper.vlsnToFileOffsetMap.size(); to.writeInt(nEntries); for (Map.Entry entry : diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/HexFormatter.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/HexFormatter.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/HexFormatter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/HexFormatter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: HexFormatter.java,v 1.13 2008/01/07 14:28:57 cwl Exp $ + * $Id: HexFormatter.java,v 1.13.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/InternalException.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/InternalException.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/InternalException.java 2008-05-20 17:52:38.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/InternalException.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: InternalException.java,v 1.19 2008/05/20 17:52:37 linda Exp $ + * $Id: InternalException.java,v 1.19.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/JarMain.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/JarMain.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/JarMain.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/JarMain.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JarMain.java,v 1.7 2008/05/15 01:52:44 linda Exp $ + * $Id: JarMain.java,v 1.7.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/PropUtil.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/PropUtil.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/PropUtil.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/PropUtil.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PropUtil.java,v 1.25 2008/01/07 14:28:57 cwl Exp $ + * $Id: PropUtil.java,v 1.26.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -38,7 +38,8 @@ * @throws DatabaseException if the property bag contains * a property not specified in the set of allowed properties. */ - public static Properties validateProps(Properties props, + @SuppressWarnings("unchecked") + public static Properties validateProps(Properties props, Set allowedProps, String apiMethod) throws DatabaseException { @@ -60,7 +61,8 @@ /** * @throws DatabaseException if the property is not valid. */ - public static void validateProp(String propName, + @SuppressWarnings("unchecked") + public static void validateProp(String propName, Set allowedProps, String apiMethod) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TestHookExecute.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TestHookExecute.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TestHookExecute.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TestHookExecute.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestHookExecute.java,v 1.7 2008/01/07 14:28:57 cwl Exp $ + * $Id: TestHookExecute.java,v 1.7.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TestHook.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TestHook.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TestHook.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TestHook.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestHook.java,v 1.11 2008/01/07 14:28:57 cwl Exp $ + * $Id: TestHook.java,v 1.11.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TinyHashSet.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TinyHashSet.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TinyHashSet.java 2008-05-15 01:52:44.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TinyHashSet.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TinyHashSet.java,v 1.9 2008/05/15 01:52:44 linda Exp $ + * $Id: TinyHashSet.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TracerFormatter.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TracerFormatter.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/TracerFormatter.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/TracerFormatter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TracerFormatter.java,v 1.5 2008/05/13 01:44:54 cwl Exp $ + * $Id: TracerFormatter.java,v 1.5.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/Tracer.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/Tracer.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/Tracer.java 2008-01-17 17:22:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/Tracer.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Tracer.java,v 1.52 2008/01/17 17:22:15 cwl Exp $ + * $Id: Tracer.java,v 1.53.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -212,6 +212,7 @@ return msg.equals(((Tracer) other).msg); } + @Override public String toString() { return (time + "/" + msg); } @@ -223,6 +224,7 @@ /** * Just in case it's ever used as a hash key. */ + @Override public int hashCode() { return toString().hashCode(); } @@ -230,6 +232,7 @@ /** * Override Object.equals */ + @Override public boolean equals(Object obj) { /* Same instance? */ if (this == obj) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/VLSN.java libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/VLSN.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/utilint/VLSN.java 2008-05-13 01:44:54.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/utilint/VLSN.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: VLSN.java,v 1.22 2008/05/13 01:44:54 cwl Exp $ + * $Id: VLSN.java,v 1.23.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.je.utilint; @@ -37,6 +37,7 @@ public VLSN() { } + @Override public boolean equals(Object obj) { if (obj == null) { return false; @@ -50,6 +51,7 @@ return (otherVLSN.sequence == sequence); } + @Override public int hashCode() { return Long.valueOf(sequence).hashCode(); } @@ -173,6 +175,7 @@ return sequence == ((VLSN) other).sequence; } + @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(sequence); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/VerifyConfig.java libdb-je-java-3.3.98/src/com/sleepycat/je/VerifyConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/VerifyConfig.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/VerifyConfig.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: VerifyConfig.java,v 1.15 2008/01/07 14:28:46 cwl Exp $ + * $Id: VerifyConfig.java,v 1.16.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; @@ -180,8 +180,9 @@ * * @return the values for each configuration attribute. */ + @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("propagateExceptions=").append(propagateExceptions); return sb.toString(); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/je/XAEnvironment.java libdb-je-java-3.3.98/src/com/sleepycat/je/XAEnvironment.java --- libdb-je-java-3.3.62/src/com/sleepycat/je/XAEnvironment.java 2008-01-07 14:28:46.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/je/XAEnvironment.java 2010-01-04 15:30:28.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: XAEnvironment.java,v 1.14 2008/01/07 14:28:46 cwl Exp $ + * $Id: XAEnvironment.java,v 1.14.2.2 2010/01/04 15:30:27 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/BasicCursor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/BasicCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/BasicCursor.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/BasicCursor.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,15 +1,18 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BasicCursor.java,v 1.12 2008/02/05 23:28:21 mark Exp $ + * $Id: BasicCursor.java,v 1.12.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; import java.util.Iterator; +/* */ +import com.sleepycat.je.CacheMode; +/* */ import com.sleepycat.je.DatabaseEntry; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.LockMode; @@ -199,6 +202,18 @@ cursor.close(); } + /* */ + public void setCacheMode(CacheMode cacheMode) { + cursor.getCursor().setCacheMode(cacheMode); + } + /* */ + + /* */ + public CacheMode getCacheMode() { + return cursor.getCursor().getCacheMode(); + } + /* */ + void checkInitialized() throws IllegalStateException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/BasicIndex.java libdb-je-java-3.3.98/src/com/sleepycat/persist/BasicIndex.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/BasicIndex.java 2008-02-06 19:48:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/BasicIndex.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BasicIndex.java,v 1.14 2008/02/06 19:48:01 linda Exp $ + * $Id: BasicIndex.java,v 1.14.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/BasicIterator.java libdb-je-java-3.3.98/src/com/sleepycat/persist/BasicIterator.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/BasicIterator.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/BasicIterator.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BasicIterator.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: BasicIterator.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/DatabaseNamer.java libdb-je-java-3.3.98/src/com/sleepycat/persist/DatabaseNamer.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/DatabaseNamer.java 2008-02-20 16:52:56.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/DatabaseNamer.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseNamer.java,v 1.4 2008/02/20 16:52:55 linda Exp $ + * $Id: DatabaseNamer.java,v 1.4.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/DataValueAdapter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/DataValueAdapter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/DataValueAdapter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/DataValueAdapter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DataValueAdapter.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: DataValueAdapter.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityCursor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityCursor.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityCursor.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,15 +1,18 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityCursor.java,v 1.12 2008/01/07 14:28:58 cwl Exp $ + * $Id: EntityCursor.java,v 1.12.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; import java.util.Iterator; +/* */ +import com.sleepycat.je.CacheMode; +/* */ import com.sleepycat.je.CursorConfig; import com.sleepycat.je.DatabaseException; import com.sleepycat.je.LockMode; @@ -603,4 +606,32 @@ */ void close() throws DatabaseException; + + /* */ + /** + * Changes the {@code CacheMode} used for operations performed using this + * cursor. For a newly opened cursor, the default is {@link + * CacheMode#DEFAULT}. + * + * @param cacheMode is the {@code CacheMode} to use for subsequent + * operations using this cursor. + * + * @see CacheMode + */ + void setCacheMode(CacheMode cacheMode); + /* */ + + /* */ + /** + * Returns the {@code CacheMode} used for operations performed using this + * cursor. For a newly opened cursor, the default is {@link + * CacheMode#DEFAULT}. + * + * @return the CacheMode object used for operations performed with this + * cursor. + * + * @see CacheMode + */ + CacheMode getCacheMode(); + /* */ } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityIndex.java libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityIndex.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityIndex.java 2008-01-24 14:59:30.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityIndex.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityIndex.java,v 1.21 2008/01/24 14:59:30 linda Exp $ + * $Id: EntityIndex.java,v 1.22.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; @@ -16,11 +16,11 @@ import com.sleepycat.je.CursorConfig; import com.sleepycat.je.Database; import com.sleepycat.je.DatabaseEntry; -import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.DatabaseException; // for javadoc import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.LockMode; -import com.sleepycat.je.SecondaryDatabase; +import com.sleepycat.je.SecondaryDatabase; // for javadoc import com.sleepycat.je.Transaction; /** diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityJoin.java libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityJoin.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityJoin.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityJoin.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityJoin.java,v 1.10 2008/01/07 14:28:58 cwl Exp $ + * $Id: EntityJoin.java,v 1.10.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityStore.java libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityStore.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityStore.java 2008-05-19 20:33:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityStore.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityStore.java,v 1.35 2008/05/19 20:33:31 mark Exp $ + * $Id: EntityStore.java,v 1.35.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; @@ -166,13 +166,6 @@ } /** - * Only public for debugging. - */ - void dumpCatalog() { - store.dumpCatalog(); - } - - /** * Returns the environment associated with this store. * * @return the environment. diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityValueAdapter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityValueAdapter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/EntityValueAdapter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/EntityValueAdapter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityValueAdapter.java,v 1.8 2008/01/07 14:28:58 cwl Exp $ + * $Id: EntityValueAdapter.java,v 1.8.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Conversion.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Conversion.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Conversion.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Conversion.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Conversion.java,v 1.12 2008/01/07 14:28:58 cwl Exp $ + * $Id: Conversion.java,v 1.14.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Converter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Converter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Converter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Converter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Converter.java,v 1.11 2008/01/07 14:28:58 cwl Exp $ + * $Id: Converter.java,v 1.11.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/DeletedClassException.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/DeletedClassException.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/DeletedClassException.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/DeletedClassException.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DeletedClassException.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: DeletedClassException.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Deleter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Deleter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Deleter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Deleter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Deleter.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: Deleter.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EntityConverter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EntityConverter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EntityConverter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EntityConverter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityConverter.java,v 1.11 2008/01/07 14:28:58 cwl Exp $ + * $Id: EntityConverter.java,v 1.11.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveConfig.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveConfig.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveConfig.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvolveConfig.java,v 1.8 2008/01/07 14:28:58 cwl Exp $ + * $Id: EvolveConfig.java,v 1.8.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveEvent.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveEvent.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveEvent.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveEvent.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvolveEvent.java,v 1.5 2008/01/07 14:28:58 cwl Exp $ + * $Id: EvolveEvent.java,v 1.5.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveInternal.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveInternal.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveInternal.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveInternal.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvolveInternal.java,v 1.6 2008/02/05 23:28:21 mark Exp $ + * $Id: EvolveInternal.java,v 1.6.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveListener.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveListener.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveListener.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveListener.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvolveListener.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: EvolveListener.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveStats.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveStats.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/EvolveStats.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/EvolveStats.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvolveStats.java,v 1.8 2008/01/07 14:28:58 cwl Exp $ + * $Id: EvolveStats.java,v 1.8.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/IncompatibleClassException.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/IncompatibleClassException.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/IncompatibleClassException.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/IncompatibleClassException.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: IncompatibleClassException.java,v 1.7 2008/01/07 14:28:58 cwl Exp $ + * $Id: IncompatibleClassException.java,v 1.7.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Mutation.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Mutation.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Mutation.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Mutation.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Mutation.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: Mutation.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Mutations.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Mutations.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Mutations.java 2008-05-19 20:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Mutations.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Mutations.java,v 1.15 2008/05/19 20:28:25 mark Exp $ + * $Id: Mutations.java,v 1.15.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/package.html libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/package.html --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/package.html 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/package.html 2008-06-06 19:23:04.000000000 +0000 @@ -1,4 +1,4 @@ - + Utilities for managing class evolution of persistent objects. @@ -237,8 +237,8 @@

The {@link com.sleepycat.persist.model.PrimaryKey#sequence} property may be added, removed, or changed to a different name.

-

The {@link com.sleepycat.persist.model.Persistent#proxyFor} property may be -NOT be added, removed, or changed to a different class.

+

The {@link com.sleepycat.persist.model.Persistent#proxyFor} property may NOT +be added, removed, or changed to a different class.

Warnings on Testing and Backups

diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Renamer.java libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Renamer.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/evolve/Renamer.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/evolve/Renamer.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Renamer.java,v 1.10 2008/01/07 14:28:58 cwl Exp $ + * $Id: Renamer.java,v 1.10.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.evolve; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/ForwardCursor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/ForwardCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/ForwardCursor.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/ForwardCursor.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ForwardCursor.java,v 1.9 2008/01/07 14:28:58 cwl Exp $ + * $Id: ForwardCursor.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/AbstractInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/AbstractInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/AbstractInput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/AbstractInput.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: AbstractInput.java,v 1.5 2008/01/07 14:28:59 cwl Exp $ + * $Id: AbstractInput.java,v 1.5.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Accessor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Accessor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Accessor.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Accessor.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Accessor.java,v 1.13 2008/01/07 14:28:59 cwl Exp $ + * $Id: Accessor.java,v 1.13.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Catalog.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Catalog.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Catalog.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Catalog.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Catalog.java,v 1.15 2008/03/18 18:38:08 mark Exp $ + * $Id: Catalog.java,v 1.15.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/CollectionProxy.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/CollectionProxy.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/CollectionProxy.java 2008-05-13 16:29:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/CollectionProxy.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CollectionProxy.java,v 1.11 2008/05/13 16:29:35 mark Exp $ + * $Id: CollectionProxy.java,v 1.11.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ComplexFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ComplexFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ComplexFormat.java 2008-05-13 01:45:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ComplexFormat.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ComplexFormat.java,v 1.41 2008/05/13 01:45:02 cwl Exp $ + * $Id: ComplexFormat.java,v 1.44.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -25,6 +25,7 @@ import com.sleepycat.persist.evolve.Renamer; import com.sleepycat.persist.model.ClassMetadata; import com.sleepycat.persist.model.EntityMetadata; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.model.FieldMetadata; import com.sleepycat.persist.model.Relationship; import com.sleepycat.persist.model.SecondaryKeyMetadata; @@ -53,7 +54,7 @@ private boolean evolveNeeded; private transient Accessor objAccessor; private transient Accessor rawAccessor; - private transient Format entityFormat; + private transient ComplexFormat entityFormat; private transient Map secKeyAddresses; private transient volatile Map rawFields; private transient volatile FieldInfo[] rawInputFields; @@ -67,7 +68,7 @@ this.clsMeta = clsMeta; this.entityMeta = entityMeta; secKeyFields = new ArrayList(); - nonKeyFields = FieldInfo.getInstanceFields(cls); + nonKeyFields = FieldInfo.getInstanceFields(cls, clsMeta); /* * Validate primary key metadata and move primary key field from @@ -176,23 +177,33 @@ } @Override - ClassMetadata getClassMetadata() { + public ClassMetadata getClassMetadata() { return clsMeta; } @Override - EntityMetadata getEntityMetadata() { + public EntityMetadata getEntityMetadata() { return entityMeta; } @Override - Format getEntityFormat() { + ComplexFormat getEntityFormat() { if (isInitialized()) { + /* The transient entityFormat field is set by initialize(). */ return entityFormat; } else { - for (Format format = this; + + /* + * If not initialized, the entity format can be found by traversing + * the super formats. However, this is only possible for an + * existing format which has its superFormat field set. + */ + if (isNew()) { + throw new IllegalStateException(toString()); + } + for (ComplexFormat format = this; format != null; - format = format.getSuperFormat()) { + format = format.getComplexSuper()) { if (format.isEntity()) { return format; } @@ -281,7 +292,7 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { Class type = getType(); boolean useEnhanced = false; if (type != null) { @@ -289,13 +300,13 @@ } /* Initialize all fields. */ if (priKeyField != null) { - priKeyField.initialize(catalog, initVersion); + priKeyField.initialize(catalog, model, initVersion); } for (FieldInfo field : secKeyFields) { - field.initialize(catalog, initVersion); + field.initialize(catalog, model, initVersion); } for (FieldInfo field : nonKeyFields) { - field.initialize(catalog, initVersion); + field.initialize(catalog, model, initVersion); } /* Set the superclass format for a new (never initialized) format. */ ComplexFormat superFormat = getComplexSuper(); @@ -309,7 +320,7 @@ } /* Initialize the superclass format and validate the super accessor. */ if (superFormat != null) { - superFormat.initializeIfNeeded(catalog); + superFormat.initializeIfNeeded(catalog, model); Accessor superAccessor = superFormat.objAccessor; if (type != null && superAccessor != null) { if (useEnhanced) { @@ -330,14 +341,27 @@ } } /* Find entity format, if any. */ - for (Format format = this; + for (ComplexFormat format = this; format != null; - format = format.getSuperFormat()) { + format = format.getComplexSuper()) { if (format.isEntity()) { entityFormat = format; break; } } + + /* + * Ensure that the current entity metadata is always referenced in + * order to return it to the user and to properly construct secondary + * key addresses. Secondary key metadata can change in an entity + * subclass or be created when a new subclass is used, but this will + * not cause evolution of the entity class; instead, the metadata is + * updated here. [#16467] + */ + if (isEntity() && isCurrentVersion()) { + entityMeta = model.getEntityMetadata(getClassName()); + } + /* Disallow proxy class that extends an entity class. [#15950] */ if (clsMeta.getProxiedClassName() != null && entityFormat != null) { throw new IllegalArgumentException @@ -378,7 +402,7 @@ secKeyAddresses = new HashMap(); ComplexFormat thisLatest = getComplexLatest(); if (thisLatest != this) { - thisLatest.initializeIfNeeded(catalog); + thisLatest.initializeIfNeeded(catalog, model); } nextKeyLoop: for (SecondaryKeyMetadata secKeyMeta : @@ -793,9 +817,32 @@ ComplexFormat newFormat = (ComplexFormat) newFormatParam; Mutations mutations = evolver.getMutations(); boolean thisChanged = false; - boolean superChanged = false; + boolean hierarchyChanged = false; Map allKeyNameMap = new HashMap(); + /* The Evolver has already ensured that entities evolve to entities. */ + assert isEntity() == newFormat.isEntity(); + assert isEntity() == (entityMeta != null); + assert newFormat.isEntity() == (newFormat.entityMeta != null); + + /* + * Keep track of the old and new entity class names for use in deleting + * and renaming secondary keys below. If the oldEntityClass is + * non-null this also signifies an entity class or subclass. Note that + * getEntityFormat cannot be called on a newly created format during + * evolution because its super format property is not yet initialized. + * [#16253] + */ + String oldEntityClass; + String newEntityClass; + if (isEntity()) { + oldEntityClass = getClassName(); + newEntityClass = newFormat.getClassName(); + } else { + oldEntityClass = null; + newEntityClass = null; + } + /* * Evolve all superclass formats, even when a deleted class appears in * the hierarchy. This ensures that the super format's @@ -826,7 +873,7 @@ if (oldSuper.oldToNewKeyMap != null) { allKeyNameMap.putAll(oldSuper.oldToNewKeyMap); } - superChanged = true; + hierarchyChanged = true; } } @@ -852,13 +899,13 @@ if (getSuperFormat() == null) { if (newFormatCls.getSuperclass() != Object.class) { thisChanged = true; - superChanged = true; + hierarchyChanged = true; } } else { if (!getSuperFormat().getLatestVersion().getClassName().equals (newFormatCls.getSuperclass().getName())) { thisChanged = true; - superChanged = true; + hierarchyChanged = true; } } @@ -877,6 +924,12 @@ if (oldSuperName.equals(newSuper2.getName())) { foundNewSuper = newSuper2; newLevel = tryNewLevel; + if (oldSuper.isEntity()) { + assert oldEntityClass == null; + assert newEntityClass == null; + oldEntityClass = oldSuper.getClassName(); + newEntityClass = foundNewSuper.getName(); + } break; } } @@ -895,7 +948,7 @@ /* * The class hierarchy changed -- a new class was inserted. */ - superChanged = true; + hierarchyChanged = true; /* * Check that the new formats skipped over above are not at @@ -925,7 +978,7 @@ * The class hierarchy changed, since an old class no longer * appears. */ - superChanged = true; + hierarchyChanged = true; /* Check that the old class can be safely removed. */ if (!oldSuper.isDeleted()) { @@ -943,7 +996,7 @@ } } - if (isEntity() && isCurrentVersion()) { + if (oldEntityClass != null && isCurrentVersion()) { Map secKeys = oldSuper.clsMeta.getSecondaryKeys(); for (FieldInfo field : oldSuper.secKeyFields) { @@ -982,22 +1035,27 @@ return false; } - /* Rename the secondary databases. */ - if (allKeyNameMap.size() > 0 && isEntity() && isCurrentVersion()) { + /* Rename and delete the secondary databases. */ + if (allKeyNameMap.size() > 0 && + oldEntityClass != null && + newEntityClass != null && + isCurrentVersion()) { for (Map.Entry entry : allKeyNameMap.entrySet()) { - String oldKeyName = entry.getKey(); - String newKeyName = entry.getValue(); + String oldKeyName = entry.getKey(); + String newKeyName = entry.getValue(); if (newKeyName != null) { evolver.renameSecondaryDatabase - (this, newFormat, oldKeyName, newKeyName); + (oldEntityClass, newEntityClass, + oldKeyName, newKeyName); } else { - evolver.deleteSecondaryDatabase(this, oldKeyName); + evolver.deleteSecondaryDatabase + (oldEntityClass, oldKeyName); } } } /* Use an EvolveReader if needed. */ - if (superChanged || thisChanged) { + if (hierarchyChanged || thisChanged) { Reader reader = new EvolveReader(newLevels); evolver.useEvolvedFormat(this, reader, newFormat); } else { @@ -1041,7 +1099,7 @@ String keyName = oldMeta.getKeyName(); if (deletedKeys.contains(keyName)) { if (isCurrentVersion()) { - evolver.deleteSecondaryDatabase(this, keyName); + evolver.deleteSecondaryDatabase(getClassName(), keyName); } } else { SecondaryKeyMetadata newMeta = newSecondaryKeys.get(keyName); @@ -1172,14 +1230,14 @@ /* Evolve primary key field. */ boolean evolveFailure = false; - boolean evolveNeeded = false; + boolean localEvolveNeeded = false; if (priKeyField != null) { int result = evolver.evolveRequiredKeyField (this, newFormat, priKeyField, newFormat.priKeyField); if (result == Evolver.EVOLVE_FAILURE) { evolveFailure = true; } else if (result == Evolver.EVOLVE_NEEDED) { - evolveNeeded = true; + localEvolveNeeded = true; } } @@ -1190,7 +1248,7 @@ if (reader == FieldReader.EVOLVE_FAILURE) { evolveFailure = true; } else if (reader != null) { - evolveNeeded = true; + localEvolveNeeded = true; } if (reader != FieldReader.EVOLVE_NEEDED) { secKeyFieldReader = reader; @@ -1203,7 +1261,7 @@ if (reader == FieldReader.EVOLVE_FAILURE) { evolveFailure = true; } else if (reader != null) { - evolveNeeded = true; + localEvolveNeeded = true; } if (reader != FieldReader.EVOLVE_NEEDED) { nonKeyFieldReader = reader; @@ -1212,7 +1270,7 @@ /* Return result. */ if (evolveFailure) { return Evolver.EVOLVE_FAILURE; - } else if (evolveNeeded) { + } else if (localEvolveNeeded) { return Evolver.EVOLVE_NEEDED; } else { return Evolver.EVOLVE_NONE; @@ -1246,7 +1304,7 @@ Evolver evolver) { Mutations mutations = evolver.getMutations(); boolean evolveFailure = false; - boolean evolveNeeded = false; + boolean localEvolveNeeded = false; boolean readerNeeded = false; List fieldReaders = new ArrayList(); FieldReader currentReader = null; @@ -1311,7 +1369,7 @@ newField = otherNewFields.get(newFieldIndex); isNewSecKeyField = !isOldSecKeyField; } - evolveNeeded = true; + localEvolveNeeded = true; readerNeeded = true; } @@ -1334,7 +1392,7 @@ (oldFieldIndex, oldField); fieldReaders.add(currentReader); readerNeeded = true; - evolveNeeded = true; + localEvolveNeeded = true; } if (isOldSecKeyField) { if (oldToNewKeyMap == null) { @@ -1385,7 +1443,7 @@ oldToNewKeyMap = new HashMap(); } oldToNewKeyMap.put(oldName, newName); - evolveNeeded = true; + localEvolveNeeded = true; } } else if (isOldSecKeyField && !isNewSecKeyField) { if (oldToNewKeyMap == null) { @@ -1408,7 +1466,7 @@ isNewSecKeyField); fieldReaders.add(currentReader); readerNeeded = true; - evolveNeeded = true; + localEvolveNeeded = true; } continue fieldLoop; } @@ -1464,7 +1522,7 @@ /* Formats are identical. Fall through. */ } else if (allClassesConverted) { /* All old classes will be converted. Fall through. */ - evolveNeeded = true; + localEvolveNeeded = true; } else if (WidenerInput.isWideningSupported (oldLatestFormat, newFieldFormat, isOldSecKeyField)) { /* Apply field widener and continue. */ @@ -1473,7 +1531,7 @@ isNewSecKeyField); fieldReaders.add(currentReader); readerNeeded = true; - evolveNeeded = true; + localEvolveNeeded = true; continue fieldLoop; } else { boolean refWidened = false; @@ -1489,7 +1547,7 @@ } if (refWidened) { /* A reference type has been widened. Fall through. */ - evolveNeeded = true; + localEvolveNeeded = true; } else { /* Types are not compatible. */ evolver.addMissingMutation @@ -1527,7 +1585,7 @@ * @SecondaryKey). [#15524] */ if (newFieldsMatched < newFields.size()) { - evolveNeeded = true; + localEvolveNeeded = true; readerNeeded = true; } @@ -1541,7 +1599,7 @@ } else { return new MultiFieldReader(fieldReaders); } - } else if (evolveNeeded) { + } else if (localEvolveNeeded) { return FieldReader.EVOLVE_NEEDED; } else { return null; @@ -1903,12 +1961,13 @@ } public void initializeReader(Catalog catalog, + EntityModel model, int initVersion, Format oldFormatParam) { ComplexFormat oldFormat = (ComplexFormat) oldFormatParam; newFormat = oldFormat.getComplexLatest(); - newFormat.initializeIfNeeded(catalog); + newFormat.initializeIfNeeded(catalog, model); /* Create newHierarchy array. */ int newDepth = 0; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/CompositeKeyFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/CompositeKeyFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/CompositeKeyFormat.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/CompositeKeyFormat.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CompositeKeyFormat.java,v 1.26 2008/01/07 14:28:59 cwl Exp $ + * $Id: CompositeKeyFormat.java,v 1.27.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -16,6 +16,7 @@ import java.util.Map; import com.sleepycat.persist.model.ClassMetadata; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.model.FieldMetadata; import com.sleepycat.persist.raw.RawField; import com.sleepycat.persist.raw.RawObject; @@ -97,7 +98,8 @@ } /* Populate fields list in fieldNames order. */ - List instanceFields = FieldInfo.getInstanceFields(cls); + List instanceFields = + FieldInfo.getInstanceFields(cls, metadata); fields = new ArrayList(instanceFields.size()); for (String fieldName : fieldNames) { FieldInfo field = null; @@ -141,7 +143,7 @@ } @Override - ClassMetadata getClassMetadata() { + public ClassMetadata getClassMetadata() { if (metadata == null) { throw new IllegalStateException(getClassName()); } @@ -178,10 +180,10 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { /* Initialize all fields. */ for (FieldInfo field : fields) { - field.initialize(catalog, initVersion); + field.initialize(catalog, model, initVersion); } /* Create the accessor. */ Class type = getType(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ConverterReader.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ConverterReader.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ConverterReader.java 2008-06-03 04:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ConverterReader.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,13 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ConverterReader.java,v 1.10 2008/06/03 04:52:23 mark Exp $ + * $Id: ConverterReader.java,v 1.10.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.evolve.Converter; import com.sleepycat.persist.raw.RawObject; @@ -28,6 +29,7 @@ } public void initializeReader(Catalog catalog, + EntityModel model, int initVersion, Format oldFormat) { this.oldFormat = oldFormat; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EnhancedAccessor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EnhancedAccessor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EnhancedAccessor.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EnhancedAccessor.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnhancedAccessor.java,v 1.15 2008/03/18 18:38:08 mark Exp $ + * $Id: EnhancedAccessor.java,v 1.15.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Enhanced.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Enhanced.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Enhanced.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Enhanced.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Enhanced.java,v 1.12 2008/01/07 14:28:59 cwl Exp $ + * $Id: Enhanced.java,v 1.12.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EntityInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EntityInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EntityInput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EntityInput.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityInput.java,v 1.19 2008/01/07 14:28:59 cwl Exp $ + * $Id: EntityInput.java,v 1.19.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EntityOutput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EntityOutput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EntityOutput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EntityOutput.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityOutput.java,v 1.16 2008/01/07 14:28:59 cwl Exp $ + * $Id: EntityOutput.java,v 1.16.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EnumFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EnumFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/EnumFormat.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/EnumFormat.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnumFormat.java,v 1.22 2008/01/07 14:28:59 cwl Exp $ + * $Id: EnumFormat.java,v 1.22.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Set; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.raw.RawObject; /** @@ -59,7 +60,7 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { if (values == null) { Class cls = getType(); if (cls != null) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Evolver.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Evolver.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Evolver.java 2008-02-06 19:48:02.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Evolver.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Evolver.java,v 1.14 2008/02/06 19:48:02 linda Exp $ + * $Id: Evolver.java,v 1.15.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -213,7 +213,7 @@ * Called by PersistCatalog after calling evolveFormat or * addNonEntityFormat for all old formats. * - * We do not require deletion of an unreferenced class for three + * We do not require deletion of an unreferenced class for two * reasons: 1) built-in proxy classes may not be referenced, 2) the * user may wish to declare persistent classes that are not yet used. */ @@ -221,12 +221,7 @@ /* Process unreferenced classes. */ for (Format oldFormat : unprocessedFormats) { oldFormat.setUnused(true); - Integer oldFormatId = oldFormat.getId(); - if (!evolvedFormats.containsKey(oldFormatId)) { - evolvedFormats.put(oldFormatId, true); - boolean result = evolveFormatInternal(oldFormat); - evolvedFormats.put(oldFormatId, result); - } + evolveFormat(oldFormat); } } @@ -235,9 +230,12 @@ * methods for all potentially referenced non-entity formats. */ boolean evolveFormat(Format oldFormat) { + if (oldFormat.isNew()) { + return true; + } boolean result; - boolean trackEntityChanges = - oldFormat.getLatestVersion().getEntityFormat() != null; + Format oldEntityFormat = oldFormat.getEntityFormat(); + boolean trackEntityChanges = oldEntityFormat != null; boolean saveNestedFormatsChanged = nestedFormatsChanged; if (trackEntityChanges) { nestedFormatsChanged = false; @@ -255,7 +253,7 @@ } if (trackEntityChanges) { if (nestedFormatsChanged) { - Format latest = oldFormat.getLatestVersion().getEntityFormat(); + Format latest = oldEntityFormat.getLatestVersion(); if (latest != null) { latest.setEvolveNeeded(true); } @@ -354,9 +352,11 @@ newFormat.getPreviousVersion() == null) { assert newFormats.containsValue(newFormat); Format oldLatestFormat = oldFormat.getLatestVersion(); - evolveFormat(oldLatestFormat); + if (!evolveFormat(oldLatestFormat)) { + return false; + } if (oldLatestFormat == oldLatestFormat.getLatestVersion()) { - assert !newFormats.containsValue(newFormat); + assert !newFormats.containsValue(newFormat) : newFormat; /* newFormat equals oldLatestFormat and was discarded. */ newFormat = oldLatestFormat; } @@ -380,7 +380,7 @@ /* Apply class Renamer and continue if successful. */ if (renamer != null) { - if (!applyRenamer(renamer, oldFormat, newFormat)) { + if (!applyClassRenamer(renamer, oldFormat, newFormat)) { return false; } } @@ -415,7 +415,7 @@ "@Entity or @Persistent annotation is still present"); return false; } - return applyDeleter(deleter, oldFormat, newFormat); + return applyClassDeleter(deleter, oldFormat, newFormat); } else { if (needDeleter) { if (newFormat == null) { @@ -456,8 +456,23 @@ assert renamedFormat == newFormat; useEvolvedFormat(oldFormat, renamedFormat, renamedFormat); } else if (newFormat != null && - oldFormat.getVersion() != newFormat.getVersion()) { - /* The user wants a new version number, but no other changes. */ + (oldFormat.getVersion() != newFormat.getVersion() || + !oldFormat.isCurrentVersion())) { + + /* + * If the user wants a new version number, but ther are no other + * changes, we will oblige. Or, if an attempt is being made to + * use an old version, then the following events happened and we + * must evolve the old format: + * 1) The (previously) latest version of the format was evolved + * because it is not equal to the live class version. Note that + * evolveFormatInternal always evolves the latest version first. + * 2) We are now attempting to evolve an older version of the same + * format, and it happens to be equal to the live class version. + * However, we're already committed to the new format, and we must + * evolve all versions. + * [#16467] + */ useEvolvedFormat(oldFormat, newFormat, newFormat); } else { /* The new format is discarded. */ @@ -482,9 +497,9 @@ setFormatsChanged(oldFormat); } - private boolean applyRenamer(Renamer renamer, - Format oldFormat, - Format newFormat) { + private boolean applyClassRenamer(Renamer renamer, + Format oldFormat, + Format newFormat) { if (!checkUpdatedVersion(renamer, oldFormat, newFormat)) { return false; } @@ -517,20 +532,18 @@ /** * Called by ComplexFormat when a secondary key name is changed. */ - void renameSecondaryDatabase(Format oldFormat, - Format newFormat, + void renameSecondaryDatabase(String oldEntityClass, + String newEntityClass, String oldKeyName, String newKeyName) { renameDbs.put - (Store.makeSecDbName - (storePrefix, oldFormat.getClassName(), oldKeyName), - Store.makeSecDbName - (storePrefix, newFormat.getClassName(), newKeyName)); + (Store.makeSecDbName(storePrefix, oldEntityClass, oldKeyName), + Store.makeSecDbName(storePrefix, newEntityClass, newKeyName)); } - private boolean applyDeleter(Deleter deleter, - Format oldFormat, - Format newFormat) { + private boolean applyClassDeleter(Deleter deleter, + Format oldFormat, + Format newFormat) { if (!checkUpdatedVersion(deleter, oldFormat, newFormat)) { return false; } @@ -546,7 +559,7 @@ } /* - * Set the format to deleted last, so that the above test using + * Set the format to deleted last, so that the above test using * isCurrentVersion works properly. */ oldFormat.setDeleted(true); @@ -561,9 +574,9 @@ /** * Called by ComplexFormat when a secondary key is dropped. */ - void deleteSecondaryDatabase(Format oldFormat, String keyName) { + void deleteSecondaryDatabase(String oldEntityClass, String keyName) { deleteDbs.add(Store.makeSecDbName - (storePrefix, oldFormat.getClassName(), keyName)); + (storePrefix, oldEntityClass, keyName)); } private boolean applyConverter(Converter converter, diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/FieldInfo.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/FieldInfo.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/FieldInfo.java 2008-06-03 04:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/FieldInfo.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FieldInfo.java,v 1.24 2008/06/03 04:52:23 mark Exp $ + * $Id: FieldInfo.java,v 1.25.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -12,10 +12,14 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.raw.RawField; +import com.sleepycat.persist.model.FieldMetadata; +import com.sleepycat.persist.model.ClassMetadata; /** * A field definition used by ComplexFormat and CompositeKeyFormat. @@ -35,14 +39,52 @@ * Returns a list of all non-transient non-static fields that are declared * in the given class. */ - static List getInstanceFields(Class cls) { - Field[] declaredFields = cls.getDeclaredFields(); - List fields = - new ArrayList(declaredFields.length); - for (Field field : declaredFields) { - int mods = field.getModifiers(); - if (!Modifier.isTransient(mods) && !Modifier.isStatic(mods)) { - fields.add(new FieldInfo(field)); + static List getInstanceFields(Class cls, + ClassMetadata clsMeta) { + List fields = null; + if (clsMeta != null) { + Collection persistentFields = + clsMeta.getPersistentFields(); + if (persistentFields != null) { + fields = new ArrayList(persistentFields.size()); + String clsName = cls.getName(); + for (FieldMetadata fieldMeta : persistentFields) { + if (!clsName.equals(fieldMeta.getDeclaringClassName())) { + throw new IllegalArgumentException + ("Persistent field " + fieldMeta + + " must be declared in " + clsName); + } + Field field; + try { + field = cls.getDeclaredField(fieldMeta.getName()); + } catch (NoSuchFieldException e) { + throw new IllegalArgumentException + ("Persistent field " + fieldMeta + + " is not declared in this class"); + } + if (!field.getType().getName().equals + (fieldMeta.getClassName())) { + throw new IllegalArgumentException + ("Persistent field " + fieldMeta + + " must be of type " + field.getType().getName()); + } + if (Modifier.isStatic(field.getModifiers())) { + throw new IllegalArgumentException + ("Persistent field " + fieldMeta + + " may not be static"); + } + fields.add(new FieldInfo(field)); + } + } + } + if (fields == null) { + Field[] declaredFields = cls.getDeclaredFields(); + fields = new ArrayList(declaredFields.length); + for (Field field : declaredFields) { + int mods = field.getModifiers(); + if (!Modifier.isTransient(mods) && !Modifier.isStatic(mods)) { + fields.add(new FieldInfo(field)); + } } } return fields; @@ -98,7 +140,7 @@ } } - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { /* * Reset the format if it was never initialized, which can occur when a diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Format.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Format.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Format.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Format.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Format.java,v 1.39 2008/01/07 14:28:59 cwl Exp $ + * $Id: Format.java,v 1.40.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -18,6 +18,10 @@ import com.sleepycat.persist.evolve.Converter; import com.sleepycat.persist.model.ClassMetadata; import com.sleepycat.persist.model.EntityMetadata; +import com.sleepycat.persist.model.EntityModel; +import com.sleepycat.persist.model.FieldMetadata; +import com.sleepycat.persist.model.PrimaryKeyMetadata; +import com.sleepycat.persist.model.SecondaryKeyMetadata; import com.sleepycat.persist.raw.RawField; import com.sleepycat.persist.raw.RawObject; import com.sleepycat.persist.raw.RawType; @@ -339,7 +343,7 @@ /** * Returns the format ID. */ - final int getId() { + public final int getId() { return id; } @@ -511,7 +515,7 @@ * bidirectional dependencies. This method will do nothing if the format * is already intialized. */ - final void initializeIfNeeded(Catalog catalog) { + final void initializeIfNeeded(Catalog catalog, EntityModel model) { if (!initialized) { initialized = true; this.catalog = catalog; @@ -535,10 +539,11 @@ } /* Perform subclass-specific initialization. */ - initialize - (catalog, catalog.getInitVersion(this, false /*forReader*/)); + initialize(catalog, model, + catalog.getInitVersion(this, false /*forReader*/)); reader.initializeReader - (catalog, catalog.getInitVersion(this, true /*forReader*/), + (catalog, model, + catalog.getInitVersion(this, true /*forReader*/), this); } } @@ -548,6 +553,7 @@ * called when no separate Reader exists, and does nothing. */ public void initializeReader(Catalog catalog, + EntityModel model, int initVersion, Format oldFormat) { } @@ -639,6 +645,14 @@ return null; } + public ClassMetadata getClassMetadata() { + return null; + } + + public EntityMetadata getEntityMetadata() { + return null; + } + /* -- End of RawType methods. -- */ /* -- Methods that may optionally be overridden by subclasses. -- */ @@ -680,26 +694,10 @@ } /** - * Returns the original model class metadata used to create this class, or - * null if this is not a model class. - */ - ClassMetadata getClassMetadata() { - return null; - } - - /** - * Returns the original model entity metadata used to create this class, or - * null if this is not an entity class. - */ - EntityMetadata getEntityMetadata() { - return null; - } - - /** * For an entity class or subclass, returns the base entity class; returns * null in other cases. */ - Format getEntityFormat() { + ComplexFormat getEntityFormat() { return null; } @@ -707,12 +705,17 @@ * Called for an existing format that may not equal the current format for * the same class. * - *

If this method returns true, then it must have determined that the - * old and new formats are equal, and it must have called either - * Evolver.useOldFormat or useEvolvedFormat. If this method returns false, - * then it must have determined that the old format could not be evolved to - * the new format, and it must have called Evolver.addInvalidMutation, - * addMissingMutation or addEvolveError.

+ *

If this method returns true, then it must have determined one of two + * things: + * - that the old and new formats are equal, and it must have called + * Evolver.useOldFormat; or + * - that the old format can be evolved to the new format, and it must + * have called Evolver.useEvolvedFormat.

+ * + *

If this method returns false, then it must have determined that the + * old format could not be evolved to the new format, and it must have + * called Evolver.addInvalidMutation, addMissingMutation or + * addEvolveError.

*/ abstract boolean evolve(Format newFormat, Evolver evolver); @@ -748,7 +751,9 @@ * Initializes an uninitialized format, initializing its related formats * (superclass formats and array component formats) first. */ - abstract void initialize(Catalog catalog, int initVersion); + abstract void initialize(Catalog catalog, + EntityModel model, + int initVersion); /** * Calls catalog.createFormat for formats that this format depends on, or @@ -926,11 +931,173 @@ @Override public String toString() { - return "[RawType class: " + getClassName() + - " version: " + getVersion() + - " internal: " + getClass().getName() + - ((reader != null) ? - (" reader: " + reader.getClass().getName()) : "") + - ']'; + final String INDENT = " "; + final String INDENT2 = INDENT + " "; + StringBuffer buf = new StringBuffer(500); + if (isSimple()) { + addTypeHeader(buf, "SimpleType"); + buf.append(" primitive=\""); + buf.append(isPrimitive()); + buf.append("\"/>\n"); + } else if (isEnum()) { + addTypeHeader(buf, "EnumType"); + buf.append(">\n"); + for (String constant : getEnumConstants()) { + buf.append(INDENT); + buf.append(""); + buf.append(constant); + buf.append("\n"); + } + buf.append("\n"); + } else if (isArray()) { + addTypeHeader(buf, "ArrayType"); + buf.append(" componentId=\""); + buf.append(getComponentType().getVersion()); + buf.append("\" componentClass=\""); + buf.append(getComponentType().getClassName()); + buf.append("\" dimensions=\""); + buf.append(getDimensions()); + buf.append("\"/>\n"); + } else { + addTypeHeader(buf, "ComplexType"); + Format superType = getSuperType(); + if (superType != null) { + buf.append(" superTypeId=\""); + buf.append(superType.getId()); + buf.append("\" superTypeClass=\""); + buf.append(superType.getClassName()); + buf.append('"'); + } + Format proxiedFormat = getProxiedFormat(); + if (proxiedFormat != null) { + buf.append(" proxiedTypeId=\""); + buf.append(proxiedFormat.getId()); + buf.append("\" proxiedTypeClass=\""); + buf.append(proxiedFormat.getClassName()); + buf.append('"'); + } + PrimaryKeyMetadata priMeta = null; + Map secondaryKeys = null; + List compositeKeyFields = null; + ClassMetadata clsMeta = getClassMetadata(); + if (clsMeta != null) { + compositeKeyFields = clsMeta.getCompositeKeyFields(); + priMeta = clsMeta.getPrimaryKey(); + secondaryKeys = clsMeta.getSecondaryKeys(); + } + buf.append(" kind=\""); + buf.append(isEntity() ? "entity" : + ((compositeKeyFields != null) ? "compositeKey" : + "persistent")); + buf.append("\">\n"); + Map fields = getFields(); + if (fields != null) { + for (RawField field : fields.values()) { + String name = field.getName(); + RawType type = field.getType(); + buf.append(INDENT); + buf.append("\n"); + } + EntityMetadata entMeta = getEntityMetadata(); + if (entMeta != null) { + buf.append(INDENT); + buf.append("\n"); + priMeta = entMeta.getPrimaryKey(); + if (priMeta != null) { + buf.append(INDENT2); + buf.append("\n"); + } + secondaryKeys = entMeta.getSecondaryKeys(); + if (secondaryKeys != null) { + for (SecondaryKeyMetadata secMeta : + secondaryKeys.values()) { + buf.append(INDENT2); + buf.append("\n"); + } + } + buf.append("\n"); + } + } + buf.append("\n"); + } + return buf.toString(); + } + + private void addTypeHeader(StringBuffer buf, String elemName) { + buf.append('<'); + buf.append(elemName); + buf.append(" id=\""); + buf.append(getId()); + buf.append("\" class=\""); + buf.append(getClassName()); + buf.append("\" version=\""); + buf.append(getVersion()); + buf.append('"'); + Format currVersion = getLatestVersion(); + if (currVersion != null) { + buf.append(" currentVersionId=\""); + buf.append(currVersion.getId()); + buf.append('"'); + } + Format prevVersion = getPreviousVersion(); + if (prevVersion != null) { + buf.append(" previousVersionId=\""); + buf.append(prevVersion.getId()); + buf.append('"'); + } } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/KeyLocation.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/KeyLocation.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/KeyLocation.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/KeyLocation.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyLocation.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: KeyLocation.java,v 1.6.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/MapProxy.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/MapProxy.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/MapProxy.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/MapProxy.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MapProxy.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: MapProxy.java,v 1.6.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/NonPersistentFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/NonPersistentFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/NonPersistentFormat.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/NonPersistentFormat.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NonPersistentFormat.java,v 1.14 2008/01/07 14:28:59 cwl Exp $ + * $Id: NonPersistentFormat.java,v 1.14.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -11,6 +11,8 @@ import java.lang.reflect.Array; import java.util.Map; +import com.sleepycat.persist.model.EntityModel; + /** * Format for a non-persistent class that is only used for declared field * types and arrays. Currently used only for Object and interface types. @@ -26,7 +28,7 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { } @Override diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ObjectArrayFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ObjectArrayFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ObjectArrayFormat.java 2008-06-03 04:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ObjectArrayFormat.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ObjectArrayFormat.java,v 1.27 2008/06/03 04:52:23 mark Exp $ + * $Id: ObjectArrayFormat.java,v 1.27.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -14,6 +14,7 @@ import java.util.Set; import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.raw.RawObject; /** @@ -71,7 +72,7 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { /* Set the component format for a new (never initialized) format. */ if (componentFormat == null) { Class cls = getType().getComponentType(); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistCatalog.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistCatalog.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistCatalog.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistCatalog.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistCatalog.java,v 1.46 2008/03/18 18:38:08 mark Exp $ + * $Id: PersistCatalog.java,v 1.47.2.3 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -17,6 +17,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; @@ -44,6 +45,7 @@ import com.sleepycat.persist.model.EntityMetadata; import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.raw.RawObject; +import com.sleepycat.persist.raw.RawType; import com.sleepycat.util.RuntimeExceptionWrapper; /** @@ -264,12 +266,12 @@ } } } + model = new StoredModel(this); for (Format format : formatList) { if (format != null) { - format.initializeIfNeeded(this); + format.initializeIfNeeded(this, model); } } - model = new StoredModel(this); success = true; return; } @@ -374,7 +376,7 @@ /* Initialize all formats. */ for (Format format : formatList) { if (format != null) { - format.initializeIfNeeded(this); + format.initializeIfNeeded(this, model); if (format == format.getLatestVersion()) { latestFormatMap.put(format.getClassName(), format); } @@ -547,9 +549,10 @@ } /** - * If the given class format is not already present in the given map, - * creates an uninitialized format, adds it to the map, and also collects - * related formats in the map. + * If the given class format is not already present in the given map and + * a format for this class name does not already exist, creates an + * uninitialized format, adds it to the map, and also collects related + * formats in the map. */ public Format createFormat(Class type, Map newFormats) { /* Return a new or existing format for this class. */ @@ -653,7 +656,20 @@ classes.add(format.getClassName()); } } - return classes; + return Collections.unmodifiableSet(classes); + } + + /** + * Returns all formats as RawTypes. + */ + public List getAllRawTypes() { + List list = new ArrayList(); + for (RawType type : formatList) { + if (type != null) { + list.add(type); + } + } + return Collections.unmodifiableList(list); } /** @@ -798,7 +814,7 @@ Catalog newFormatCatalog = new ReadOnlyCatalog(newFormatList, newFormatMap); for (Format newFormat : newFormats.values()) { - newFormat.initializeIfNeeded(newFormatCatalog); + newFormat.initializeIfNeeded(newFormatCatalog, model); newLatestFormatMap.put(newFormat.getClassName(), newFormat); } @@ -918,11 +934,24 @@ public Object convertRawObject(RawObject o, IdentityHashMap converted) { Format format = (Format) o.getType(); if (this != format.getCatalog()) { - String className = format.getClassName(); - format = getFormat(className); + + /* + * Use the corresponding format in this catalog when the external + * raw object was created using a different catalog. Create the + * format if it does not already exist, for example, when this + * store is empty. [#16253]. + */ + String clsName = format.getClassName(); + Class cls; + try { + cls = SimpleCatalog.classForName(clsName); + format = getFormat(cls, true /*openEntitySubclassIndexes*/); + } catch (ClassNotFoundException e) { + format = null; + } if (format == null) { throw new IllegalArgumentException - ("External raw type not found: " + className); + ("External raw type not found: " + clsName); } } Format proxiedFormat = format.getProxiedFormat(); @@ -934,19 +963,4 @@ } return format.convertRawObject(this, false, o, converted); } - - public void dump() { - System.out.println("--- Begin formats ---"); - for (Format format : formatList) { - if (format != null) { - System.out.println - ("ID: " + format.getId() + - " class: " + format.getClassName() + - " version: " + format.getVersion() + - " current: " + - (format == formatMap.get(format.getClassName()))); - } - } - System.out.println("--- End formats ---"); - } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistComparator.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistComparator.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistComparator.java 2008-05-19 17:52:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistComparator.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistComparator.java,v 1.11 2008/05/19 17:52:20 linda Exp $ + * $Id: PersistComparator.java,v 1.11.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistEntityBinding.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistEntityBinding.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistEntityBinding.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistEntityBinding.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistEntityBinding.java,v 1.20 2008/03/18 18:38:08 mark Exp $ + * $Id: PersistEntityBinding.java,v 1.20.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -33,21 +33,10 @@ String entityClassName, boolean rawAccess) { this.catalog = catalog; - if (rawAccess) { - entityFormat = catalog.getFormat(entityClassName); - if (entityFormat == null || !entityFormat.isEntity()) { - throw new IllegalArgumentException - ("Not an entity class: " + entityClassName); - } - } else { - Class entityCls; - try { - entityCls = EntityModel.classForName(entityClassName); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(e); - } - entityFormat = catalog.getFormat - (entityCls, true /*openEntitySubclassIndexes*/); + entityFormat = getOrCreateFormat(catalog, entityClassName, rawAccess); + if (!entityFormat.isEntity()) { + throw new IllegalArgumentException + ("Not an entity class: " + entityClassName); } this.rawAccess = rawAccess; } @@ -167,4 +156,24 @@ return format; } + + /** + * Utility method for getting or creating a format as appropriate for + * bindings and key creators. + */ + static Format getOrCreateFormat(Catalog catalog, + String clsName, + boolean rawAccess) { + if (rawAccess) { + Format format = catalog.getFormat(clsName); + if (format == null) { + throw new IllegalArgumentException + ("Not a persistent class: " + clsName); + } + return format; + } else { + Class cls = SimpleCatalog.keyClassForName(clsName); + return catalog.getFormat(cls, true /*openEntitySubclassIndexes*/); + } + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistKeyAssigner.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistKeyAssigner.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistKeyAssigner.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistKeyAssigner.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistKeyAssigner.java,v 1.16 2008/01/07 14:28:59 cwl Exp $ + * $Id: PersistKeyAssigner.java,v 1.16.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistKeyBinding.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistKeyBinding.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistKeyBinding.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistKeyBinding.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistKeyBinding.java,v 1.22 2008/03/18 18:38:08 mark Exp $ + * $Id: PersistKeyBinding.java,v 1.22.2.4 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -30,11 +30,8 @@ String clsName, boolean rawAccess) { this.catalog = catalog; - keyFormat = catalog.getFormat(clsName); - if (keyFormat == null) { - throw new IllegalArgumentException - ("Class is not persistent: " + clsName); - } + keyFormat = PersistEntityBinding.getOrCreateFormat + (catalog, clsName, rawAccess); if (!keyFormat.isSimple() && (keyFormat.getClassMetadata() == null || keyFormat.getClassMetadata().getCompositeKeyFields() == null)) { @@ -60,7 +57,7 @@ keyFormat = catalog.getFormat(cls, false /*openEntitySubclassIndexes*/); } - keyFormat.initializeIfNeeded(catalog); + keyFormat.initializeIfNeeded(catalog, null /*model*/); } /** diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistKeyCreator.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistKeyCreator.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PersistKeyCreator.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PersistKeyCreator.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistKeyCreator.java,v 1.18 2008/01/07 14:28:59 cwl Exp $ + * $Id: PersistKeyCreator.java,v 1.18.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -49,13 +49,15 @@ public PersistKeyCreator(Catalog catalog, EntityMetadata entityMeta, String keyClassName, - SecondaryKeyMetadata secKeyMeta) { + SecondaryKeyMetadata secKeyMeta, + boolean rawAccess) { this.catalog = catalog; - Format priKeyFormat = - catalog.getFormat(entityMeta.getPrimaryKey().getClassName()); + Format priKeyFormat = PersistEntityBinding.getOrCreateFormat + (catalog, entityMeta.getPrimaryKey().getClassName(), rawAccess); priKeyFormatId = priKeyFormat.getId(); keyName = secKeyMeta.getKeyName(); - keyFormat = catalog.getFormat(keyClassName); + keyFormat = PersistEntityBinding.getOrCreateFormat + (catalog, keyClassName, rawAccess); if (keyFormat == null) { throw new IllegalArgumentException ("Not a key class: " + keyClassName); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PrimitiveArrayFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PrimitiveArrayFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/PrimitiveArrayFormat.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/PrimitiveArrayFormat.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrimitiveArrayFormat.java,v 1.24 2008/03/18 18:38:08 mark Exp $ + * $Id: PrimitiveArrayFormat.java,v 1.24.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Set; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.raw.RawObject; /** @@ -53,9 +54,14 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { + + /* + * getExistingType is allowed (to support raw mode) because primitive + * arrays are always available in Java. + */ componentFormat = (SimpleFormat) - catalog.getFormat(getType().getComponentType(), + catalog.getFormat(getExistingType().getComponentType(), false /*openEntitySubclassIndexes*/); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ProxiedFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ProxiedFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ProxiedFormat.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ProxiedFormat.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ProxiedFormat.java,v 1.24 2008/01/07 14:28:59 cwl Exp $ + * $Id: ProxiedFormat.java,v 1.24.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Set; +import com.sleepycat.persist.model.EntityModel; import com.sleepycat.persist.model.PersistentProxy; import com.sleepycat.persist.raw.RawObject; @@ -67,7 +68,7 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { /* Set the proxy format for a new (never initialized) format. */ if (proxyFormat == null) { assert proxyClassName != null; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawAbstractInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawAbstractInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawAbstractInput.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawAbstractInput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawAbstractInput.java,v 1.10 2008/03/18 18:38:08 mark Exp $ + * $Id: RawAbstractInput.java,v 1.10.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawAccessor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawAccessor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawAccessor.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawAccessor.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawAccessor.java,v 1.9 2008/01/07 14:28:59 cwl Exp $ + * $Id: RawAccessor.java,v 1.9.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawArrayInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawArrayInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawArrayInput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawArrayInput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawArrayInput.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: RawArrayInput.java,v 1.6.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawComplexInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawComplexInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawComplexInput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawComplexInput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawComplexInput.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: RawComplexInput.java,v 1.6.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawSingleInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawSingleInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RawSingleInput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RawSingleInput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawSingleInput.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: RawSingleInput.java,v 1.6.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Reader.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Reader.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Reader.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Reader.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,15 +1,17 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Reader.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: Reader.java,v 1.6.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; import java.io.Serializable; +import com.sleepycat.persist.model.EntityModel; + /** * Interface to the "read object" methods of the Format class. For the * latest version format, the Format object provides the implementation of @@ -21,7 +23,10 @@ */ interface Reader extends Serializable { - void initializeReader(Catalog catalog, int initVersion, Format oldFormat); + void initializeReader(Catalog catalog, + EntityModel model, + int initVersion, + Format oldFormat); Object newInstance(EntityInput input, boolean rawAccess); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ReadOnlyCatalog.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ReadOnlyCatalog.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ReadOnlyCatalog.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ReadOnlyCatalog.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReadOnlyCatalog.java,v 1.12 2008/03/18 18:38:08 mark Exp $ + * $Id: ReadOnlyCatalog.java,v 1.12.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RecordInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RecordInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RecordInput.java 2008-05-16 13:33:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RecordInput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecordInput.java,v 1.9 2008/05/16 13:33:07 mark Exp $ + * $Id: RecordInput.java,v 1.9.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RecordOutput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RecordOutput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/RecordOutput.java 2008-05-16 13:33:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/RecordOutput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecordOutput.java,v 1.10 2008/05/16 13:33:07 mark Exp $ + * $Id: RecordOutput.java,v 1.10.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ReflectionAccessor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ReflectionAccessor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/ReflectionAccessor.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/ReflectionAccessor.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReflectionAccessor.java,v 1.23 2008/03/18 18:38:08 mark Exp $ + * $Id: ReflectionAccessor.java,v 1.23.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/SimpleCatalog.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/SimpleCatalog.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/SimpleCatalog.java 2008-03-18 19:38:08.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/SimpleCatalog.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SimpleCatalog.java,v 1.26 2008/03/18 18:38:08 mark Exp $ + * $Id: SimpleCatalog.java,v 1.26.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -191,7 +191,7 @@ */ private void setFormat(int id, SimpleFormat format) { format.setId(id); - format.initializeIfNeeded(this); + format.initializeIfNeeded(this, null /*model*/); formatList.set(id, format); formatMap.put(format.getClassName(), format); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/SimpleFormat.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/SimpleFormat.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/SimpleFormat.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/SimpleFormat.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SimpleFormat.java,v 1.24 2008/01/07 14:28:59 cwl Exp $ + * $Id: SimpleFormat.java,v 1.24.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -15,6 +15,7 @@ import java.util.Set; import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.persist.model.EntityModel; /** * Format for simple types, including primitives. Additional methods are @@ -60,7 +61,7 @@ } @Override - void initialize(Catalog catalog, int initVersion) { + void initialize(Catalog catalog, EntityModel model, int initVersion) { } @Override diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/StoredModel.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/StoredModel.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/StoredModel.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/StoredModel.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: StoredModel.java,v 1.12 2008/01/07 14:28:59 cwl Exp $ + * $Id: StoredModel.java,v 1.12.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Store.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Store.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/Store.java 2008-05-19 20:33:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/Store.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Store.java,v 1.36 2008/05/19 20:33:32 mark Exp $ + * $Id: Store.java,v 1.36.2.5 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; @@ -259,10 +259,6 @@ return storeName; } - public void dumpCatalog() { - catalog.dump(); - } - /* */ public static Set getStoreNames(Environment env) throws DatabaseException { @@ -1045,7 +1041,7 @@ rel == Relationship.MANY_TO_MANY); setBtreeComparator(config, secKeyMeta.getClassName()); PersistKeyCreator keyCreator = new PersistKeyCreator - (catalog, entityMeta, keyClassName, secKeyMeta); + (catalog, entityMeta, keyClassName, secKeyMeta, rawAccess); if (rel == Relationship.ONE_TO_MANY || rel == Relationship.MANY_TO_MANY) { config.setMultiKeyCreator(keyCreator); @@ -1322,9 +1318,10 @@ oneWritten = true; nWritten += 1; } + /* Update event stats, even if no listener. [#17024] */ + EvolveInternal.updateEvent + (event, entityClassName, 1, oneWritten ? 1 : 0); if (listener != null) { - EvolveInternal.updateEvent - (event, entityClassName, 1, oneWritten ? 1 : 0); if (!listener.evolveProgress(event)) { break; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/WidenerInput.java libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/WidenerInput.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/impl/WidenerInput.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/impl/WidenerInput.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: WidenerInput.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: WidenerInput.java,v 1.6.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.impl; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/KeySelector.java libdb-je-java-3.3.98/src/com/sleepycat/persist/KeySelector.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/KeySelector.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/KeySelector.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeySelector.java,v 1.9 2008/02/05 23:28:21 mark Exp $ + * $Id: KeySelector.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/KeysIndex.java libdb-je-java-3.3.98/src/com/sleepycat/persist/KeysIndex.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/KeysIndex.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/KeysIndex.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeysIndex.java,v 1.10 2008/02/05 23:28:21 mark Exp $ + * $Id: KeysIndex.java,v 1.10.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/KeyValueAdapter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/KeyValueAdapter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/KeyValueAdapter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/KeyValueAdapter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyValueAdapter.java,v 1.8 2008/01/07 14:28:58 cwl Exp $ + * $Id: KeyValueAdapter.java,v 1.8.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/AnnotationModel.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/AnnotationModel.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/AnnotationModel.java 2008-05-05 13:15:40.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/AnnotationModel.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: AnnotationModel.java,v 1.24 2008/05/05 13:15:40 mark Exp $ + * $Id: AnnotationModel.java,v 1.25.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; @@ -118,18 +118,25 @@ } /* Get instance fields. */ List fields = new ArrayList(); - for (Field field : type.getDeclaredFields()) { - int mods = field.getModifiers(); - if (!Modifier.isTransient(mods) && !Modifier.isStatic(mods)) { - fields.add(field); + boolean nonDefaultRules = getInstanceFields(fields, type); + Collection nonDefaultFields = null; + if (nonDefaultRules) { + nonDefaultFields = new ArrayList(fields.size()); + for (Field field : fields) { + nonDefaultFields.add(new FieldMetadata + (field.getName(), field.getType().getName(), + type.getName())); } + nonDefaultFields = + Collections.unmodifiableCollection(nonDefaultFields); } /* Get the rest of the metadata and save it. */ metadata = new ClassMetadata (className, version, proxiedClassName, isEntity, getPrimaryKey(type, fields), getSecondaryKeys(type, fields), - getCompositeKeyFields(type, fields)); + getCompositeKeyFields(type, fields), + nonDefaultFields); classMap.put(className, metadata); /* Add any new information about entities. */ updateEntityInfo(metadata); @@ -137,6 +144,45 @@ return metadata; } + /** + * Fills in the fields array and returns true if the default rules for + * field persistence were overridden. + */ + private boolean getInstanceFields(List fields, Class type) { + boolean nonDefaultRules = false; + for (Field field : type.getDeclaredFields()) { + boolean notPersistent = + (field.getAnnotation(NotPersistent.class) != null); + boolean notTransient = + (field.getAnnotation(NotTransient.class) != null); + if (notPersistent && notTransient) { + throw new IllegalArgumentException + ("Both @NotTransient and @NotPersistent not allowed"); + } + if (notPersistent || notTransient) { + nonDefaultRules = true; + } + int mods = field.getModifiers(); + + if (!Modifier.isStatic(mods) && + !notPersistent && + (!Modifier.isTransient(mods) || notTransient)) { + /* Field is DPL persistent. */ + fields.add(field); + } else { + /* If non-persistent, no other annotations should be used. */ + if (field.getAnnotation(PrimaryKey.class) != null || + field.getAnnotation(SecondaryKey.class) != null || + field.getAnnotation(KeyField.class) != null) { + throw new IllegalArgumentException + ("@PrimaryKey, @SecondaryKey and @KeyField not " + + "allowed on non-persistent field"); + } + } + } + return nonDefaultRules; + } + private PrimaryKeyMetadata getPrimaryKey(Class type, List fields) { Field foundField = null; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/BytecodeEnhancer.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/BytecodeEnhancer.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/BytecodeEnhancer.java 2008-05-30 14:04:18.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/BytecodeEnhancer.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BytecodeEnhancer.java,v 1.16 2008/05/30 14:04:18 mark Exp $ + * $Id: BytecodeEnhancer.java,v 1.17.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; @@ -171,8 +171,9 @@ throw abort(); } FieldVisitor ret = super.visitField(access, name, desc, sig, value); - if ((access & (ACC_STATIC | ACC_TRANSIENT)) == 0) { - FieldInfo info = new FieldInfo(ret, name, desc); + if ((access & ACC_STATIC) == 0) { + FieldInfo info = new FieldInfo(ret, name, desc, + (access & ACC_TRANSIENT) != 0); nonKeyFields.add(info); ret = info; } @@ -247,7 +248,9 @@ } else { for (int i = 0; i < nonKeyFields.size();) { FieldInfo field = nonKeyFields.get(i); - if (field.isPriKey) { + if (field.isTransient) { + nonKeyFields.remove(i); + } else if (field.isPriKey) { if (priKeyField == null) { priKeyField = field; nonKeyFields.remove(i); @@ -1453,10 +1456,15 @@ OrderInfo order; boolean isPriKey; boolean isSecKey; + boolean isTransient; - FieldInfo(FieldVisitor parent, String name, String desc) { + FieldInfo(FieldVisitor parent, + String name, + String desc, + boolean isTransient) { this.parent = parent; this.name = name; + this.isTransient = isTransient; type = Type.getType(desc); } @@ -1473,6 +1481,12 @@ } else if (desc.equals ("Lcom/sleepycat/persist/model/SecondaryKey;")) { isSecKey = true; + } else if (desc.equals + ("Lcom/sleepycat/persist/model/NotPersistent;")) { + isTransient = true; + } else if (desc.equals + ("Lcom/sleepycat/persist/model/NotTransient;")) { + isTransient = false; } return ret; } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ClassEnhancer.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ClassEnhancer.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ClassEnhancer.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ClassEnhancer.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ClassEnhancer.java,v 1.18 2008/02/05 23:28:22 mark Exp $ + * $Id: ClassEnhancer.java,v 1.18.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ClassEnhancerTask.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ClassEnhancerTask.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ClassEnhancerTask.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ClassEnhancerTask.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ClassEnhancerTask.java,v 1.11 2008/01/07 14:28:59 cwl Exp $ + * $Id: ClassEnhancerTask.java,v 1.11.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ClassMetadata.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ClassMetadata.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ClassMetadata.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ClassMetadata.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,14 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ClassMetadata.java,v 1.13 2008/01/07 14:28:59 cwl Exp $ + * $Id: ClassMetadata.java,v 1.14.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; import java.io.Serializable; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -37,9 +38,11 @@ private PrimaryKeyMetadata primaryKey; private Map secondaryKeys; private List compositeKeyFields; + private Collection persistentFields; /** * Used by an {@code EntityModel} to construct persistent class metadata. + * The optional {@link #getPersistentFields} property will be set to null. */ public ClassMetadata(String className, int version, @@ -48,6 +51,22 @@ PrimaryKeyMetadata primaryKey, Map secondaryKeys, List compositeKeyFields) { + + this(className, version, proxiedClassName, entityClass, primaryKey, + secondaryKeys, compositeKeyFields, null /*persistentFields*/); + } + + /** + * Used by an {@code EntityModel} to construct persistent class metadata. + */ + public ClassMetadata(String className, + int version, + String proxiedClassName, + boolean entityClass, + PrimaryKeyMetadata primaryKey, + Map secondaryKeys, + List compositeKeyFields, + Collection persistentFields) { this.className = className; this.version = version; this.proxiedClassName = proxiedClassName; @@ -55,6 +74,7 @@ this.primaryKey = primaryKey; this.secondaryKeys = secondaryKeys; this.compositeKeyFields = compositeKeyFields; + this.persistentFields = persistentFields; } /** @@ -119,6 +139,23 @@ return compositeKeyFields; } + /** + * Returns an unmodifiable list of metadata for the persistent fields in + * this class, or null if the default rules for persistent fields should be + * used. All fields returned must be declared in this class and must be + * non-static. + * + *

By default (if null is returned) the persistent fields of a class + * will be all declared instance fields that are non-transient (are not + * declared with the transient keyword). The default rules + * may be overridden by an {@link EntityModel}. For example, the {@link + * AnnotationModel} overrides the default rules when the {@link + * NotPersistent} or {@link NotTransient} annotation is specified.

+ */ + public Collection getPersistentFields() { + return persistentFields; + } + @Override public boolean equals(Object other) { if (other instanceof ClassMetadata) { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/DeleteAction.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/DeleteAction.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/DeleteAction.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/DeleteAction.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DeleteAction.java,v 1.8 2008/01/07 14:28:59 cwl Exp $ + * $Id: DeleteAction.java,v 1.8.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/Entity.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/Entity.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/Entity.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/Entity.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Entity.java,v 1.15 2008/01/07 14:28:59 cwl Exp $ + * $Id: Entity.java,v 1.15.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/EntityMetadata.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/EntityMetadata.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/EntityMetadata.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/EntityMetadata.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityMetadata.java,v 1.13 2008/01/07 14:28:59 cwl Exp $ + * $Id: EntityMetadata.java,v 1.13.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/EntityModel.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/EntityModel.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/EntityModel.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/EntityModel.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntityModel.java,v 1.20 2008/01/07 14:28:59 cwl Exp $ + * $Id: EntityModel.java,v 1.20.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; @@ -214,6 +214,22 @@ } /** + * Returns all versions of all known types. + * + * @return an unmodifiable list of types. + * + * @throws IllegalStateException if this method is called for a model that + * is not associated with an open store. + */ + public final List getAllRawTypes() { + if (catalog != null) { + return catalog.getAllRawTypes(); + } else { + throw new IllegalStateException("Store is not open"); + } + } + + /** * Converts a given raw object to a live object according to the current * class definitions. * diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/FieldMetadata.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/FieldMetadata.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/FieldMetadata.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/FieldMetadata.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FieldMetadata.java,v 1.12 2008/01/07 14:28:59 cwl Exp $ + * $Id: FieldMetadata.java,v 1.13.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; @@ -78,4 +78,10 @@ ClassMetadata.hashCode(className) + ClassMetadata.hashCode(declaringClassName); } + + @Override + public String toString() { + return "[FieldMetadata name: " + name + " className: " + className + + " declaringClassName: " + declaringClassName + ']'; + } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/KeyField.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/KeyField.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/KeyField.java 2008-02-27 21:58:14.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/KeyField.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyField.java,v 1.12 2008/02/27 21:58:14 mark Exp $ + * $Id: KeyField.java,v 1.12.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ModelInternal.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ModelInternal.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/ModelInternal.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/ModelInternal.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ModelInternal.java,v 1.9 2008/02/05 23:28:22 mark Exp $ + * $Id: ModelInternal.java,v 1.9.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/NotPersistent.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/NotPersistent.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/NotPersistent.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/NotPersistent.java 2010-03-22 21:53:34.000000000 +0000 @@ -0,0 +1,42 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002,2010 Oracle. All rights reserved. + * + * $Id: NotPersistent.java,v 1.1.2.3 2010/03/22 21:53:33 mark Exp $ + */ + +package com.sleepycat.persist.model; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Overrides the default rules for field persistence and defines a field as + * being non-persistent even when it is not declared with the + * transient keyword. + * + *

By default, the persistent fields of a class are all declared instance + * fields that are non-transient (are not declared with the + * transient keyword). The default rules may be overridden by + * specifying the {@link NotPersistent} or {@link NotTransient} annotation.

+ * + *

For example, the following field is non-transient (persistent) with + * respect to Java serialization but is transient with respect to the DPL.

+ * + *
+ *      {@code @NotPersistent}
+ *      int myField;
+ * }
+ * 
+ * + * @see NotTransient + * @author Mark Hayes + */ +@Documented @Retention(RUNTIME) @Target(FIELD) +public @interface NotPersistent { +} diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/NotTransient.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/NotTransient.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/NotTransient.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/NotTransient.java 2010-03-22 21:53:34.000000000 +0000 @@ -0,0 +1,42 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002,2010 Oracle. All rights reserved. + * + * $Id: NotTransient.java,v 1.1.2.3 2010/03/22 21:53:33 mark Exp $ + */ + +package com.sleepycat.persist.model; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Overrides the default rules for field persistence and defines a field as + * being persistent even when it is declared with the transient + * keyword. + * + *

By default, the persistent fields of a class are all declared instance + * fields that are non-transient (are not declared with the + * transient keyword). The default rules may be overridden by + * specifying the {@link NotPersistent} or {@link NotTransient} annotation.

+ * + *

For example, the following field is transient with respect to Java + * serialization but is persistent with respect to the DPL.

+ * + *
+ *      {@code @NotTransient}
+ *      transient int myField;
+ * }
+ * 
+ * + * @see NotPersistent + * @author Mark Hayes + */ +@Documented @Retention(RUNTIME) @Target(FIELD) +public @interface NotTransient { +} diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/Persistent.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/Persistent.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/Persistent.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/Persistent.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Persistent.java,v 1.8 2008/01/07 14:28:59 cwl Exp $ + * $Id: Persistent.java,v 1.8.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/PersistentProxy.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/PersistentProxy.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/PersistentProxy.java 2008-05-13 16:29:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/PersistentProxy.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PersistentProxy.java,v 1.17 2008/05/13 16:29:35 mark Exp $ + * $Id: PersistentProxy.java,v 1.17.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/PrimaryKey.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/PrimaryKey.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/PrimaryKey.java 2008-03-17 23:52:52.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/PrimaryKey.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrimaryKey.java,v 1.15 2008/03/17 22:52:52 mark Exp $ + * $Id: PrimaryKey.java,v 1.15.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/PrimaryKeyMetadata.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/PrimaryKeyMetadata.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/PrimaryKeyMetadata.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/PrimaryKeyMetadata.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrimaryKeyMetadata.java,v 1.14 2008/01/07 14:28:59 cwl Exp $ + * $Id: PrimaryKeyMetadata.java,v 1.14.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/Relationship.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/Relationship.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/Relationship.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/Relationship.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Relationship.java,v 1.6 2008/01/07 14:28:59 cwl Exp $ + * $Id: Relationship.java,v 1.6.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/SecondaryKey.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/SecondaryKey.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/SecondaryKey.java 2008-04-24 22:51:04.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/SecondaryKey.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryKey.java,v 1.12 2008/04/24 22:51:03 mark Exp $ + * $Id: SecondaryKey.java,v 1.12.2.2 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/model/SecondaryKeyMetadata.java libdb-je-java-3.3.98/src/com/sleepycat/persist/model/SecondaryKeyMetadata.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/model/SecondaryKeyMetadata.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/model/SecondaryKeyMetadata.java 2010-01-04 15:30:40.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryKeyMetadata.java,v 1.15 2008/01/07 14:28:59 cwl Exp $ + * $Id: SecondaryKeyMetadata.java,v 1.15.2.3 2010/01/04 15:30:39 cwl Exp $ */ package com.sleepycat.persist.model; @@ -100,7 +100,7 @@ SecondaryKeyMetadata o = (SecondaryKeyMetadata) other; return super.equals(o) && relationship == o.relationship && - deleteAction == o.deleteAction && + ClassMetadata.nullOrEqual(deleteAction, o.deleteAction) && ClassMetadata.nullOrEqual(keyName, o.keyName) && ClassMetadata.nullOrEqual(elementClassName, o.elementClassName) && @@ -114,7 +114,7 @@ public int hashCode() { return super.hashCode() + relationship.hashCode() + - deleteAction.hashCode() + + ClassMetadata.hashCode(deleteAction) + ClassMetadata.hashCode(keyName) + ClassMetadata.hashCode(elementClassName) + ClassMetadata.hashCode(relatedEntity); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/PrimaryIndex.java libdb-je-java-3.3.98/src/com/sleepycat/persist/PrimaryIndex.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/PrimaryIndex.java 2008-05-27 15:30:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/PrimaryIndex.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrimaryIndex.java,v 1.21 2008/05/27 15:30:36 mark Exp $ + * $Id: PrimaryIndex.java,v 1.21.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/PrimaryKeyValueAdapter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/PrimaryKeyValueAdapter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/PrimaryKeyValueAdapter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/PrimaryKeyValueAdapter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PrimaryKeyValueAdapter.java,v 1.8 2008/01/07 14:28:58 cwl Exp $ + * $Id: PrimaryKeyValueAdapter.java,v 1.8.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawField.java libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawField.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawField.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawField.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawField.java,v 1.10 2008/01/07 14:29:00 cwl Exp $ + * $Id: RawField.java,v 1.10.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.persist.raw; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawObject.java libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawObject.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawObject.java 2008-05-27 15:22:16.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawObject.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawObject.java,v 1.15 2008/05/27 15:22:16 mark Exp $ + * $Id: RawObject.java,v 1.15.2.3 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.persist.raw; @@ -216,6 +216,9 @@ (superObject != null ? superObject.hashCode() : 0); } + /** + * Returns an XML representation of the raw object. + */ @Override public String toString() { StringBuffer buf = new StringBuffer(500); @@ -227,52 +230,60 @@ String indent, String id, boolean isSuper) { - String indent2 = indent + INDENT; - String endTag; - buf.append(indent); - if (type.isArray()) { - buf.append(""); + buf.append(enumConstant); + buf.append("\n"); } else { - buf.append("\n"); + if (type.isArray()) { + buf.append(" length=\""); + buf.append(elements.length); + buf.append('"'); + } + buf.append(" class=\""); + buf.append(type.getClassName()); + buf.append("\" typeId=\""); + buf.append(type.getId()); + buf.append("\">\n"); - if (superObject != null) { - superObject.formatRawObject(buf, indent2, null, true); - } - if (type.isArray()) { - for (int i = 0; i < elements.length; i += 1) { - formatValue(buf, indent2, String.valueOf(i), elements[i]); + if (superObject != null) { + superObject.formatRawObject(buf, indent2, null, true); } - } else if (type.isEnum()) { - buf.append(enumConstant); - } else { - TreeSet keys = new TreeSet(values.keySet()); - for (String name : keys) { - formatValue(buf, indent2, name, values.get(name)); + if (type.isArray()) { + for (int i = 0; i < elements.length; i += 1) { + formatValue(buf, indent2, String.valueOf(i), elements[i]); + } + } else { + TreeSet keys = new TreeSet(values.keySet()); + for (String name : keys) { + formatValue(buf, indent2, name, values.get(name)); + } } + buf.append(indent); + buf.append(endTag); + buf.append("\n"); } - buf.append(indent); - buf.append(endTag); - buf.append("\n"); } private static void formatValue(StringBuffer buf, @@ -299,12 +310,14 @@ } private static void formatId(StringBuffer buf, String id) { - if (Character.isDigit(id.charAt(0))) { - buf.append(" index=\""); - } else { - buf.append(" field=\""); + if (id != null) { + if (Character.isDigit(id.charAt(0))) { + buf.append(" index=\""); + } else { + buf.append(" field=\""); + } + buf.append(id); + buf.append('"'); } - buf.append(id); - buf.append('"'); } } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawStore.java libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawStore.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawStore.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawStore.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawStore.java,v 1.16 2008/01/07 14:29:00 cwl Exp $ + * $Id: RawStore.java,v 1.16.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.persist.raw; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawType.java libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawType.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/raw/RawType.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/raw/RawType.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RawType.java,v 1.12 2008/01/07 14:29:00 cwl Exp $ + * $Id: RawType.java,v 1.12.2.3 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.persist.raw; @@ -11,7 +11,9 @@ import java.util.List; import java.util.Map; +import com.sleepycat.persist.model.ClassMetadata; import com.sleepycat.persist.model.Entity; +import com.sleepycat.persist.model.EntityMetadata; import com.sleepycat.persist.model.Persistent; /** @@ -47,6 +49,11 @@ int getVersion(); /** + * Returns the internal unique ID for this type. + */ + int getId(); + + /** * Returns whether this is a {@link simple type}: primitive, * primitive wrapper, BigInteger, String or Date. @@ -132,4 +139,21 @@ * an array type). */ RawType getSuperType(); + + /** + * Returns the original model class metadata used to create this class, or + * null if this is not a model class. + */ + ClassMetadata getClassMetadata(); + + /** + * Returns the original model entity metadata used to create this class, or + * null if this is not an entity class. + */ + EntityMetadata getEntityMetadata(); + + /** + * Returns an XML representation of the raw type. + */ + String toString(); } diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/SecondaryIndex.java libdb-je-java-3.3.98/src/com/sleepycat/persist/SecondaryIndex.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/SecondaryIndex.java 2008-05-27 15:30:36.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/SecondaryIndex.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryIndex.java,v 1.19 2008/05/27 15:30:36 mark Exp $ + * $Id: SecondaryIndex.java,v 1.19.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/StoreConfig.java libdb-je-java-3.3.98/src/com/sleepycat/persist/StoreConfig.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/StoreConfig.java 2008-05-19 20:33:32.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/StoreConfig.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: StoreConfig.java,v 1.18 2008/05/19 20:33:31 mark Exp $ + * $Id: StoreConfig.java,v 1.18.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/SubIndexCursor.java libdb-je-java-3.3.98/src/com/sleepycat/persist/SubIndexCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/SubIndexCursor.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/SubIndexCursor.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SubIndexCursor.java,v 1.8 2008/02/05 23:28:21 mark Exp $ + * $Id: SubIndexCursor.java,v 1.9.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; @@ -26,12 +26,14 @@ super(cursor, adapter, false/*updateAllowed*/); } + @Override public EntityCursor dup() throws DatabaseException { return new SubIndexCursor(cursor.dup(true), adapter); } + @Override public V nextDup(LockMode lockMode) throws DatabaseException { @@ -39,12 +41,14 @@ return null; } + @Override public V nextNoDup(LockMode lockMode) throws DatabaseException { return returnValue(cursor.getNext(key, pkey, data, lockMode)); } + @Override public V prevDup(LockMode lockMode) throws DatabaseException { @@ -52,6 +56,7 @@ return null; } + @Override public V prevNoDup(LockMode lockMode) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/SubIndex.java libdb-je-java-3.3.98/src/com/sleepycat/persist/SubIndex.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/SubIndex.java 2008-02-05 23:28:22.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/SubIndex.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SubIndex.java,v 1.16 2008/02/05 23:28:21 mark Exp $ + * $Id: SubIndex.java,v 1.16.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/persist/ValueAdapter.java libdb-je-java-3.3.98/src/com/sleepycat/persist/ValueAdapter.java --- libdb-je-java-3.3.62/src/com/sleepycat/persist/ValueAdapter.java 2008-01-07 14:28:58.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/persist/ValueAdapter.java 2010-01-04 15:30:38.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ValueAdapter.java,v 1.7 2008/01/07 14:28:58 cwl Exp $ + * $Id: ValueAdapter.java,v 1.7.2.2 2010/01/04 15:30:38 cwl Exp $ */ package com.sleepycat.persist; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/util/FastInputStream.java libdb-je-java-3.3.98/src/com/sleepycat/util/FastInputStream.java --- libdb-je-java-3.3.62/src/com/sleepycat/util/FastInputStream.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/util/FastInputStream.java 2008-06-10 02:52:18.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: FastInputStream.java,v 1.20 2008/01/07 14:29:00 cwl Exp $ + * $Id: FastInputStream.java,v 1.21 2008/06/10 02:52:17 cwl Exp $ */ package com.sleepycat.util; @@ -59,26 +59,31 @@ // --- begin ByteArrayInputStream compatible methods --- + @Override public int available() { return len - off; } + @Override public boolean markSupported() { return true; } + @Override public void mark(int readLimit) { mark = off; } + @Override public void reset() { off = mark; } + @Override public long skip(long count) { int myCount = (int) count; @@ -89,16 +94,19 @@ return myCount; } + @Override public int read() throws IOException { return readFast(); } + @Override public int read(byte[] toBuf) throws IOException { return readFast(toBuf, 0, toBuf.length); } + @Override public int read(byte[] toBuf, int offset, int length) throws IOException { return readFast(toBuf, offset, length); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/util/FastOutputStream.java libdb-je-java-3.3.98/src/com/sleepycat/util/FastOutputStream.java --- libdb-je-java-3.3.62/src/com/sleepycat/util/FastOutputStream.java 2008-01-07 14:29:00.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/util/FastOutputStream.java 2008-06-10 02:52:18.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: FastOutputStream.java,v 1.23 2008/01/07 14:29:00 cwl Exp $ + * $Id: FastOutputStream.java,v 1.24 2008/06/10 02:52:17 cwl Exp $ */ package com.sleepycat.util; @@ -128,11 +128,13 @@ writeFast(b); } + @Override public void write(byte[] fromBuf) throws IOException { writeFast(fromBuf); } + @Override public void write(byte[] fromBuf, int offset, int length) throws IOException { @@ -144,6 +146,7 @@ out.write(buf, 0, len); } + @Override public String toString() { return new String(buf, 0, len); diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/util/IOExceptionWrapper.java libdb-je-java-3.3.98/src/com/sleepycat/util/IOExceptionWrapper.java --- libdb-je-java-3.3.62/src/com/sleepycat/util/IOExceptionWrapper.java 2008-05-20 17:52:38.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/util/IOExceptionWrapper.java 2008-06-10 02:52:18.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: IOExceptionWrapper.java,v 1.19 2008/05/20 17:52:37 linda Exp $ + * $Id: IOExceptionWrapper.java,v 1.20 2008/06/10 02:52:17 cwl Exp $ */ package com.sleepycat.util; @@ -34,6 +34,7 @@ return e; } + @Override public Throwable getCause() { return e; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/util/keyrange/KeyRange.java libdb-je-java-3.3.98/src/com/sleepycat/util/keyrange/KeyRange.java --- libdb-je-java-3.3.62/src/com/sleepycat/util/keyrange/KeyRange.java 2008-05-19 17:52:20.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/util/keyrange/KeyRange.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyRange.java,v 1.8 2008/05/19 17:52:20 linda Exp $ + * $Id: KeyRange.java,v 1.9.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.util.keyrange; @@ -109,6 +109,7 @@ /** * Formats this range as a string for debugging. */ + @Override public String toString() { return "[KeyRange " + beginKey + ' ' + beginInclusive + diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/util/keyrange/RangeCursor.java libdb-je-java-3.3.98/src/com/sleepycat/util/keyrange/RangeCursor.java --- libdb-je-java-3.3.62/src/com/sleepycat/util/keyrange/RangeCursor.java 2008-02-05 23:28:24.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/util/keyrange/RangeCursor.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RangeCursor.java,v 1.10 2008/02/05 23:28:23 mark Exp $ + * $Id: RangeCursor.java,v 1.10.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.util.keyrange; diff -Nru libdb-je-java-3.3.62/src/com/sleepycat/util/RuntimeExceptionWrapper.java libdb-je-java-3.3.98/src/com/sleepycat/util/RuntimeExceptionWrapper.java --- libdb-je-java-3.3.62/src/com/sleepycat/util/RuntimeExceptionWrapper.java 2008-05-20 17:52:38.000000000 +0000 +++ libdb-je-java-3.3.98/src/com/sleepycat/util/RuntimeExceptionWrapper.java 2008-06-10 02:52:18.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: RuntimeExceptionWrapper.java,v 1.18 2008/05/20 17:52:37 linda Exp $ + * $Id: RuntimeExceptionWrapper.java,v 1.19 2008/06/10 02:52:17 cwl Exp $ */ package com.sleepycat.util; @@ -32,6 +32,7 @@ return e; } + @Override public Throwable getCause() { return e; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/MarshalledObject.java libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/MarshalledObject.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/MarshalledObject.java 2008-05-20 17:52:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/MarshalledObject.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MarshalledObject.java,v 1.23 2008/05/20 17:52:38 linda Exp $ + * $Id: MarshalledObject.java,v 1.23.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.serial.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/NullClassCatalog.java libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/NullClassCatalog.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/NullClassCatalog.java 2008-01-07 14:29:02.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/NullClassCatalog.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NullClassCatalog.java,v 1.20 2008/01/07 14:29:01 cwl Exp $ + * $Id: NullClassCatalog.java,v 1.20.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.serial.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/SerialBindingTest.java libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/SerialBindingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/SerialBindingTest.java 2008-05-30 14:04:18.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/SerialBindingTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SerialBindingTest.java,v 1.37 2008/05/30 14:04:18 mark Exp $ + * $Id: SerialBindingTest.java,v 1.37.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.serial.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/TestClassCatalog.java libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/TestClassCatalog.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/serial/test/TestClassCatalog.java 2008-01-07 14:29:02.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/serial/test/TestClassCatalog.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestClassCatalog.java,v 1.18 2008/01/07 14:29:01 cwl Exp $ + * $Id: TestClassCatalog.java,v 1.18.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.serial.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/test/BindingSpeedTest.java libdb-je-java-3.3.98/test/com/sleepycat/bind/test/BindingSpeedTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/test/BindingSpeedTest.java 2008-05-30 14:04:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/test/BindingSpeedTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BindingSpeedTest.java,v 1.31 2008/05/30 14:04:19 mark Exp $ + * $Id: BindingSpeedTest.java,v 1.31.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/MarshalledObject.java libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/MarshalledObject.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/MarshalledObject.java 2008-01-07 14:29:02.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/MarshalledObject.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MarshalledObject.java,v 1.22 2008/01/07 14:29:02 cwl Exp $ + * $Id: MarshalledObject.java,v 1.22.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.tuple.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/TupleBindingTest.java libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/TupleBindingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/TupleBindingTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/TupleBindingTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TupleBindingTest.java,v 1.41 2008/02/05 23:28:25 mark Exp $ + * $Id: TupleBindingTest.java,v 1.41.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.tuple.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/TupleFormatTest.java libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/TupleFormatTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/TupleFormatTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/TupleFormatTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TupleFormatTest.java,v 1.29 2008/02/05 23:28:25 mark Exp $ + * $Id: TupleFormatTest.java,v 1.29.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.tuple.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/TupleOrderingTest.java libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/TupleOrderingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/bind/tuple/test/TupleOrderingTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/bind/tuple/test/TupleOrderingTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TupleOrderingTest.java,v 1.27 2008/02/05 23:28:25 mark Exp $ + * $Id: TupleOrderingTest.java,v 1.27.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.bind.tuple.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/KeyRangeTest.java libdb-je-java-3.3.98/test/com/sleepycat/collections/KeyRangeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/KeyRangeTest.java 2008-05-30 14:04:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/KeyRangeTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyRangeTest.java,v 1.45 2008/05/30 14:04:19 mark Exp $ + * $Id: KeyRangeTest.java,v 1.45.2.2 2010/01/04 15:30:41 cwl Exp $ */ package com.sleepycat.collections; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/CollectionTest.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/CollectionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/CollectionTest.java 2008-05-28 14:50:08.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/CollectionTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CollectionTest.java,v 1.63 2008/05/28 14:50:07 mark Exp $ + * $Id: CollectionTest.java,v 1.63.2.3 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; @@ -21,6 +21,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; +import java.util.concurrent.ConcurrentMap; import junit.framework.Test; import junit.framework.TestCase; @@ -370,7 +371,7 @@ assertEquals(expectSize, cont.size()); } - void testMapCreation(Map map) + void testMapCreation(ConcurrentMap map) throws Exception { assertTrue(map.values() instanceof Set); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/IterDeadlockTest.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/IterDeadlockTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/IterDeadlockTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/IterDeadlockTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: IterDeadlockTest.java,v 1.10 2008/02/05 23:28:25 mark Exp $ + * $Id: IterDeadlockTest.java,v 1.10.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/NullTransactionRunner.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/NullTransactionRunner.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/NullTransactionRunner.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/NullTransactionRunner.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NullTransactionRunner.java,v 1.18 2008/01/07 14:29:03 cwl Exp $ + * $Id: NullTransactionRunner.java,v 1.18.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/SecondaryDeadlockTest.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/SecondaryDeadlockTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/SecondaryDeadlockTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/SecondaryDeadlockTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryDeadlockTest.java,v 1.13 2008/02/05 23:28:25 mark Exp $ + * $Id: SecondaryDeadlockTest.java,v 1.13.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestDataBinding.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestDataBinding.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestDataBinding.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestDataBinding.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestDataBinding.java,v 1.26 2008/01/07 14:29:03 cwl Exp $ + * $Id: TestDataBinding.java,v 1.26.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestEntityBinding.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestEntityBinding.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestEntityBinding.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestEntityBinding.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestEntityBinding.java,v 1.25 2008/01/07 14:29:03 cwl Exp $ + * $Id: TestEntityBinding.java,v 1.25.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestEntity.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestEntity.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestEntity.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestEntity.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestEntity.java,v 1.15 2008/01/07 14:29:03 cwl Exp $ + * $Id: TestEntity.java,v 1.15.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestKeyAssigner.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestKeyAssigner.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestKeyAssigner.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestKeyAssigner.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestKeyAssigner.java,v 1.22 2008/01/07 14:29:03 cwl Exp $ + * $Id: TestKeyAssigner.java,v 1.22.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestKeyCreator.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestKeyCreator.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestKeyCreator.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestKeyCreator.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestKeyCreator.java,v 1.26 2008/01/07 14:29:03 cwl Exp $ + * $Id: TestKeyCreator.java,v 1.26.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestSR15721.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestSR15721.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestSR15721.java 2008-02-06 19:48:02.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestSR15721.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestSR15721.java,v 1.8 2008/02/06 19:48:02 linda Exp $ + * $Id: TestSR15721.java,v 1.8.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestStore.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestStore.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TestStore.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TestStore.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestStore.java,v 1.44 2008/02/05 23:28:25 mark Exp $ + * $Id: TestStore.java,v 1.44.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TransactionTest.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TransactionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/TransactionTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/TransactionTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TransactionTest.java,v 1.53 2008/02/05 23:28:26 mark Exp $ + * $Id: TransactionTest.java,v 1.53.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/collections/test/XACollectionTest.java libdb-je-java-3.3.98/test/com/sleepycat/collections/test/XACollectionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/collections/test/XACollectionTest.java 2008-02-05 23:28:26.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/collections/test/XACollectionTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: XACollectionTest.java,v 1.9 2008/02/05 23:28:26 mark Exp $ + * $Id: XACollectionTest.java,v 1.9.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.collections.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/ApiTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/ApiTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/ApiTest.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/ApiTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ApiTest.java,v 1.19 2008/01/07 14:29:04 cwl Exp $ + * $Id: ApiTest.java,v 1.19.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/BackgroundIOTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/BackgroundIOTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/BackgroundIOTest.java 2008-04-18 22:57:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/BackgroundIOTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BackgroundIOTest.java,v 1.10 2008/04/18 22:57:38 mark Exp $ + * $Id: BackgroundIOTest.java,v 1.10.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/CleanerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/CleanerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/CleanerTest.java 2008-05-23 18:50:50.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/CleanerTest.java 2010-01-30 01:10:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CleanerTest.java,v 1.102 2008/05/23 18:50:50 mark Exp $ + * $Id: CleanerTest.java,v 1.103.2.8 2010/01/30 01:10:55 mark Exp $ */ package com.sleepycat.je.cleaner; @@ -37,6 +37,7 @@ import com.sleepycat.je.StatsConfig; import com.sleepycat.je.Transaction; import com.sleepycat.je.cleaner.Cleaner; +import com.sleepycat.je.cleaner.FileSelector; import com.sleepycat.je.cleaner.FileSummary; import com.sleepycat.je.cleaner.TrackedFileSummary; import com.sleepycat.je.cleaner.UtilizationProfile; @@ -45,11 +46,13 @@ import com.sleepycat.je.dbi.DatabaseImpl; import com.sleepycat.je.dbi.EnvironmentImpl; import com.sleepycat.je.dbi.MemoryBudget; +import com.sleepycat.je.junit.JUnitThread; import com.sleepycat.je.log.FileManager; import com.sleepycat.je.recovery.Checkpointer; import com.sleepycat.je.tree.BIN; import com.sleepycat.je.tree.FileSummaryLN; import com.sleepycat.je.tree.IN; +import com.sleepycat.je.tree.Node; import com.sleepycat.je.txn.BasicLocker; import com.sleepycat.je.txn.LockType; import com.sleepycat.je.util.StringDbt; @@ -71,6 +74,8 @@ private Environment exampleEnv; private Database exampleDb; private CheckpointConfig forceConfig; + private JUnitThread junitThread; + private volatile int synchronizer; public CleanerTest() { envHome = new File(System.getProperty(TestUtils.DEST_DIR)); @@ -95,8 +100,6 @@ envConfig.setTxnNoSync(Boolean.getBoolean(TestUtils.NO_SYNC)); envConfig.setConfigParam(EnvironmentParams.LOG_FILE_MAX.getName(), Integer.toString(FILE_SIZE)); - envConfig.setConfigParam(EnvironmentParams.ENV_CHECK_LEAKS.getName(), - "false"); envConfig.setConfigParam(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); envConfig.setConfigParam(EnvironmentParams.CLEANER_REMOVE.getName(), @@ -109,10 +112,6 @@ envConfig.setConfigParam(EnvironmentParams.BIN_DELTA_PERCENT.getName(), "75"); - /* Don't use detail tracking in this test. */ - envConfig.setConfigParam - (EnvironmentParams.CLEANER_TRACK_DETAIL.getName(), "false"); - exampleEnv = new Environment(envHome, envConfig); String databaseName = "cleanerDb"; @@ -126,6 +125,14 @@ public void tearDown() throws IOException, DatabaseException { + if (junitThread != null) { + while (junitThread.isAlive()) { + junitThread.interrupt(); + Thread.yield(); + } + junitThread = null; + } + if (exampleEnv != null) { try { exampleEnv.close(); @@ -136,7 +143,7 @@ exampleDb = null; exampleEnv = null; - /* + //* try { TestUtils.removeLogFiles("TearDown", envHome, true); TestUtils.removeFiles("TearDown", envHome, FileManager.DEL_SUFFIX); @@ -190,7 +197,8 @@ EnvironmentImpl environment = DbInternal.envGetEnvironmentImpl(exampleEnv); FileManager fileManager = environment.getFileManager(); - Map expectedMap = new HashMap(); + Map> expectedMap = + new HashMap>(); doLargePut(expectedMap, nKeys, nDupsPerKey, true); Long lastNum = fileManager.getLastFileNum(); @@ -246,7 +254,8 @@ DbInternal.envGetEnvironmentImpl(exampleEnv); FileManager fileManager = environment.getFileManager(); /* Insert a lot of keys. ExpectedMap holds the expected data */ - Map expectedMap = new HashMap(); + Map> expectedMap = + new HashMap>(); doLargePut(expectedMap, nKeys, 1, true); /* Modify every other piece of data. */ @@ -302,7 +311,8 @@ FileManager fileManager = environment.getFileManager(); /* Insert some non dup data, modify, insert dup data. */ - Map expectedMap = new HashMap(); + Map> expectedMap = + new HashMap>(); doLargePut(expectedMap, nKeys, 1, true); modifyData(expectedMap, 10, true); doLargePut(expectedMap, nKeys, nDupsPerKey, true); @@ -504,6 +514,84 @@ } /** + * Tests that the FileSelector memory budget is subtracted when the + * environment is closed. Before the fix in SR [#16368], it was not. + */ + public void testFileSelectorMemBudget() + throws Throwable { + + final int fileSize = 1000000; + EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + envConfig.setAllowCreate(true); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false"); + envConfig.setConfigParam + (EnvironmentParams.LOG_FILE_MAX.getName(), + Integer.toString(fileSize)); + envConfig.setConfigParam + (EnvironmentParams.CLEANER_MIN_UTILIZATION.getName(), "80"); + Environment env = new Environment(envHome, envConfig); + + DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate(true); + Database db = env.openDatabase(null, "foo", dbConfig); + + DatabaseEntry key = new DatabaseEntry(new byte[1]); + DatabaseEntry data = new DatabaseEntry(new byte[fileSize]); + for (int i = 0; i <= 10; i += 1) { + db.put(null, key, data); + } + env.checkpoint(forceConfig); + + int nFiles = env.cleanLog(); + assertTrue(nFiles > 0); + + db.close(); + + /* + * To force the memory leak to be detected we have to close without a + * checkpoint. The checkpoint will finish processing all cleaned files + * and subtract them from the budget. But this should happen during + * close, even without a checkpoint. + */ + EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env); + envImpl.close(false /*doCheckpoint*/); + } + + /** + * Tests that the cleanLog cannot be called in a read-only environment. + * [#16368] + */ + public void testCleanLogReadOnly() + throws Throwable { + + /* Open read-write. */ + EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + envConfig.setAllowCreate(true); + exampleEnv = new Environment(envHome, envConfig); + exampleEnv.close(); + exampleEnv = null; + + /* Open read-only. */ + envConfig.setAllowCreate(false); + envConfig.setReadOnly(true); + exampleEnv = new Environment(envHome, envConfig); + + /* Try cleanLog in a read-only env. */ + try { + exampleEnv.cleanLog(); + fail(); + } catch (IllegalStateException e) { + assertEquals + ("Log cleaning not allowed in a read-only or memory-only " + + "environment", e.getMessage()); + + } + } + + /** * Tests that when a file being cleaned is deleted, we ignore the error and * don't repeatedly try to clean it. This is happening when we mistakedly * clean a file after it has been queued for deletion. The workaround is @@ -517,7 +605,7 @@ initEnv(true, false); EnvironmentMutableConfig config = exampleEnv.getMutableConfig(); config.setConfigParam - (EnvironmentParams.ENV_RUN_CLEANER.getName(), "true"); + (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); config.setConfigParam (EnvironmentParams.CLEANER_MIN_UTILIZATION.getName(), "80"); exampleEnv.setMutableConfig(config); @@ -525,17 +613,31 @@ final EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(exampleEnv); final Cleaner cleaner = envImpl.getCleaner(); + final FileSelector fileSelector = cleaner.getFileSelector(); - Map expectedMap = new HashMap(); + Map> expectedMap = + new HashMap>(); doLargePut(expectedMap, 1000, 1, true); checkData(expectedMap); + final long file1 = 0; + final long file2 = 1; + for (int i = 0; i < 100; i += 1) { modifyData(expectedMap, 1, true); checkData(expectedMap); - cleaner.injectFileForCleaning(new Long(0)); - exampleEnv.cleanLog(); + fileSelector.injectFileForCleaning(new Long(file1)); + fileSelector.injectFileForCleaning(new Long(file2)); + assertTrue(fileSelector.getToBeCleanedFiles().contains(file1)); + assertTrue(fileSelector.getToBeCleanedFiles().contains(file2)); + while (exampleEnv.cleanLog() > 0) {} + assertTrue(!fileSelector.getToBeCleanedFiles().contains(file1)); + assertTrue(!fileSelector.getToBeCleanedFiles().contains(file2)); exampleEnv.checkpoint(forceConfig); + Map allFiles = envImpl.getUtilizationProfile(). + getFileSummaryMap(true /*includeTrackedFiles*/); + assertTrue(!allFiles.containsKey(file1)); + assertTrue(!allFiles.containsKey(file2)); } checkData(expectedMap); @@ -546,7 +648,7 @@ * Helper routine. Generates keys with random alpha values while data * is numbered numerically. */ - private void doLargePut(Map expectedMap, + private void doLargePut(Map> expectedMap, int nKeys, int nDupsPerKey, boolean commit) @@ -562,7 +664,7 @@ * The data map is keyed by key value, and holds a hash * map of all data values. */ - Set dataVals = new HashSet(); + Set dataVals = new HashSet(); if (commit) { expectedMap.put(keyString, dataVals); } @@ -584,7 +686,7 @@ /** * Increment each data value. */ - private void modifyData(Map expectedMap, + private void modifyData(Map> expectedMap, int increment, boolean commit) throws DatabaseException { @@ -610,7 +712,7 @@ /* If committing, adjust the expected map. */ if (commit) { - Set dataVals = (Set) expectedMap.get(foundKeyString); + Set dataVals = expectedMap.get(foundKeyString); if (dataVals == null) { fail("Couldn't find " + foundKeyString + "/" + foundDataString); @@ -647,7 +749,7 @@ /** * Delete data. */ - private void deleteData(Map expectedMap, + private void deleteData(Map> expectedMap, boolean everyOther, boolean commit) throws DatabaseException { @@ -671,7 +773,7 @@ /* If committing, adjust the expected map */ if (commit) { - Set dataVals = (Set) expectedMap.get(foundKeyString); + Set dataVals = expectedMap.get(foundKeyString); if (dataVals == null) { fail("Couldn't find " + foundKeyString + "/" + foundDataString); @@ -707,7 +809,7 @@ /** * Check what's in the database against what's in the expected map. */ - private void checkData(Map expectedMap) + private void checkData(Map> expectedMap) throws DatabaseException { StringDbt foundKey = new StringDbt(); @@ -722,13 +824,14 @@ * Also make a set of counts for each key value, to test count. */ - Map checkMap = new HashMap(); - Map countMap = new HashMap(); - Iterator iter = expectedMap.entrySet().iterator(); + Map> checkMap = new HashMap>(); + MapcountMap = new HashMap(); + Iterator>> iter = + expectedMap.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - Set copySet = new HashSet(); - copySet.addAll((Set) entry.getValue()); + Map.Entry> entry = iter.next(); + Set copySet = new HashSet(); + copySet.addAll(entry.getValue()); checkMap.put(entry.getKey(), copySet); countMap.put(entry.getKey(), new Integer(copySet.size())); } @@ -738,7 +841,7 @@ String foundDataString = foundData.getString(); /* Check that the current value is in the check values map */ - Set dataVals = (Set) checkMap.get(foundKeyString); + Set dataVals = checkMap.get(foundKeyString); if (dataVals == null) { fail("Couldn't find " + foundKeyString + "/" + foundDataString); @@ -756,7 +859,7 @@ /* Check that the count is right. */ int count = cursor.count(); - assertEquals(((Integer)countMap.get(foundKeyString)).intValue(), + assertEquals(countMap.get(foundKeyString).intValue(), count); status = cursor.getNext(foundKey, foundData, LockMode.DEFAULT); @@ -938,8 +1041,6 @@ envConfig.setAllowCreate(true); envConfig.setTransactional(true); envConfig.setConfigParam - (EnvironmentParams.ENV_CHECK_LEAKS.getName(), "false"); - envConfig.setConfigParam (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); envConfig.setConfigParam (EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false"); @@ -1044,8 +1145,8 @@ exampleEnv = new Environment(envHome, envConfig); EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(exampleEnv); - DatabaseImpl fileSummaryDb = - envImpl.getUtilizationProfile().getFileSummaryDb(); + UtilizationProfile up = envImpl.getUtilizationProfile(); + DatabaseImpl fileSummaryDb = up.getFileSummaryDb(); MemoryBudget memBudget = envImpl.getMemoryBudget(); BasicLocker locker = null; @@ -1079,12 +1180,18 @@ (keyBytes, ln, false /*allowDuplicates*/, fileSummaryDb.getRepContext()); assertSame(status, OperationStatus.SUCCESS); + + assertSame(parent, cursor.latchBIN()); + ln.addExtraMarshaledMemorySize(parent); + cursor.releaseBIN(); + long newSize = ln.getMemorySizeIncludedByParent(); long newParentSize = getMemSize(parent, memBudget); /* The size of the LN increases during logging. */ assertEquals(newSize, - oldSize + ln.getObsoleteOffsets().getExtraMemorySize()); + oldSize + + ln.getObsoleteOffsets().getExtraMemorySize()); /* The correct size is accounted for by the parent BIN. */ assertEquals(newSize + keySize, newParentSize - oldParentSize); @@ -1094,6 +1201,7 @@ cursor.evict(); newParentSize = getMemSize(parent, memBudget); assertEquals(oldParentSize - newSize, newParentSize); + long evictedParentSize = newParentSize; /* Fetch a fresh FileSummaryLN before deleting it. */ oldParentSize = newParentSize; @@ -1116,6 +1224,13 @@ assertTrue(oldSize - newSize > ln.getObsoleteOffsets().getExtraMemorySize()); assertEquals(newSize - oldSize, newParentSize - oldParentSize); + + /* Correct size is subtracted during eviction. */ + oldParentSize = newParentSize; + cursor.evict(); + newParentSize = getMemSize(parent, memBudget); + assertEquals(oldParentSize - newSize, newParentSize); + assertEquals(evictedParentSize, newParentSize); } finally { if (cursor != null) { cursor.releaseBINs(); @@ -1126,6 +1241,18 @@ } } + TestUtils.validateNodeMemUsage(envImpl, true /*assertOnError*/); + + /* Insert again, this time using the UtilizationProfile method. */ + FileSummaryLN ln = new FileSummaryLN(envImpl, new FileSummary()); + TrackedFileSummary tfs = new TrackedFileSummary + (envImpl.getUtilizationTracker(), 0 /*fileNum*/, + true /*trackDetail*/); + tfs.trackObsolete(0); + ln.setTrackedSummary(tfs); + assertTrue(up.insertFileSummary(ln, 0 /*fileNum*/, 123 /*sequence*/)); + TestUtils.validateNodeMemUsage(envImpl, true /*assertOnError*/); + closeEnv(); } @@ -1262,4 +1389,326 @@ in.getInMemorySize() - in.getBudgetedMemorySize(); } + + /** + * Tests that dirtiness is logged upwards during a checkpoint, even if a + * node is evicted and refetched after being added to the checkpointer's + * dirty map, and before that entry in the dirty map is processed by the + * checkpointer. [#16523] + * + * Root INa + * / \ + * INb ... + * / + * INc + * / + * BINd + * + * The scenario that causes the bug is: + * + * 1) Prior to the final checkpoint, the cleaner processes a log file + * containing BINd. The cleaner marks BINd dirty so that it will be + * flushed prior to the end of the next checkpoint, at which point the file + * containing BINd will be deleted. The cleaner also calls + * setProhibitNextDelta on BINd to ensure that a full version will be + * logged. + * + * 2) At checkpoint start, BINd is added to the checkpoiner's dirty map. + * It so happens that INa is also dirty, perhaps as the result of a split, + * and added to the dirty map. The checkpointer's max flush level is 4. + * + * 3) The evictor flushes BINd and then its parent INc. Both are logged + * provisionally, since their level is less than 4, the checkpointer's max + * flush level. INb, the parent of INc, is dirty. + * + * 4) INc, along with BINd, is loaded back into the Btree as the result of + * reading an LN in BINd. INc and BINd are both non-dirty. INb, the + * parent of INc, is still dirty. + * + * 5) The checkpointer processes its reference to BINd in the dirty map. + * It finds that BINd is not dirty, so does not need to be logged. It + * attempts to add the parent, INc, to the dirty map in order to propogate + * changes upward. However, becaue INc is not dirty, it is not added to + * the dirty map -- this was the bug, it should be added even if not dirty. + * So as the result of this step, the checkpointer does no logging and does + * not add anything to the dirty map. + * + * 6) The checkpointer logs INa (it was dirty at the start of the + * checkpoint) and the checkpoint finishes. It deletes the cleaned log + * file that contains the original version of BINd. + * + * The key thing is that INb is now dirty and was not logged. It should + * have been logged as the result of being an ancestor of BINd, which was + * in the dirty map. Its parent INa was logged, but does not refer to the + * latest version of INb/INc/BINd. + * + * 7) Now we recover. INc and BINd, which were evicted during step (3), + * are not replayed because they are provisional -- they are lost. When a + * search for an LN in BINd is performed, we traverse down to the old + * version of BINd, which causes LogFileNotFound. + * + * The fix is to add INc to the dirty map at step (5), even though it is + * not dirty. When the reference to INc in the dirty map is processed we + * will not log INc, but we will add its parent INb to the dirty map. Then + * when the reference to INb is processed, it will be logged because it is + * dirty. Then INa is logged and refers to the latest version of + * INb/INc/BINd. + * + * This problem could only occur with a Btree of depth 4 or greater. + */ + public void testEvictionDuringCheckpoint() + throws DatabaseException { + + /* Use small fanout to create a deep tree. */ + final int FANOUT = 6; + final int N_KEYS = FANOUT * FANOUT * FANOUT; + + /* Open environment without interference of daemon threads. */ + EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + envConfig.setAllowCreate(true); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false"); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false"); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false"); + exampleEnv = new Environment(envHome, envConfig); + final EnvironmentImpl envImpl = + DbInternal.envGetEnvironmentImpl(exampleEnv); + + /* Open database. */ + DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate(true); + dbConfig.setNodeMaxEntries(FANOUT); + exampleDb = exampleEnv.openDatabase(null, "foo", dbConfig); + DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(exampleDb); + + /* Write to database to create a 4 level Btree. */ + final DatabaseEntry keyEntry = new DatabaseEntry(); + final DatabaseEntry dataEntry = new DatabaseEntry(new byte[0]); + int nRecords; + for (nRecords = 1;; nRecords += 1) { + LongBinding.longToEntry(nRecords, keyEntry); + assertSame(OperationStatus.SUCCESS, + exampleDb.put(null, keyEntry, dataEntry)); + if (nRecords % 10 == 0) { + int level = envImpl.getDbTree().getHighestLevel(dbImpl); + if ((level & IN.LEVEL_MASK) >= 4) { + break; + } + } + } + + /* Flush all dirty nodes. */ + exampleEnv.sync(); + + /* Get BINd and its ancestors. Mark BINd and INa dirty. */ + final IN nodeINa = dbImpl.getTree().getRootIN(CacheMode.DEFAULT); + nodeINa.releaseLatch(); + final IN nodeINb = (IN) nodeINa.getTarget(0); + final IN nodeINc = (IN) nodeINb.getTarget(0); + final BIN nodeBINd = (BIN) nodeINc.getTarget(0); + assertNotNull(nodeBINd); + nodeINa.setDirty(true); + nodeBINd.setDirty(true); + + /* + * The test hook is called after creating the checkpoint dirty map and + * just before flushing dirty nodes. + */ + final StringBuilder hookCalledFlag = new StringBuilder(); + + Checkpointer.setBeforeFlushHook(new TestHook() { + public void doHook() { + hookCalledFlag.append(1); + /* Don't call the test hook repeatedly. */ + Checkpointer.setBeforeFlushHook(null); + try { + /* Evict BINd and INc. */ + simulateEviction(exampleEnv, envImpl, nodeBINd, nodeINc); + simulateEviction(exampleEnv, envImpl, nodeINc, nodeINb); + + /* + * Force BINd and INc to be loaded into cache by fetching + * the left-most record. + * + * Note that nodeINc and nodeBINd are different instances + * and are no longer in the Btree but we don't change these + * variables because they are final. They should not be + * used past this point. + */ + LongBinding.longToEntry(1, keyEntry); + assertSame(OperationStatus.SUCCESS, + exampleDb.get(null, keyEntry, dataEntry, null)); + } catch (DatabaseException e) { + throw new RuntimeException(e); + } + } + public Object getHookValue() { + throw new UnsupportedOperationException(); + } + public void doIOHook() throws IOException { + throw new UnsupportedOperationException(); + } + public void hookSetup() { + throw new UnsupportedOperationException(); + } + }); + exampleEnv.checkpoint(forceConfig); + assertTrue(hookCalledFlag.length() > 0); + assertTrue(!nodeINa.getDirty()); + assertTrue(!nodeINb.getDirty()); /* This failed before the bug fix. */ + + closeEnv(); + } + + /** + * Simulate eviction by logging this node, updating the LSN in its + * parent slot, setting the Node to null in the parent slot, and + * removing the IN from the INList. Logging is provisional. The + * parent is dirtied. May not be called unless this node is dirty and + * none of its children are dirty. Children may be resident. + */ + private void simulateEviction(Environment env, + EnvironmentImpl envImpl, + IN nodeToEvict, + IN parentNode) + throws DatabaseException { + + assertTrue("not dirty " + nodeToEvict.getNodeId(), + nodeToEvict.getDirty()); + assertTrue(!hasDirtyChildren(nodeToEvict)); + parentNode.latch(); + long lsn = TestUtils.logIN + (env, nodeToEvict, true /*provisional*/, parentNode); + int index; + for (index = 0;; index += 1) { + if (index >= parentNode.getNEntries()) { + fail(); + } + if (parentNode.getTarget(index) == nodeToEvict) { + break; + } + } + parentNode.updateNode(index, null /*node*/, lsn, null /*lnSlotKey*/); + parentNode.releaseLatch(); + envImpl.getInMemoryINs().remove(nodeToEvict); + } + + private boolean hasDirtyChildren(IN parent) { + for (int i = 0; i < parent.getNEntries(); i += 1) { + Node child = parent.getTarget(i); + if (child instanceof IN) { + IN in = (IN) child; + if (in.getDirty()) { + return true; + } + } + } + return false; + } + + public void testMultiCleaningBug() + throws DatabaseException { + + initEnv(true, false); + + final EnvironmentImpl envImpl = + DbInternal.envGetEnvironmentImpl(exampleEnv); + final FileSelector fileSelector = + envImpl.getCleaner().getFileSelector(); + + Map> expectedMap = + new HashMap>(); + doLargePut(expectedMap, 1000, 1, true); + modifyData(expectedMap, 1, true); + checkData(expectedMap); + + final TestHook hook = new TestHook() { + public void doHook() { + /* Signal that hook was called. */ + if (synchronizer != 99) { + synchronizer = 1; + } + /* Wait for signal to proceed with cleaning. */ + while (synchronizer != 2 && + synchronizer != 99 && + !Thread.interrupted()) { + Thread.yield(); + } + } + public Object getHookValue() { + throw new UnsupportedOperationException(); + } + public void doIOHook() throws IOException { + throw new UnsupportedOperationException(); + } + public void hookSetup() { + throw new UnsupportedOperationException(); + } + }; + + junitThread = new JUnitThread("TestMultiCleaningBug") { + public void testBody() + throws DatabaseException { + + try { + while (synchronizer != 99) { + /* Wait for initial state. */ + while (synchronizer != 0 && + synchronizer != 99 && + !Thread.interrupted()) { + Thread.yield(); + } + /* Clean with hook set, hook is called next. */ + fileSelector.setFileChosenHook(hook); + exampleEnv.cleanLog(); + /* Signal that cleaning is done. */ + if (synchronizer != 99) { + synchronizer = 3; + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + }; + + /* Kick off thread above. */ + synchronizer = 0; + junitThread.start(); + + for (int i = 0; i < 100 && junitThread.isAlive(); i += 1) { + /* Wait for hook to be called when a file is chosen. */ + while (synchronizer != 1 && junitThread.isAlive()) { + Thread.yield(); + } + /* Allow the thread to clean the chosen file. */ + synchronizer = 2; + /* But immediately clean here, which could select the same file. */ + fileSelector.setFileChosenHook(null); + exampleEnv.cleanLog(); + /* Wait for both cleaner runs to finish. */ + while (synchronizer != 3 && junitThread.isAlive()) { + Thread.yield(); + } + /* Make more waste to be cleaned. */ + modifyData(expectedMap, 1, true); + synchronizer = 0; + } + + synchronizer = 99; + + try { + junitThread.finishTest(); + junitThread = null; + } catch (Throwable e) { + e.printStackTrace(); + fail(e.toString()); + } + + closeEnv(); + } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/CleanerTestUtils.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/CleanerTestUtils.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/CleanerTestUtils.java 2008-03-27 18:06:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/CleanerTestUtils.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CleanerTestUtils.java,v 1.14 2008/03/27 17:06:38 linda Exp $ + * $Id: CleanerTestUtils.java,v 1.14.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/FileSelectionTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/FileSelectionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/FileSelectionTest.java 2008-03-27 15:53:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/FileSelectionTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileSelectionTest.java,v 1.41 2008/03/27 14:53:28 mark Exp $ + * $Id: FileSelectionTest.java,v 1.42.2.4 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -36,8 +36,10 @@ import com.sleepycat.je.LockMode; import com.sleepycat.je.OperationStatus; import com.sleepycat.je.Transaction; +import com.sleepycat.je.cleaner.DbFileSummaryMap; import com.sleepycat.je.config.EnvironmentParams; import com.sleepycat.je.dbi.CursorImpl; +import com.sleepycat.je.dbi.DatabaseImpl; import com.sleepycat.je.dbi.EnvironmentImpl; import com.sleepycat.je.dbi.MemoryBudget; import com.sleepycat.je.junit.JUnitThread; @@ -89,8 +91,6 @@ config.setConfigParam (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false"); config.setConfigParam - (EnvironmentParams.CLEANER_MIN_FILES_TO_DELETE.getName(), "1"); - config.setConfigParam (EnvironmentParams.CLEANER_LOCK_TIMEOUT.getName(), "1"); config.setConfigParam (EnvironmentParams.CLEANER_MAX_BATCH_FILES.getName(), "1"); @@ -602,7 +602,8 @@ int fileCount = envImpl.getFileManager().getAllFileNumbers().length; assertTrue("fileCount=" + fileCount + - " maxFileCount=" + maxFileCount, + " maxFileCount=" + maxFileCount + + " iteration=" + i, fileCount <= maxFileCount); if (false) { System.out.println("fileCount=" + fileCount + @@ -818,6 +819,11 @@ * Tests that when cleaned files are deleted during a compression, the * flushing of the local tracker does not transfer tracker information * for the deleted files. [#15528] + * + * This test also checks that tracker information is not transfered to the + * MapLN's per-DB utilization information in DbFileSummaryMap. This was + * occuring in JE 3.3.74 and earlier, under the same circumstances as + * tested here (IN compression). [#16610] */ public void testCompressionBug() throws DatabaseException { @@ -832,10 +838,13 @@ return; } - /* Disable compressor so we can compress explicitly. */ EnvironmentConfig envConfig = initConfig(); + /* Disable compressor so we can compress explicitly. */ envConfig.setConfigParam (EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false"); + /* Ensure that we check for resurrected file leaks. */ + envConfig.setConfigParam + (EnvironmentParams.ENV_CHECK_LEAKS.getName(), "true"); openEnv(envConfig); /* Write and then delete all data. */ @@ -871,7 +880,9 @@ public void doHook() { synchronizer = 1; /* Wait for log cleaning to complete. */ - while (synchronizer < 2) Thread.yield(); + while (synchronizer < 2 && !Thread.interrupted()) { + Thread.yield(); + } } public Object getHookValue() { throw new UnsupportedOperationException(); @@ -912,6 +923,89 @@ } /** + * Checks that DB utilization is repaired when damaged by JE 3.3.74 or + * earlier. Go to some trouble to create a DatabaseImpl with the repair + * done flag not set, and with a DB file summary for a deleted file. + * [#16610] + */ + public void testDbUtilizationRepair() + throws DatabaseException, IOException { + + openEnv(); + writeData(); + forceCleanOne(); + verifyDeletedFiles(new int[] {0}); + + DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(db); + DbFileSummaryMap summaries = dbImpl.getDbFileSummaries(); + + /* New version DB does not need repair. */ + assertTrue(dbImpl.getUtilizationRepairDone()); + + /* Deleted file is absent from summary map. */ + assertNull(summaries.get(0L /*fileNum*/, true /*adjustMemBudget*/, + true /*checkResurrected*/, + envImpl.getFileManager())); + + /* + * Force addition of deleted file to summary map by creating a dummy + * file to prevent assertions from firing. + */ + File dummyFile = new File(env.getHome(), "00000000.jdb"); + assertTrue(dummyFile.createNewFile()); + assertNotNull(summaries.get(0L /*fileNum*/, true /*adjustMemBudget*/, + false /*checkResurrected*/, + envImpl.getFileManager())); + assertTrue(dummyFile.delete()); + + /* Now an entry in the summary map is there for a deleted file.. */ + assertNotNull(summaries.get(0L /*fileNum*/, true /*adjustMemBudget*/, + true /*checkResurrected*/, + envImpl.getFileManager())); + + /* Force the MapLN with the bad entry to be flushed. */ + dbImpl.setDirtyUtilization(); + env.checkpoint(forceConfig); + closeEnv(); + + /* If the DB is temporary, we can't test it further. */ + if (temporary) { + return; + } + + /* + * When the DB is opened, the repair should not take place, because we + * did not clear the repair done flag above. + */ + openEnv(); + dbImpl = DbInternal.dbGetDatabaseImpl(db); + summaries = dbImpl.getDbFileSummaries(); + assertTrue(dbImpl.getUtilizationRepairDone()); + assertNotNull(summaries.get(0L /*fileNum*/, true /*adjustMemBudget*/, + true /*checkResurrected*/, + envImpl.getFileManager())); + + /* Clear the repair done flag and force the MapLN to be flushed. */ + dbImpl.clearUtilizationRepairDone(); + dbImpl.setDirtyUtilization(); + env.checkpoint(forceConfig); + closeEnv(); + + /* + * Since the repair done flag was cleared above, when the DB is opened, + * the repair should take place. + */ + openEnv(); + dbImpl = DbInternal.dbGetDatabaseImpl(db); + summaries = dbImpl.getDbFileSummaries(); + assertTrue(dbImpl.getUtilizationRepairDone()); + assertNull(summaries.get(0L /*fileNum*/, true /*adjustMemBudget*/, + true /*checkResurrected*/, + envImpl.getFileManager())); + closeEnv(); + } + + /** * Force cleaning of one file. */ private void forceCleanOne() diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/INUtilizationTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/INUtilizationTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/INUtilizationTest.java 2008-03-27 18:06:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/INUtilizationTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INUtilizationTest.java,v 1.27 2008/03/27 17:06:38 linda Exp $ + * $Id: INUtilizationTest.java,v 1.27.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/MakeMigrationLogFiles.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/MakeMigrationLogFiles.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/MakeMigrationLogFiles.java 2008-03-27 15:53:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/MakeMigrationLogFiles.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MakeMigrationLogFiles.java,v 1.2 2008/03/27 14:53:28 mark Exp $ + * $Id: MakeMigrationLogFiles.java,v 1.2.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/OffsetTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/OffsetTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/OffsetTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/OffsetTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: OffsetTest.java,v 1.7 2008/01/07 14:29:05 cwl Exp $ + * $Id: OffsetTest.java,v 1.7.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReadOnlyLockingTest.java,v 1.12 2008/01/07 14:29:05 cwl Exp $ + * $Id: ReadOnlyLockingTest.java,v 1.12.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/ReadOnlyProcess.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/ReadOnlyProcess.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/ReadOnlyProcess.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/ReadOnlyProcess.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReadOnlyProcess.java,v 1.9 2008/01/07 14:29:05 cwl Exp $ + * $Id: ReadOnlyProcess.java,v 1.9.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/RMWLockingTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/RMWLockingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/RMWLockingTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/RMWLockingTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RMWLockingTest.java,v 1.9 2008/01/07 14:29:05 cwl Exp $ + * $Id: RMWLockingTest.java,v 1.9.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR10553Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR10553Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR10553Test.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR10553Test.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SR10553Test.java,v 1.13 2008/01/07 14:29:05 cwl Exp $ + * $Id: SR10553Test.java,v 1.13.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR10597Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR10597Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR10597Test.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR10597Test.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SR10597Test.java,v 1.10 2008/01/07 14:29:05 cwl Exp $ + * $Id: SR10597Test.java,v 1.10.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR12885Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR12885Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR12885Test.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR12885Test.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SR12885Test.java,v 1.8 2008/01/07 14:29:05 cwl Exp $ + * $Id: SR12885Test.java,v 1.8.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR12978Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR12978Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR12978Test.java 2008-02-06 02:05:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR12978Test.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SR12978Test.java,v 1.10 2008/02/06 02:05:04 cwl Exp $ + * $Id: SR12978Test.java,v 1.10.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR18227Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR18227Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/SR18227Test.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/SR18227Test.java 2010-01-30 01:10:56.000000000 +0000 @@ -0,0 +1,397 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002-2010 Oracle. All rights reserved. + * + * $Id: SR18227Test.java,v 1.1.2.2 2010/01/30 01:10:55 mark Exp $ + */ + +package com.sleepycat.je.cleaner; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; + +import junit.framework.TestCase; + +import com.sleepycat.bind.tuple.IntegerBinding; +import com.sleepycat.je.Database; +import com.sleepycat.je.DatabaseConfig; +import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.DbInternal; +import com.sleepycat.je.Environment; +import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.config.EnvironmentParams; +import com.sleepycat.je.dbi.DatabaseId; +import com.sleepycat.je.dbi.DatabaseImpl; +import com.sleepycat.je.dbi.EnvironmentImpl; +import com.sleepycat.je.junit.JUnitThread; +import com.sleepycat.je.latch.LatchSupport; +import com.sleepycat.je.log.FileManager; +import com.sleepycat.je.tree.BIN; +import com.sleepycat.je.tree.IN; +import com.sleepycat.je.tree.LN; +import com.sleepycat.je.util.TestUtils; +import com.sleepycat.je.utilint.DbLsn; +import com.sleepycat.je.utilint.TestHook; + +public class SR18227Test extends TestCase { + + private static final String DB_NAME = "foo"; + + private File envHome; + private Environment env; + private EnvironmentImpl envImpl; + private Database db; + private JUnitThread junitThread; + private boolean deferredWrite; + + public SR18227Test() { + envHome = new File(System.getProperty(TestUtils.DEST_DIR)); + } + + @Override + public void setUp() + throws IOException { + + TestUtils.removeLogFiles("Setup", envHome, false); + TestUtils.removeFiles("Setup", envHome, FileManager.DEL_SUFFIX); + } + + @Override + public void tearDown() { + if (junitThread != null) { + while (junitThread.isAlive()) { + junitThread.interrupt(); + Thread.yield(); + } + junitThread = null; + } + + try { + if (env != null) { + env.close(); + } + } catch (Throwable e) { + System.out.println("tearDown: " + e); + } + + //* + try { + TestUtils.removeLogFiles("tearDown", envHome, true); + TestUtils.removeFiles("tearDown", envHome, FileManager.DEL_SUFFIX); + } catch (Throwable e) { + System.out.println("tearDown: " + e); + } + //*/ + + db = null; + env = null; + envImpl = null; + envHome = null; + } + + /** + * Opens the environment and database. + */ + private void openEnv() + throws DatabaseException { + + EnvironmentConfig config = TestUtils.initEnvConfig(); + config.setAllowCreate(true); + + /* Do not run the daemons. */ + config.setConfigParam + (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); + config.setConfigParam + (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false"); + config.setConfigParam + (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false"); + config.setConfigParam + (EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false"); + + /* Use a small cache size to increase eviction. */ + config.setConfigParam(EnvironmentParams.MAX_MEMORY.getName(), + Integer.toString(1024 * 96)); + + /* + * Disable critical eviction, we want to test under controlled + * circumstances. + */ + config.setConfigParam + (EnvironmentParams.EVICTOR_CRITICAL_PERCENTAGE.getName(), "1000"); + + env = new Environment(envHome, config); + envImpl = DbInternal.envGetEnvironmentImpl(env); + + DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate(true); + if (deferredWrite) { + dbConfig.setDeferredWrite(true); + } else { + dbConfig.setTemporary(true); + } + db = env.openDatabase(null, DB_NAME, dbConfig); + } + + /** + * Closes the environment and database. + */ + private void closeEnv() + throws DatabaseException { + + if (db != null) { + db.close(); + db = null; + } + if (env != null) { + env.close(); + env = null; + } + } + + /** + * Tests additionally with deferred-write instead of a temporary database + * as a double-check that the test is correct and that the problem is + * limited to temporary DBs. + */ + public void testDeferredWrite() + throws DatabaseException { + + deferredWrite = true; + testSR18227(); + } + + /** + * Tests a fix for a bug where a BIN was evicted, without flushing it, when + * it contained a LN that had been dirtied by log cleaning. + */ + public void testSR18227() + throws DatabaseException { + + openEnv(); + + /* + * Insert many records to cause eviction of BINs. Critical eviction is + * disabled, so no eviction occurs until evictMemory is invoked. + */ + final int RECORD_COUNT = 100000; + final DatabaseEntry key = new DatabaseEntry(); + final DatabaseEntry data = new DatabaseEntry(new byte[100]); + for (int i = 0; i < RECORD_COUNT; i += 1) { + IntegerBinding.intToEntry(i, key); + db.put(null, key, data); + } + /* Evict to flush data to disk, then load again. */ + env.evictMemory(); + for (int i = 0; i < RECORD_COUNT; i += 1) { + IntegerBinding.intToEntry(i, key); + db.get(null, key, data, null); + } + + final AtomicReference foundBin = new AtomicReference(null); + final AtomicLong foundLsn = new AtomicLong(DbLsn.NULL_LSN); + final AtomicInteger foundLn = new AtomicInteger(-1); + + /* Simulate processing of an LN in the log cleaner. */ + junitThread = new JUnitThread("testSR18227") { + public void testBody() { + final BIN bin = foundBin.get(); + assertNotNull(bin); + final int index = foundLn.get(); + assertTrue(index >= 0); + + final FileProcessor processor = new FileProcessor + ("testSR18227", envImpl, envImpl.getCleaner(), + envImpl.getUtilizationProfile(), + envImpl.getCleaner().getFileSelector()); + + final Map dbCache = + new HashMap(); + try { + processor.testProcessLN + ((LN) bin.getTarget(index), bin.getLsn(index), + bin.getKey(index), null /*dupKey*/, + bin.getDatabase().getId(), dbCache); + } catch (DatabaseException e) { + throw new RuntimeException(e); + } finally { + envImpl.getDbTree().releaseDbs(dbCache); + } + } + }; + + /* + * When an IN is about to be evicted, get control while it is latched + * but before the evictor re-searches for the parent IN. + */ + final TestHook preEvictINHook = new TestHook() { + public void doHook() { + try { + if (foundLn.get() >= 0) { + return; + } + assertEquals(1, LatchSupport.countLatchesHeld()); + final BIN bin = findNonDirtyLatchedBIN(); + if (bin != null) { + foundBin.set(bin); + foundLsn.set(bin.getLastFullVersion()); + final int index = findDurableLN(bin); + if (index >= 0) { + foundLn.set(index); + final LN ln = (LN) bin.fetchTarget(index); + assertNotNull(ln); + final IN parent = findBINParent(bin); + if (parent.latchNoWait()) { + parent.releaseLatch(); + } else { + fail("Parent should not currently be latched."); + } + junitThread.start(); + + /* + * Loop until BIN parent is latched by cleaner in + * separate thread. When this occurs, the cleaner + * will then try to latch the BIN itself. + */ + while (junitThread.isAlive()) { + if (parent.latchNoWait()) { + parent.releaseLatch(); + Thread.yield(); + } else { + break; + } + } + + /* + * Perform one final yield to ensure that the + * cleaner has time to request the latch on the + * BIN. + */ + Thread.yield(); + assertEquals(1, LatchSupport.countLatchesHeld()); + } + } + } catch (DatabaseException e) { + throw new RuntimeException(e); + } + } + public Object getHookValue() { + throw new UnsupportedOperationException(); + } + public void doIOHook() { + throw new UnsupportedOperationException(); + } + public void hookSetup() { + throw new UnsupportedOperationException(); + } + }; + + /* + * Set the pre-eviction hook and start eviction in this thread. When + * evictMemory is called, that sets off the following sequence of + * events using the thread and hook defined further above. + * + * 1. The evictor (in this thread) will select a BIN for eviction. + * 2. The hook (above) will choose a BIN that is selected by evictor + * (it determines this by finding the BIN that is latched). It is + * looking for a BIN in the temp DB that is non-dirty. + * 3. The hook starts the separate thread to simulate processing of the + * LN by the log cleaner. + * 4. When the log cleaner (separate thread) has latched the BIN's + * parent and is attemping to latch the BIN, the hook returns to + * allow the evictor to continue. + * 5. The evictor then releases the latch on the BIN, in order to + * re-search for it's parent. By releasing the BIN latch, the + * separate thread is then activated, since it was waiting on a + * latch request for that BIN. + * 6. The separate thread then marks the LN in the BIN dirty. The bug + * is that it neglected to mark the BIN dirty. This thread then + * finishes. + * 7. The evictor now continues because it can get the latch on the + * BIN. When the bug was present, it would NOT flush the BIN, + * because it was not dirty. With the bug fix, the BIN is now + * dirtied by the cleaner, and the evictor will flush it. + */ + envImpl.getEvictor().setPreEvictINHook(preEvictINHook); + env.evictMemory(); + + /* Ensure separate thread is finished and report any exceptions. */ + try { + junitThread.finishTest(); + junitThread = null; + } catch (Throwable e) { + e.printStackTrace(); + fail(e.toString()); + } + + /* + * After that entire process is complete, we can check that it did what + * we expected, and the BIN was flushed by the evictor. + */ + final BIN bin = foundBin.get(); + assertNotNull(bin); + final int index = foundLn.get(); + assertTrue(index >= 0); + /* Ensure the BIN was evicted. */ + assertFalse(envImpl.getInMemoryINs().contains(bin)); + /* Ensure the BIN was flushed: this failed before the bug fix. */ + assertTrue(bin.getLastFullVersion() != foundLsn.get()); + /* Ensure the dirty LN was written. */ + final LN ln = (LN) bin.getTarget(index); + assertNotNull(ln); + assertFalse(ln.isDirty()); + assertTrue(DbLsn.NULL_LSN != bin.getLsn(index)); + + closeEnv(); + } + + private BIN findNonDirtyLatchedBIN() { + for (IN in : envImpl.getInMemoryINs()) { + if (in.isLatchOwnerForWrite()) { + if (in.getDatabase() != DbInternal.dbGetDatabaseImpl(db)) { + return null; + } + if (!(in instanceof BIN)) { + return null; + } + BIN bin = (BIN) in; + if (bin.getDirty()) { + return null; + } + return bin; + } + } + fail("No IN latched"); + return null; // for compiler + } + + private IN findBINParent(BIN bin) { + for (IN in : envImpl.getInMemoryINs()) { + if (in.getLevel() != IN.BIN_LEVEL + 1) { + continue; + } + for (int i = 0; i < in.getNEntries(); i += 1) { + if (in.getTarget(i) == bin) { + return in; + } + } + } + fail("No BIN parent"); + return null; // for compiler + } + + private int findDurableLN(BIN bin) { + for (int i = 0; i < bin.getNEntries(); i += 1) { + if (bin.getLsn(i) != DbLsn.NULL_LSN) { + return i; + } + } + return -1; + } +} diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java 2008-03-27 18:06:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TruncateAndRemoveTest.java,v 1.29 2008/03/27 17:06:38 linda Exp $ + * $Id: TruncateAndRemoveTest.java,v 1.29.2.3 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; @@ -818,6 +818,35 @@ } } + /** + * Tickles a bug that caused NPE during recovery during the sequence: + * delete record, trucate DB, crash (close without checkpoint), and + * recover. [#16515] + */ + public void testDeleteTruncateRecover() + throws DatabaseException { + + /* Delete a record. */ + openEnv(true); + openDb(null, DB_NAME1); + writeAndCountRecords(null, 1); + closeDb(); + + /* Truncate DB. */ + Transaction txn = env.beginTransaction(null, null); + truncate(txn, false); + txn.commit(); + + /* Close without checkpoint. */ + envImpl.close(false /*doCheckpoint*/); + envImpl = null; + env = null; + + /* Recover -- the bug cause NPE here. */ + openEnv(true); + closeEnv(); + } + private void writeAndCountRecords(Transaction txn, long count) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/UtilizationTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/UtilizationTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/cleaner/UtilizationTest.java 2008-03-27 18:06:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/cleaner/UtilizationTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: UtilizationTest.java,v 1.28 2008/03/27 17:06:38 linda Exp $ + * $Id: UtilizationTest.java,v 1.28.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je.cleaner; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/config/EnvironmentParamsTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/config/EnvironmentParamsTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/config/EnvironmentParamsTest.java 2008-05-30 19:07:42.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/config/EnvironmentParamsTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentParamsTest.java,v 1.14 2008/05/30 19:07:42 mark Exp $ + * $Id: EnvironmentParamsTest.java,v 1.15.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.config; @@ -41,7 +41,6 @@ assertTrue(mvParam.isMultiValueParam()); try { - ConfigParam param = new ConfigParam(null, "foo", false /* mutable */, false /* for replication */); fail("should disallow null name"); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/CursorEdgeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/CursorEdgeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/CursorEdgeTest.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/CursorEdgeTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CursorEdgeTest.java,v 1.38 2008/01/07 14:29:04 cwl Exp $ + * $Id: CursorEdgeTest.java,v 1.39.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -541,7 +541,7 @@ * Check that it's a transaction problem. Crude, but since we * don't want to add exception types, necessary. */ - String eMsg = e.getMessage(); + e.getMessage(); assertTrue(TestUtils.skipVersion(e).startsWith("A transaction was not supplied")); } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/CursorTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/CursorTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/CursorTest.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/CursorTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CursorTest.java,v 1.82 2008/01/07 14:29:04 cwl Exp $ + * $Id: CursorTest.java,v 1.82.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseComparatorsTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseComparatorsTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseComparatorsTest.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseComparatorsTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseComparatorsTest.java,v 1.10 2008/01/07 14:29:04 cwl Exp $ + * $Id: DatabaseComparatorsTest.java,v 1.11.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -25,7 +25,6 @@ private File envHome; private Environment env; - private Database db; private boolean DEBUG = false; public DatabaseComparatorsTest() { @@ -77,8 +76,8 @@ private Database openDb(boolean transactional, boolean dups, - Class btreeComparator, - Class dupComparator) + Class> btreeComparator, + Class> dupComparator) throws DatabaseException { DatabaseConfig dbConfig = new DatabaseConfig(); @@ -164,15 +163,15 @@ } } - public static class ReverseComparator implements Comparator { + public static class ReverseComparator implements Comparator { public ReverseComparator() { } - public int compare(Object o1, Object o2) { + public int compare(byte[] o1, byte[] o2) { - DatabaseEntry arg1 = new DatabaseEntry((byte[]) o1); - DatabaseEntry arg2 = new DatabaseEntry((byte[]) o2); + DatabaseEntry arg1 = new DatabaseEntry(o1); + DatabaseEntry arg2 = new DatabaseEntry(o2); int val1 = IntegerBinding.entryToInt(arg1); int val2 = IntegerBinding.entryToInt(arg2); @@ -409,8 +408,6 @@ Partial2PartComparator.class /*btreeComparator*/, null /*dupComparator*/); - DatabaseEntry key = new DatabaseEntry(); - DatabaseEntry data = new DatabaseEntry(); OperationStatus status; /* Insert key={0,0}/data={0} and data={1}. */ @@ -495,11 +492,10 @@ /** * Compares only the first integer in the byte arrays. */ - public static class Partial2PartComparator implements Comparator { - - public int compare(Object o1, Object o2) { - int val1 = new TupleInput((byte[]) o1).readInt(); - int val2 = new TupleInput((byte[]) o2).readInt(); + public static class Partial2PartComparator implements Comparator { + public int compare(byte[] o1, byte[] o2) { + int val1 = new TupleInput(o1).readInt(); + int val2 = new TupleInput(o2).readInt(); return val1 - val2; } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseConfigTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseConfigTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseConfigTest.java 2008-05-30 14:04:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseConfigTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseConfigTest.java,v 1.30 2008/05/30 14:04:20 mark Exp $ + * $Id: DatabaseConfigTest.java,v 1.30.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseEntryTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseEntryTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseEntryTest.java 2008-01-07 14:29:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseEntryTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseEntryTest.java,v 1.34 2008/01/07 14:29:04 cwl Exp $ + * $Id: DatabaseEntryTest.java,v 1.34.2.3 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -282,6 +282,22 @@ closeDb(); } + public void testToString() { + DatabaseEntry entry = new DatabaseEntry(new byte[] {1, 2, 3}, 1, 2); + String s1 = entry.toString(); + entry.setPartial(3, 4, true); + String s2 = entry.toString(); + + /* + * Normally leave this disabled. Enable it to manually look at the + * toString output and ensure it is valid XML. + */ + if (false) { + System.out.println(s1); + System.out.println(s2); + } + } + private void openDb(boolean dups) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DatabaseTest.java 2008-01-24 14:59:32.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DatabaseTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DatabaseTest.java,v 1.110 2008/01/24 14:59:31 linda Exp $ + * $Id: DatabaseTest.java,v 1.111.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -693,8 +693,6 @@ try { Database myDb = initEnvAndDb(true, false, true, false, null); - DatabaseEntry key = new DatabaseEntry(); - DatabaseEntry data = new DatabaseEntry(); long count = myDb.count(); assertEquals(0, count); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DbHandleLockTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/DbHandleLockTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DbHandleLockTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DbHandleLockTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbHandleLockTest.java,v 1.26 2008/01/07 14:29:05 cwl Exp $ + * $Id: DbHandleLockTest.java,v 1.27.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -14,6 +14,10 @@ import com.sleepycat.je.util.TestUtils; +/** + * BDB's transactional DDL operations (database creation, truncation, + * remove and rename) need special support through what we call "handle" locks. + */ public class DbHandleLockTest extends TestCase { private File envHome; private Environment env; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/APILockoutTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/APILockoutTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/APILockoutTest.java 2008-04-16 01:56:18.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/APILockoutTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: APILockoutTest.java,v 1.10 2008/04/16 01:56:18 linda Exp $ + * $Id: APILockoutTest.java,v 1.10.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/CodeCoverageTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/CodeCoverageTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/CodeCoverageTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/CodeCoverageTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CodeCoverageTest.java,v 1.9 2008/01/07 14:29:06 cwl Exp $ + * $Id: CodeCoverageTest.java,v 1.9.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbConfigManagerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbConfigManagerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbConfigManagerTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbConfigManagerTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbConfigManagerTest.java,v 1.29 2008/01/07 14:29:06 cwl Exp $ + * $Id: DbConfigManagerTest.java,v 1.29.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDeleteTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDeleteTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDeleteTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDeleteTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorDeleteTest.java,v 1.39 2008/01/07 14:29:06 cwl Exp $ + * $Id: DbCursorDeleteTest.java,v 1.39.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDuplicateDeleteTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDuplicateDeleteTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDuplicateDeleteTest.java 2008-03-25 03:26:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDuplicateDeleteTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorDuplicateDeleteTest.java,v 1.61 2008/03/25 02:26:37 linda Exp $ + * $Id: DbCursorDuplicateDeleteTest.java,v 1.61.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDuplicateTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDuplicateTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDuplicateTest.java 2008-05-30 14:04:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDuplicateTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorDuplicateTest.java,v 1.61 2008/05/30 14:04:20 mark Exp $ + * $Id: DbCursorDuplicateTest.java,v 1.61.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDuplicateValidationTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDuplicateValidationTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDuplicateValidationTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDuplicateValidationTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorDuplicateValidationTest.java,v 1.24 2008/01/07 14:29:06 cwl Exp $ + * $Id: DbCursorDuplicateValidationTest.java,v 1.24.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDupTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDupTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorDupTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorDupTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorDupTest.java,v 1.32 2008/01/07 14:29:06 cwl Exp $ + * $Id: DbCursorDupTest.java,v 1.33.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; @@ -43,6 +43,7 @@ OperationStatus status = cursor.getNext(new DatabaseEntry(), new DatabaseEntry(), LockMode.DEFAULT); + assertEquals(OperationStatus.SUCCESS, status); Cursor cursorDup = cursor.dup(true); cursor.close(); cursorDup.close(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorSearchTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorSearchTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorSearchTest.java 2008-05-20 03:27:36.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorSearchTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorSearchTest.java,v 1.37 2008/05/20 03:27:36 linda Exp $ + * $Id: DbCursorSearchTest.java,v 1.37.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorTestBase.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorTestBase.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorTestBase.java 2008-05-30 14:04:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorTestBase.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorTestBase.java,v 1.106 2008/05/30 14:04:20 mark Exp $ + * $Id: DbCursorTestBase.java,v 1.106.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbCursorTest.java 2008-03-20 19:13:54.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbCursorTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbCursorTest.java,v 1.85 2008/03/20 18:13:54 linda Exp $ + * $Id: DbCursorTest.java,v 1.85.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbEnvPoolTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbEnvPoolTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbEnvPoolTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbEnvPoolTest.java 2008-07-01 03:21:04.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: DbEnvPoolTest.java,v 1.11 2008/01/07 14:29:06 cwl Exp $ + * $Id: DbEnvPoolTest.java,v 1.13 2008/07/01 03:21:04 tao Exp $ */ package com.sleepycat.je.dbi; @@ -19,8 +19,6 @@ public class DbEnvPoolTest extends TestCase { - private static final boolean DEBUG = false; - private File envHome = new File(System.getProperty(TestUtils.DEST_DIR)); public DbEnvPoolTest() { @@ -42,7 +40,6 @@ throws Throwable { try { - File file1 = new File(System.getProperty(TestUtils.DEST_DIR)); File file2 = new File("build/test/classes"); /* Create an environment. */ diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbTreeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbTreeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/DbTreeTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/DbTreeTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbTreeTest.java,v 1.29 2008/01/07 14:29:06 cwl Exp $ + * $Id: DbTreeTest.java,v 1.29.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/INListTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/INListTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/INListTest.java 2008-01-18 22:59:52.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/INListTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INListTest.java,v 1.44 2008/01/18 22:59:52 mark Exp $ + * $Id: INListTest.java,v 1.44.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/MemoryBudgetTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/MemoryBudgetTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/MemoryBudgetTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/MemoryBudgetTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MemoryBudgetTest.java,v 1.19 2008/01/07 14:29:06 cwl Exp $ + * $Id: MemoryBudgetTest.java,v 1.19.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/NullCursor.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/NullCursor.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/NullCursor.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/NullCursor.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NullCursor.java,v 1.17 2008/01/07 14:29:06 cwl Exp $ + * $Id: NullCursor.java,v 1.17.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/SortedLSNTreeWalkerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/SortedLSNTreeWalkerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/SortedLSNTreeWalkerTest.java 2008-05-06 18:01:36.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/SortedLSNTreeWalkerTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SortedLSNTreeWalkerTest.java,v 1.17 2008/05/06 18:01:35 linda Exp $ + * $Id: SortedLSNTreeWalkerTest.java,v 1.17.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/SR12641.java libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/SR12641.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/dbi/SR12641.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/dbi/SR12641.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SR12641.java,v 1.9 2008/01/07 14:29:06 cwl Exp $ + * $Id: SR12641.java,v 1.9.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.dbi; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DbTestProxy.java libdb-je-java-3.3.98/test/com/sleepycat/je/DbTestProxy.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DbTestProxy.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DbTestProxy.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbTestProxy.java,v 1.13 2008/01/07 14:29:05 cwl Exp $ + * $Id: DbTestProxy.java,v 1.13.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/DirtyReadTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/DirtyReadTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/DirtyReadTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/DirtyReadTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DirtyReadTest.java,v 1.20 2008/01/07 14:29:05 cwl Exp $ + * $Id: DirtyReadTest.java,v 1.20.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/EnvironmentConfigTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/EnvironmentConfigTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/EnvironmentConfigTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/EnvironmentConfigTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentConfigTest.java,v 1.13 2008/01/07 14:29:05 cwl Exp $ + * $Id: EnvironmentConfigTest.java,v 1.14.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -87,7 +87,7 @@ config.setLocking(false); config.setTransactional(true); File envHome = new File(System.getProperty(TestUtils.DEST_DIR)); - Environment env = new Environment(envHome, config); + new Environment(envHome, config); fail("Should fail because of inconsistent param values"); } catch (IllegalArgumentException e) { // expected. diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/EnvironmentStatTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/EnvironmentStatTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/EnvironmentStatTest.java 2008-03-25 03:26:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/EnvironmentStatTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentStatTest.java,v 1.23 2008/03/25 02:26:37 linda Exp $ + * $Id: EnvironmentStatTest.java,v 1.23.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/EnvironmentTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/EnvironmentTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/EnvironmentTest.java 2008-06-04 18:46:48.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/EnvironmentTest.java 2010-03-23 15:02:24.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvironmentTest.java,v 1.212 2008/06/04 18:46:48 cwl Exp $ + * $Id: EnvironmentTest.java,v 1.213.2.33 2010/03/23 15:02:23 cwl Exp $ */ package com.sleepycat.je; @@ -88,7 +88,7 @@ throws Throwable { try { - assertEquals("Checking version", "3.3.62", + assertEquals("Checking version", "3.3.98", JEVersion.CURRENT_VERSION.getVersionString()); EnvironmentConfig envConfig = TestUtils.initEnvConfig(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/EvictActionTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/EvictActionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/EvictActionTest.java 2008-03-18 02:17:44.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/EvictActionTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvictActionTest.java,v 1.34 2008/03/18 01:17:44 cwl Exp $ + * $Id: EvictActionTest.java,v 1.35.2.3 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.evictor; @@ -448,6 +448,78 @@ } /** + * Checks that a dirty root IN is not evicted in a read-only environment. + * [#16368] + */ + public void testReadOnlyRootINEviction() + throws DatabaseException { + + OperationStatus status; + + openEnv(80, SMALL_CACHE_SIZE); + + /* Big record will be used to force eviction. */ + DatabaseEntry bigRecordKey = new DatabaseEntry(new byte[1]); + status = db.put(null, bigRecordKey, + new DatabaseEntry(new byte[BIG_CACHE_SIZE])); + assertSame(OperationStatus.SUCCESS, status); + + /* Open DB1 and insert a record to create the root IN. */ + DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate(true); + Database db1 = env.openDatabase(null, "db1", dbConfig); + + DatabaseEntry smallRecordKey = new DatabaseEntry(new byte[1]); + DatabaseEntry smallData = new DatabaseEntry(new byte[1]); + status = db1.put(null, smallRecordKey, smallData); + assertSame(OperationStatus.SUCCESS, status); + + /* Close environment and re-open it read-only. */ + db1.close(); + closeEnv(); + + EnvironmentConfig envConfig = + getEnvConfig(80, SMALL_CACHE_SIZE, true /*readOnly*/); + envConfig.setConfigParam + (EnvironmentParams.EVICTOR_NODES_PER_SCAN.getName(), "1"); + openEnv(envConfig); + + dbConfig.setReadOnly(true); + dbConfig.setAllowCreate(false); + db1 = env.openDatabase(null, "db1", dbConfig); + + /* Load a record to load the root IN. */ + status = db1.get(null, smallRecordKey, new DatabaseEntry(), null); + assertSame(OperationStatus.SUCCESS, status); + assertTrue(isRootResident(db1)); + + /* + * Set the root dirty to prevent eviction. In real life, this can only + * be done by recovery in a read-only environment, but that's very + * difficult to simulate precisely. + */ + IN rootIN = DbInternal.dbGetDatabaseImpl(db1). + getTree(). + getRootIN(CacheMode.DEFAULT); + rootIN.setDirty(true); + rootIN.releaseLatch(); + + /* Root should not be evicted while dirty. */ + forceReadOnlyEviction(bigRecordKey); + assertTrue(isRootResident(db1)); + forceReadOnlyEviction(bigRecordKey); + assertTrue(isRootResident(db1)); + + /* When made non-dirty, it can be evicted. */ + rootIN.setDirty(false); + forceReadOnlyEviction(bigRecordKey); + assertTrue(!isRootResident(db1)); + + db1.close(); + closeEnv(); + } + + /** * Check that opening a database in a transaction and then aborting the * transaction will decrement the database use count. [#13415] */ @@ -563,7 +635,6 @@ throws DatabaseException { EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env); - MemoryBudget mb = envImpl.getMemoryBudget(); OperationStatus status; /* @@ -593,12 +664,56 @@ } /** + * Force eviction by reading a large record. + */ + private void forceReadOnlyEviction(DatabaseEntry key) + throws DatabaseException { + + EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env); + OperationStatus status; + + /* + * Repeat twice to cause a 2nd pass over the INList. The second pass + * evicts BINs that were only stripped of LNs in the first pass. + */ + for (int i = 0; i < 2; i += 1) { + Cursor c = db.openCursor(null, null); + status = c.getSearchKey(key, new DatabaseEntry(), null); + assertSame(OperationStatus.SUCCESS, status); + + /* + * Evict while cursor pins LN memory, to ensure eviction of other + * DB INs, including the DB root. When lruOnly=false, root IN + * eviction may not occur unless a cursor is used to pin the LN. + */ + env.evictMemory(); + + c.close(); + } + + TestUtils.validateNodeMemUsage(envImpl, true); + } + + /** * Open an environment and database. */ private void openEnv(int floor, int maxMem) throws DatabaseException { + EnvironmentConfig envConfig = + getEnvConfig(floor, maxMem, false /*readonly*/); + openEnv(envConfig); + } + + /** + * Open an environment and database. + */ + private EnvironmentConfig getEnvConfig(int floor, + int maxMem, + boolean readOnly) + throws DatabaseException { + /* Convert floor percentage into bytes. */ long evictBytes = 0; if (floor > 0) { @@ -607,7 +722,8 @@ /* Make a non-txnal env w/no daemons and small nodes. */ EnvironmentConfig envConfig = TestUtils.initEnvConfig(); - envConfig.setAllowCreate(true); + envConfig.setAllowCreate(!readOnly); + envConfig.setReadOnly(readOnly); envConfig.setTxnNoSync(Boolean.getBoolean(TestUtils.NO_SYNC)); envConfig.setConfigParam(EnvironmentParams. ENV_RUN_EVICTOR.getName(), "false"); @@ -649,11 +765,20 @@ NODE_MAX.getName(), "4"); envConfig.setConfigParam(EnvironmentParams. NODE_MAX_DUPTREE.getName(), "4"); + + return envConfig; + } + + private void openEnv(EnvironmentConfig envConfig) + throws DatabaseException { + env = new Environment(envHome, envConfig); + boolean readOnly = envConfig.getReadOnly(); - /* Open a database. */ + /* Open database. */ DatabaseConfig dbConfig = new DatabaseConfig(); - dbConfig.setAllowCreate(true); + dbConfig.setAllowCreate(!readOnly); + dbConfig.setReadOnly(readOnly); dbConfig.setSortedDuplicates(true); db = env.openDatabase(null, "foo", dbConfig); } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/EvictNNodesStatsTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/EvictNNodesStatsTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/EvictNNodesStatsTest.java 2008-03-18 02:17:44.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/EvictNNodesStatsTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvictNNodesStatsTest.java,v 1.3 2008/03/18 01:17:44 cwl Exp $ + * $Id: EvictNNodesStatsTest.java,v 1.3.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.evictor; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/EvictSelectionTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/EvictSelectionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/EvictSelectionTest.java 2008-01-07 14:29:08.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/EvictSelectionTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EvictSelectionTest.java,v 1.22 2008/01/07 14:29:07 cwl Exp $ + * $Id: EvictSelectionTest.java,v 1.22.2.3 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.evictor; @@ -16,6 +16,7 @@ import junit.framework.TestCase; import com.sleepycat.bind.tuple.IntegerBinding; +import com.sleepycat.je.Cursor; import com.sleepycat.je.Database; import com.sleepycat.je.DatabaseConfig; import com.sleepycat.je.DatabaseEntry; @@ -23,7 +24,9 @@ import com.sleepycat.je.DbInternal; import com.sleepycat.je.Environment; import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.EnvironmentMutableConfig; import com.sleepycat.je.EnvironmentStats; +import com.sleepycat.je.OperationStatus; import com.sleepycat.je.StatsConfig; import com.sleepycat.je.config.EnvironmentParams; import com.sleepycat.je.dbi.EnvironmentImpl; @@ -328,4 +331,81 @@ } return nIterated; } + + /** + * Tests a fix for an eviction bug that could cause an OOME in a read-only + * environment. [#17590] + * + * Before the bug fix, a dirty IN prevented eviction from working if the + * dirty IN is returned by Evictor.selectIN repeatedly, only to be rejected + * by Evictor.evictIN because it is dirty. A dirty IN was considered as a + * target and sometimes selected by selectIN as a way to avoid an infinite + * loop when all INs are dirty. This is unnecessary, since a condition was + * added to cause the selectIN loop to terminate when all INs in the INList + * have been iterated. Now, with the fix, a dirty IN in a read-only + * environment is never considered as a target or returned by selectIN. + * + * The OOME was reproduced with a simple test that uses a cursor to iterate + * through 100k records, each 100k in size, in a read-only enviroment with + * a 16m heap. However, reproducing the problem in a fast-running unit + * test is very difficult. Instead, since the code change only impacts a + * read-only environment, this unit test only ensures that the fix does not + * cause an infinte loop when all nodes are dirty. + */ + public void testReadOnlyAllDirty() + throws Throwable { + + /* Create an environment, database, and insert some data. */ + initialize(true /*makeDatabase*/); + env.close(); + env = null; + envImpl = null; + + /* Open the environment read-only. */ + final EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + envConfig.setReadOnly(true); + env = new Environment(envHome, envConfig); + envImpl = DbInternal.envGetEnvironmentImpl(env); + + /* Load everything into cache. */ + { + final DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setReadOnly(true); + final Database db = env.openDatabase(null, "foo", dbConfig); + final Cursor cursor = db.openCursor(null, null); + final DatabaseEntry key = new DatabaseEntry(); + final DatabaseEntry data = new DatabaseEntry(); + OperationStatus status = cursor.getFirst(key, data, null); + while (status == OperationStatus.SUCCESS) { + status = cursor.getNext(key, data, null); + } + cursor.close(); + db.close(); + } + + /* Artificially make all nodes dirty in a read-only environment. */ + for (IN in : envImpl.getInMemoryINs()) { + in.setDirty(true); + } + + /* + * Force an eviction. No nodes will be selected for an eviction, + * because all nodes are dirty. If the (nIterated < maxNodesToIterate) + * condition is removed from the selectIN loop, an infinite loop will + * occur. + */ + final EnvironmentMutableConfig mutableConfig = env.getMutableConfig(); + mutableConfig.setCacheSize(MemoryBudget.MIN_MAX_MEMORY_SIZE); + env.setMutableConfig(mutableConfig); + final StatsConfig clearStats = new StatsConfig(); + clearStats.setClear(true); + EnvironmentStats stats = env.getStats(clearStats); + env.evictMemory(); + stats = env.getStats(clearStats); + assertEquals(0, stats.getNNodesSelected()); + + env.close(); + env = null; + envImpl = null; + } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/LRUTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/LRUTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/LRUTest.java 2008-03-18 02:17:44.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/LRUTest.java 2010-03-26 13:23:56.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LRUTest.java,v 1.3 2008/03/18 01:17:44 cwl Exp $ + * $Id: LRUTest.java,v 1.3.2.4 2010/03/26 13:23:55 mark Exp $ */ package com.sleepycat.je.evictor; @@ -286,6 +286,126 @@ close(); } + public void testCacheMode_MAKE_COLD() + throws DatabaseException { + + open(); + for (int i = 0; i < N_DBS; i += 1) { + write(dbs[i], DB_CACHE_SIZE); + } + long[] results = new long[100]; + for (int repeat = 0; repeat < 100; repeat += 1) { + + /* Read all DBs evenly. */ + DatabaseEntry key = new DatabaseEntry(); + DatabaseEntry data = new DatabaseEntry(); + boolean done = false; + Cursor[] cursors = new Cursor[N_DBS]; + for (int j = 0; j < N_DBS; j++) { + cursors[j] = dbs[j].openCursor(null, null); + } + cursors[0].setCacheMode(CacheMode.MAKE_COLD); + cursors[1].setCacheMode(CacheMode.MAKE_COLD); + cursors[2].setCacheMode(CacheMode.UNCHANGED); + cursors[3].setCacheMode(CacheMode.UNCHANGED); + cursors[4].setCacheMode(CacheMode.UNCHANGED); + for (int i = 0; !done; i += 1) { + IntegerBinding.intToEntry(i, key); + for (int j = 0; j < N_DBS; j += 1) { + if (cursors[j].getSearchKey(key, data, null) != + OperationStatus.SUCCESS) { + done = true; + } + } + } + + for (int j = 0; j < N_DBS; j++) { + cursors[j].close(); + } + + /* + * Check that db[0] and db[1] use more than the other three. + */ + StringBuffer buf = new StringBuffer(); + long[] dbBytes = new long[N_DBS]; + for (int i = 0; i < N_DBS; i += 1) { + dbBytes[i] = getDatabaseCacheBytes(dbs[i]); + buf.append(" db=" + i + " bytes=" + dbBytes[i]); + } + assertTrue(dbBytes[0] < dbBytes[2]); + assertTrue(dbBytes[0] < dbBytes[3]); + assertTrue(dbBytes[0] < dbBytes[4]); + assertTrue(dbBytes[1] < dbBytes[2]); + assertTrue(dbBytes[1] < dbBytes[3]); + assertTrue(dbBytes[1] < dbBytes[4]); + //System.out.println(buf); + } + Arrays.sort(results); + //System.out.println(Arrays.toString(results)); + + close(); + } + + public void testCacheMode_EVICT_LN() + throws DatabaseException { + + open(); + for (int i = 0; i < N_DBS; i += 1) { + write(dbs[i], DB_CACHE_SIZE); + } + long[] results = new long[100]; + for (int repeat = 0; repeat < 100; repeat += 1) { + + /* Read all DBs evenly. */ + DatabaseEntry key = new DatabaseEntry(); + DatabaseEntry data = new DatabaseEntry(); + boolean done = false; + Cursor[] cursors = new Cursor[N_DBS]; + for (int j = 0; j < N_DBS; j++) { + cursors[j] = dbs[j].openCursor(null, null); + } + cursors[0].setCacheMode(CacheMode.EVICT_LN); + cursors[1].setCacheMode(CacheMode.EVICT_LN); + cursors[2].setCacheMode(CacheMode.MAKE_COLD); + cursors[3].setCacheMode(CacheMode.MAKE_COLD); + cursors[4].setCacheMode(CacheMode.MAKE_COLD); + for (int i = 0; !done; i += 1) { + IntegerBinding.intToEntry(i, key); + for (int j = 0; j < N_DBS; j += 1) { + if (cursors[j].getSearchKey(key, data, null) != + OperationStatus.SUCCESS) { + done = true; + } + } + } + + for (int j = 0; j < N_DBS; j++) { + cursors[j].close(); + } + + /* + * Check that db[0] and db[1] use more than the other three. + */ + StringBuffer buf = new StringBuffer(); + long[] dbBytes = new long[N_DBS]; + for (int i = 0; i < N_DBS; i += 1) { + dbBytes[i] = getDatabaseCacheBytes(dbs[i]); + buf.append(" db=" + i + " bytes=" + dbBytes[i]); + } + assertTrue(dbBytes[0] < dbBytes[2]); + assertTrue(dbBytes[0] < dbBytes[3]); + assertTrue(dbBytes[0] < dbBytes[4]); + assertTrue(dbBytes[1] < dbBytes[2]); + assertTrue(dbBytes[1] < dbBytes[3]); + assertTrue(dbBytes[1] < dbBytes[4]); + //System.out.println(buf); + } + Arrays.sort(results); + //System.out.println(Arrays.toString(results)); + + close(); + } + private long getDatabaseCacheBytes(Database db) throws DatabaseException { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/SharedCacheTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/SharedCacheTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/evictor/SharedCacheTest.java 2008-05-30 00:46:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/evictor/SharedCacheTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SharedCacheTest.java,v 1.11 2008/05/30 00:46:09 mark Exp $ + * $Id: SharedCacheTest.java,v 1.11.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.evictor; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/GetSearchBothRangeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/GetSearchBothRangeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/GetSearchBothRangeTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/GetSearchBothRangeTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: GetSearchBothRangeTest.java,v 1.14 2008/01/07 14:29:05 cwl Exp $ + * $Id: GetSearchBothRangeTest.java,v 1.14.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/incomp/EmptyBINTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/incomp/EmptyBINTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/incomp/EmptyBINTest.java 2008-01-07 14:29:08.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/incomp/EmptyBINTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EmptyBINTest.java,v 1.11 2008/01/07 14:29:07 cwl Exp $ + * $Id: EmptyBINTest.java,v 1.11.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.incomp; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/incomp/INCompressorTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/incomp/INCompressorTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/incomp/INCompressorTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/incomp/INCompressorTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INCompressorTest.java,v 1.20 2008/05/22 19:35:38 linda Exp $ + * $Id: INCompressorTest.java,v 1.20.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.incomp; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/InterruptTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/InterruptTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/InterruptTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/InterruptTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: InterruptTest.java,v 1.14 2008/01/07 14:29:05 cwl Exp $ + * $Id: InterruptTest.java,v 1.14.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/jmx/MBeanTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/jmx/MBeanTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/jmx/MBeanTest.java 2008-01-07 14:29:08.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/jmx/MBeanTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MBeanTest.java,v 1.18 2008/01/07 14:29:08 cwl Exp $ + * $Id: MBeanTest.java,v 1.18.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.jmx; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/junit/JUnitMethodThread.java libdb-je-java-3.3.98/test/com/sleepycat/je/junit/JUnitMethodThread.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/junit/JUnitMethodThread.java 2008-01-07 14:29:08.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/junit/JUnitMethodThread.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JUnitMethodThread.java,v 1.8 2008/01/07 14:29:08 cwl Exp $ + * $Id: JUnitMethodThread.java,v 1.8.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.junit; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/junit/JUnitThread.java libdb-je-java-3.3.98/test/com/sleepycat/je/junit/JUnitThread.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/junit/JUnitThread.java 2008-01-07 14:29:08.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/junit/JUnitThread.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JUnitThread.java,v 1.21 2008/01/07 14:29:08 cwl Exp $ + * $Id: JUnitThread.java,v 1.21.2.2 2010/01/04 15:30:43 cwl Exp $ */ package com.sleepycat.je.junit; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/latch/LatchTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/latch/LatchTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/latch/LatchTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/latch/LatchTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LatchTest.java,v 1.37 2008/01/07 14:29:09 cwl Exp $ + * $Id: LatchTest.java,v 1.37.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.latch; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileEdgeCaseTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileEdgeCaseTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileEdgeCaseTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileEdgeCaseTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileEdgeCaseTest.java,v 1.6 2008/01/07 14:29:09 cwl Exp $ + * $Id: FileEdgeCaseTest.java,v 1.6.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileManagerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileManagerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileManagerTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileManagerTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileManagerTest.java,v 1.71 2008/01/07 14:29:09 cwl Exp $ + * $Id: FileManagerTest.java,v 1.72.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; @@ -397,7 +397,6 @@ FileManagerTestUtils.createLogFile(fileManager, envImpl, FILE_SIZE); byte[] badData = new byte[]{1,1}; - int headerSize = FileManager.firstLogEntryOffset(); RandomAccessFile file0 = new RandomAccessFile (fileManager.getFullFileName(0, FileManager.JE_SUFFIX), @@ -407,7 +406,7 @@ fileManager.clear(); try { - FileHandle file0Handle = fileManager.getFileHandle(0L); + fileManager.getFileHandle(0L); fail("expect to catch a checksum error"); } catch (DbChecksumException e) { } @@ -462,7 +461,7 @@ Long f3 = new Long(3L); Long f4 = new Long(4L); - Set keySet = fileManager.getCacheKeys(); + Set keySet = fileManager.getCacheKeys(); assertEquals("should have 0 keys", 0, keySet.size()); /* diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileManagerTestUtils.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileManagerTestUtils.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileManagerTestUtils.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileManagerTestUtils.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileManagerTestUtils.java,v 1.8 2008/01/07 14:29:09 cwl Exp $ + * $Id: FileManagerTestUtils.java,v 1.8.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileReaderBufferingTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileReaderBufferingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileReaderBufferingTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileReaderBufferingTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FileReaderBufferingTest.java,v 1.18 2008/05/22 19:35:38 linda Exp $ + * $Id: FileReaderBufferingTest.java,v 1.18.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileReaderTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileReaderTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/FileReaderTest.java 2008-04-18 22:57:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/FileReaderTest.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2005,2008 Oracle. All rights reserved. * - * $Id: FileReaderTest.java,v 1.15 2008/04/18 22:57:39 mark Exp $ + * $Id: FileReaderTest.java,v 1.16 2008/06/30 20:54:47 linda Exp $ */ package com.sleepycat.je.log; @@ -27,14 +27,10 @@ */ public class FileReaderTest extends TestCase { - static private final boolean DEBUG = false; - private File envHome; - public FileReaderTest() throws Exception { - envHome = new File(System.getProperty(TestUtils.DEST_DIR)); } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/FSyncManagerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/FSyncManagerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/FSyncManagerTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/FSyncManagerTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FSyncManagerTest.java,v 1.13 2008/01/07 14:29:09 cwl Exp $ + * $Id: FSyncManagerTest.java,v 1.13.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/INFileReaderTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/INFileReaderTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/INFileReaderTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/INFileReaderTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INFileReaderTest.java,v 1.87 2008/05/22 19:35:38 linda Exp $ + * $Id: INFileReaderTest.java,v 1.87.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/IOExceptionTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/IOExceptionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/IOExceptionTest.java 2008-01-17 17:22:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/IOExceptionTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: IOExceptionTest.java,v 1.20 2008/01/17 17:22:16 cwl Exp $ + * $Id: IOExceptionTest.java,v 1.22.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; @@ -228,7 +228,6 @@ CheckpointConfig chkConf = new CheckpointConfig(); chkConf.setForce(true); Transaction txn = env.beginTransaction(null, null); - int keyInt = 0; for (int i = 0; i < N_RECS; i++) { String keyStr = Integer.toString(i); DatabaseEntry key = @@ -543,9 +542,6 @@ dbConfig.setAllowCreate(true); db = env.openDatabase(null, "foo", dbConfig); - String stuff = new String("..hello world ......................" + - "..................................."); - /* * Put one record into the database so it gets populated w/INs and * LNs, and we can fake out the RMW commits used below. @@ -593,9 +589,15 @@ /* Eat exception thrown by TraceLogHandler. */ } - /* Generated a forced record by calling commit. */ + /* + * Generate a forced record by calling commit. Since RMW + * transactions that didn't actually do a write won't log a + * commit record, do an addLogInfo to trick the txn into + * logging a commit. + */ Transaction txn = env.beginTransaction(null, null); db.get(txn, key, data, LockMode.RMW); + DbInternal.getTxn(txn).addLogInfo(DbLsn.makeLsn(3, 3)); txn.commit(); } db.close(); @@ -756,7 +758,6 @@ FileManager.IO_EXCEPTION_TESTING_ON_WRITE = true; LockStats stats = env.getLockStats(null); int nLocksPreGet = stats.getNTotalLocks(); - int nLocksPostGet = -1; /* Loop doing aborts until the buffer fills up and we get an IOE. */ while (true) { @@ -771,10 +772,9 @@ assertTrue(status == (OperationStatus.SUCCESS)); stats = env.getLockStats(null); - nLocksPostGet = stats.getNTotalLocks(); try { - txn.abort(); + txn.abort(); /* * Keep going until we actually get an IOException from the @@ -831,9 +831,7 @@ writeAndVerify(txn, false, "k6", "d6", false); writeAndVerify(txn, true, "k6a", "d6a", false); - stats = env.getLockStats(null); - int nLocksPostPut = stats.getNTotalLocks(); - + stats = env.getLockStats(null); try { txn.commit(); fail("expected DatabaseException"); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LastFileReaderTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LastFileReaderTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LastFileReaderTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LastFileReaderTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LastFileReaderTest.java,v 1.76 2008/05/22 19:35:38 linda Exp $ + * $Id: LastFileReaderTest.java,v 1.76.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LNFileReaderTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LNFileReaderTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LNFileReaderTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LNFileReaderTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LNFileReaderTest.java,v 1.101 2008/05/22 19:35:38 linda Exp $ + * $Id: LNFileReaderTest.java,v 1.101.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogBufferPoolTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogBufferPoolTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogBufferPoolTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogBufferPoolTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogBufferPoolTest.java,v 1.66 2008/05/22 19:35:38 linda Exp $ + * $Id: LogBufferPoolTest.java,v 1.66.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogEntryTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogEntryTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogEntryTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogEntryTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogEntryTest.java,v 1.20 2008/01/07 14:29:09 cwl Exp $ + * $Id: LogEntryTest.java,v 1.20.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LoggableTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LoggableTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LoggableTest.java 2008-05-13 01:57:02.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LoggableTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LoggableTest.java,v 1.93 2008/05/13 01:57:02 linda Exp $ + * $Id: LoggableTest.java,v 1.94.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; @@ -12,8 +12,6 @@ import java.io.IOException; import java.nio.ByteBuffer; -import javax.xml.parsers.DocumentBuilderFactory; - import junit.framework.TestCase; import com.sleepycat.je.DatabaseConfig; @@ -59,12 +57,6 @@ throws Exception { envHome = new File(System.getProperty(TestUtils.DEST_DIR)); - - /* - * Attempt to validate that the db print log output is valid - * xml -- isn't quite working - */ - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); } public void setUp() diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogManagerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogManagerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogManagerTest.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogManagerTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogManagerTest.java,v 1.85 2008/05/22 19:35:38 linda Exp $ + * $Id: LogManagerTest.java,v 1.85.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogUtilsTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogUtilsTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/LogUtilsTest.java 2008-01-17 17:22:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/LogUtilsTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogUtilsTest.java,v 1.24 2008/01/17 17:22:16 cwl Exp $ + * $Id: LogUtilsTest.java,v 1.24.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/log/TestUtilLogReader.java libdb-je-java-3.3.98/test/com/sleepycat/je/log/TestUtilLogReader.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/log/TestUtilLogReader.java 2008-03-10 20:59:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/log/TestUtilLogReader.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestUtilLogReader.java,v 1.11 2008/03/10 19:59:19 linda Exp $ + * $Id: TestUtilLogReader.java,v 1.11.2.3 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.log; @@ -60,6 +60,10 @@ return entryType; } + public int getEntryVersion() { + return currentEntryHeader.getVersion(); + } + public LogEntry getEntry() { return entry; } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/LogEntryVersionTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/LogEntryVersionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/LogEntryVersionTest.java 2008-05-30 14:04:22.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/LogEntryVersionTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogEntryVersionTest.java,v 1.23 2008/05/30 14:04:21 mark Exp $ + * $Id: LogEntryVersionTest.java,v 1.24.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.logversion; @@ -47,7 +47,6 @@ private Environment env; private Database db1; private Database db2; - private Database db3; public LogEntryVersionTest() { envHome = new File(System.getProperty(TestUtils.DEST_DIR)); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/LogHeaderVersionTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/LogHeaderVersionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/LogHeaderVersionTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/LogHeaderVersionTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogHeaderVersionTest.java,v 1.10 2008/01/07 14:29:10 cwl Exp $ + * $Id: LogHeaderVersionTest.java,v 1.10.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.logversion; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/MakeLogEntryVersionData.java libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/MakeLogEntryVersionData.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/MakeLogEntryVersionData.java 2008-05-28 15:35:18.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/MakeLogEntryVersionData.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MakeLogEntryVersionData.java,v 1.19 2008/05/28 15:35:18 linda Exp $ + * $Id: MakeLogEntryVersionData.java,v 1.19.2.4 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.logversion; @@ -218,12 +218,14 @@ env.close(); /* - * Get the set of all log entry types we expect to output. We punt on - * one type -- MapLN_TX -- because MapLN (non-transactional) is now - * used instead. + * Get the set of all log entry types we expect to output. We exclude + * two types: + * - MapLN_TX, because MapLN (non-transactional) is now used instead. + * - INDelete, because root compression is no longer used. */ Set expectedTypes = LogEntryType.getAllTypes(); expectedTypes.remove(LogEntryType.LOG_MAPLN_TRANSACTIONAL); + expectedTypes.remove(LogEntryType.LOG_IN_DELETE_INFO); /* Open read-only and write all LogEntryType names to a text file. */ envConfig.setReadOnly(true); @@ -234,7 +236,8 @@ (DbInternal.envGetEnvironmentImpl(env2), true /* readFullItem */); while (reader.readNextEntry()) { LogEntryType type = reader.getEntryType(); - writer.println(type.toString()); + writer.println(type.toStringNoVersion() + '/' + + reader.getEntryVersion()); expectedTypes.remove(type); } writer.close(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/MakeLogHeaderVersionData.java libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/MakeLogHeaderVersionData.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/MakeLogHeaderVersionData.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/MakeLogHeaderVersionData.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MakeLogHeaderVersionData.java,v 1.10 2008/01/07 14:29:10 cwl Exp $ + * $Id: MakeLogHeaderVersionData.java,v 1.10.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.logversion; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/Utils.java libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/Utils.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/logversion/Utils.java 2008-05-13 01:57:02.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/logversion/Utils.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Utils.java,v 1.9 2008/05/13 01:57:02 linda Exp $ + * $Id: Utils.java,v 1.9.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.logversion; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/ReadCommittedTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/ReadCommittedTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/ReadCommittedTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/ReadCommittedTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReadCommittedTest.java,v 1.8 2008/01/07 14:29:05 cwl Exp $ + * $Id: ReadCommittedTest.java,v 1.8.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckBase.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckBase.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckBase.java 2008-05-22 19:35:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckBase.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: CheckBase.java,v 1.22 2008/05/22 19:35:38 linda Exp $ + * $Id: CheckBase.java,v 1.24 2008/06/30 20:54:48 linda Exp $ */ package com.sleepycat.je.recovery; @@ -198,8 +198,8 @@ saveLogFiles(envHome); /* txnId -> LogEntryInfo */ - Map newUncommittedRecords = new HashMap(); - Map deletedUncommittedRecords = new HashMap(); + Map> newUncommittedRecords = new HashMap>(); + Map> deletedUncommittedRecords = new HashMap>(); /* Now run recovery repeatedly, truncating at different locations. */ String status = null; @@ -209,8 +209,6 @@ * Some tests are not working with starting at 0. As a workaround, * start at another iteration. */ - DatabaseEntry keyEntry = new DatabaseEntry(); - DatabaseEntry dataEntry = new DatabaseEntry(); for (int i = startingIteration; i < logDescription.size(); i++ ) { /* Find out where to truncate. */ @@ -311,7 +309,8 @@ /* * The found and expected data sets need to match exactly after recovery. */ - void validate(HashSet expected) + @SuppressWarnings("unchecked") // clone() returns Object + void validate(HashSet expected) throws DatabaseException { Set useExpected = (Set) expected.clone(); @@ -503,12 +502,6 @@ /* If true, generate a log description to use in stepwise testing. */ boolean generateLogDescription; - /* - * Some generators run off a list of test operations which specify - * what actions to use when generating data. - */ - public List operationList; - public TestGenerator() { } @@ -516,10 +509,6 @@ this.generateLogDescription = generateLogDescription; } - public TestGenerator(List operationList) { - this.operationList = operationList; - } - void generateData(Database db) throws Exception { } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckDupMaxFlushLevelTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckDupMaxFlushLevelTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckDupMaxFlushLevelTest.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckDupMaxFlushLevelTest.java 2008-12-13 18:24:04.000000000 +0000 @@ -0,0 +1,224 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2004,2008 Oracle. All rights reserved. + * + * $Id: CheckDupMaxFlushLevelTest.java,v 1.1.2.1 2008/12/13 18:24:04 mark Exp $ + */ +package com.sleepycat.je.recovery; + +import com.sleepycat.bind.tuple.IntegerBinding; +import com.sleepycat.je.CacheMode; +import com.sleepycat.je.CheckpointConfig; +import com.sleepycat.je.Cursor; +import com.sleepycat.je.Database; +import com.sleepycat.je.DatabaseConfig; +import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.DbInternal; +import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.OperationStatus; +import com.sleepycat.je.dbi.DatabaseImpl; +import com.sleepycat.je.tree.BIN; +import com.sleepycat.je.tree.DIN; +import com.sleepycat.je.tree.Node; +import com.sleepycat.je.tree.Tree.SearchType; +import com.sleepycat.je.util.TestUtils; + +public class CheckDupMaxFlushLevelTest extends CheckBase { + + private static final String DB_NAME = "foo"; + + /** + * Tests a fix for a bug in the way that the maxFlushLevel is used to + * determine when to log a DIN root as provisional. [#16712] + * + * Imagine this Btree. + * + * IN-A + * | + * BIN-B + * / \ + * DIN-C DIN-E + * | | + * DBIN-D DIN-F + * | + * DBIN-G + * + * When the checkpoint starts, DIN-C and DIN-E are the highest nodes that + * are dirty. So the max flush level is .... 3! + * + * DIN-C is level 2 and DIN-E is level 3. They are at the same height + * relative to the top, but not to the bottom. + * + * When we flush DIN-E, we make it non-provisional because its level (3) is + * equal to the max flush level (3). + * + * But when we flush DIN-C, we make it provisional + * (Provisional.BEFORE_CKPT_END to be exact, but provisional in effect) + * because its level (2) is less than the max flush level (3). + * + * When we recover, we don't replay DIN-C because it is provisional. So + * any references it contains (or its children contain) that were necessary + * for log cleaning, are lost. If we deleted a log file based on those + * lost references, we'll get LogFileNotFound. + * + * The solution is to log DIN-C non-provisionally, even though its level is + * less than the max flush level. It must be logged non-provisionally + * when the parent's level is greater than the max flush level. + */ + public void testDupMaxFlushLevel() + throws Throwable { + + final EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + turnOffEnvDaemons(envConfig); + envConfig.setAllowCreate(true); + turnOffEnvDaemons(envConfig); + + final DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate(true); + dbConfig.setSortedDuplicates(true); + dbConfig.setNodeMaxDupTreeEntries(4); + + setCheckLsns(false); + + testOneCase(DB_NAME, + envConfig, + dbConfig, + new TestGenerator(){ + void generateData(Database db) + throws DatabaseException { + + createMultiLevelDupTree(db); + } + }, + envConfig, + dbConfig); + } + + private void insert(Database db, int key, int data) + throws DatabaseException { + + final DatabaseEntry keyEntry = new DatabaseEntry(); + IntegerBinding.intToEntry(key, keyEntry); + final DatabaseEntry dataEntry = new DatabaseEntry(); + IntegerBinding.intToEntry(data, dataEntry); + assertSame(OperationStatus.SUCCESS, + db.putNoDupData(null, keyEntry, dataEntry)); + } + + private void remove(Database db, int key, int data) + throws DatabaseException { + + final DatabaseEntry keyEntry = new DatabaseEntry(); + IntegerBinding.intToEntry(key, keyEntry); + final DatabaseEntry dataEntry = new DatabaseEntry(); + IntegerBinding.intToEntry(data, dataEntry); + final Cursor c = db.openCursor(null, null); + try { + assertSame(OperationStatus.SUCCESS, + c.getSearchBoth(keyEntry, dataEntry, null)); + assertSame(OperationStatus.SUCCESS, c.delete()); + } finally { + c.close(); + } + } + + private void createMultiLevelDupTree(Database db) + throws DatabaseException { + + final DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(db); + + /* Create a 3 level dup tree for key 1. */ + for (int data = 1; getDupTreeDepth(dbImpl, 1) != 3; data += 1) { + insert(db, 1, data); + } + + /* Create a 2 level dup tree for key 2. */ + for (int data = 1; getDupTreeDepth(dbImpl, 2) != 2; data += 1) { + insert(db, 2, data); + } + + /* Flush all the way to the root. */ + final CheckpointConfig ckptConfig = new CheckpointConfig(); + ckptConfig.setForce(true); + ckptConfig.setMinimizeRecoveryTime(true); + env.checkpoint(ckptConfig); + + /* + * Remove one entry for key 2, for which the DIN will be flushed + * provisionally (incorrectly) when the bug occurs. + */ + remove(db, 2, 1); + + /* Make both DIN roots dirty. */ + setDINRootDirty(dbImpl, 1); + setDINRootDirty(dbImpl, 2); + + /* + * Perform a normal checkpoint which should flush only up to the DIN + * roots. The bug causes the DIN root for key 2 to be incorrectly + * logged as provisional. During recovery, the removal of record (2,1) + * will be lost. + */ + ckptConfig.setForce(true); + ckptConfig.setMinimizeRecoveryTime(false); + env.checkpoint(ckptConfig); + } + + private int getDupTreeDepth(DatabaseImpl dbImpl, int key) + throws DatabaseException { + + final DIN din = getLatchedDINRoot(dbImpl, key); + if (din == null) { + return 0; + } + try { + return din.getLevel(); + } finally { + din.releaseLatch(); + } + } + + private void setDINRootDirty(DatabaseImpl dbImpl, int key) + throws DatabaseException { + + final DIN din = getLatchedDINRoot(dbImpl, key); + assertNotNull(din); + try { + din.setDirty(true); + } finally { + din.releaseLatch(); + } + } + + private DIN getLatchedDINRoot(DatabaseImpl dbImpl, int key) + throws DatabaseException { + + final DatabaseEntry keyEntry = new DatabaseEntry(); + IntegerBinding.intToEntry(key, keyEntry); + final byte[] keyBytes = keyEntry.getData(); + + final BIN bin = (BIN) dbImpl.getTree().search + (keyBytes, SearchType.NORMAL, -1, null, CacheMode.DEFAULT); + if (bin == null) { + return null; + } + try { + final int idx = bin.findEntry(keyBytes, false, true); + if (idx < 0) { + return null; + } + final Node child = bin.fetchTarget(idx); + if (!(child instanceof DIN)) { + return null; + } + final DIN din = (DIN) child; + assertNotNull(din); + din.latch(); + return din; + } finally { + bin.releaseLatch(); + } + } +} diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckNewRootTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckNewRootTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckNewRootTest.java 2008-05-07 01:51:18.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckNewRootTest.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: CheckNewRootTest.java,v 1.16 2008/05/07 01:51:17 linda Exp $ + * $Id: CheckNewRootTest.java,v 1.17 2008/06/30 20:54:48 linda Exp $ */ package com.sleepycat.je.recovery; @@ -27,6 +27,7 @@ import com.sleepycat.je.log.LogEntryType; import com.sleepycat.je.log.ReplicationContext; import com.sleepycat.je.log.entry.SingleItemEntry; +import com.sleepycat.je.recovery.stepwise.TestData; import com.sleepycat.je.util.TestUtils; import com.sleepycat.je.utilint.TestHook; import com.sleepycat.je.utilint.Tracer; @@ -39,7 +40,6 @@ private static final boolean DEBUG = false; private static final String DB_NAME = "simpleDB"; - private boolean purgeRoot = false; private boolean useDups = false; private static CheckpointConfig FORCE_CONFIG = new CheckpointConfig(); static { @@ -81,7 +81,7 @@ * Now run the test in a stepwise loop, truncate after each log entry. * Our baseline expected set is empty -- no records expected. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -161,7 +161,7 @@ * Now run the test in a stepwise loop, truncate after each log entry. * Our baseline expected set is empty -- no records expected. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -234,7 +234,7 @@ * Now run the test in a stepwise loop, truncate after each log entry. * Our baseline expected set is empty -- no records expected. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -342,7 +342,7 @@ * Now run the test in a stepwise loop, truncate after each log entry. * Our baseline expected set is empty -- no records expected. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckpointActivationTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckpointActivationTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckpointActivationTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckpointActivationTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CheckpointActivationTest.java,v 1.21 2008/01/07 14:29:10 cwl Exp $ + * $Id: CheckpointActivationTest.java,v 1.21.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckReverseSplitsTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckReverseSplitsTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckReverseSplitsTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckReverseSplitsTest.java 2009-08-02 20:04:44.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: CheckReverseSplitsTest.java,v 1.11 2008/01/07 14:29:10 cwl Exp $ + * $Id: CheckReverseSplitsTest.java,v 1.12.2.1 2009/08/02 20:04:43 mark Exp $ */ package com.sleepycat.je.recovery; @@ -38,7 +38,6 @@ */ public class CheckReverseSplitsTest extends CheckBase { - private static final boolean DEBUG = false; private static final String DB_NAME = "simpleDB"; private int max = 12; @@ -84,7 +83,7 @@ */ /* Establish the base set of records we expect. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); DatabaseEntry keyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); for (int i = 2; i < max; i++) { @@ -231,7 +230,7 @@ * Now run the test in a stepwise loop, truncate after each log entry. * Our baseline expected set is empty -- no records expected. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -301,11 +300,8 @@ if (useDups) { assertEquals(0, stats.getDuplicateInternalNodeCount()); } else { - if (purgeRoot) { - assertEquals(0, stats.getInternalNodeCount()); - } else { - assertEquals(1, stats.getBottomInternalNodeCount()); - } + /* COMPRESSOR_PURGE_ROOT is disabled, node should always exist. */ + assertEquals(1, stats.getBottomInternalNodeCount()); } /* Insert new data. */ diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckSplitAuntTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckSplitAuntTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckSplitAuntTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckSplitAuntTest.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: CheckSplitAuntTest.java,v 1.6 2008/01/07 14:29:10 cwl Exp $ + * $Id: CheckSplitAuntTest.java,v 1.7 2008/06/30 20:54:48 linda Exp $ */ package com.sleepycat.je.recovery; @@ -20,13 +20,13 @@ import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.OperationStatus; import com.sleepycat.je.config.EnvironmentParams; +import com.sleepycat.je.recovery.stepwise.TestData; import com.sleepycat.je.util.TestUtils; import com.sleepycat.je.utilint.Tracer; public class CheckSplitAuntTest extends CheckBase { private static final String DB_NAME = "simpleDB"; - private boolean useDups; /** */ @@ -67,7 +67,7 @@ * log entry. We start the steps before the inserts, so the base * expected set is empty. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); if (TestUtils.runLongTests()) { stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckSplitsTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckSplitsTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/CheckSplitsTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/CheckSplitsTest.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: CheckSplitsTest.java,v 1.16 2008/01/07 14:29:10 cwl Exp $ + * $Id: CheckSplitsTest.java,v 1.18 2008/06/30 20:54:48 linda Exp $ */ package com.sleepycat.je.recovery; @@ -21,6 +21,7 @@ import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.OperationStatus; import com.sleepycat.je.config.EnvironmentParams; +import com.sleepycat.je.recovery.stepwise.TestData; import com.sleepycat.je.util.TestUtils; import com.sleepycat.je.utilint.Tracer; @@ -34,7 +35,6 @@ */ public void testBasicInsert() throws Throwable { - boolean foo = TestUtils.runLongTests(); EnvironmentConfig envConfig = TestUtils.initEnvConfig(); turnOffEnvDaemons(envConfig); @@ -66,7 +66,7 @@ * log entry. We start the steps before the inserts, so the base * expected set is empty. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -138,7 +138,7 @@ * log entry. We start the steps before the inserts, so the base * expected set is empty. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); if (TestUtils.runLongTests()) { stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -236,7 +236,7 @@ * log entry. We start the steps before the inserts, so the base * expected set is empty. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); if (TestUtils.runLongTests()) { stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } @@ -329,7 +329,7 @@ * log entry. We start the steps before the inserts, so the base * expected set is empty. */ - HashSet currentExpected = new HashSet(); + HashSet currentExpected = new HashSet(); if (TestUtils.runLongTests()) { stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/LevelRecorderTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/LevelRecorderTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/LevelRecorderTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/LevelRecorderTest.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: LevelRecorderTest.java,v 1.6 2008/01/07 14:29:10 cwl Exp $ + * $Id: LevelRecorderTest.java,v 1.7 2008/06/30 20:54:48 linda Exp $ */ package com.sleepycat.je.recovery; @@ -45,7 +45,7 @@ * We should only have to redo recovery for dbs 1 and 5. Db 10 had * INs all of the same level. */ - Set reprocessSet = recorder.getDbsWithDifferentLevels(); + Set reprocessSet = recorder.getDbsWithDifferentLevels(); assertEquals(2, reprocessSet.size()); assertTrue(reprocessSet.contains(id5)); assertTrue(reprocessSet.contains(id1)); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/MultiEnvTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/MultiEnvTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/MultiEnvTest.java 2008-05-20 03:27:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/MultiEnvTest.java 2008-06-30 20:54:48.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2004,2008 Oracle. All rights reserved. * - * $Id: MultiEnvTest.java,v 1.15 2008/05/20 03:27:37 linda Exp $ + * $Id: MultiEnvTest.java,v 1.16 2008/06/30 20:54:48 linda Exp $ */ package com.sleepycat.je.recovery; @@ -13,17 +13,12 @@ import junit.framework.TestCase; -import com.sleepycat.je.DatabaseException; -import com.sleepycat.je.Environment; -import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.util.TestUtils; public class MultiEnvTest extends TestCase { private File envHome1; private File envHome2; - private Environment env1; - private Environment env2; public MultiEnvTest() { envHome1 = new File(System.getProperty(TestUtils.DEST_DIR)); @@ -55,14 +50,4 @@ * a static field. */ } - - private Environment openEnv(File envHome) - throws DatabaseException { - - /* Create an environment. */ - EnvironmentConfig envConfig = TestUtils.initEnvConfig(); - envConfig.setAllowCreate(true); - Environment e = new Environment(envHome, envConfig); - return e; - } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/Recovery2PCTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/Recovery2PCTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/Recovery2PCTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/Recovery2PCTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,15 +1,17 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Recovery2PCTest.java,v 1.14 2008/01/07 14:29:10 cwl Exp $ + * $Id: Recovery2PCTest.java,v 1.15.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; import java.io.IOException; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; @@ -24,8 +26,6 @@ import com.sleepycat.je.log.LogUtils.XidImpl; public class Recovery2PCTest extends RecoveryTestBase { - private static final boolean DEBUG = false; - private boolean explicitTxn; private boolean commit; private boolean recover; @@ -121,7 +121,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert all the data. */ XidImpl xid = new XidImpl(1, "TwoPCTest1".getBytes(), null); @@ -174,8 +175,11 @@ try { /* Set up an repository of expected data. */ - final Hashtable expectedData1 = new Hashtable(); - final Hashtable expectedData2 = new Hashtable(); + final Map> expectedData1 = + new HashMap>(); + + final Map> expectedData2 = + new HashMap>(); /* Insert all the data. */ final Transaction txn1 = diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryAbortTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryAbortTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryAbortTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryAbortTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,14 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryAbortTest.java,v 1.58 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryAbortTest.java,v 1.59.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import com.sleepycat.je.Cursor; import com.sleepycat.je.Database; @@ -42,7 +44,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert all the data. */ Transaction txn = env.beginTransaction(null, null); @@ -73,7 +76,8 @@ } try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert 0 - N and commit. */ Transaction txn = env.beginTransaction(null, null); @@ -126,7 +130,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert data without duplicates. */ Transaction txn = env.beginTransaction(null, null); @@ -289,7 +294,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert data without duplicates. */ Transaction txn = env.beginTransaction(null, null); @@ -331,7 +337,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert data without duplicates. */ Transaction txn = env.beginTransaction(null, null); @@ -382,7 +389,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert data without duplicates. */ Transaction txn = env.beginTransaction(null, null); @@ -446,7 +454,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert data without duplicates. */ Transaction txn = env.beginTransaction(null, null); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryCheckpointTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryCheckpointTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryCheckpointTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryCheckpointTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,14 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryCheckpointTest.java,v 1.41 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryCheckpointTest.java,v 1.42.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import com.sleepycat.je.CheckpointConfig; import com.sleepycat.je.Cursor; @@ -72,7 +74,9 @@ assertEquals(2, stats.getLastCheckpointId()); /* Shutdown, recover. */ - Hashtable expectedData = new Hashtable(); // expected values + Map> expectedData = + new HashMap>(); + closeEnv(); recoverAndVerify(expectedData, NUM_DBS); // 0 checkpoints @@ -111,7 +115,9 @@ assertEquals(1, stats.getLastCheckpointId()); /* Shutdown, recover. */ - Hashtable expectedData = new Hashtable(); // expected values + Map> expectedData = + new HashMap>(); + Transaction txn = env.beginTransaction(null, null); insertData(txn, 0, 1, expectedData, 1, true, NUM_DBS); txn.commit(); @@ -178,7 +184,9 @@ * because the threshold percentage is 25%, and 25% of 4 is 1. */ int numRecs = 4; - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); + Transaction txn = env.beginTransaction(null, null); insertData(txn, 0, numRecs, expectedData, 1, true, NUM_DBS); env.checkpoint(forceConfig); @@ -219,7 +227,9 @@ try { int numRecs = 1; - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); + Transaction txn = env.beginTransaction(null, null); insertData(txn, 0, numRecs, expectedData, 1, false, NUM_DBS); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryCreateDupTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryCreateDupTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryCreateDupTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryCreateDupTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,14 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryCreateDupTest.java,v 1.12 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryCreateDupTest.java,v 1.13.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import com.sleepycat.bind.tuple.IntegerBinding; import com.sleepycat.je.CheckpointConfig; @@ -91,7 +93,8 @@ * Set up an repository of expected data. We'll be inserting * 2 records, varying whether they are in the same txn or not. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); Transaction txn = env.beginTransaction(null, null); dbs[0].put(txn, keyEntry1, dataEntry1); @@ -212,7 +215,8 @@ * Now create a duplicate tree, reusing the known deleted slot * in the bin. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); IntegerBinding.intToEntry(100, key); IntegerBinding.intToEntry(1, data); dbs[0].put(null, key, data); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryDeleteTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryDeleteTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryDeleteTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryDeleteTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,14 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryDeleteTest.java,v 1.9 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryDeleteTest.java,v 1.10.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import com.sleepycat.je.CheckpointConfig; import com.sleepycat.je.DatabaseException; @@ -33,7 +35,8 @@ try { // Set up an repository of expected data - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); // insert all the data Transaction txn = env.beginTransaction(null, null); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryDeltaTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryDeltaTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryDeltaTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryDeltaTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,14 +1,16 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryDeltaTest.java,v 1.30 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryDeltaTest.java,v 1.31.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; -import java.util.Hashtable; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import com.sleepycat.je.Cursor; import com.sleepycat.je.DatabaseEntry; @@ -58,7 +60,8 @@ int numRecs = 20; try { // Set up an repository of expected data - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); // insert all the data Transaction txn = env.beginTransaction(null, null); @@ -98,7 +101,8 @@ int numRecs = 20; try { /* Set up a repository of expected data */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* * Force a checkpoint, to flush a full version of the BIN @@ -119,7 +123,7 @@ env.checkpoint(forceConfig); closeEnv(); - List infoList = recoverAndVerify(expectedData, NUM_DBS); + List infoList = recoverAndVerify(expectedData, NUM_DBS); /* Check that this recovery processed deltas */ RecoveryInfo firstInfo = (RecoveryInfo) infoList.get(0); @@ -149,7 +153,8 @@ try { /* Set up a repository of expected data */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert data and abort. */ Transaction txn = env.beginTransaction(null, null); @@ -193,7 +198,7 @@ removeCursors(cursors); closeEnv(); - List infoList = recoverAndVerify(expectedData, NUM_DBS); + List infoList = recoverAndVerify(expectedData, NUM_DBS); /* Check that this recovery processed deltas */ RecoveryInfo firstInfo = (RecoveryInfo) infoList.get(0); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryDuplicatesTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryDuplicatesTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryDuplicatesTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryDuplicatesTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,17 +1,19 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryDuplicatesTest.java,v 1.15 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryDuplicatesTest.java,v 1.16.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; -import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.Environment; +import com.sleepycat.je.EnvironmentConfig; import com.sleepycat.je.Transaction; import com.sleepycat.je.config.EnvironmentParams; import com.sleepycat.je.util.TestUtils; @@ -27,7 +29,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert all the data. */ Transaction txn = env.beginTransaction(null, null); @@ -51,7 +54,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert all the data. */ Transaction txn = env.beginTransaction(null, null); @@ -100,7 +104,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert all the data. */ Transaction txn = env.beginTransaction(null, null); @@ -142,7 +147,8 @@ try { /* Set up an repository of expected data. */ - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Insert all the data. */ Transaction txn = env.beginTransaction(null, null); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryEdgeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryEdgeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryEdgeTest.java 2008-05-06 18:01:36.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryEdgeTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryEdgeTest.java,v 1.71 2008/05/06 18:01:36 linda Exp $ + * $Id: RecoveryEdgeTest.java,v 1.72.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; @@ -12,8 +12,10 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.util.Enumeration; -import java.util.Hashtable; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import junit.framework.Test; import junit.framework.TestSuite; @@ -46,7 +48,8 @@ return allTests; } - private static void addTests(TestSuite allTests, + @SuppressWarnings("unchecked") // suite.tests returns untyped Enumeration + private static void addTests(TestSuite allTests, boolean keyPrefixing) { TestSuite suite = new TestSuite(RecoveryEdgeTest.class); @@ -84,7 +87,7 @@ noFileConfig, null /*sharedCacheEnv*/, false /*replicationIntended*/); - List dbList = envImpl.getDbTree().getDbNames(); + List dbList = envImpl.getDbTree().getDbNames(); assertEquals("no dbs exist", 0, dbList.size()); /* Fake a shutdown/startup. */ @@ -179,7 +182,9 @@ try { /* Create an environment and databases. */ createEnvAndDbs(1024, true, NUM_DBS); - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); + Transaction txn = env.beginTransaction(null, null); insertData(txn, 0, 4, expectedData, 1, true, NUM_DBS); txn.commit(); @@ -244,7 +249,8 @@ try { /* Create an environment and databases. */ createEnvAndDbs(1024, true, NUM_DBS); - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Make txns before and after a checkpoint */ Transaction txn = env.beginTransaction(null, null); @@ -350,7 +356,7 @@ * the records. */ createEnv(1024, false); - List dbNames = env.getDatabaseNames(); + List dbNames = env.getDatabaseNames(); assertEquals(2, dbNames.size()); assertEquals("Txnal", dbNames.get(1)); assertEquals("NotTxnal", dbNames.get(0)); @@ -372,7 +378,8 @@ try { /* Create an environment and databases. */ createEnvAndDbs(2048, false, 1); - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Make txns before and after a checkpoint */ Transaction txn = env.beginTransaction(null, null); @@ -412,7 +419,8 @@ try { /* Create an environment and databases. */ createEnvAndDbs(500, false, 1); - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); /* Commit some data, checkpoint. */ Transaction txn = env.beginTransaction(null, null); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryTestBase.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryTestBase.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryTestBase.java 2008-05-19 17:52:22.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryTestBase.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryTestBase.java,v 1.117 2008/05/19 17:52:22 linda Exp $ + * $Id: RecoveryTestBase.java,v 1.118.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; @@ -15,7 +15,6 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; -import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -171,8 +170,9 @@ DatabaseConfig dbConfig = new DatabaseConfig(); if (btreeComparisonFunction != null) { - dbConfig.setBtreeComparator((Class>) - btreeComparisonFunction.getClass()); + dbConfig.setBtreeComparator + ((Class>) + btreeComparisonFunction.getClass()); } dbConfig.setTransactional(true); dbConfig.setAllowCreate(true); @@ -249,7 +249,7 @@ * Recover the databases and check the data. Return a list of the * RecoveryInfos generated by each recovery. */ - protected List recoverAndVerify(Hashtable expectedData, int numDbs) + protected List recoverAndVerify(Map> expectedData, int numDbs) throws DatabaseException { return recoverAndVerifyInternal(expectedData, numDbs, @@ -257,7 +257,7 @@ false); // readOnly } - protected List recoverROAndVerify(Hashtable expectedData, int numDbs) + protected List recoverROAndVerify(Map> expectedData, int numDbs) throws DatabaseException { return recoverAndVerifyInternal(expectedData, numDbs, @@ -269,7 +269,7 @@ * Recover the databases and check the data. Return a list of the * RecoveryInfos generated by each recovery. */ - protected List xaRecoverAndVerify(Hashtable expectedData, int numDbs) + protected List xaRecoverAndVerify(Map> expectedData, int numDbs) throws DatabaseException { return recoverAndVerifyInternal(expectedData, numDbs, @@ -277,13 +277,13 @@ false); // readOnly } - private List recoverAndVerifyInternal(Hashtable expectedData, + private List recoverAndVerifyInternal(Map> expectedData, int numDbs, boolean createXAEnv, boolean readOnlyMode) throws DatabaseException { - List infoList = recoverOnlyInternal(numDbs, createXAEnv, readOnlyMode); + List infoList = recoverOnlyInternal(numDbs, createXAEnv, readOnlyMode); verifyData(expectedData, numDbs); TestUtils.validateNodeMemUsage(DbInternal.envGetEnvironmentImpl(env), false); @@ -330,7 +330,7 @@ return recoveryConfig; } - protected List recoverOnly(int numDbs) + protected List recoverOnly(int numDbs) throws DatabaseException { return recoverOnlyInternal(numDbs, @@ -338,7 +338,7 @@ false); // read only } - protected List xaRecoverOnly(int numDbs) + protected List xaRecoverOnly(int numDbs) throws DatabaseException { return recoverOnlyInternal(numDbs, @@ -346,12 +346,12 @@ false); // read only } - private List recoverOnlyInternal(int numDbs, + private List recoverOnlyInternal(int numDbs, boolean createXAEnv, boolean readOnlyMode) throws DatabaseException { - List infoList = new ArrayList(); + List infoList = new ArrayList(); /* Open it again, which will run recovery. */ if (createXAEnv) { @@ -372,7 +372,7 @@ * Compare the data in the databases agains the data in the expected data * set. */ - protected void verifyData(Hashtable expectedData, int numDbs) + protected void verifyData(Map> expectedData, int numDbs) throws DatabaseException { verifyData(expectedData, true, numDbs); @@ -382,7 +382,7 @@ * Compare the data in the databases against the data in the expected data * set. */ - protected void verifyData(Hashtable expectedData, + protected void verifyData(Map> expectedData, boolean checkInList, int numDbs) throws DatabaseException { @@ -390,7 +390,8 @@ verifyData(expectedData, checkInList, 0, numDbs); } - protected void verifyData(Hashtable expectedData, + @SuppressWarnings("unchecked") + protected void verifyData(Map> expectedData, boolean checkInList, int startDb, int endDb) @@ -409,21 +410,27 @@ * need to keep the expectedData set intact because we call verify * repeatedly. */ - Map useData = new Hashtable(); - Iterator iter = expectedData.entrySet().iterator(); + Map> useData = + new HashMap>(); + + Iterator>> iter = + expectedData.entrySet().iterator(); + while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - useData.put(entry.getKey(), ((HashSet) entry.getValue()).clone()); + Map.Entry> entry = iter.next(); + Set clone = (Set)((HashSet)entry.getValue()).clone(); + useData.put(entry.getKey(), clone); } /* Generate an expected count map. */ - Map countMap = generateCountMap(expectedData); + Map countMap = generateCountMap(expectedData); /* Check each db in turn. */ DatabaseConfig dbConfig = new DatabaseConfig(); if (btreeComparisonFunction != null) { - dbConfig.setBtreeComparator((Class>) - btreeComparisonFunction.getClass()); + dbConfig.setBtreeComparator + ((Class>) + btreeComparisonFunction.getClass()); } dbConfig.setTransactional(env.getConfig().getTransactional()); dbConfig.setSortedDuplicates(true); @@ -471,18 +478,19 @@ * Process the expected data map to generate expected counts. For each * database, make a map of key value to count. */ - private Map generateCountMap(Map expectedData) { + private Map + generateCountMap(Map> expectedData) { - Map countMap = new HashMap(); + Map countMap = new HashMap(); - Iterator iter = expectedData.values().iterator(); + Iterator> iter = expectedData.values().iterator(); while (iter.hasNext()) { - Set dataSet = (Set) iter.next(); - Iterator dataIter = dataSet.iterator(); + Set dataSet = iter.next(); + Iterator dataIter = dataSet.iterator(); while (dataIter.hasNext()) { - TestData t = (TestData) dataIter.next(); + TestData t = dataIter.next(); TestData countKey = new TestData(t.dbNum, t.key); - Integer count = (Integer) countMap.get(countKey); + Integer count = countMap.get(countKey); if (count == null) { countMap.put(countKey, new Integer(1)); } else { @@ -496,11 +504,10 @@ /** * @return the expected count value for a given key in a given db. */ - private int getExpectedCount(Map countMap, + private int getExpectedCount(Map countMap, int whichDb, DatabaseEntry key) { - return ((Integer) - countMap.get(new TestData(whichDb, key.getData()))).intValue(); + return countMap.get(new TestData(whichDb, key.getData())).intValue(); } /** @@ -509,7 +516,7 @@ protected void insertData(Transaction txn, int startVal, int endVal, - Map expectedData, + Map> expectedData, int nDuplicatesPerKey, boolean addToExpectedData, int numDbs) @@ -523,7 +530,7 @@ protected void insertData(Transaction txn, int startVal, int endVal, - Map expectedData, + Map> expectedData, int nDuplicatesPerKey, boolean addToExpectedData, int startDb, @@ -543,7 +550,7 @@ protected void insertData(Transaction txn, int startVal, int endVal, - Map expectedData, + Map> expectedData, int nDuplicatesPerKey, boolean toggle, boolean addToExpectedData, @@ -562,7 +569,7 @@ protected void insertData(Transaction txn, int startVal, int endVal, - Map expectedData, + Map> expectedData, int nDuplicatesPerKey, boolean toggle, boolean addToExpectedData, @@ -599,16 +606,16 @@ * object that wraps db number and key, and points to sets of TestData * objects that wrap db number, key, and data. */ - protected void addExpectedData(Map expectedData, + protected void addExpectedData(Map> expectedData, int dbNum, DatabaseEntry key, DatabaseEntry data, boolean expectCommit) { if (expectCommit) { TestData keyTestData = new TestData(dbNum, key, null); - Set dataSet = (Set) expectedData.get(keyTestData); + Set dataSet = expectedData.get(keyTestData); if (dataSet == null) { - dataSet = new HashSet(); + dataSet = new HashSet(); expectedData.put(keyTestData, dataSet); } @@ -619,14 +626,14 @@ /** * Remove from the set of expected results. */ - private void removeExpectedData(Map expectedData, + private void removeExpectedData(Map> expectedData, int dbNum, DatabaseEntry key, DatabaseEntry data, boolean expectCommit) { if (expectCommit) { TestData keyTestData = new TestData(dbNum, key, null); - Set dataSet = (Set) expectedData.get(keyTestData); + Set dataSet = expectedData.get(keyTestData); assertTrue("Should be a data set for " + keyTestData, (dataSet != null)); assertTrue("Should be able to remove key " + key + @@ -656,7 +663,7 @@ */ private void insertOneRecord(Cursor[] cursors, int val, - Map expectedData, + Map> expectedData, int nDuplicatesPerKey, boolean expectCommit) throws DatabaseException { @@ -688,7 +695,7 @@ /** * Delete either every other or all data. */ - protected void deleteData(Transaction txn, Map expectedData, + protected void deleteData(Transaction txn, Map> expectedData, boolean all, boolean expectCommit, int numDbs) throws DatabaseException { @@ -732,7 +739,7 @@ * we don't want to do this because we plan to make the txn abort. */ protected void modifyData(Transaction txn, int endVal, - Map expectedData, int increment, + Map> expectedData, int increment, boolean expectCommit, int numDbs) throws DatabaseException { @@ -783,8 +790,9 @@ DatabaseConfig dbConfig = new DatabaseConfig(); if (btreeComparisonFunction != null) { - dbConfig.setBtreeComparator((Class>) - btreeComparisonFunction.getClass()); + dbConfig.setBtreeComparator + ((Class>) + btreeComparisonFunction.getClass()); } dbConfig.setSortedDuplicates(true); dbConfig.setTransactional(true); @@ -816,15 +824,15 @@ /** * Print the contents of the expected map for debugging. */ - protected void dumpExpected(Map expectedData) + protected void dumpExpected(Map> expectedData) throws DatabaseException { System.out.println("Expected = " ); - Iterator iter = expectedData.values().iterator(); + Iterator> iter = expectedData.values().iterator(); while (iter.hasNext()) { - Set dataSet = (Set) iter.next(); - Iterator dataIter = dataSet.iterator(); + Set dataSet = iter.next(); + Iterator dataIter = dataSet.iterator(); while (dataIter.hasNext()) { - TestData t = (TestData) dataIter.next(); + TestData t = dataIter.next(); System.out.println(t); } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/RecoveryTest.java 2008-01-07 14:29:10.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/RecoveryTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,15 +1,17 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecoveryTest.java,v 1.60 2008/01/07 14:29:10 cwl Exp $ + * $Id: RecoveryTest.java,v 1.61.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery; import java.util.Comparator; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import com.sleepycat.je.Cursor; import com.sleepycat.je.Database; @@ -41,7 +43,7 @@ public void testBasicRecoveryWithBtreeComparator() throws Throwable { - btreeComparisonFunction = new BtreeComparator(true); + btreeComparisonFunction = new BtreeComparator(true); doBasic(true); } @@ -49,33 +51,34 @@ * Test that put(OVERWRITE) works correctly with duplicates. */ public void testDuplicateOverwrite() - throws Throwable { + throws Throwable { createEnvAndDbs(1 << 10, false, NUM_DBS); try { - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); - Transaction txn = env.beginTransaction(null, null); - DatabaseEntry key = new DatabaseEntry("aaaaa".getBytes()); - DatabaseEntry data1 = new DatabaseEntry("dddddddddd".getBytes()); - DatabaseEntry data2 = new DatabaseEntry("eeeeeeeeee".getBytes()); - DatabaseEntry data3 = new DatabaseEntry("ffffffffff".getBytes()); - Database db = dbs[0]; - assertEquals(OperationStatus.SUCCESS, - db.put(null, key, data1)); - addExpectedData(expectedData, 0, key, data1, true); - assertEquals(OperationStatus.SUCCESS, - db.put(null, key, data2)); - addExpectedData(expectedData, 0, key, data2, true); - assertEquals(OperationStatus.SUCCESS, - db.put(null, key, data3)); - addExpectedData(expectedData, 0, key, data3, true); - assertEquals(OperationStatus.SUCCESS, - db.put(null, key, data3)); - txn.commit(); - closeEnv(); + Transaction txn = env.beginTransaction(null, null); + DatabaseEntry key = new DatabaseEntry("aaaaa".getBytes()); + DatabaseEntry data1 = new DatabaseEntry("dddddddddd".getBytes()); + DatabaseEntry data2 = new DatabaseEntry("eeeeeeeeee".getBytes()); + DatabaseEntry data3 = new DatabaseEntry("ffffffffff".getBytes()); + Database db = dbs[0]; + assertEquals(OperationStatus.SUCCESS, + db.put(null, key, data1)); + addExpectedData(expectedData, 0, key, data1, true); + assertEquals(OperationStatus.SUCCESS, + db.put(null, key, data2)); + addExpectedData(expectedData, 0, key, data2, true); + assertEquals(OperationStatus.SUCCESS, + db.put(null, key, data3)); + addExpectedData(expectedData, 0, key, data3, true); + assertEquals(OperationStatus.SUCCESS, + db.put(null, key, data3)); + txn.commit(); + closeEnv(); - recoverAndVerify(expectedData, NUM_DBS); + recoverAndVerify(expectedData, NUM_DBS); } catch (Throwable t) { t.printStackTrace(); throw t; @@ -94,74 +97,74 @@ public void testSR8984Part1() throws Throwable { - doTestSR8984Work(true); + doTestSR8984Work(true); } public void testSR8984Part2() throws Throwable { - doTestSR8984Work(false); + doTestSR8984Work(false); } private void doTestSR8984Work(boolean sameKey) - throws DatabaseException { + throws DatabaseException { - final int NUM_EXTRA_DUPS = 150; - EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + final int NUM_EXTRA_DUPS = 150; + EnvironmentConfig envConfig = TestUtils.initEnvConfig(); /* Make an environment and open it */ envConfig.setTransactional(false); envConfig.setAllowCreate(true); envConfig.setConfigParam(EnvironmentParams.ENV_CHECK_LEAKS.getName(), - "false"); + "false"); envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6"); - envConfig.setConfigParam(EnvironmentParams.ENV_RUN_CLEANER.getName(), - "false"); + envConfig.setConfigParam(EnvironmentParams.ENV_RUN_CLEANER.getName(), + "false"); - envConfig.setConfigParam - (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false"); + envConfig.setConfigParam + (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false"); env = new Environment(envHome, envConfig); DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(false); dbConfig.setAllowCreate(true); dbConfig.setSortedDuplicates(true); - Database db = env.openDatabase(null, "testSR8984db", dbConfig); + Database db = env.openDatabase(null, "testSR8984db", dbConfig); + + DatabaseEntry key = new DatabaseEntry("k1".getBytes()); + DatabaseEntry data = new DatabaseEntry("d1".getBytes()); + assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); + assertEquals(OperationStatus.SUCCESS, db.delete(null, key)); + + if (!sameKey) { + data.setData("d2".getBytes()); + } + /* Cause a dup tree of some depth to be created. */ + assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); + for (int i = 3; i < NUM_EXTRA_DUPS; i++) { + data.setData(("d" + i).getBytes()); + assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); + } - DatabaseEntry key = new DatabaseEntry("k1".getBytes()); - DatabaseEntry data = new DatabaseEntry("d1".getBytes()); - assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); - assertEquals(OperationStatus.SUCCESS, db.delete(null, key)); - - if (!sameKey) { - data.setData("d2".getBytes()); - } - /* Cause a dup tree of some depth to be created. */ - assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); - for (int i = 3; i < NUM_EXTRA_DUPS; i++) { - data.setData(("d" + i).getBytes()); - assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); - } - - data.setData("d1".getBytes()); - - Cursor c = db.openCursor(null, null); - assertEquals(OperationStatus.SUCCESS, - c.getFirst(key, data, LockMode.DEFAULT)); + data.setData("d1".getBytes()); - c.close(); - db.close(); + Cursor c = db.openCursor(null, null); + assertEquals(OperationStatus.SUCCESS, + c.getFirst(key, data, LockMode.DEFAULT)); + + c.close(); + db.close(); /* Force an abrupt close so there is no checkpoint at the end. */ closeEnv(); env = new Environment(envHome, envConfig); - db = env.openDatabase(null, "testSR8984db", dbConfig); - c = db.openCursor(null, null); - assertEquals(OperationStatus.SUCCESS, - c.getFirst(key, data, LockMode.DEFAULT)); - assertEquals(NUM_EXTRA_DUPS - 2, c.count()); - c.close(); - db.close(); - env.close(); + db = env.openDatabase(null, "testSR8984db", dbConfig); + c = db.openCursor(null, null); + assertEquals(OperationStatus.SUCCESS, + c.getFirst(key, data, LockMode.DEFAULT)); + assertEquals(NUM_EXTRA_DUPS - 2, c.count()); + c.close(); + db.close(); + env.close(); } /** @@ -175,7 +178,8 @@ try { // Set up an repository of expected data - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); // insert all the data Transaction txn = env.beginTransaction(null, null); @@ -211,7 +215,8 @@ int numRecs = NUM_RECS; try { // Set up an repository of expected data - Hashtable expectedData = new Hashtable(); + Map> expectedData = + new HashMap>(); // insert all the data Transaction txn = env.beginTransaction(null, null); @@ -238,52 +243,52 @@ } } - protected static class BtreeComparator implements Comparator { - protected boolean ascendingComparison = true; + protected static class BtreeComparator implements Comparator { + protected boolean ascendingComparison = true; - public BtreeComparator() { - } + public BtreeComparator() { + } - protected BtreeComparator(boolean ascendingComparison) { - this.ascendingComparison = ascendingComparison; - } - - public int compare(Object o1, Object o2) { - byte[] arg1; - byte[] arg2; - if (ascendingComparison) { - arg1 = (byte[]) o1; - arg2 = (byte[]) o2; - } else { - arg1 = (byte[]) o2; - arg2 = (byte[]) o1; - } - int a1Len = arg1.length; - int a2Len = arg2.length; - - int limit = Math.min(a1Len, a2Len); - - for (int i = 0; i < limit; i++) { - byte b1 = arg1[i]; - byte b2 = arg2[i]; - if (b1 == b2) { - continue; - } else { - /* Remember, bytes are signed, so convert to shorts so that - we effectively do an unsigned byte comparison. */ - short s1 = (short) (b1 & 0x7F); - short s2 = (short) (b2 & 0x7F); - if (b1 < 0) { - s1 |= 0x80; - } - if (b2 < 0) { - s2 |= 0x80; - } - return (s1 - s2); - } - } + protected BtreeComparator(boolean ascendingComparison) { + this.ascendingComparison = ascendingComparison; + } + + public int compare(byte[] o1, byte[] o2) { + byte[] arg1; + byte[] arg2; + if (ascendingComparison) { + arg1 = (byte[]) o1; + arg2 = (byte[]) o2; + } else { + arg1 = (byte[]) o2; + arg2 = (byte[]) o1; + } + int a1Len = arg1.length; + int a2Len = arg2.length; + + int limit = Math.min(a1Len, a2Len); + + for (int i = 0; i < limit; i++) { + byte b1 = arg1[i]; + byte b2 = arg2[i]; + if (b1 == b2) { + continue; + } else { + /* Remember, bytes are signed, so convert to shorts so that + we effectively do an unsigned byte comparison. */ + short s1 = (short) (b1 & 0x7F); + short s2 = (short) (b2 & 0x7F); + if (b1 < 0) { + s1 |= 0x80; + } + if (b2 < 0) { + s2 |= 0x80; + } + return (s1 - s2); + } + } - return (a1Len - a2Len); - } + return (a1Len - a2Len); + } } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/Rollback2PCTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/Rollback2PCTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/Rollback2PCTest.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/Rollback2PCTest.java 2010-01-04 15:30:44.000000000 +0000 @@ -0,0 +1,134 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002,2010 Oracle. All rights reserved. + * + * $Id: Rollback2PCTest.java,v 1.6.2.2 2010/01/04 15:30:44 cwl Exp $ + */ + +package com.sleepycat.je.recovery; + +import java.io.File; + +import javax.transaction.xa.XAException; + +import junit.framework.TestCase; + +import com.sleepycat.bind.tuple.IntegerBinding; +import com.sleepycat.je.CheckpointConfig; +import com.sleepycat.je.Database; +import com.sleepycat.je.DatabaseConfig; +import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.DbInternal; +import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.OperationStatus; +import com.sleepycat.je.Transaction; +import com.sleepycat.je.XAEnvironment; +import com.sleepycat.je.log.FileManager; +import com.sleepycat.je.log.LogUtils.XidImpl; +import com.sleepycat.je.util.TestUtils; + +public class Rollback2PCTest extends TestCase { + private final File envHome; + + public Rollback2PCTest() { + envHome = new File(System.getProperty(TestUtils.DEST_DIR)); + } + + @Override + public void setUp() { + try { + TestUtils.removeFiles("Setup", envHome, FileManager.JE_SUFFIX); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void tearDown() { + //* + try { + TestUtils.removeFiles("TearDown", envHome, FileManager.JE_SUFFIX); + } catch (Throwable t) { + t.printStackTrace(); + } + //*/ + } + + /** + * Verifies a bug fix to a problem that occurs when aborting a prepared txn + * after recovery. During recovery, we were counting the old version of an + * LN as obsolete when replaying the prepared txn LN. But if that txn + * aborts later, the old version becomes active. The fix is to use inexact + * counting. [#17022] + */ + public void testLogCleanAfterRollbackPrepared() + throws DatabaseException, XAException { + + /* Setup environment. */ + EnvironmentConfig envConfig = new EnvironmentConfig(); + envConfig.setTransactional(true); + envConfig.setAllowCreate(true); + envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, "false"); + envConfig.setConfigParam + (EnvironmentConfig.CLEANER_MIN_UTILIZATION, "90"); + XAEnvironment xaEnv = new XAEnvironment(envHome, envConfig); + + /* Setup database. */ + DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setTransactional(true); + dbConfig.setAllowCreate(true); + Database db = xaEnv.openDatabase(null, "foo", dbConfig); + + DatabaseEntry key = new DatabaseEntry(); + DatabaseEntry data = new DatabaseEntry(); + IntegerBinding.intToEntry(1, key); + IntegerBinding.intToEntry(99, data); + assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); + DbInternal.envGetEnvironmentImpl(xaEnv).forceLogFileFlip(); + DbInternal.envGetEnvironmentImpl(xaEnv).forceLogFileFlip(); + DbInternal.envGetEnvironmentImpl(xaEnv).forceLogFileFlip(); + + /* + * Start an XA transaction and add a record. Then crash the + * environment. + */ + XidImpl xid = new XidImpl(1, "FooTxn".getBytes(), null); + Transaction preCrashTxn = xaEnv.beginTransaction(null, null); + xaEnv.setXATransaction(xid, preCrashTxn); + IntegerBinding.intToEntry(100, data); + assertEquals(OperationStatus.SUCCESS, db.put(preCrashTxn, key, data)); + db.close(); + xaEnv.prepare(xid); + DbInternal.envGetEnvironmentImpl(xaEnv).getLogManager().flush(); + + /* Crash */ + DbInternal.envGetEnvironmentImpl(xaEnv).abnormalClose(); + xaEnv = null; + + /* Recover */ + envConfig.setAllowCreate(false); + xaEnv = new XAEnvironment(envHome, envConfig); + + /* Rollback. */ + xaEnv.rollback(xid); + + /* Force log cleaning. */ + CheckpointConfig force = new CheckpointConfig(); + force.setForce(true); + xaEnv.checkpoint(force); + xaEnv.cleanLog(); + xaEnv.checkpoint(force); + + /* Close and re-open, ensure we can read the original record. */ + xaEnv.close(); + xaEnv = new XAEnvironment(envHome, envConfig); + db = xaEnv.openDatabase(null, "foo", dbConfig); + /* Before the fix, the get() caused a LogFileNotFound. */ + assertEquals(OperationStatus.SUCCESS, db.get(null, key, data, null)); + assertEquals(99, IntegerBinding.entryToInt(data)); + db.close(); + xaEnv.close(); + } +} diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/CommitEntry.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/CommitEntry.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/CommitEntry.java 2008-01-07 14:29:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/CommitEntry.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CommitEntry.java,v 1.7 2008/01/07 14:29:11 cwl Exp $ + * $Id: CommitEntry.java,v 1.8.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; @@ -30,27 +30,29 @@ this.txnId = txnId; } - public void updateExpectedSet(Set useExpected, - Map newUncommittedRecords, - Map deletedUncommittedRecords) { + @Override + public void updateExpectedSet + (Set useExpected, + Map> newUncommittedRecords, + Map> deletedUncommittedRecords) { Long mapKey = new Long(txnId); /* Add any new records to the expected set. */ - Set records = (Set) newUncommittedRecords.get(mapKey); + Set records = newUncommittedRecords.get(mapKey); if (records != null) { - Iterator iter = records.iterator(); + Iterator iter = records.iterator(); while (iter.hasNext()) { - useExpected.add((TestData) iter.next()); + useExpected.add(iter.next()); } } /* Remove any deleted records from expected set. */ - records = (Set) deletedUncommittedRecords.get(mapKey); + records = deletedUncommittedRecords.get(mapKey); if (records != null) { - Iterator iter = records.iterator(); + Iterator iter = records.iterator(); while (iter.hasNext()) { - useExpected.remove((TestData) iter.next()); + useExpected.remove(iter.next()); } } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/EntryTrackerReader.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/EntryTrackerReader.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/EntryTrackerReader.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/EntryTrackerReader.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EntryTrackerReader.java,v 1.11 2008/05/22 19:35:39 linda Exp $ + * $Id: EntryTrackerReader.java,v 1.11.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/LogEntryInfo.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/LogEntryInfo.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/LogEntryInfo.java 2008-01-07 14:29:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/LogEntryInfo.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LogEntryInfo.java,v 1.7 2008/01/07 14:29:11 cwl Exp $ + * $Id: LogEntryInfo.java,v 1.8.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; @@ -42,7 +42,10 @@ * * The default action is that the expected set is not changed. */ - public void updateExpectedSet(Set expectedSet, Map newUncommittedRecords, Map deletedUncommittedRecords) {} + public void updateExpectedSet + (Set expectedSet, + Map> newUncommittedRecords, + Map> deletedUncommittedRecords) {} public String toString() { StringBuffer sb = new StringBuffer(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/NonTxnalDeletedEntry.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/NonTxnalDeletedEntry.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/NonTxnalDeletedEntry.java 2008-01-07 14:29:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/NonTxnalDeletedEntry.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NonTxnalDeletedEntry.java,v 1.6 2008/01/07 14:29:11 cwl Exp $ + * $Id: NonTxnalDeletedEntry.java,v 1.7.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; @@ -26,10 +26,15 @@ } /* Delete this item from the expected set. */ - public void updateExpectedSet(Set useExpected, Map newUncommittedRecords, Map deletedUncommittedRecords) { - Iterator iter = useExpected.iterator(); + @Override + public void updateExpectedSet + (Set useExpected, + Map> newUncommittedRecords, + Map> deletedUncommittedRecords) { + + Iterator iter = useExpected.iterator(); while (iter.hasNext()) { - TestData setItem = (TestData) iter.next(); + TestData setItem = iter.next(); int keyValInSet = IntegerBinding.entryToInt(setItem.getKey()); if (keyValInSet == key) { if (data == -1) { @@ -37,7 +42,8 @@ iter.remove(); break; } else { - int dataValInSet = IntegerBinding.entryToInt(setItem.getData()); + int dataValInSet = + IntegerBinding.entryToInt(setItem.getData()); if (dataValInSet == data) { iter.remove(); break; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/NonTxnalEntry.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/NonTxnalEntry.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/NonTxnalEntry.java 2008-01-07 14:29:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/NonTxnalEntry.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NonTxnalEntry.java,v 1.7 2008/01/07 14:29:11 cwl Exp $ + * $Id: NonTxnalEntry.java,v 1.8.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; @@ -30,7 +30,12 @@ * expected set. A txnal delete LN record would delete the record * from the expecte set at commit time. */ - public void updateExpectedSet(Set useExpected, Map newUncommittedRecords, Map deletedUncommittedRecords) { + @Override + public void updateExpectedSet + (Set useExpected, + Map> newUncommittedRecords, + Map> deletedUncommittedRecords) { + DatabaseEntry keyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/TxnalDeletedEntry.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/TxnalDeletedEntry.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/TxnalDeletedEntry.java 2008-01-07 14:29:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/TxnalDeletedEntry.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnalDeletedEntry.java,v 1.7 2008/01/07 14:29:11 cwl Exp $ + * $Id: TxnalDeletedEntry.java,v 1.8.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; @@ -36,9 +36,12 @@ * expected set. A txnal delete LN record would delete the record * from the expecte set at commit time. */ - public void updateExpectedSet(Set useExpected, - Map newUncommittedRecords, - Map deletedUncommittedRecords) { + @Override + public void updateExpectedSet + (Set useExpected, + Map> newUncommittedRecords, + Map> deletedUncommittedRecords) { + DatabaseEntry keyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); @@ -46,9 +49,9 @@ IntegerBinding.intToEntry(data, dataEntry); Long mapKey = new Long(txnId); - Set records = (Set) deletedUncommittedRecords.get(mapKey); + Set records = deletedUncommittedRecords.get(mapKey); if (records == null) { - records = new HashSet(); + records = new HashSet(); deletedUncommittedRecords.put(mapKey, records); } records.add(new TestData(keyEntry, dataEntry)); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/TxnalEntry.java libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/TxnalEntry.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/recovery/stepwise/TxnalEntry.java 2008-01-07 14:29:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/recovery/stepwise/TxnalEntry.java 2010-01-04 15:30:44.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnalEntry.java,v 1.7 2008/01/07 14:29:11 cwl Exp $ + * $Id: TxnalEntry.java,v 1.8.2.2 2010/01/04 15:30:44 cwl Exp $ */ package com.sleepycat.je.recovery.stepwise; @@ -36,9 +36,12 @@ * expected set. A txnal delete LN record would delete the record * from the expecte set at commit time. */ - public void updateExpectedSet(Set useExpected, - Map newUncommittedRecords, - Map deletedUncommittedRecords) { + @Override + public void updateExpectedSet + (Set useExpected, + Map> newUncommittedRecords, + Map> deletedUncommittedRecords) { + DatabaseEntry keyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); @@ -46,9 +49,9 @@ IntegerBinding.intToEntry(data, dataEntry); Long mapKey = new Long(txnId); - Set records = (Set) newUncommittedRecords.get(mapKey); + Set records = newUncommittedRecords.get(mapKey); if (records == null) { - records = new HashSet(); + records = new HashSet(); newUncommittedRecords.put(mapKey, records); } records.add(new TestData(keyEntry, dataEntry)); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/RunRecoveryFailureTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/RunRecoveryFailureTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/RunRecoveryFailureTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/RunRecoveryFailureTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RunRecoveryFailureTest.java,v 1.38 2008/01/07 14:29:05 cwl Exp $ + * $Id: RunRecoveryFailureTest.java,v 1.38.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/ScanLogTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/ScanLogTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/ScanLogTest.java 2008-01-07 14:29:06.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/ScanLogTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ScanLogTest.java,v 1.5 2008/01/07 14:29:05 cwl Exp $ + * $Id: ScanLogTest.java,v 1.6.2.2 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -23,9 +23,7 @@ * Basic database operations, excluding configuration testing. */ public class ScanLogTest extends TestCase { - private static final boolean DEBUG = false; private static final int NUM_RECS = 3; - private static final int NUM_DUPS = 3; private File envHome; private Environment env; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/AtomicPutTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/AtomicPutTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/AtomicPutTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/AtomicPutTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: AtomicPutTest.java,v 1.17 2008/02/05 23:28:27 mark Exp $ + * $Id: AtomicPutTest.java,v 1.17.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/DeferredWriteTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/DeferredWriteTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/DeferredWriteTest.java 2008-05-30 14:04:22.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/DeferredWriteTest.java 2010-02-05 14:22:24.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DeferredWriteTest.java,v 1.17 2008/05/30 14:04:21 mark Exp $ + * $Id: DeferredWriteTest.java,v 1.18.2.5 2010/02/05 14:22:24 cwl Exp $ */ package com.sleepycat.je.test; @@ -547,6 +547,67 @@ closeEnv(true /*normalClose*/); } + public void testTempEvictionAndObsoleteCounting() + throws DatabaseException { + + EnvironmentConfig envConfig = getEnvConfig(false); + envConfig.setConfigParam + (EnvironmentParams.NODE_MAX.getName(), "128"); + envConfig.setConfigParam + (EnvironmentParams.NODE_MAX_DUPTREE.getName(), "128"); + /* Use a small cache to cause eviction. */ + envConfig.setCacheSize(MemoryBudget.MIN_MAX_MEMORY_SIZE); + envConfig.setConfigParam("je.env.runCleaner", "false"); + envConfig.setConfigParam("je.env.runCheckpointer", "false"); + envConfig.setConfigParam("je.env.runINCompressor", "false"); + env = new Environment(envHome, envConfig); + + /* Create DB and insert until 1000 INs are evicted. */ + Database db = createTempDb(DBNAME); + int start; + for (start = 1;; start += 1000) { + insert(db, + null, // txn + start, // start + start + 1000, // end + new HashSet(), // expected + true); // useRandom + EnvironmentStats stats = env.getStats(null); + if (stats.getNNodesExplicitlyEvicted() > 1000) { + break; + } + } + + /* + * Update all records twice, to cause eviction and log multiple + * versions of the INs. + */ + int lastStart = start; + for (start = 1; start <= lastStart; start += 1000) { + update(db, + null, // txn + start, // start + start + 1000); // end + } + for (start = 1; start < lastStart; start += 1000) { + update(db, + null, // txn + start, // start + start + 1000); // end + } + + assertTrue(DbInternal.envGetEnvironmentImpl(env). + getUtilizationProfile(). + getFileSummaryMap(true). + get(0L). + obsoleteINCount > 1000); + + db.close(); + closeEnv(true /*normalClose*/, + true /*expectAccurateObsoleteLNCount*/, + false /*expectAccurateDbUtilization*/); + } + private HashSet insertAndCheck(Database db) throws DatabaseException { @@ -603,7 +664,7 @@ boolean syncBeforeRecovery, boolean expectEviction) throws DatabaseException { - + env = new Environment(envHome, envConfig); Database db = createDb(true); HashSet expected = new HashSet(); @@ -659,7 +720,7 @@ */ public void testDups() throws DatabaseException { - + EnvironmentConfig envConfig = getEnvConfig(false); env = new Environment(envHome, envConfig); @@ -743,7 +804,7 @@ */ public void testCompressAfterSlotReuse() throws DatabaseException { - + EnvironmentConfig envConfig = getEnvConfig(false); /* Disable daemons to prevent async compression. */ envConfig.setConfigParam("je.env.runCleaner", "false"); @@ -1036,7 +1097,6 @@ /* We'll do inserts in two batches. */ HashSet expectedBatch1 = new HashSet(); HashSet expectedBatch2 = new HashSet(); - HashSet finalExpectedSet = null; int batch1Size = 100; int batch2Size = 110; @@ -1115,6 +1175,7 @@ boolean useRandom) throws DatabaseException{ + OperationStatus status; DatabaseEntry entry = new DatabaseEntry(); Random rand = new Random(); for (int i = start; i < end; i++) { @@ -1122,11 +1183,12 @@ IntegerBinding.intToEntry(value, entry); if (dups) { - assertEquals(OperationStatus.SUCCESS, - db.putNoDupData(txn, MAIN_KEY_FOR_DUPS, entry)); + status = db.putNoDupData(txn, MAIN_KEY_FOR_DUPS, entry); } else { - assertEquals(OperationStatus.SUCCESS, - db.putNoOverwrite(txn, entry, entry)); + status = db.putNoOverwrite(txn, entry, entry); + } + if (!useRandom) { + assertEquals(OperationStatus.SUCCESS, status); } expected.add(new Integer(value)); } @@ -1174,6 +1236,63 @@ } /** + * Update a set of records. + */ + private void update(Database db, + Transaction txn, + int start, + int end) + throws DatabaseException{ + + OperationStatus status; + DatabaseEntry entry = new DatabaseEntry(); + for (int i = start; i < end; i++) { + IntegerBinding.intToEntry(i, entry); + if (dups) { + status = db.put(txn, MAIN_KEY_FOR_DUPS, entry); + } else { + status = db.put(txn, entry, entry); + } + assertEquals(OperationStatus.SUCCESS, status); + } + } + + /** + * Delete a set of records, update the values in the expected set. + * @param useRandom If True, use random values. + */ + private void delete(Database db, + Transaction txn, + int start, + int end, + Set expected, + boolean useRandom) + throws DatabaseException{ + + DatabaseEntry entry = new DatabaseEntry(); + Random rand = new Random(); + for (int i = start; i < end; i++) { + int value = useRandom ? (start + rand.nextInt(end - start)) : i; + + IntegerBinding.intToEntry(value, entry); + if (dups) { + final Cursor c = db.openCursor(txn, null); + try { + if (c.getSearchBoth(MAIN_KEY_FOR_DUPS, entry, null) == + OperationStatus.SUCCESS) { + c.delete(); + } + } finally { + c.close(); + } + } else { + db.delete(txn, entry); + } + expected.remove(new Integer(value)); + } + } + + /** * The database should hold exactly the values in the expected set. */ private void checkExactContentMatch(Database db, HashSet expected) @@ -1251,4 +1370,164 @@ env.checkpoint(force); } } + + /** + * Tests that record deletion is durable after Database.sync, when a crash + * ocurs after the sync and the previous version of the LN is in the + * recovery interval. Before logging deferred-write LNs provisionally, the + * previous version of the LN was reinserted into the BIN by recovery. + * + * [#16864] + */ + public void testDelete() + throws DatabaseException { + + final EnvironmentConfig envConfig = getEnvConfig(false); + env = new Environment(envHome, envConfig); + Database db = createDb(true); + + final int NUM_RECORDS = 100; + final HashSet expected = new HashSet(); + insert(db, null, 1, NUM_RECORDS, expected, false); + db.sync(); + delete(db, null, 1, NUM_RECORDS, expected, false); + db.sync(); + assertTrue(expected.isEmpty()); + checkExactContentMatch(db, expected); + + /* Close without a checkpoint to redo the LNs during recovery. */ + DbInternal.envGetEnvironmentImpl(env).abnormalClose(); + env = null; + + /* Recover and check again. */ + env = new Environment(envHome, envConfig); + db = createDb(true); + checkExactContentMatch(db, expected); + db.close(); + env.close(); + env = null; + } + + /** + * Tests a fix for a LogFileNotFound exception in the following sequence + * for a deferred-write database. + * + * 100 LN-A + * 200 BIN-B, parent of LN-A + * ... LN-A is deleted, marked dirty and not logged + * ... BIN-B is compressed, LN-A is counted obsolete in utilization tracker + * 300 BIN-B flushed by eviction (this step is optional) + * 400 FileSummaryLN with LN-A obsolete offset is flushed as the result of + * utilization tracker eviction + * ... Crash and recover, LN-A is mistakedly inserted into BIN-B by redo + * + * When the log file containing 100 LN-A is cleaned, it will not be + * migrated because it was counted obsolete. Yet it is referenced by its + * BIN parent. This caused a LogFileNotFound exception later when + * attempting to access the LN. + * + * [#16864] + */ + public void testCleanAfterDelete() + throws DatabaseException{ + + if (dups) { + /* There is no variant of this test for dups. */ + return; + } + final int CACHE_SIZE = 4 << 20; + final EnvironmentConfig envConfig = TestUtils.initEnvConfig(); + envConfig.setAllowCreate(true); + envConfig.setConfigParam + (EnvironmentConfig.MAX_MEMORY, String.valueOf(CACHE_SIZE)); + envConfig.setConfigParam + (EnvironmentConfig.CLEANER_DETAIL_MAX_MEMORY_PERCENTAGE, "1"); + envConfig.setConfigParam + (EnvironmentConfig.CLEANER_EXPUNGE, "false"); + /* Disable daemons to prevent async compression. */ + envConfig.setConfigParam + (EnvironmentConfig.ENV_RUN_CLEANER, "false"); + envConfig.setConfigParam + (EnvironmentConfig.ENV_RUN_CHECKPOINTER, "false"); + envConfig.setConfigParam + (EnvironmentConfig.ENV_RUN_IN_COMPRESSOR, "false"); + env = new Environment(envHome, envConfig); + + final DatabaseConfig dbConfig = new DatabaseConfig(); + dbConfig.setAllowCreate(true); + dbConfig.setDeferredWrite(true); + Database db = env.openDatabase(null, DBNAME, dbConfig); + + final DatabaseEntry key = new DatabaseEntry(); + final DatabaseEntry data = new DatabaseEntry(new byte[1000]); + final int N_RECORDS = 10000; + + IntegerBinding.intToEntry(0, key); + assertSame(OperationStatus.SUCCESS, + db.putNoOverwrite(null, key, data)); + IntegerBinding.intToEntry(1, key); + assertSame(OperationStatus.SUCCESS, + db.putNoOverwrite(null, key, data)); + db.sync(); + IntegerBinding.intToEntry(0, key); + assertSame(OperationStatus.SUCCESS, + db.delete(null, key)); + env.compress(); + db.sync(); + + /* Cause enough eviction to flush the FileSummaryLNs. */ + for (int i = 1; i < N_RECORDS; i += 1) { + IntegerBinding.intToEntry(i, key); + assertSame(OperationStatus.SUCCESS, + db.put(null, key, data)); + } + db.sync(); + for (int i = 1; i < N_RECORDS; i += 1) { + IntegerBinding.intToEntry(i, key); + assertSame(OperationStatus.SUCCESS, + db.put(null, key, data)); + } + db.sync(); + for (int i = 1; i < N_RECORDS; i += 1) { + IntegerBinding.intToEntry(i, key); + assertSame(OperationStatus.SUCCESS, + db.put(null, key, data)); + } + db.sync(); + + /* Crash and recover. */ + DbInternal.envGetEnvironmentImpl(env).abnormalClose(); + db = null; + env = null; + envConfig.setAllowCreate(false); + env = new Environment(envHome, envConfig); + dbConfig.setAllowCreate(false); + db = env.openDatabase(null, DBNAME, dbConfig); + + /* Create enough waste to cause log file zero to be cleaned. */ + for (int i = 1; i < N_RECORDS; i += 1) { + IntegerBinding.intToEntry(i, key); + assertSame(OperationStatus.SUCCESS, + db.put(null, key, data)); + } + db.sync(); + for (int i = 1; i < N_RECORDS; i += 1) { + IntegerBinding.intToEntry(i, key); + assertSame(OperationStatus.SUCCESS, + db.delete(null, key)); + } + db.sync(); + env.cleanLog(); + env.checkpoint(CHECKPOINT_FORCE_CONFIG); + assertTrue(!(new File(envHome, TestUtils.LOG_FILE_NAME)).exists()); + + /* Before the fix, a LogFileNotFound exception was thrown here. */ + IntegerBinding.intToEntry(0, key); + assertSame(OperationStatus.NOTFOUND, + db.get(null, key, data, null)); + + db.close(); + env.close(); + env = null; + } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/ForeignKeyTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/ForeignKeyTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/ForeignKeyTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/ForeignKeyTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ForeignKeyTest.java,v 1.16 2008/01/07 14:29:13 cwl Exp $ + * $Id: ForeignKeyTest.java,v 1.16.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/JoinTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/JoinTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/JoinTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/JoinTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JoinTest.java,v 1.16 2008/01/07 14:29:13 cwl Exp $ + * $Id: JoinTest.java,v 1.16.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/MultiEnvOpenCloseTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/MultiEnvOpenCloseTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/MultiEnvOpenCloseTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/MultiEnvOpenCloseTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MultiEnvOpenCloseTest.java,v 1.13 2008/01/07 14:29:13 cwl Exp $ + * $Id: MultiEnvOpenCloseTest.java,v 1.13.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/MultiKeyTxnTestCase.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/MultiKeyTxnTestCase.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/MultiKeyTxnTestCase.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/MultiKeyTxnTestCase.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MultiKeyTxnTestCase.java,v 1.8 2008/02/05 23:28:27 mark Exp $ + * $Id: MultiKeyTxnTestCase.java,v 1.8.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/PhantomRestartTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/PhantomRestartTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/PhantomRestartTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/PhantomRestartTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PhantomRestartTest.java,v 1.14 2008/01/07 14:29:13 cwl Exp $ + * $Id: PhantomRestartTest.java,v 1.14.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/PhantomTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/PhantomTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/PhantomTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/PhantomTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PhantomTest.java,v 1.16 2008/01/07 14:29:13 cwl Exp $ + * $Id: PhantomTest.java,v 1.16.2.3 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; @@ -249,6 +249,7 @@ /* Insertions are never blocked. */ try { insert(1); + insert(3); } catch (DeadlockException e) { fail(); } @@ -275,6 +276,7 @@ /* Insertions are never blocked. */ try { insert(1, 1); + insert(1, 4); } catch (DeadlockException e) { fail(); } @@ -297,6 +299,13 @@ Cursor cursor = db.openCursor(readerTxn, null); assertEquals(OperationStatus.NOTFOUND, searchKey(cursor, 2)); + /* Insertions before 2 are never blocked. */ + try { + insert(0); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -339,6 +348,14 @@ Cursor cursor = db.openCursor(readerTxn, null); assertEquals(OperationStatus.NOTFOUND, searchKey(cursor, 1, 1)); + /* Insertions after {2,2} are never blocked. */ + try { + insert(2, 3); + insert(3, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,1} in a writer thread. */ startInsert(1, 1); @@ -383,6 +400,7 @@ /* Insertions are never blocked. */ try { insert(1); + insert(3); } catch (DeadlockException e) { fail(); } @@ -408,7 +426,11 @@ /* Insertions are never blocked. */ try { + insert(0, 0); + insert(1, 0); insert(1, 2); + insert(1, 4); + insert(2, 0); } catch (DeadlockException e) { fail(); } @@ -431,6 +453,13 @@ Cursor cursor = db.openCursor(readerTxn, null); assertEquals(OperationStatus.NOTFOUND, searchBoth(cursor, 2)); + /* Insertions before 2 are never blocked. */ + try { + insert(0); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -473,6 +502,16 @@ Cursor cursor = db.openCursor(readerTxn, null); assertEquals(OperationStatus.NOTFOUND, searchBoth(cursor, 1, 2)); + /* Insertions before {1,2} or after {1,3} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(1, 4); + insert(2, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,2} in a writer thread. */ startInsert(1, 2); @@ -521,6 +560,14 @@ assertEquals(OperationStatus.SUCCESS, status); assertEquals(3, IntegerBinding.entryToInt(key)); + /* Insertions before 2 and after 3 are never blocked. */ + try { + insert(0); + insert(4); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -578,6 +625,16 @@ assertEquals(2, IntegerBinding.entryToInt(data)); assertEquals(OperationStatus.SUCCESS, status); + /* Insertions before 2 and after {3,3} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(3, 4); + insert(4, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {3,1} in a writer thread. */ startInsert(3, 1); @@ -633,6 +690,13 @@ status = cursor.getSearchKeyRange(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before 2 are never blocked. */ + try { + insert(0); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 3 in a writer thread. */ startInsert(3); @@ -686,6 +750,14 @@ status = cursor.getSearchKeyRange(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before 2 are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {3,1} in a writer thread. */ startInsert(3, 1); @@ -754,6 +826,15 @@ assertEquals(3, IntegerBinding.entryToInt(key)); assertEquals(2, IntegerBinding.entryToInt(data)); + /* Insertions before {1,1} and after {3,2} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(3, 4); + } catch (DeadlockException e) { + fail(); + } + /* Insert {3,1} in a writer thread. */ startInsert(3, 1); @@ -812,6 +893,13 @@ status = cursor.getSearchBothRange(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before 1 are never blocked. */ + try { + insert(0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {3, 1} in a writer thread. */ startInsert(3, 1); @@ -870,6 +958,14 @@ status = cursor.getSearchBothRange(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before {3,0} are never blocked. */ + try { + insert(3, -1); + insert(2, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {3,3} in a writer thread. */ startInsert(3, 3); @@ -926,6 +1022,13 @@ assertEquals(OperationStatus.SUCCESS, status); assertEquals(2, IntegerBinding.entryToInt(key)); + /* Insertions after 2 are never blocked. */ + try { + insert(3); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 1 in a writer thread. */ startInsert(1); @@ -978,6 +1081,14 @@ assertEquals(1, IntegerBinding.entryToInt(key)); assertEquals(2, IntegerBinding.entryToInt(data)); + /* Insertions after {1,3} are never blocked. */ + try { + insert(1, 4); + insert(2, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,1} in a writer thread. */ startInsert(1, 1); @@ -1186,6 +1297,7 @@ /* Insertions before current position are never blocked. */ try { insert(1, 1); + insert(0, 0); } catch (DeadlockException e) { fail(); } @@ -1339,6 +1451,14 @@ assertEquals(OperationStatus.SUCCESS, status); assertEquals(3, IntegerBinding.entryToInt(key)); + /* Insertions before 1 and after 3 are never blocked. */ + try { + insert(0); + insert(4); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -1394,6 +1514,16 @@ assertEquals(1, IntegerBinding.entryToInt(key)); assertEquals(3, IntegerBinding.entryToInt(data)); + /* Insertions before {1,1} and after {1,3} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(1, 4); + insert(2, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,2} in a writer thread. */ startInsert(1, 2); @@ -1449,6 +1579,13 @@ status = cursor.getNext(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before 1 are never blocked. */ + try { + insert(0); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -1502,6 +1639,14 @@ status = cursor.getNext(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before {1,1} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,3} in a writer thread. */ startInsert(1, 3); @@ -1559,6 +1704,16 @@ assertEquals(1, IntegerBinding.entryToInt(key)); assertEquals(3, IntegerBinding.entryToInt(data)); + /* Insertions before {1,1} and after {1,3} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(1, 4); + insert(2, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,2} in a writer thread. */ startInsert(1, 2); @@ -1617,6 +1772,16 @@ status = cursor.getNextDup(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before {1,1} and after {2,2} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(2, 3); + insert(3, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,3} in a writer thread. */ startInsert(1, 3); @@ -1673,6 +1838,14 @@ assertEquals(OperationStatus.SUCCESS, status); assertEquals(3, IntegerBinding.entryToInt(key)); + /* Insertions before 1 and after 3 are never blocked. */ + try { + insert(0); + insert(4); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -1730,6 +1903,16 @@ assertEquals(3, IntegerBinding.entryToInt(key)); assertEquals(1, IntegerBinding.entryToInt(data)); + /* Insertions before {1,1} and after {3,2} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + insert(3, 3); + insert(4, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {2,1} in a writer thread. */ startInsert(2, 1); @@ -1785,6 +1968,13 @@ status = cursor.getNextNoDup(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before 1 are never blocked. */ + try { + insert(0); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 2 in a writer thread. */ startInsert(2); @@ -1838,6 +2028,14 @@ status = cursor.getNextNoDup(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions before {1,1} are never blocked. */ + try { + insert(1, 0); + insert(0, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {2,1} in a writer thread. */ startInsert(2, 1); @@ -1894,9 +2092,10 @@ assertEquals(OperationStatus.SUCCESS, status); assertEquals(1, IntegerBinding.entryToInt(key)); - /* Insertions before current position are never blocked. */ + /* Insertions before 1 and after 3 are never blocked. */ try { insert(0); + insert(4); } catch (DeadlockException e) { fail(); } @@ -1956,9 +2155,12 @@ assertEquals(1, IntegerBinding.entryToInt(key)); assertEquals(1, IntegerBinding.entryToInt(data)); - /* Insertions before current position are never blocked. */ + /* Insertions before {1,1} and after {1,3} are never blocked. */ try { insert(1, 0); + insert(0, 0); + insert(1, 4); + insert(2, 0); } catch (DeadlockException e) { fail(); } @@ -2018,6 +2220,13 @@ status = cursor.getPrev(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions after 2 are never blocked. */ + try { + insert(3); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 1 in a writer thread. */ startInsert(1); @@ -2071,6 +2280,14 @@ status = cursor.getPrev(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions after {2,3} are never blocked. */ + try { + insert(2, 4); + insert(3, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {2,1} in a writer thread. */ startInsert(2, 1); @@ -2128,9 +2345,12 @@ assertEquals(1, IntegerBinding.entryToInt(key)); assertEquals(1, IntegerBinding.entryToInt(data)); - /* Insertions before current position are never blocked. */ + /* Insertions before {1,1} and after {1,3} are never blocked. */ try { insert(1, 0); + insert(0, 0); + insert(1, 4); + insert(2, 0); } catch (DeadlockException e) { fail(); } @@ -2191,6 +2411,14 @@ status = cursor.getPrevDup(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions after {2,3} are never blocked. */ + try { + insert(2, 4); + insert(3, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {2,1} in a writer thread. */ startInsert(2, 1); @@ -2247,9 +2475,10 @@ assertEquals(OperationStatus.SUCCESS, status); assertEquals(1, IntegerBinding.entryToInt(key)); - /* Insertions before current position are never blocked. */ + /* Insertions before 1 and after 3 are never blocked. */ try { insert(0); + insert(4); } catch (DeadlockException e) { fail(); } @@ -2311,10 +2540,12 @@ assertEquals(1, IntegerBinding.entryToInt(key)); assertEquals(2, IntegerBinding.entryToInt(data)); - /* Insertions before current position are never blocked. */ + /* Insertions before {1,2} and after {3,2} are never blocked. */ try { insert(1, 1); insert(0, 0); + insert(3, 3); + insert(4, 0); } catch (DeadlockException e) { fail(); } @@ -2374,6 +2605,13 @@ status = cursor.getPrevNoDup(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions after 2 are never blocked. */ + try { + insert(3); + } catch (DeadlockException e) { + fail(); + } + /* Insert key 1 in a writer thread. */ startInsert(1); @@ -2427,6 +2665,14 @@ status = cursor.getPrevNoDup(key, data, null); assertEquals(OperationStatus.NOTFOUND, status); + /* Insertions after {2,2} are never blocked. */ + try { + insert(2, 3); + insert(3, 0); + } catch (DeadlockException e) { + fail(); + } + /* Insert {1,1} in a writer thread. */ startInsert(1, 1); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/SecondaryDirtyReadTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/SecondaryDirtyReadTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/SecondaryDirtyReadTest.java 2008-02-06 19:48:04.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/SecondaryDirtyReadTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryDirtyReadTest.java,v 1.17 2008/02/06 19:48:03 linda Exp $ + * $Id: SecondaryDirtyReadTest.java,v 1.17.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/SecondaryTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/SecondaryTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/SecondaryTest.java 2008-01-24 14:59:32.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/SecondaryTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SecondaryTest.java,v 1.43 2008/01/24 14:59:32 linda Exp $ + * $Id: SecondaryTest.java,v 1.43.2.3 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; @@ -1200,12 +1200,39 @@ fail(); } catch (DatabaseException expected) {} + /* Cursor.dup works whether initialized or not. */ + { + Cursor c2 = secCursor.dup(false); + c2.close(); + c2 = secCursor.dup(true); + c2.close(); + c2 = secCursor.dup(false); + c2.close(); + c2 = secCursor.dup(true); + c2.close(); + } + /* Initialize, then close, then check all operations. */ assertEquals(OperationStatus.SUCCESS, cursor.getSearchKey(key, found, null)); assertEquals(OperationStatus.SUCCESS, secCursor.getSearchKey(secKey, found, null)); + + /* Cursor.dup works whether initialized or not. */ + { + Cursor c2 = cursor.dup(false); + c2.close(); + c2 = cursor.dup(true); + c2.close(); + c2 = secCursor.dup(false); + c2.close(); + c2 = secCursor.dup(true); + c2.close(); + } + + /* Close, then check all operations. */ + secCursor.close(); cursor.close(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/SequenceTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/SequenceTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/SequenceTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/SequenceTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SequenceTest.java,v 1.10 2008/02/05 23:28:27 mark Exp $ + * $Id: SequenceTest.java,v 1.10.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/SR11297Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/SR11297Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/SR11297Test.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/SR11297Test.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SR11297Test.java,v 1.10 2008/01/07 14:29:13 cwl Exp $ + * $Id: SR11297Test.java,v 1.10.2.2 2010/01/04 15:30:47 cwl Exp $ */ package com.sleepycat.je.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/test/ToManyTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/test/ToManyTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/test/ToManyTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/test/ToManyTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ToManyTest.java,v 1.8 2008/02/05 23:28:27 mark Exp $ + * $Id: ToManyTest.java,v 1.10.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.test; @@ -46,8 +46,8 @@ * mirrors the secondary database, and for every secondary key (Byte) * contains a set of primary keys (set of Byte). */ - private Map priMap0 = new HashMap(); - private Map secMap0 = new HashMap(); + private Map> priMap0 = new HashMap>(); + private Map> secMap0 = new HashMap>(); private Database priDb; private SecondaryDatabase secDb; @@ -169,14 +169,14 @@ /** * Updates map 0 to reflect a record added to the primary database. */ - private void updateMaps(Byte priKey, Set newPriData) { + private void updateMaps(Byte priKey, Set newPriData) { /* Remove old secondary keys. */ - Set oldPriData = (Set) priMap0.get(priKey); + Set oldPriData = priMap0.get(priKey); if (oldPriData != null) { - for (Iterator i = oldPriData.iterator(); i.hasNext();) { + for (Iterator i = oldPriData.iterator(); i.hasNext();) { Byte secKey = (Byte) i.next(); - Set priKeySet = (Set) secMap0.get(secKey); + Set priKeySet = secMap0.get(secKey); assertNotNull(priKeySet); assertTrue(priKeySet.remove(priKey)); if (priKeySet.isEmpty()) { @@ -189,11 +189,11 @@ /* Put primary entry. */ priMap0.put(priKey, newPriData); /* Add new secondary keys. */ - for (Iterator i = newPriData.iterator(); i.hasNext();) { - Byte secKey = (Byte) i.next(); - Set priKeySet = (Set) secMap0.get(secKey); + for (Iterator i = newPriData.iterator(); i.hasNext();) { + Byte secKey = i.next(); + Set priKeySet = secMap0.get(secKey); if (priKeySet == null) { - priKeySet = new HashSet(); + priKeySet = new HashSet(); secMap0.put(secKey, priKeySet); } assertTrue(priKeySet.add(priKey)); @@ -214,28 +214,28 @@ DatabaseEntry priKeyEntry = new DatabaseEntry(); DatabaseEntry secKeyEntry = new DatabaseEntry(); DatabaseEntry dataEntry = new DatabaseEntry(); - Map priMap1 = new HashMap(); - Map priMap2 = new HashMap(); - Map secMap1 = new HashMap(); - Map secMap2 = new HashMap(); + Map> priMap1 = new HashMap>(); + Map> priMap2 = new HashMap>(); + Map> secMap1 = new HashMap>(); + Map> secMap2 = new HashMap>(); /* Build map 1 from the primary database. */ - priMap2 = new HashMap(); + priMap2 = new HashMap>(); Cursor priCursor = priDb.openCursor(txn, null); while (priCursor.getNext(priKeyEntry, dataEntry, null) == OperationStatus.SUCCESS) { Byte priKey = new Byte(priKeyEntry.getData()[0]); - Set priData = bytesToSet(dataEntry.getData()); + Set priData = bytesToSet(dataEntry.getData()); /* Update primary map. */ priMap1.put(priKey, priData); /* Update secondary map. */ - for (Iterator i = priData.iterator(); i.hasNext();) { - Byte secKey = (Byte) i.next(); - Set priKeySet = (Set) secMap1.get(secKey); + for (Iterator i = priData.iterator(); i.hasNext();) { + Byte secKey = i.next(); + Set priKeySet = secMap1.get(secKey); if (priKeySet == null) { - priKeySet = new HashSet(); + priKeySet = new HashSet(); secMap1.put(secKey, priKeySet); } assertTrue(priKeySet.add(priKey)); @@ -259,17 +259,17 @@ Byte secKey = new Byte(secKeyEntry.getData()[0]); /* Update primary map. */ - Set priData = (Set) priMap2.get(priKey); + Set priData = priMap2.get(priKey); if (priData == null) { - priData = new HashSet(); + priData = new HashSet(); priMap2.put(priKey, priData); } priData.add(secKey); /* Update secondary map. */ - Set secData = (Set) secMap2.get(secKey); + Set secData = secMap2.get(secKey); if (secData == null) { - secData = new HashSet(); + secData = new HashSet(); secMap2.put(secKey, secData); } secData.add(priKey); @@ -285,10 +285,10 @@ txnCommit(txn); } - private Set bytesToSet(byte[] bytes) { - Set set = null; + private Set bytesToSet(byte[] bytes) { + Set set = null; if (bytes != null) { - set = new HashSet(); + set = new HashSet(); for (int i = 0; i < bytes.length; i += 1) { set.add(new Byte(bytes[i])); } @@ -335,7 +335,7 @@ public void createSecondaryKeys(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, - Set results) + Set results) throws DatabaseException { for (int i = 0; i < data.getSize(); i+= 1) { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/BinDeltaTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/BinDeltaTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/BinDeltaTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/BinDeltaTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BinDeltaTest.java,v 1.50 2008/01/07 14:29:13 cwl Exp $ + * $Id: BinDeltaTest.java,v 1.50.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/GetParentNodeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/GetParentNodeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/GetParentNodeTest.java 2008-03-18 02:17:46.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/GetParentNodeTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: GetParentNodeTest.java,v 1.47 2008/03/18 01:17:46 cwl Exp $ + * $Id: GetParentNodeTest.java,v 1.47.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/INTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/INTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/INTest.java 2008-03-25 03:26:38.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/INTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: INTest.java,v 1.67 2008/03/25 02:26:38 linda Exp $ + * $Id: INTest.java,v 1.67.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/KeyPrefixTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/KeyPrefixTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/KeyPrefixTest.java 2008-03-20 19:13:54.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/KeyPrefixTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyPrefixTest.java,v 1.2 2008/03/20 18:13:54 linda Exp $ + * $Id: KeyPrefixTest.java,v 1.2.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/KeyTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/KeyTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/KeyTest.java 2008-03-13 04:15:48.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/KeyTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: KeyTest.java,v 1.18 2008/03/13 03:15:48 cwl Exp $ + * $Id: KeyTest.java,v 1.18.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/LSNArrayTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/LSNArrayTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/LSNArrayTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/LSNArrayTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LSNArrayTest.java,v 1.7 2008/01/07 14:29:13 cwl Exp $ + * $Id: LSNArrayTest.java,v 1.7.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/MemorySizeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/MemorySizeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/MemorySizeTest.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/MemorySizeTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MemorySizeTest.java,v 1.31 2008/05/22 19:35:39 linda Exp $ + * $Id: MemorySizeTest.java,v 1.31.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/ReleaseLatchesTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/ReleaseLatchesTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/ReleaseLatchesTest.java 2008-04-18 22:57:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/ReleaseLatchesTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ReleaseLatchesTest.java,v 1.21 2008/04/18 22:57:39 mark Exp $ + * $Id: ReleaseLatchesTest.java,v 1.21.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/SplitTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/SplitTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/SplitTest.java 2008-02-07 17:23:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/SplitTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SplitTest.java,v 1.29 2008/02/07 17:23:20 cwl Exp $ + * $Id: SplitTest.java,v 1.29.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/TreeDuplicateTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/TreeDuplicateTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/TreeDuplicateTest.java 2008-03-18 02:17:46.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/TreeDuplicateTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TreeDuplicateTest.java,v 1.50 2008/03/18 01:17:46 cwl Exp $ + * $Id: TreeDuplicateTest.java,v 1.50.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/TreeTestBase.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/TreeTestBase.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/TreeTestBase.java 2008-03-18 02:17:46.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/TreeTestBase.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TreeTestBase.java,v 1.59 2008/03/18 01:17:46 cwl Exp $ + * $Id: TreeTestBase.java,v 1.59.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/TreeTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/TreeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/TreeTest.java 2008-03-18 02:17:46.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/TreeTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TreeTest.java,v 1.94 2008/03/18 01:17:46 cwl Exp $ + * $Id: TreeTest.java,v 1.94.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/tree/ValidateSubtreeDeleteTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/tree/ValidateSubtreeDeleteTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/tree/ValidateSubtreeDeleteTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/tree/ValidateSubtreeDeleteTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ValidateSubtreeDeleteTest.java,v 1.34 2008/01/07 14:29:13 cwl Exp $ + * $Id: ValidateSubtreeDeleteTest.java,v 1.34.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.tree; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/TruncateTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/TruncateTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/TruncateTest.java 2008-04-08 21:30:00.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/TruncateTest.java 2010-01-04 15:30:42.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TruncateTest.java,v 1.22 2008/04/08 21:30:00 cwl Exp $ + * $Id: TruncateTest.java,v 1.22.2.3 2010/01/04 15:30:42 cwl Exp $ */ package com.sleepycat.je; @@ -43,11 +43,13 @@ public void tearDown() throws Exception { - try { - /* Close in case we hit an exception and didn't close. */ - env.close(); - } catch (DatabaseException e) { - /* Ok if already closed */ + if (env != null) { + try { + /* Close in case we hit an exception and didn't close. */ + env.close(); + } catch (DatabaseException e) { + /* Ok if already closed */ + } } env = null; // for JUNIT, to reduce memory usage when run in a suite. TestUtils.removeLogFiles("TearDown", envHome, false); @@ -371,6 +373,45 @@ } /** + * Test that truncateDatabase and removeDatabase can be called after + * replaying an LN in that database during recovery. This is to test a fix + * to a bug where truncateDatabase caused a hang because DbTree.releaseDb + * was not called by RecoveryUtilizationTracker. [#16329] + */ + public void testTruncateAfterRecovery() + throws Throwable { + + DatabaseEntry key = new DatabaseEntry(new byte[10]); + DatabaseEntry data = new DatabaseEntry(new byte[10]); + + Database db = initEnvAndDb(true); + EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env); + + /* Write a single record for recovery. */ + OperationStatus status = db.put(null, key, data); + assertSame(OperationStatus.SUCCESS, status); + + /* Close without a checkpoint and run recovery. */ + db.close(); + envImpl.abnormalClose(); + envImpl = null; + env = null; + db = initEnvAndDb(true); + + /* Ensure that truncateDatabase does not hang. */ + db.close(); + long truncateCount = env.truncateDatabase(null, DB_NAME, true); + assertEquals(1, truncateCount); + + /* removeDatabase should also work. */ + env.removeDatabase(null, DB_NAME); + assertTrue(!env.getDatabaseNames().contains(DB_NAME)); + + env.close(); + env = null; + } + + /** * Set up the environment and db. */ private Database initEnvAndDb(boolean isTransactional) diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/CursorTxnTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/CursorTxnTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/CursorTxnTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/CursorTxnTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: CursorTxnTest.java,v 1.43 2008/01/07 14:29:14 cwl Exp $ + * $Id: CursorTxnTest.java,v 1.43.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/LockManagerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/LockManagerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/LockManagerTest.java 2008-01-17 17:22:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/LockManagerTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockManagerTest.java,v 1.55 2008/01/17 17:22:30 cwl Exp $ + * $Id: LockManagerTest.java,v 1.55.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/LockTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/LockTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/LockTest.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/LockTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: LockTest.java,v 1.61 2008/05/22 19:35:40 linda Exp $ + * $Id: LockTest.java,v 1.61.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TwoPCTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TwoPCTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TwoPCTest.java 2008-05-15 09:44:36.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TwoPCTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TwoPCTest.java,v 1.10 2008/05/15 09:44:35 chao Exp $ + * $Id: TwoPCTest.java,v 1.10.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnEndTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnEndTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnEndTest.java 2008-05-15 09:44:36.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnEndTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnEndTest.java,v 1.73 2008/05/15 09:44:35 chao Exp $ + * $Id: TxnEndTest.java,v 1.74.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; @@ -411,10 +411,11 @@ Thread.yield(); DatabaseEntry key = new DatabaseEntry(); key.setData("abc".getBytes()); - OperationStatus status; - status = + OperationStatus status = c.getSearchKeyRange(key, data, LockMode.DEFAULT); + assertEquals(status, OperationStatus.SUCCESS); status = c.delete(); + assertEquals(status, OperationStatus.SUCCESS); } catch (Throwable T) { T.printStackTrace(); } finally { @@ -426,8 +427,8 @@ tester1.start(); Thread.yield(); key.setData("abc".getBytes()); - OperationStatus status; - status = db.delete(txn1, key); + OperationStatus status = db.delete(txn1, key); + assertEquals(OperationStatus.SUCCESS, status); txn1.abort(); Thread.yield(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnFSyncTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnFSyncTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnFSyncTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnFSyncTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnFSyncTest.java,v 1.15 2008/02/05 23:28:27 mark Exp $ + * $Id: TxnFSyncTest.java,v 1.15.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnMemoryTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnMemoryTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnMemoryTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnMemoryTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnMemoryTest.java,v 1.17 2008/01/07 14:29:14 cwl Exp $ + * $Id: TxnMemoryTest.java,v 1.17.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnTest.java 2008-05-13 20:03:12.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnTest.java,v 1.71 2008/05/13 20:03:11 sam Exp $ + * $Id: TxnTest.java,v 1.74.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; @@ -42,6 +42,7 @@ import com.sleepycat.je.tree.LN; import com.sleepycat.je.tree.WithRootLatched; import com.sleepycat.je.util.TestUtils; +import com.sleepycat.je.utilint.DbLsn; /* * Simple transaction testing @@ -218,10 +219,8 @@ assertEquals(2, envStats.getNTotalLocks()); try { - LockGrantType lockGrant2 = userTxn2.lock - (ln.getNodeId(), LockType.WRITE, false, - DbInternal.dbGetDatabaseImpl(db)). - getLockGrant(); + userTxn2.lock(ln.getNodeId(), LockType.WRITE, false, + DbInternal.dbGetDatabaseImpl(db)).getLockGrant(); } catch (DeadlockException DE) { // ok } @@ -297,7 +296,13 @@ assertEquals(LockGrantType.EXISTING, lockGrant); checkHeldLocks(userTxn, 1, 1); - /* Shouldn't release at operation end. */ + + /* + * The commit won't actually write a log record if this + * transaction has never done an update, so fake it out and simulate + * a write. + */ + userTxn.addLogInfo(DbLsn.makeLsn(0, 100)); long commitLsn = userTxn.commit(TransactionConfig.SYNC); checkHeldLocks(userTxn, 0, 0); @@ -381,7 +386,7 @@ * [#14349] Make sure the txn is printable after closing. We * once had a NullPointerException. */ - String s = txn.toString(); + txn.toString(); } catch (Throwable t) { /* print stack trace before going to teardown. */ t.printStackTrace(); diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnTimeoutTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnTimeoutTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/txn/TxnTimeoutTest.java 2008-02-27 15:03:52.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/txn/TxnTimeoutTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnTimeoutTest.java,v 1.34 2008/02/27 15:03:52 mark Exp $ + * $Id: TxnTimeoutTest.java,v 1.34.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.txn; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/Adler32Test.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/Adler32Test.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/Adler32Test.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/Adler32Test.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Adler32Test.java,v 1.13 2008/01/07 14:29:14 cwl Exp $ + * $Id: Adler32Test.java,v 1.13.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/BadFileFilter.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/BadFileFilter.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/BadFileFilter.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/BadFileFilter.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BadFileFilter.java,v 1.14 2008/01/07 14:29:14 cwl Exp $ + * $Id: BadFileFilter.java,v 1.14.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbBackupTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbBackupTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbBackupTest.java 2008-05-30 14:04:22.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbBackupTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbBackupTest.java,v 1.13 2008/05/30 14:04:22 mark Exp $ + * $Id: DbBackupTest.java,v 1.13.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbDumpTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbDumpTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbDumpTest.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbDumpTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbDumpTest.java,v 1.49 2008/05/22 19:35:40 linda Exp $ + * $Id: DbDumpTest.java,v 1.49.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbLsnTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbLsnTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbLsnTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbLsnTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbLsnTest.java,v 1.20 2008/01/07 14:29:14 cwl Exp $ + * $Id: DbLsnTest.java,v 1.20.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbScavengerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbScavengerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/DbScavengerTest.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/DbScavengerTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DbScavengerTest.java,v 1.21 2008/05/22 19:35:40 linda Exp $ + * $Id: DbScavengerTest.java,v 1.21.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/DebugRecordTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/DebugRecordTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/DebugRecordTest.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/DebugRecordTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: DebugRecordTest.java,v 1.51 2008/05/22 19:35:40 linda Exp $ + * $Id: DebugRecordTest.java,v 1.51.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/HexFormatterTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/HexFormatterTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/HexFormatterTest.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/HexFormatterTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: HexFormatterTest.java,v 1.14 2008/01/07 14:29:14 cwl Exp $ + * $Id: HexFormatterTest.java,v 1.14.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/InfoFileFilter.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/InfoFileFilter.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/InfoFileFilter.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/InfoFileFilter.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: InfoFileFilter.java,v 1.13 2008/01/07 14:29:14 cwl Exp $ + * $Id: InfoFileFilter.java,v 1.13.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/MiniPerf.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/MiniPerf.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/MiniPerf.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/MiniPerf.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: MiniPerf.java,v 1.23 2008/01/07 14:29:14 cwl Exp $ + * $Id: MiniPerf.java,v 1.23.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/PropUtilTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/PropUtilTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/PropUtilTest.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/PropUtilTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PropUtilTest.java,v 1.22 2008/05/22 19:35:40 linda Exp $ + * $Id: PropUtilTest.java,v 1.22.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/RecordSearch.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/RecordSearch.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/RecordSearch.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/RecordSearch.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RecordSearch.java,v 1.28 2008/01/07 14:29:14 cwl Exp $ + * $Id: RecordSearch.java,v 1.28.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/StringDbt.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/StringDbt.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/StringDbt.java 2008-01-07 14:29:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/StringDbt.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: StringDbt.java,v 1.15 2008/01/07 14:29:14 cwl Exp $ + * $Id: StringDbt.java,v 1.15.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/util/TestUtils.java libdb-je-java-3.3.98/test/com/sleepycat/je/util/TestUtils.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/util/TestUtils.java 2008-05-22 19:35:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/util/TestUtils.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestUtils.java,v 1.88 2008/05/22 19:35:40 linda Exp $ + * $Id: TestUtils.java,v 1.88.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.util; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/utilint/BitMapTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/utilint/BitMapTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/utilint/BitMapTest.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/utilint/BitMapTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BitMapTest.java,v 1.7 2008/01/07 14:29:15 cwl Exp $ + * $Id: BitMapTest.java,v 1.7.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/je/utilint/ExceptionListenerTest.java libdb-je-java-3.3.98/test/com/sleepycat/je/utilint/ExceptionListenerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/je/utilint/ExceptionListenerTest.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/je/utilint/ExceptionListenerTest.java 2010-01-04 15:30:48.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ExceptionListenerTest.java,v 1.11 2008/01/07 14:29:15 cwl Exp $ + * $Id: ExceptionListenerTest.java,v 1.11.2.2 2010/01/04 15:30:48 cwl Exp $ */ package com.sleepycat.je.utilint; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/BindingTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/BindingTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/BindingTest.java 2008-05-19 17:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/BindingTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BindingTest.java,v 1.33 2008/05/19 17:52:23 linda Exp $ + * $Id: BindingTest.java,v 1.33.2.3 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; @@ -1879,7 +1879,8 @@ /* Create key creator/nullifier. */ SecondaryKeyCreator keyCreator = new PersistKeyCreator - (catalog, entityMeta, keyCls.getName(), secKeyMeta); + (catalog, entityMeta, keyCls.getName(), secKeyMeta, + false /*rawAcess*/); /* Convert entity to bytes. */ PersistEntityBinding entityBinding = @@ -1924,7 +1925,8 @@ /* Create key creator/nullifier. */ SecondaryMultiKeyCreator keyCreator = new PersistKeyCreator - (catalog, entityMeta, keyCls.getName(), secKeyMeta); + (catalog, entityMeta, keyCls.getName(), secKeyMeta, + false /*rawAcess*/); /* Convert entity to bytes. */ PersistEntityBinding entityBinding = @@ -1968,7 +1970,8 @@ /* Create key creator/nullifier. */ ForeignMultiKeyNullifier keyNullifier = new PersistKeyCreator - (catalog, entityMeta, keyCls.getName(), secKeyMeta); + (catalog, entityMeta, keyCls.getName(), secKeyMeta, + false /*rawAcess*/); /* Convert entity to bytes. */ PersistEntityBinding entityBinding = @@ -2017,7 +2020,8 @@ /* Create key creator/nullifier. */ ForeignMultiKeyNullifier keyNullifier = new PersistKeyCreator - (catalog, entityMeta, keyCls.getName(), secKeyMeta); + (catalog, entityMeta, keyCls.getName(), secKeyMeta, + false /*rawAcess*/); /* Convert entity to bytes. */ PersistEntityBinding entityBinding = diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/ConvertAndAddTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/ConvertAndAddTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/ConvertAndAddTest.java 2008-05-30 14:04:22.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/ConvertAndAddTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ConvertAndAddTest.java,v 1.6 2008/05/30 14:04:22 mark Exp $ + * $Id: ConvertAndAddTest.java,v 1.6.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/DevolutionTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/DevolutionTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/DevolutionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/DevolutionTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -0,0 +1,180 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 2002,2010 Oracle. All rights reserved. + * + * $Id: DevolutionTest.java,v 1.1.2.3 2010/01/04 15:30:49 cwl Exp $ + */ + +package com.sleepycat.persist.test; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.Environment; +import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.util.TestUtils; +import com.sleepycat.persist.EntityStore; +import com.sleepycat.persist.PrimaryIndex; +import com.sleepycat.persist.StoreConfig; +import com.sleepycat.persist.evolve.Mutations; +import com.sleepycat.persist.evolve.Renamer; +import com.sleepycat.persist.model.Entity; +import com.sleepycat.persist.model.EntityModel; +import com.sleepycat.persist.model.Persistent; +import com.sleepycat.persist.model.PrimaryKey; +import com.sleepycat.persist.model.Relationship; +import com.sleepycat.persist.model.SecondaryKey; +import com.sleepycat.util.test.TestEnv; + +/** + * Test a bug fix for an evolution error when a class is evolved and then + * changed back to its original version. Say there are two versions of a + * class A1 and A2 in the catalog, plus a new version A3 of the class. The + * problem occurs when A2 is different than A3 and must be evolved, but A1 + * happens to be identical to A3 and no evolution is needed. In that case, A3 + * was never added to the format list in the catalog (never assigned a format + * ID), but was still used as the "latest version" of A2. This caused all + * kinds of trouble since the class catalog was effectively corrupt. [#16467] + * + * We reproduce this scenario using type Other[], which is represented using + * ArrayObjectFormat internally. By renaming Other to Other2, and then back to + * Other, we create the scenario described above for the array format itself. + * Array formats are only evolved if their component class name has changed + * (see ArrayObjectFormat.evolve). + * + * A modified version of this program was run manually with JE 3.3.71 to + * produce a log, which is the result of the testSetup() test. The sole log + * file was renamed from 00000000.jdb to DevolutionTest.jdb and added to CVS + * in this directory. When that log file is opened here, the bug is + * reproduced. + * + * This test should be excluded from the BDB build because it uses a stored JE + * log file and it tests a fix for a bug that was never present in BDB. + * + * @author Mark Hayes + */ +public class DevolutionTest extends TestCase { + + private static final String STORE_NAME = "test"; + + private File envHome; + private Environment env; + + public void setUp() + throws IOException { + + envHome = new File(System.getProperty(TestUtils.DEST_DIR)); + TestUtils.removeLogFiles("Setup", envHome, false); + } + + public void tearDown() + throws IOException { + + if (env != null) { + try { + env.close(); + } catch (Throwable e) { + System.out.println("During tearDown: " + e); + } + } + try { + TestUtils.removeLogFiles("TearDown", envHome, false); + } catch (Throwable e) { + System.out.println("During tearDown: " + e); + } + envHome = null; + env = null; + } + + private EntityStore open() + throws DatabaseException { + + EnvironmentConfig envConfig = TestEnv.BDB.getConfig(); + envConfig.setAllowCreate(true); + env = new Environment(envHome, envConfig); + + /* + * When version 0 of Other is used, no renamer is configured. When + * version 1 is used, a renamer from Other version 0 to Other2 is used. + * For version 2, the current version, a renamer from Other2 version 1 + * to Other is used. + */ + String clsName = getClass().getName() + "$Other"; + Renamer renamer = new Renamer(clsName + '2', 1, clsName); + Mutations mutations = new Mutations(); + mutations.addRenamer(renamer); + + StoreConfig storeConfig = new StoreConfig(); + storeConfig.setAllowCreate(true); + storeConfig.setMutations(mutations); + return new EntityStore(env, "foo", storeConfig); + } + + private void close(EntityStore store) + throws DatabaseException { + + store.close(); + env.close(); + env = null; + } + + public void testDevolution() + throws DatabaseException, IOException { + + /* Copy log file resource to log file zero. */ + TestUtils.loadLog(getClass(), "DevolutionTest.jdb", envHome); + + EntityStore store = open(); + + PrimaryIndex index = + store.getPrimaryIndex(Long.class, MyEntity.class); + + MyEntity entity = index.get(1L); + assertNotNull(entity); + assertEquals(123, entity.b); + + close(store); + } + + public void xtestSetup() + throws DatabaseException { + + EntityStore store = open(); + + PrimaryIndex index = + store.getPrimaryIndex(Long.class, MyEntity.class); + + MyEntity entity = new MyEntity(); + entity.key = 1L; + entity.b = 123; + index.put(entity); + + close(store); + } + + /** + * This class name is changed from Other to Other2 in version 1 and back to + * Other in the version 2. testSetup is executed for versions 0 and 1, + * which evolves the format. testDevolution is run with version 2. + */ + @Persistent(version=2) + static class Other { + } + + @Entity(version=0) + static class MyEntity { + + @PrimaryKey + long key; + + Other[] a; + + int b; + + private MyEntity() {} + } +} Binary files /tmp/fENspI5OcX/libdb-je-java-3.3.62/test/com/sleepycat/persist/test/DevolutionTest.jdb and /tmp/JpVSj7KJOY/libdb-je-java-3.3.98/test/com/sleepycat/persist/test/DevolutionTest.jdb differ diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced0.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced0.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced0.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced0.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Enhanced0.java,v 1.6 2008/01/07 14:29:15 cwl Exp $ + * $Id: Enhanced0.java,v 1.6.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced1.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced1.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced1.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced1.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Enhanced1.java,v 1.10 2008/01/07 14:29:15 cwl Exp $ + * $Id: Enhanced1.java,v 1.10.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced2.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced2.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced2.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced2.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Enhanced2.java,v 1.8 2008/01/07 14:29:15 cwl Exp $ + * $Id: Enhanced2.java,v 1.8.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced3.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced3.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/Enhanced3.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/Enhanced3.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: Enhanced3.java,v 1.8 2008/01/07 14:29:15 cwl Exp $ + * $Id: Enhanced3.java,v 1.8.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveCase.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveCase.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveCase.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveCase.java 2008-06-23 19:18:28.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: EvolveCase.java,v 1.12 2008/01/07 14:29:15 cwl Exp $ + * $Id: EvolveCase.java,v 1.13 2008/06/23 19:18:27 mark Exp $ */ package com.sleepycat.persist.test; @@ -181,7 +181,7 @@ TestCase.assertNotNull(all); assert names.length == versions.length; - TestCase.assertEquals(names.length, all.size()); + TestCase.assertEquals(all.toString(), names.length, all.size()); Iterator iter = all.iterator(); for (int i = 0; i < names.length; i += 1) { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveClasses.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveClasses.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveClasses.java 2008-06-03 04:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveClasses.java 2009-03-27 17:12:56.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: EvolveClasses.java,v 1.25 2008/06/03 04:52:24 mark Exp $ + * $Id: EvolveClasses.java,v 1.26.2.2 2009/03/27 17:12:55 mark Exp $ */ package com.sleepycat.persist.test; @@ -53,10 +53,19 @@ private static final String PREFIX = EvolveClasses.class.getName() + '$'; private static final String CASECLS = EvolveCase.class.getName(); + private static RawObject readRaw(RawStore store, + Object key, + Object... classVersionPairs) + throws DatabaseException { + + return readRaw(store, null, key, classVersionPairs); + } + /** * Reads a raw object and checks its superclass names and versions. */ private static RawObject readRaw(RawStore store, + String entityClsName, Object key, Object... classVersionPairs) throws DatabaseException { @@ -64,7 +73,9 @@ TestCase.assertNotNull(store); TestCase.assertNotNull(key); - String entityClsName = (String) classVersionPairs[0]; + if (entityClsName == null) { + entityClsName = (String) classVersionPairs[0]; + } PrimaryIndex index = store.getPrimaryIndex(entityClsName); TestCase.assertNotNull(index); @@ -495,7 +506,7 @@ /** * Allow removing a Persistent class when a Deleter mutation is * specified, and the Entity class that embedded the Persistent class - * is also be deleted properly (by removing the Entity annotation in this + * is also deleted properly (by removing the Entity annotation in this * case). */ static class DeletedPersist2_ClassRemoved_WithDeleter extends EvolveCase { @@ -4307,6 +4318,114 @@ } } + @SuppressWarnings("serial") + static class ConvertFieldContent_Conversion implements Conversion { + + public void initialize(EntityModel model) { + } + + public Object convert(Object fromValue) { + String s1 = (String) fromValue; + return (new StringBuilder(s1)).reverse().toString(); + } + + @Override + public boolean equals(Object o) { + return o instanceof ConvertFieldContent_Conversion; + } + } + + @Entity(version=1) + static class ConvertFieldContent_Entity + extends EvolveCase { + + private static final String NAME = + ConvertFieldContent_Entity.class.getName(); + + @PrimaryKey + int key = 99; + + String f1; + String f2; + + @Override + Mutations getMutations() { + Mutations m = new Mutations(); + Converter converter = new Converter + (ConvertFieldContent_Entity.class.getName(), 0, + "f1", new ConvertFieldContent_Conversion()); + m.addConverter(converter); + converter = new Converter + (ConvertFieldContent_Entity.class.getName(), 0, + "f2", new ConvertFieldContent_Conversion()); + m.addConverter(converter); + return m; + } + + @Override + void checkEvolvedModel(EntityModel model, + Environment env, + boolean oldTypesExist) { + checkEntity(true, model, env, NAME, 1, null); + if (oldTypesExist) { + checkVersions(model, NAME, 1, NAME, 0); + } else { + checkVersions(model, NAME, 1); + } + } + + @Override + void readObjects(EntityStore store, boolean doUpdate) + throws DatabaseException { + + PrimaryIndex + index = store.getPrimaryIndex + (Integer.class, + ConvertFieldContent_Entity.class); + ConvertFieldContent_Entity obj = index.get(99); + TestCase.assertNotNull(obj); + TestCase.assertEquals(99, obj.key); + TestCase.assertEquals("43210", obj.f1); + TestCase.assertEquals("98765", obj.f2); + + if (doUpdate) { + index.put(obj); + } + } + + @Override + void copyRawObjects(RawStore rawStore, EntityStore newStore) + throws DatabaseException { + + PrimaryIndex + index = newStore.getPrimaryIndex + (Integer.class, + ConvertFieldContent_Entity.class); + RawObject raw = rawStore.getPrimaryIndex(NAME).get(99); + index.put((ConvertFieldContent_Entity) + newStore.getModel().convertRawObject(raw)); + } + + @Override + void readRawObjects(RawStore store, + boolean expectEvolved, + boolean expectUpdated) + throws DatabaseException { + + RawObject obj = + readRaw(store, 99, NAME, expectEvolved ? 1 : 0, CASECLS, 0); + if (expectEvolved) { + checkRawFields(obj, "key", 99, + "f1", "43210", + "f2", "98765"); + } else { + checkRawFields(obj, "key", 99, + "f1", "01234", + "f2", "56789"); + } + } + } + @Persistent(version=1) static class ConvertExample1_Address { String street; @@ -5897,6 +6016,7 @@ * dropField = 77; * dropAnnotation = 66; * addField = 55; + * renamedField = 44; // was toBeRenamedField * aa = 33; * ff = 22; */ @@ -5911,12 +6031,17 @@ @SecondaryKey(relate=ONE_TO_ONE) Integer addField; + @SecondaryKey(relate=ONE_TO_ONE) + int renamedField; + int ff; @Override Mutations getMutations() { Mutations m = new Mutations(); m.addDeleter(new Deleter(NAME, 0, "dropField")); + m.addRenamer(new Renamer(NAME, 0, "toBeRenamedField", + "renamedField")); return m; } @@ -5945,6 +6070,8 @@ checkValues(store.getSecondaryIndex (index, Integer.class, "addAnnotation").get(88)); + checkValues(store.getSecondaryIndex + (index, Integer.class, "renamedField").get(44)); if (updated) { checkValues(store.getSecondaryIndex (index, Integer.class, "addField").get(55)); @@ -5982,6 +6109,7 @@ TestCase.assertEquals(99, obj.key); TestCase.assertEquals(88, obj.addAnnotation); TestCase.assertEquals(66, obj.dropAnnotation); + TestCase.assertEquals(44, obj.renamedField); TestCase.assertEquals(33, obj.aa); TestCase.assertEquals(22, obj.ff); if (updated) { @@ -6004,12 +6132,14 @@ "addAnnotation", 88, "dropAnnotation", 66, "addField", 55, + "renamedField", 44, "aa", 33, "ff", 22); } else if (expectEvolved) { checkRawFields(obj, "key", 99, "addAnnotation", 88, "dropAnnotation", 66, + "renamedField", 44, "aa", 33, "ff", 22); } else { @@ -6017,18 +6147,203 @@ "addAnnotation", 88, "dropField", 77, "dropAnnotation", 66, + "toBeRenamedField", 44, "aa", 33, "ff", 22); } Environment env = store.getEnvironment(); assertDbExists(expectEvolved, env, NAME, "addAnnotation"); assertDbExists(expectEvolved, env, NAME, "addField"); + assertDbExists(expectEvolved, env, NAME, "renamedField"); + assertDbExists(!expectEvolved, env, NAME, "toBeRenamedField"); assertDbExists(!expectEvolved, env, NAME, "dropField"); assertDbExists(!expectEvolved, env, NAME, "dropAnnotation"); } } - /** [#15524] */ + /** + * Same test as AllowChangeKeyMetadata but with the secondary keys in an + * entity subclass. [#16253] + */ + @Persistent(version=1) + static class AllowChangeKeyMetadataInSubclass + extends AllowChangeKeyMetadataEntity { + + private static final String NAME = + AllowChangeKeyMetadataInSubclass.class.getName(); + private static final String NAME2 = + AllowChangeKeyMetadataEntity.class.getName(); + + /* + * Combined fields from version 0 and 1: + * addAnnotation = 88; + * dropField = 77; + * dropAnnotation = 66; + * addField = 55; + * renamedField = 44; // was toBeRenamedField + * aa = 33; + * ff = 22; + */ + + int aa; + + @SecondaryKey(relate=ONE_TO_ONE) + int addAnnotation; + + int dropAnnotation; + + @SecondaryKey(relate=ONE_TO_ONE) + Integer addField; + + @SecondaryKey(relate=ONE_TO_ONE) + int renamedField; + + int ff; + + @Override + Mutations getMutations() { + Mutations m = new Mutations(); + m.addDeleter(new Deleter(NAME, 0, "dropField")); + m.addRenamer(new Renamer(NAME, 0, "toBeRenamedField", + "renamedField")); + return m; + } + + @Override + void checkEvolvedModel(EntityModel model, + Environment env, + boolean oldTypesExist) { + checkNonEntity(true, model, env, NAME, 1); + checkEntity(true, model, env, NAME2, 0, null); + if (oldTypesExist) { + checkVersions(model, NAME, 1, NAME, 0); + checkVersions(model, NAME2, 0); + } else { + checkVersions(model, NAME, 1); + checkVersions(model, NAME2, 0); + } + } + + @Override + void readObjects(EntityStore store, boolean doUpdate) + throws DatabaseException { + + PrimaryIndex + index = store.getPrimaryIndex + (Integer.class, + AllowChangeKeyMetadataEntity.class); + AllowChangeKeyMetadataEntity obj = index.get(99); + checkValues(obj); + + checkValues(store.getSecondaryIndex + (index, Integer.class, "addAnnotation").get(88)); + checkValues(store.getSecondaryIndex + (index, Integer.class, "renamedField").get(44)); + if (updated) { + checkValues(store.getSecondaryIndex + (index, Integer.class, "addField").get(55)); + } else { + TestCase.assertNull(store.getSecondaryIndex + (index, Integer.class, "addField").get(55)); + } + + if (doUpdate) { + ((AllowChangeKeyMetadataInSubclass) obj).addField = 55; + index.put(obj); + updated = true; + checkValues(store.getSecondaryIndex + (index, Integer.class, "addAnnotation").get(88)); + checkValues(store.getSecondaryIndex + (index, Integer.class, "addField").get(55)); + } + } + + @Override + void copyRawObjects(RawStore rawStore, EntityStore newStore) + throws DatabaseException { + + PrimaryIndex + index = newStore.getPrimaryIndex + (Integer.class, + AllowChangeKeyMetadataEntity.class); + RawObject raw = rawStore.getPrimaryIndex(NAME2).get(99); + index.put((AllowChangeKeyMetadataInSubclass) + newStore.getModel().convertRawObject(raw)); + } + + private void checkValues(AllowChangeKeyMetadataEntity objParam) { + AllowChangeKeyMetadataInSubclass obj = + (AllowChangeKeyMetadataInSubclass) objParam; + TestCase.assertNotNull(obj); + TestCase.assertEquals(99, obj.key); + TestCase.assertEquals(88, obj.addAnnotation); + TestCase.assertEquals(66, obj.dropAnnotation); + TestCase.assertEquals(44, obj.renamedField); + TestCase.assertEquals(33, obj.aa); + TestCase.assertEquals(22, obj.ff); + if (updated) { + TestCase.assertEquals(Integer.valueOf(55), obj.addField); + } else { + TestCase.assertNull(obj.addField); + } + } + + @Override + void readRawObjects(RawStore store, + boolean expectEvolved, + boolean expectUpdated) + throws DatabaseException { + + RawObject obj = readRaw + (store, NAME2, 99, NAME, expectEvolved ? 1 : 0, + NAME2, 0, CASECLS, 0); + checkRawFields(obj.getSuper(), "key", 99); + if (expectUpdated) { + checkRawFields(obj, + "addAnnotation", 88, + "dropAnnotation", 66, + "addField", 55, + "renamedField", 44, + "aa", 33, + "ff", 22); + } else if (expectEvolved) { + checkRawFields(obj, + "addAnnotation", 88, + "dropAnnotation", 66, + "renamedField", 44, + "aa", 33, + "ff", 22); + } else { + checkRawFields(obj, + "addAnnotation", 88, + "dropField", 77, + "dropAnnotation", 66, + "toBeRenamedField", 44, + "aa", 33, + "ff", 22); + } + Environment env = store.getEnvironment(); + assertDbExists(expectEvolved, env, NAME2, "addAnnotation"); + assertDbExists(expectEvolved, env, NAME2, "addField"); + assertDbExists(expectEvolved, env, NAME2, "renamedField"); + assertDbExists(!expectEvolved, env, NAME2, "toBeRenamedField"); + assertDbExists(!expectEvolved, env, NAME2, "dropField"); + assertDbExists(!expectEvolved, env, NAME2, "dropAnnotation"); + } + } + + @Entity + static class AllowChangeKeyMetadataEntity + extends EvolveCase { + + @PrimaryKey + int key; + } + + /** + * Special case of adding secondaries that caused + * IndexOutOfBoundsException. [#15524] + */ @Entity(version=1) static class AllowAddSecondary extends EvolveCase { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveClasses.java.original libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveClasses.java.original --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveClasses.java.original 2008-06-03 04:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveClasses.java.original 2009-03-27 17:12:56.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: EvolveClasses.java.original,v 1.16 2008/06/03 04:52:24 mark Exp $ + * $Id: EvolveClasses.java.original,v 1.17.2.1 2009/03/27 17:12:55 mark Exp $ */ package com.sleepycat.persist.test; @@ -2050,6 +2050,34 @@ } } + @Entity + static class ConvertFieldContent_Entity + extends EvolveCase { + + @PrimaryKey + int key; + + String f1; + String f2; + + private void init() { + key = 99; + f1 = "01234"; + f2 = "56789"; + } + + @Override + void writeObjects(EntityStore store) + throws DatabaseException { + + PrimaryIndex + index = store.getPrimaryIndex + (Integer.class, ConvertFieldContent_Entity.class); + init(); + index.put(this); + } + } + @Persistent static class ConvertExample1_Address { String street; @@ -2597,6 +2625,9 @@ @SecondaryKey(relate=ONE_TO_ONE) int dropAnnotation; + @SecondaryKey(relate=ONE_TO_ONE) + int toBeRenamedField; + int ff; private void init() { @@ -2604,6 +2635,7 @@ addAnnotation = 88; dropField = 77; dropAnnotation = 66; + toBeRenamedField = 44; aa = 33; ff = 22; } @@ -2620,6 +2652,56 @@ } } + /** [#16253] */ + @Persistent + static class AllowChangeKeyMetadataInSubclass + extends AllowChangeKeyMetadataEntity { + + int aa; + + int addAnnotation; + + @SecondaryKey(relate=ONE_TO_ONE) + int dropField; + + @SecondaryKey(relate=ONE_TO_ONE) + int dropAnnotation; + + @SecondaryKey(relate=ONE_TO_ONE) + int toBeRenamedField; + + int ff; + + private void init() { + key = 99; + addAnnotation = 88; + dropField = 77; + dropAnnotation = 66; + toBeRenamedField = 44; + aa = 33; + ff = 22; + } + + @Override + void writeObjects(EntityStore store) + throws DatabaseException { + + PrimaryIndex + index = store.getPrimaryIndex + (Integer.class, AllowChangeKeyMetadataEntity.class); + init(); + index.put(this); + } + } + + @Entity + static class AllowChangeKeyMetadataEntity + extends EvolveCase { + + @PrimaryKey + int key; + } + /** [#15524] */ @Entity static class AllowAddSecondary diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveTestBase.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveTestBase.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveTestBase.java 2008-06-03 04:52:24.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveTestBase.java 2009-03-27 17:12:56.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: EvolveTestBase.java,v 1.14 2008/06/03 04:52:24 mark Exp $ + * $Id: EvolveTestBase.java,v 1.15.2.1 2009/03/27 17:12:55 mark Exp $ */ package com.sleepycat.persist.test; @@ -185,6 +185,8 @@ null, "AllowFieldTypeChanges", null, + "ConvertFieldContent_Entity", + null, "ConvertExample1_Entity", null, "ConvertExample2_Person", @@ -215,6 +217,8 @@ null, "AllowChangeKeyMetadata", null, + "AllowChangeKeyMetadataInSubclass", + null, "AllowAddSecondary", null, "FieldAddAndConvert", diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/EvolveTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/EvolveTest.java 2009-03-27 17:12:56.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2000,2008 Oracle. All rights reserved. * - * $Id: EvolveTest.java,v 1.13 2008/02/05 23:28:28 mark Exp $ + * $Id: EvolveTest.java,v 1.13.2.1 2009/03/27 17:12:55 mark Exp $ */ package com.sleepycat.persist.test; @@ -29,6 +29,9 @@ */ public class EvolveTest extends EvolveTestBase { + /* Toggle to use listener every other test case. */ + private static boolean useEvolveListener; + public static Test suite() throws Exception { @@ -141,14 +144,22 @@ } EvolveConfig config = new EvolveConfig(); - config.setEvolveListener(new EvolveListener() { - public boolean evolveProgress(EvolveEvent event) { - EvolveStats stats = event.getStats(); - evolveNRead = stats.getNRead(); - evolveNConverted = stats.getNConverted(); - return true; - } - }); + + /* + * Use listener every other time to ensure that the stats are returned + * correctly when no listener is configured. [#17024] + */ + useEvolveListener = !useEvolveListener; + if (useEvolveListener) { + config.setEvolveListener(new EvolveListener() { + public boolean evolveProgress(EvolveEvent event) { + EvolveStats stats = event.getStats(); + evolveNRead = stats.getNRead(); + evolveNConverted = stats.getNConverted(); + return true; + } + }); + } openEnv(); @@ -166,11 +177,13 @@ if (nExpected > 0) { assertTrue(PersistCatalog.unevolvedFormatsEncountered); } - assertTrue(evolveNRead == nExpected); - assertTrue(evolveNConverted == nExpected); - assertTrue(evolveNConverted >= evolveNRead); - assertEquals(evolveNRead, stats.getNRead()); - assertEquals(evolveNConverted, stats.getNConverted()); + assertTrue(stats.getNRead() == nExpected); + assertTrue(stats.getNConverted() == nExpected); + assertTrue(stats.getNConverted() >= stats.getNRead()); + if (useEvolveListener) { + assertEquals(evolveNRead, stats.getNRead()); + assertEquals(evolveNConverted, stats.getNConverted()); + } /* Evolve again and expect that no entities are converted. */ evolveNRead = 0; @@ -178,10 +191,12 @@ PersistCatalog.unevolvedFormatsEncountered = false; stats = store.evolve(config); assertTrue(!PersistCatalog.unevolvedFormatsEncountered); - assertTrue(evolveNRead == 0); - assertTrue(evolveNConverted == 0); assertEquals(0, stats.getNRead()); assertEquals(0, stats.getNConverted()); + if (useEvolveListener) { + assertTrue(evolveNRead == 0); + assertTrue(evolveNConverted == 0); + } /* Ensure that we can read all entities without evolution. */ PersistCatalog.unevolvedFormatsEncountered = false; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/IndexTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/IndexTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/IndexTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/IndexTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: IndexTest.java,v 1.19 2008/02/05 23:28:28 mark Exp $ + * $Id: IndexTest.java,v 1.19.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/JoinTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/JoinTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/JoinTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/JoinTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: JoinTest.java,v 1.8 2008/02/05 23:28:28 mark Exp $ + * $Id: JoinTest.java,v 1.8.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/NegativeTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/NegativeTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/NegativeTest.java 2008-04-25 15:52:14.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/NegativeTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: NegativeTest.java,v 1.17 2008/04/25 15:52:13 mark Exp $ + * $Id: NegativeTest.java,v 1.19.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; @@ -48,7 +48,7 @@ open(null); } - private void open(Class clsToRegister) + private void open(Class clsToRegister) throws DatabaseException { StoreConfig config = new StoreConfig(); @@ -92,9 +92,7 @@ open(); try { - PrimaryIndex index = - store.getPrimaryIndex - (BadKeyClass1.class, UseBadKeyClass1.class); + store.getPrimaryIndex(BadKeyClass1.class, UseBadKeyClass1.class); fail(); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().indexOf("@KeyField") >= 0); @@ -124,19 +122,14 @@ open(); try { - PrimaryIndex index = - store.getPrimaryIndex - (Boolean.class, BadSequenceKeyEntity1.class); + store.getPrimaryIndex(Boolean.class, BadSequenceKeyEntity1.class); fail(); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().indexOf ("Type not allowed for sequence") >= 0); } try { - PrimaryIndex index = - store.getPrimaryIndex - (BadSequenceKeyEntity2.Key.class, + store.getPrimaryIndex(BadSequenceKeyEntity2.Key.class, BadSequenceKeyEntity2.class); fail(); } catch (IllegalArgumentException expected) { @@ -144,10 +137,7 @@ ("Type not allowed for sequence") >= 0); } try { - PrimaryIndex index = - store.getPrimaryIndex - (BadSequenceKeyEntity3.Key.class, + store.getPrimaryIndex(BadSequenceKeyEntity3.Key.class, BadSequenceKeyEntity3.class); fail(); } catch (IllegalArgumentException expected) { diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/OperationTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/OperationTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/OperationTest.java 2008-05-19 20:33:32.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/OperationTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: OperationTest.java,v 1.22 2008/05/19 20:33:32 mark Exp $ + * $Id: OperationTest.java,v 1.23.2.4 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; @@ -20,6 +20,9 @@ import junit.framework.Test; +/* */ +import com.sleepycat.je.CacheMode; +/* */ import com.sleepycat.je.Database; import com.sleepycat.je.DatabaseConfig; import com.sleepycat.je.DatabaseException; @@ -33,6 +36,8 @@ import com.sleepycat.persist.impl.Store; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.KeyField; +import com.sleepycat.persist.model.NotPersistent; +import com.sleepycat.persist.model.NotTransient; import com.sleepycat.persist.model.Persistent; import com.sleepycat.persist.model.PrimaryKey; import com.sleepycat.persist.model.SecondaryKey; @@ -138,6 +143,43 @@ } /* */ + /* */ + public void testCacheMode() + throws DatabaseException { + + open(); + + PrimaryIndex priIndex = + store.getPrimaryIndex(Integer.class, MyEntity.class); + + Transaction txn = txnBeginCursor(); + + MyEntity e = new MyEntity(); + e.priKey = 1; + e.secKey = 1; + priIndex.put(txn, e); + + EntityCursor entities = priIndex.entities(txn, null); + + assertSame(CacheMode.DEFAULT, entities.getCacheMode()); + e = entities.first(); + assertNotNull(e); + assertSame(CacheMode.DEFAULT, entities.getCacheMode()); + entities.setCacheMode(CacheMode.KEEP_HOT); + assertSame(CacheMode.KEEP_HOT, entities.getCacheMode()); + e = entities.first(); + assertNotNull(e); + assertSame(CacheMode.KEEP_HOT, entities.getCacheMode()); + entities.setCacheMode(CacheMode.UNCHANGED); + entities.update(e); + entities.setCacheMode(CacheMode.UNCHANGED); + + entities.close(); + txnCommit(txn); + close(); + } + /* */ + public void testUninitializedCursor() throws DatabaseException { @@ -1007,4 +1049,71 @@ assertNotNull(x); close(); } + + public void testPersistentFields() + throws DatabaseException { + + open(); + PrimaryIndex pri = + store.getPrimaryIndex(Integer.class, PersistentFields.class); + PersistentFields o1 = new PersistentFields(-1, 1, 2, 3, 4, 5, 6); + assertNull(pri.put(o1)); + PersistentFields o2 = pri.get(-1); + assertNotNull(o2); + assertEquals(0, o2.transient1); + assertEquals(0, o2.transient2); + assertEquals(0, o2.transient3); + assertEquals(4, o2.persistent1); + assertEquals(5, o2.persistent2); + assertEquals(6, o2.persistent3); + close(); + } + + @Entity + static class PersistentFields { + + @PrimaryKey int key; + + transient int transient1; + @NotPersistent int transient2; + @NotPersistent transient int transient3; + + int persistent1; + @NotTransient int persistent2; + @NotTransient transient int persistent3; + + PersistentFields(int k, + int t1, + int t2, + int t3, + int p1, + int p2, + int p3) { + key = k; + transient1 = t1; + transient2 = t2; + transient3 = t3; + persistent1 = p1; + persistent2 = p2; + persistent3 = p3; + } + + private PersistentFields() {} + } + + /** + * When a primary or secondary has a persistent key class, the key class + * was not recognized as being persistent when getPrimaryConfig, + * getSecondaryConfig, or getSubclassIndex was called, if that key class + * was not previously referenced. All three cases are tested by calling + * getSecondaryConfig. This was a bug in JE 3.3.69, reported on OTN. + * [#16407] + */ + public void testKeyClassInitialization() + throws DatabaseException { + + open(); + store.getSecondaryConfig(ToManyKeyEntity.class, "key2"); + close(); + } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/SequenceTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/SequenceTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/SequenceTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/SequenceTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SequenceTest.java,v 1.5 2008/02/05 23:28:28 mark Exp $ + * $Id: SequenceTest.java,v 1.5.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/persist/test/SubclassIndexTest.java libdb-je-java-3.3.98/test/com/sleepycat/persist/test/SubclassIndexTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/persist/test/SubclassIndexTest.java 2008-02-05 23:28:28.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/persist/test/SubclassIndexTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SubclassIndexTest.java,v 1.9 2008/02/05 23:28:28 mark Exp $ + * $Id: SubclassIndexTest.java,v 1.9.2.3 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.persist.test; @@ -34,6 +34,7 @@ private File envHome; private Environment env; + private EntityStore store; public void setUp() throws IOException { @@ -48,20 +49,20 @@ if (env != null) { try { env.close(); - } catch (DatabaseException e) { + } catch (Throwable e) { System.out.println("During tearDown: " + e); } } try { - SharedTestUtils.emptyDir(envHome); - } catch (Error e) { + //SharedTestUtils.emptyDir(envHome); + } catch (Throwable e) { System.out.println("During tearDown: " + e); } envHome = null; env = null; } - public void testSubclassIndex() + private void open() throws IOException, DatabaseException { EnvironmentConfig envConfig = TestEnv.BDB.getConfig(); @@ -70,7 +71,22 @@ StoreConfig storeConfig = new StoreConfig(); storeConfig.setAllowCreate(true); - EntityStore store = new EntityStore(env, "foo", storeConfig); + store = new EntityStore(env, "foo", storeConfig); + } + + private void close() + throws DatabaseException { + + store.close(); + store = null; + env.close(); + env = null; + } + + public void testSubclassIndex() + throws IOException, DatabaseException { + + open(); PrimaryIndex employeesById = store.getPrimaryIndex(String.class, Employee.class); @@ -133,9 +149,50 @@ } catch (IllegalArgumentException expected) { } - store.close(); - env.close(); - env = null; + close(); + } + + public void testAddSecKey() + throws IOException, DatabaseException { + + open(); + PrimaryIndex employeesById = + store.getPrimaryIndex(String.class, Employee.class); + employeesById.put(new Employee("1")); + assertTrue(!hasEntityKey("dept")); + close(); + + open(); + employeesById = store.getPrimaryIndex(String.class, Employee.class); + assertTrue(!hasEntityKey("dept")); + employeesById.put(new Manager("2", "a")); + assertTrue(hasEntityKey("dept")); + close(); + + open(); + assertTrue(hasEntityKey("dept")); + close(); + + open(); + employeesById = store.getPrimaryIndex(String.class, Employee.class); + assertTrue(!hasEntityKey("salary")); + employeesById.put(new SalariedManager("3", "a", "111")); + assertTrue(hasEntityKey("salary")); + close(); + + open(); + assertTrue(hasEntityKey("dept")); + assertTrue(hasEntityKey("salary")); + close(); + } + + private boolean hasEntityKey(String keyName) { + return store.getModel(). + getRawType(Employee.class.getName()). + getEntityMetadata(). + getSecondaryKeys(). + keySet(). + contains(keyName); } @Entity @@ -167,4 +224,18 @@ private Manager() {} } + + @Persistent + private static class SalariedManager extends Manager { + + @SecondaryKey(relate=MANY_TO_ONE) + String salary; + + SalariedManager(String id, String dept, String salary) { + super(id, dept); + this.salary = salary; + } + + private SalariedManager() {} + } } diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/ExceptionWrapperTest.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/ExceptionWrapperTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/ExceptionWrapperTest.java 2008-02-05 23:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/ExceptionWrapperTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ExceptionWrapperTest.java,v 1.18 2008/02/05 23:28:29 mark Exp $ + * $Id: ExceptionWrapperTest.java,v 1.18.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/FastOutputStreamTest.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/FastOutputStreamTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/FastOutputStreamTest.java 2008-02-05 23:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/FastOutputStreamTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: FastOutputStreamTest.java,v 1.7 2008/02/05 23:28:29 mark Exp $ + * $Id: FastOutputStreamTest.java,v 1.7.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/PackedIntegerTest.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/PackedIntegerTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/PackedIntegerTest.java 2008-01-07 14:29:16.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/PackedIntegerTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: PackedIntegerTest.java,v 1.6 2008/01/07 14:29:16 cwl Exp $ + * $Id: PackedIntegerTest.java,v 1.6.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/SharedTestUtils.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/SharedTestUtils.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/SharedTestUtils.java 2008-02-05 23:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/SharedTestUtils.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: SharedTestUtils.java,v 1.1 2008/02/05 23:28:29 mark Exp $ + * $Id: SharedTestUtils.java,v 1.1.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/TestEnv.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/TestEnv.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/TestEnv.java 2008-02-05 23:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/TestEnv.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TestEnv.java,v 1.1 2008/02/05 23:28:29 mark Exp $ + * $Id: TestEnv.java,v 1.1.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/TxnTestCase.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/TxnTestCase.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/TxnTestCase.java 2008-02-05 23:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/TxnTestCase.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: TxnTestCase.java,v 1.1 2008/02/05 23:28:29 mark Exp $ + * $Id: TxnTestCase.java,v 1.1.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/com/sleepycat/util/test/UtfTest.java libdb-je-java-3.3.98/test/com/sleepycat/util/test/UtfTest.java --- libdb-je-java-3.3.62/test/com/sleepycat/util/test/UtfTest.java 2008-02-05 23:28:30.000000000 +0000 +++ libdb-je-java-3.3.98/test/com/sleepycat/util/test/UtfTest.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: UtfTest.java,v 1.21 2008/02/05 23:28:29 mark Exp $ + * $Id: UtfTest.java,v 1.21.2.2 2010/01/04 15:30:49 cwl Exp $ */ package com.sleepycat.util.test; diff -Nru libdb-je-java-3.3.62/test/standalone/BigDW.java libdb-je-java-3.3.98/test/standalone/BigDW.java --- libdb-je-java-3.3.62/test/standalone/BigDW.java 2008-05-30 14:04:24.000000000 +0000 +++ libdb-je-java-3.3.98/test/standalone/BigDW.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: BigDW.java,v 1.4 2008/05/30 14:04:23 mark Exp $ + * $Id: BigDW.java,v 1.4.2.2 2010/01/04 15:30:49 cwl Exp $ */ import java.io.File; diff -Nru libdb-je-java-3.3.62/test/standalone/CleanWithSmallCache.java libdb-je-java-3.3.98/test/standalone/CleanWithSmallCache.java --- libdb-je-java-3.3.62/test/standalone/CleanWithSmallCache.java 2008-01-28 21:17:42.000000000 +0000 +++ libdb-je-java-3.3.98/test/standalone/CleanWithSmallCache.java 2009-07-28 20:32:24.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (c) 2005,2008 Oracle. All rights reserved. * - * $Id: CleanWithSmallCache.java,v 1.3 2008/01/28 21:17:42 linda Exp $ + * $Id: CleanWithSmallCache.java,v 1.3.2.1 2009/07/28 20:32:24 mark Exp $ */ import java.io.File; @@ -35,7 +35,7 @@ * * And then to clean that set of logs: * - * java -Xmx10m -cp .:before.jar CleanWithSmallCache \ + * java -Xmx15m -cp .:before.jar CleanWithSmallCache \ * -records 40000 -key 48 -data 10 -h tmp -random -cache 250k \ * -seconds 22000 -read 10 -clean */ @@ -69,6 +69,12 @@ public static void main(String[] args) { try { + System.out.print("Command line: "); + for (String s : args) { + System.out.print(s); + System.out.print(' '); + } + System.out.println(); CleanWithSmallCache test = new CleanWithSmallCache(args); long start = System.currentTimeMillis(); System.out.println("Opening environment"); @@ -78,8 +84,10 @@ test.close(); long end = System.currentTimeMillis(); System.out.println("Time: " + ((end - start) / 1000) + " sec"); + System.exit(0); } catch (Throwable e) { - e.printStackTrace(System.out); + e.printStackTrace(); + System.exit(1); } } diff -Nru libdb-je-java-3.3.62/test/standalone/ClosedDbEviction.java libdb-je-java-3.3.98/test/standalone/ClosedDbEviction.java --- libdb-je-java-3.3.62/test/standalone/ClosedDbEviction.java 2008-01-17 05:41:40.000000000 +0000 +++ libdb-je-java-3.3.98/test/standalone/ClosedDbEviction.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: ClosedDbEviction.java,v 1.1 2008/01/17 05:41:39 chao Exp $ + * $Id: ClosedDbEviction.java,v 1.2.2.2 2010/01/04 15:30:49 cwl Exp $ */ import java.io.File; @@ -427,7 +427,6 @@ public void run() { try { - int ops = 0; while (runDataAccessThread) { /* Access records to fill up cache. */ DatabaseEntry key = new DatabaseEntry(); diff -Nru libdb-je-java-3.3.62/test/standalone/EnvSharedCache.java libdb-je-java-3.3.98/test/standalone/EnvSharedCache.java --- libdb-je-java-3.3.62/test/standalone/EnvSharedCache.java 2008-01-30 11:12:50.000000000 +0000 +++ libdb-je-java-3.3.98/test/standalone/EnvSharedCache.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: EnvSharedCache.java,v 1.18 2008/01/30 11:12:50 chao Exp $ + * $Id: EnvSharedCache.java,v 1.19.2.2 2010/01/04 15:30:49 cwl Exp $ */ import java.io.File; @@ -674,7 +674,6 @@ byte[] lastInsertKey = null; Transaction txn = null; Cursor c = null; - int retry = 0; int nKeys = 0; OperationStatus status; diff -Nru libdb-je-java-3.3.62/test/standalone/RemoveDbStress.java libdb-je-java-3.3.98/test/standalone/RemoveDbStress.java --- libdb-je-java-3.3.62/test/standalone/RemoveDbStress.java 2008-01-07 14:29:20.000000000 +0000 +++ libdb-je-java-3.3.98/test/standalone/RemoveDbStress.java 2010-01-04 15:30:50.000000000 +0000 @@ -1,9 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2002,2008 Oracle. All rights reserved. + * Copyright (c) 2002,2010 Oracle. All rights reserved. * - * $Id: RemoveDbStress.java,v 1.2 2008/01/07 14:29:20 cwl Exp $ + * $Id: RemoveDbStress.java,v 1.2.2.2 2010/01/04 15:30:50 cwl Exp $ */ import java.io.File;