|
IBM WebSphere Application ServerTM Release 8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.websphere.logging.hpel.reader.MergedRepository
public class MergedRepository
Helper class to merge separate RepositoryLogRecord
collections together.
For merging it uses record's timestamp retrieved via RepositoryLogRecordHeader.getMillis()
method to put records in ascending order in the output. It assumes that records in input streams
have already been sorted into ascending order.
For example, to merge log records from the recent run of servers storing their
log records in repositories the following
code can be used:
A similar sample, but merging the logs of a z/OS controller with all of the associated servants:
// One argument per repository base, each will be merged. Example of arg0: /opt/IBM/WasX/profiles/AppSrv01/logs/server1
public static void main(String[] args) {
ServerInstanceLogRecordList [] silrlArray = new ServerInstanceLogRecordList[args.length] ;
for (int i = 0; i < args.length; i++) {
// Create a repository reader (requires base directory of repository
RepositoryReader logRepository = new RepositoryReaderImpl(args[i]) ;
// Pull from just the current instance of the server for merging on appropriate times
// Could pull from all or use filter criteria that would select several, this is for simplicity
silrlArray[i] = logRepository.getLogListForCurrentServerInstance() ;
}
MergedRepository result = new MergedRepository(silrlArray) ; // Merge the current serverInstance from each server
for (RepositoryLogRecord repositoryLogRecord : result) { // For each record in new merged set
String pid = result.getHeader(repositoryLogRecord).getProperty(ServerInstanceLogRecordList.HEADER_PROCESSID) ;
// Just printing some key information here. Note that the repositoryRecord exposes all fields
// with simple get methods and gives access to the header information associated with each as well
System.out.println("Pid: "+pid+" Rec: "+repositoryLogRecord.getFormattedMessage());
}
}
public static void main(String[] args) {
// The string arg here is just to the directory where the log files reside (ie: <profileHome>/logs/server1)
RepositoryReader logRepository = new RepositoryReaderImpl(args[0]) ;
// Get iterator of server instances (start/stop of the server) extracting all log messages with
// severity between INFO and SEVERE. Lots of different filtering options, this is just one sample
Iterable<ServerInstanceLogRecordList> repResults = logRepository.getLogLists(Level.INFO, Level.SEVERE) ;
// Go through each server instance
for (ServerInstanceLogRecordList silrl: repResults) { // For each list (server lifeCycle)
Map <String, ServerInstanceLogRecordList> servantMap = silrl.getChildren() ;
Iterator <String> servantKeys = servantMap.keySet().iterator() ;
// Array of lists will be one for each servant + 1 for the controller
ServerInstanceLogRecordList [] silrlArray = new ServerInstanceLogRecordList[servantMap.size()+1] ;
int curIdx = 0 ; // Which index into the array of record lists
silrlArray[curIdx++] = silrl ;
while (servantKeys.hasNext()) {
String label = servantKeys.next() ;
silrlArray[curIdx++] = servantMap.get(label) ;
}
System.out.println("\n\n\nPrinting results for a serverInstance\n");
MergedRepository result = new MergedRepository(silrlArray) ; // Merge this controller with all servants
for (RepositoryLogRecord repositoryLogRecord : result) { // For each record in new merged set
String pid = result.getHeader(repositoryLogRecord).getProperty(ServerInstanceLogRecordList.HEADER_PROCESSID) ;
// Just printing some key information here. Note that the repositoryRecord exposes all fields
// with simple get methods and gives access to the header information associated with each as well
System.out.println(pid+" "+repositoryLogRecord.getFormattedMessage());
}
}
}
Constructor Summary | |
---|---|
MergedRepository(java.lang.Iterable<ServerInstanceLogRecordList> servers)
Creates new iterable instance from the list of results obtained from different servers. |
|
MergedRepository(ServerInstanceLogRecordList[] servers)
Creates new iterable instance from the list of results obtained from different servers. |
Method Summary | |
---|---|
java.util.Properties |
getHeader(RepositoryLogRecord record)
Returns header information for the server this record was created on. |
java.util.Iterator<RepositoryLogRecord> |
iterator()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MergedRepository(java.lang.Iterable<ServerInstanceLogRecordList> servers)
servers
- list of log record lists from different servers.public MergedRepository(ServerInstanceLogRecordList[] servers)
servers
- array of log record lists from different servers.Method Detail |
---|
public java.util.Properties getHeader(RepositoryLogRecord record)
record
- instance previously return by an iterator over this merged list.
record
.public java.util.Iterator<RepositoryLogRecord> iterator()
iterator
in interface java.lang.Iterable<RepositoryLogRecord>
|
IBM WebSphere Application ServerTM Release 8 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |