Source Code Cross Referenced for DbPrintLog.java in  » JMX » je » com » sleepycat » je » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.je.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: DbPrintLog.java,v 1.39.2.6 2008/01/07 15:14:17 cwl Exp $
007:         */
008:
009:        package com.sleepycat.je.util;
010:
011:        import java.io.File;
012:        import java.io.IOException;
013:
014:        import com.sleepycat.je.DatabaseException;
015:        import com.sleepycat.je.config.EnvironmentParams;
016:        import com.sleepycat.je.dbi.EnvironmentImpl;
017:        import com.sleepycat.je.log.DumpFileReader;
018:        import com.sleepycat.je.log.FileManager;
019:        import com.sleepycat.je.log.PrintFileReader;
020:        import com.sleepycat.je.log.StatsFileReader;
021:        import com.sleepycat.je.tree.Key;
022:        import com.sleepycat.je.tree.Key.DumpType;
023:        import com.sleepycat.je.utilint.CmdUtil;
024:        import com.sleepycat.je.utilint.DbLsn;
025:
026:        /**
027:         * DbPrintLog is a debugging utility that dumps JE log files into a human
028:         * readable form.
029:         */
030:        public class DbPrintLog {
031:
032:            /**
033:             * Dump a JE log into human readable form.
034:             */
035:            private void dump(File envHome, String entryTypes, String txnIds,
036:                    long startLsn, long endLsn, boolean verbose, boolean stats)
037:                    throws IOException, DatabaseException {
038:
039:                EnvironmentImpl env = CmdUtil.makeUtilityEnvironment(envHome,
040:                        true);
041:                FileManager fileManager = env.getFileManager();
042:                fileManager.setIncludeDeletedFiles(true);
043:                int readBufferSize = env.getConfigManager().getInt(
044:                        EnvironmentParams.LOG_ITERATOR_READ_SIZE);
045:
046:                /* Make a reader. */
047:                DumpFileReader reader = null;
048:                if (stats) {
049:                    reader = new StatsFileReader(env, readBufferSize, startLsn,
050:                            endLsn, entryTypes, txnIds, verbose);
051:                } else {
052:                    reader = new PrintFileReader(env, readBufferSize, startLsn,
053:                            endLsn, entryTypes, txnIds, verbose);
054:                }
055:
056:                /* Enclose the output in a tag to keep proper XML syntax. */
057:                System.out.println("<DbPrintLog>");
058:                while (reader.readNextEntry()) {
059:                }
060:                reader.summarize();
061:                System.out.println("</DbPrintLog>");
062:                env.close();
063:            }
064:
065:            /**
066:             * Main
067:             */
068:            public static void main(String[] argv) {
069:                try {
070:                    int whichArg = 0;
071:                    String entryTypes = null;
072:                    String txnIds = null;
073:                    long startLsn = DbLsn.NULL_LSN;
074:                    long endLsn = DbLsn.NULL_LSN;
075:                    boolean verbose = true;
076:                    boolean stats = false;
077:
078:                    /* Default to looking in current directory. */
079:                    File envHome = new File(".");
080:                    Key.DUMP_TYPE = DumpType.BINARY;
081:
082:                    while (whichArg < argv.length) {
083:                        String nextArg = argv[whichArg];
084:                        if (nextArg.equals("-h")) {
085:                            whichArg++;
086:                            envHome = new File(CmdUtil.getArg(argv, whichArg));
087:                        } else if (nextArg.equals("-ty")) {
088:                            whichArg++;
089:                            entryTypes = CmdUtil.getArg(argv, whichArg);
090:                        } else if (nextArg.equals("-tx")) {
091:                            whichArg++;
092:                            txnIds = CmdUtil.getArg(argv, whichArg);
093:                        } else if (nextArg.equals("-s")) {
094:                            whichArg++;
095:                            String arg = CmdUtil.getArg(argv, whichArg);
096:                            int slashOff = arg.indexOf("/");
097:                            if (slashOff < 0) {
098:                                long startFileNum = CmdUtil.readLongNumber(arg);
099:                                startLsn = DbLsn.makeLsn(startFileNum, 0);
100:                            } else {
101:                                long startFileNum = CmdUtil.readLongNumber(arg
102:                                        .substring(0, slashOff));
103:                                long startOffset = CmdUtil.readLongNumber(arg
104:                                        .substring(slashOff + 1));
105:                                startLsn = DbLsn.makeLsn(startFileNum,
106:                                        startOffset);
107:                            }
108:                        } else if (nextArg.equals("-e")) {
109:                            whichArg++;
110:                            String arg = CmdUtil.getArg(argv, whichArg);
111:                            int slashOff = arg.indexOf("/");
112:                            if (slashOff < 0) {
113:                                long endFileNum = CmdUtil.readLongNumber(arg);
114:                                endLsn = DbLsn.makeLsn(endFileNum, 0);
115:                            } else {
116:                                long endFileNum = CmdUtil.readLongNumber(arg
117:                                        .substring(0, slashOff));
118:                                long endOffset = CmdUtil.readLongNumber(arg
119:                                        .substring(slashOff + 1));
120:                                endLsn = DbLsn.makeLsn(endFileNum, endOffset);
121:                            }
122:                        } else if (nextArg.equals("-k")) {
123:                            whichArg++;
124:                            String dumpType = CmdUtil.getArg(argv, whichArg);
125:                            if (dumpType.equalsIgnoreCase("text")) {
126:                                Key.DUMP_TYPE = DumpType.TEXT;
127:                            } else if (dumpType.equalsIgnoreCase("hex")) {
128:                                Key.DUMP_TYPE = DumpType.HEX;
129:                            } else if (dumpType.equalsIgnoreCase("binary")) {
130:                                Key.DUMP_TYPE = DumpType.BINARY;
131:                            } else if (dumpType.equalsIgnoreCase("obfuscate")) {
132:                                Key.DUMP_TYPE = DumpType.OBFUSCATE;
133:                            } else if (dumpType.equalsIgnoreCase("none")) {
134:                                Key.DUMP_TYPE = DumpType.NONE;
135:                            } else {
136:                                System.err
137:                                        .println(dumpType
138:                                                + " is not a supported dump format type.");
139:                            }
140:                        } else if (nextArg.equals("-q")) {
141:                            whichArg++;
142:                            verbose = false;
143:                        } else if (nextArg.equals("-S")) {
144:                            whichArg++;
145:                            stats = true;
146:                        } else {
147:                            System.err.println(nextArg
148:                                    + " is not a supported option.");
149:                            usage();
150:                            System.exit(-1);
151:                        }
152:                        whichArg++;
153:                    }
154:
155:                    DbPrintLog printer = new DbPrintLog();
156:                    printer.dump(envHome, entryTypes, txnIds, startLsn, endLsn,
157:                            verbose, stats);
158:
159:                } catch (Throwable e) {
160:                    e.printStackTrace();
161:                    System.out.println(e.getMessage());
162:                    usage();
163:                    System.exit(1);
164:                }
165:            }
166:
167:            private static void usage() {
168:                System.out.println("Usage: "
169:                        + CmdUtil.getJavaCommand(DbPrintLog.class));
170:                System.out.println(" -h  <envHomeDir>");
171:                System.out.println(" -e  <end file number or LSN, in hex>");
172:                System.out.println(" -k  <binary|text|hex|obfuscate|none> "
173:                        + "(format for dumping the key)");
174:                System.out.println(" -s  <start file number or LSN, in hex>");
175:                System.out.println(" -tx <targetted txn ids, comma separated>");
176:                System.out
177:                        .println(" -ty <targetted entry types, comma separated>");
178:                System.out.println(" -S  show Summary of log entries");
179:                System.out
180:                        .println(" -q  if specified, concise version is printed");
181:                System.out.println("     Default is verbose version.)");
182:                System.out.println("All arguments are optional");
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.