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; import journal.action.Action; public class ClientWorkspaceReporter implements Action { 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>(); public void commitMarker(JournalEntry entry) { } public void deleteValue(JournalEntry entry) { // ignore } 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); System.out.println(sb.toString()); } } public void flushMarker(JournalEntry entry) { // TODO Auto-generated method stub } 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 = new Date(((Integer) dataEntry.getValue("access")).longValue() * 1000); 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 (clientInfos.containsKey(clientName)) { clientInfos.get(clientName).haveEntries++; } else { 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 (clientInfos.containsKey(client)) { clientInfos.get(client).openFiles++; } else { System.err.println("Severe problem, working points to non-existing workspace " + client); } } } public void replaceValue(JournalEntry entry) { // TODO Auto-generated method stub } public void start() { } public void verifyValue(JournalEntry entry) { // TODO Auto-generated method stub } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 7374 | Sven Erik Knop | Rename/move file(s) - correct location for Eclipse project | ||
#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. |