KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > logversion > MakeLogHeaderVersionData


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: MakeLogHeaderVersionData.java,v 1.7 2006/10/30 21:14:47 bostic Exp $
7  */

8
9 package com.sleepycat.je.logversion;
10
11 import java.io.File JavaDoc;
12 import java.util.logging.Level JavaDoc;
13
14 import com.sleepycat.je.EnvironmentConfig;
15 import com.sleepycat.je.Environment;
16 import com.sleepycat.je.config.EnvironmentParams;
17 import com.sleepycat.je.util.TestUtils;
18
19 /**
20  * This standalone command line program creates a single 00000000.jdb log file.
21  * It was used to generate maxversion.jdb and minversion.jdb, and although it
22  * may never need to be used again, below are instructions.
23  *
24  * <p>Before running this program change FileHeader.LOG_VERSION to
25  * Integer.MAX_VALUE or zero temporarily, just for creating a file with the
26  * maximum or minimum version number. A single command line argument is
27  * required for the home directory. After running this program rename the
28  * 00000000.jdb file to maxversion.jdb or minversion.jdb file in the directory
29  * of this source package. When adding it to CVS make sure to use -kb since it
30  * is a binary file. Don't forget to change FileHeader.LOG_VERSION back to the
31  * correct value.</p>
32  *
33  * @see LogHeaderVersionTest
34  */

35 public class MakeLogHeaderVersionData {
36
37     private MakeLogHeaderVersionData() {
38     }
39
40     public static void main(String JavaDoc[] args)
41         throws Exception JavaDoc {
42
43         if (args.length != 1) {
44             throw new Exception JavaDoc("Home directory arg is required.");
45         }
46
47         File JavaDoc homeDir = new File JavaDoc(args[0]);
48         File JavaDoc logFile = new File JavaDoc(homeDir, TestUtils.LOG_FILE_NAME);
49
50         if (logFile.exists()) {
51             throw new Exception JavaDoc("Home directory must be empty of log files.");
52         }
53
54         EnvironmentConfig envConfig = TestUtils.initEnvConfig();
55         envConfig.setAllowCreate(true);
56         envConfig.setTransactional(true);
57         /* Make as small a log as possible to save space in CVS. */
58         envConfig.setConfigParam
59             (EnvironmentParams.JE_LOGGING_LEVEL.getName(),
60              Level.OFF.getName());
61         envConfig.setConfigParam
62             (EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false");
63         envConfig.setConfigParam
64             (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
65         envConfig.setConfigParam
66             (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");
67         envConfig.setConfigParam
68             (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");
69
70         Environment env = new Environment(homeDir, envConfig);
71         env.close();
72
73         if (!logFile.exists()) {
74             throw new Exception JavaDoc("Home directory does not contain: " + logFile);
75         }
76
77         System.out.println("Sucessfully created: " + logFile);
78     }
79 }
80
Popular Tags