File: MakeLogHeaderVersionData.java

package info (click to toggle)
libdb-je-java 3.3.98-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,052 kB
  • sloc: java: 153,077; xml: 2,034; makefile: 3
file content (79 lines) | stat: -rw-r--r-- 2,827 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2002,2010 Oracle.  All rights reserved.
 *
 * $Id: MakeLogHeaderVersionData.java,v 1.10.2.2 2010/01/04 15:30:44 cwl Exp $
 */

package com.sleepycat.je.logversion;

import java.io.File;
import java.util.logging.Level;

import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.Environment;
import com.sleepycat.je.config.EnvironmentParams;
import com.sleepycat.je.util.TestUtils;

/**
 * This standalone command line program creates a single 00000000.jdb log file.
 * It was used to generate maxversion.jdb and minversion.jdb, and although it
 * may never need to be used again, below are instructions.
 *
 * <p>Before running this program change LogEntryType.LOG_VERSION to
 * Integer.MAX_VALUE or zero temporarily, just for creating a file with the
 * maximum or minimum version number.  A single command line argument is
 * required for the home directory.  After running this program rename the
 * 00000000.jdb file to maxversion.jdb or minversion.jdb file in the directory
 * of this source package.  When adding it to CVS make sure to use -kb since it
 * is a binary file.  Don't forget to change LogEntryType.LOG_VERSION back to
 * the correct value.</p>
 *
 * @see LogHeaderVersionTest
 */
public class MakeLogHeaderVersionData {

    private MakeLogHeaderVersionData() {
    }

    public static void main(String[] args)
        throws Exception {

        if (args.length != 1) {
            throw new Exception("Home directory arg is required.");
        }

        File homeDir = new File(args[0]);
        File logFile = new File(homeDir, TestUtils.LOG_FILE_NAME);

        if (logFile.exists()) {
            throw new Exception("Home directory must be empty of log files.");
        }

        EnvironmentConfig envConfig = TestUtils.initEnvConfig();
        envConfig.setAllowCreate(true);
        envConfig.setTransactional(true);
        /* Make as small a log as possible to save space in CVS. */
        envConfig.setConfigParam
            (EnvironmentParams.JE_LOGGING_LEVEL.getName(),
             Level.OFF.getName());
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(), "false");
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");

        Environment env = new Environment(homeDir, envConfig);
        env.close();

        if (!logFile.exists()) {
            throw new Exception("Home directory does not contain: " + logFile);
        }

        System.out.println("Sucessfully created: " + logFile);
    }
}