package journal.action; import java.util.Date; import java.util.Formatter; import java.util.HashMap; import java.util.Map; import journal.reader.DataJournalEntry; import journal.reader.JournalEntry; public class ClientWorkspaceReporter extends BaseAction { static class ClientInfo { public ClientInfo(String name, Date lastAccessed) { this.name = name; this.lastAccessed = lastAccessed; this.haveEntries = 0; this.openFiles = 0; } String name; Date lastAccessed; int haveEntries; int openFiles; } private Map<String, ClientInfo> clientInfos = new HashMap<String, ClientInfo>(); @Override public void finish() { for (Map.Entry<String, ClientInfo> entry : clientInfos.entrySet()) { ClientInfo info = entry.getValue(); StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb); long deltaDays = ((new Date()).getTime() - info.lastAccessed.getTime()) / (24 * 3600 * 1000); formatter.format("%-32s\tlast accessed = %TD (%d days ago)\thave = %d\topened = %d", info.name, info.lastAccessed, deltaDays, info.haveEntries, info.openFiles); out.println(sb.toString()); } out.println("\nErrors encountered: ****"); out.println("\tHave Errors : " + haveErrors); out.println("\tWorking Errors : " + workingErrors); } @Override public void putValue(JournalEntry entry) { DataJournalEntry dataEntry = (DataJournalEntry) entry; if (dataEntry.getTableName().equals("db.domain")) { String name = (String) dataEntry.getValue("name"); int type = (Integer) dataEntry.getValue("type"); Date access = (Date) dataEntry.getValue("access"); if (options.caseInsensitive) { name = name.toLowerCase(); } if (type == 99) { // found a client workspace ClientInfo info = new ClientInfo(name, access); clientInfos.put(name, info); } } else if (dataEntry.getTableName().equals("db.have")) { String cfile = (String) dataEntry.getValue("cfile"); int slash = cfile.indexOf('/', 2); // find the first slash separating client name and path String clientName = cfile.substring(2, slash); if (options.caseInsensitive) { clientName = clientName.toLowerCase(); } if (clientInfos.containsKey(clientName)) { clientInfos.get(clientName).haveEntries++; } else { options.errorStream.println(entry.toJournalString()); haveErrors++; // ignore errors for this run // System.err.println("Severe problem, have points to non-existing workspace " + clientName); } } else if (dataEntry.getTableName().equals("db.working")) { String client = (String) dataEntry.getValue("client"); if (options.caseInsensitive) { client = client.toLowerCase(); } if (clientInfos.containsKey(client)) { clientInfos.get(client).openFiles++; } else { options.errorStream.println(entry.toJournalString()); workingErrors++; // System.err.println("Severe problem, working points to non-existing workspace " + client); } } } private int haveErrors = 0; private int workingErrors = 0; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 7529 | Sven Erik Knop |
Deleted the whole JournalReader. It has actually moved to //guest/sven_erik_knop/java/JournalReader/. |
||
#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/ClientWorkspaceReporter.java | |||||
#2 | 7117 | Sven Erik Knop |
Added HighAsciiFinderAction, an action that displays all journal/checkpoint entries that contain high ascii characters in any of their text fields. Small adjustment in journal.schema.TableVersion to provide an iterator for all attributes: for (Attribute attr : tableVersion) |
||
#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. |