Recovery.java revision 2362
2362N/A * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 2362N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary sanity test for log sudden-death and recovery 0N/A * @run ignore Requires special hooks in ReliableLog not yet putback. 0N/A/* The ReliableLog uses three filenames and renaming to effect atomic 0N/A * versionFile updates. First, a newVersionFile (an intention list) 0N/A * is written. Next, the current versionFile is renamed to an 0N/A * oldVersionFile (an undo list). Finally, the newVersionFile is 0N/A * renamed to the current versionFile, and the undo list is discarded. 0N/A * If the current version file does not exist on restart, then 0N/A * stability can always be restored by reading the oldVersionFile. 0N/A * This test uses little conditional bombs. When a switch is flipped 0N/A * in ReliableLog, the code will abort with an InternalError at a 0N/A * particular point. We then pretend to have come up from scratch and 0N/A * recover from the bombed situation. 0N/A//import javasoft.sqe.harness.Status; 0N/A//import javasoft.sqe.harness.Test; 0N/A //Status status = test.run (argv, System.err, System.out); 0N/A //public Status run (String argv[], PrintStream log, PrintStream out) 0N/A // Trash the log directory 0N/A // Generate a number of updates (size - 1) until failing 0N/A char[] u =
new char[
1];
0N/A u[
0] = (
char)(
64 + (i %
26));
0N/A throw e;
// oops, not ours 0N/A // deathpoint == 0 means that there is no deathpoint and we are testing 0N/A // undisastered behaviour. 0N/A " this test; test skipped");
0N/A // Now try to recover. 0N/A // Recovered thingy must be equal to writ or to writ + f, but nothing 0N/A // else (or in between). 0N/A +
": rolled back to v1");
0N/A +
": committed to v2");
0N/A //return (Status.failed 0N/A (
"Exception in sanity test for sun.rmi.log.ReliableLog"));
0N/A //return (Status.passed ("OKAY")); 0N/A // implements LogHandler.applyUpdate() 0N/A // basicUpdate appends the string 0N/A // an "update" is a short string to append to this.contents (must ignore state)