package journal.action; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import journal.reader.DataJournalEntry; import journal.reader.JournalEntry; public class JournalSplitter extends BaseAction { private String base; private String fileName = null; private String currentTable = null; public JournalSplitter(String base) { this.base = base; } public JournalSplitter() { this.base = "."; } private void checkFile(DataJournalEntry entry) { if (fileName == null) { createFile(entry); } else if ( ! currentTable.equals( entry.getTableName() ) ) { closeFile(); } } private void createFile(DataJournalEntry entry) { try { currentTable = entry.getTableName(); fileName = base + File.separatorChar + currentTable + ".ckp"; System.err.println("Next file : " + fileName); out = new PrintStream( new FileOutputStream( fileName ) ); } catch( FileNotFoundException e) { System.err.println("File not found, probably fileName illegal " + fileName); e.printStackTrace(System.err); System.exit(1); } } private void closeFile() { out.close(); currentTable = null; fileName = null; } public void finish() throws Exception { super.finish(); if (fileName != null) { // should not happen - unless the last commit is missing closeFile(); } } public void putValue(JournalEntry entry) throws Exception{ checkFile((DataJournalEntry) entry); super.putValue(entry); } public void replaceValue(JournalEntry entry) { warnCheckpointOnly(); } public void deleteValue(JournalEntry entry) { warnCheckpointOnly(); } public void verifyValue(JournalEntry entry) { warnCheckpointOnly(); } private void warnCheckpointOnly() { System.err.println("Splitting only makes sense for checkpoint files. Sorry ..."); System.exit(1); } public void commitMarker(JournalEntry entry) throws Exception { // this comes first to write the entry // need to write the commit marker to the file before // closing it super.commitMarker(entry); closeFile(); } public void flushMarker(JournalEntry entry) throws Exception { super.flushMarker(entry); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 7529 | Sven Erik Knop |
Deleted the whole JournalReader. It has actually moved to //guest/sven_erik_knop/java/JournalReader/. |
||
#3 | 7427 | Sven Erik Knop |
Major update of the JournalReader: - New help (usage) system, which explains all options - Config file that allows storing of parameters in a file. These are necessary for the SQLLoader and Updater, because classpath, classname and connection parameters need to be set. (see the example *.cfg files provided) - Now tested with MySQL, SQLite and Oracle 10 XE |
||
#2 | 7375 | Sven Erik Knop |
Major update of the JournalReader. Complete rewrite of the command line parsing Change in the options parsing within the journal reader New SQLLoader action. Currently only against MySQL (needs MySQL JDBC driver) with fixed database and user name. This will be replaced by a config file at some stage. |
||
#1 | 7374 | Sven Erik Knop | Rename/move file(s) - correct location for Eclipse project | ||
//guest/sven_erik_knop/JournalReader/journal/action/JournalSplitter.java | |||||
#1 | 6467 | Sven Erik Knop |
Added JournalReader, a Java library of useful tools to read and process checkpoints and journals. Added are a readme.txt to explain some details, and a jar file that contains the compiled class files. The programs will need Java 1.6 to run. |