public class LogAnalyser
extends java.lang.Object
| Constructor and Description |
|---|
LogAnalyser() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String[] |
analyseQuery(java.lang.String query)
Take a search query string and pull out all of the meaningful information
from it, giving the results in the form of a String array, a single word
to each element
|
static void |
createOutput()
generate the analyser's output to the specified out file
|
static java.lang.String |
getConfigFile()
get the current config file name
|
static java.io.File[] |
getLogFiles(java.lang.String logDir)
get an array of file objects representing the passed log directory
|
static LogLine |
getLogLine(java.lang.String line)
split the given line into it's relevant segments if applicable (i.e.
|
static java.lang.Integer |
getNumItems(Context context)
get the total number of items in the archive at time of execution,
ignoring all other constraints
|
static java.lang.Integer |
getNumItems(Context context,
java.lang.String type)
get the number of items in the archive which were accessioned between
the provided start and end dates, with the given value for the DC field
'type' (unqualified)
|
static java.lang.Integer |
increment(java.util.Map<java.lang.String,java.lang.Integer> map,
java.lang.String key)
increment the value of the given map at the given key by one.
|
static void |
main(java.lang.String[] argv)
main method to be run from command line.
|
static java.util.Date |
parseDate(java.lang.String date)
Take the standard date string requested at the command line and convert
it into a Date object.
|
static void |
processLogs(Context context,
java.lang.String myLogDir,
java.lang.String myFileTemplate,
java.lang.String myConfigFile,
java.lang.String myOutFile,
java.util.Date myStartDate,
java.util.Date myEndDate,
boolean myLookUp)
using the pre-configuration information passed here, analyse the logs
and produce the aggregation file
|
static void |
readConfig()
Read in the current config file and populate the class globals.
|
static void |
readConfig(java.lang.String configFile)
Read in the given config file and populate the class globals.
|
static void |
setParameters(java.lang.String myLogDir,
java.lang.String myFileTemplate,
java.lang.String myConfigFile,
java.lang.String myOutFile,
java.util.Date myStartDate,
java.util.Date myEndDate,
boolean myLookUp)
set the passed parameters up as global class variables.
|
static void |
setRegex(java.lang.String fileTemplate)
set up the regular expressions to be used by this analyser.
|
static java.lang.String |
unParseDate(java.util.Date date)
Take the date object and convert it into a string of the form YYYY-MM-DD
|
static void |
usage()
print out the usage information for this class to the standard out
|
public static void main(java.lang.String[] argv)
throws java.lang.Exception,
java.sql.SQLException
java.lang.Exceptionjava.sql.SQLExceptionpublic static void processLogs(Context context, java.lang.String myLogDir, java.lang.String myFileTemplate, java.lang.String myConfigFile, java.lang.String myOutFile, java.util.Date myStartDate, java.util.Date myEndDate, boolean myLookUp) throws java.io.IOException, java.sql.SQLException
context - the DSpace context object this occurs undermyLogDir - the passed log directory. Uses default if nullmyFileTemplate - the passed file name regex. Uses default if nullmyConfigFile - the DStat config file. Uses default if nullmyOutFile - the file to which to output aggregation data. Uses default if nullmyStartDate - the desired start of the analysis. Starts from the beginning otherwisemyEndDate - the desired end of the analysis. Goes to the end otherwisemyLookUp - force a lookup of the databasejava.io.IOExceptionjava.sql.SQLExceptionpublic static void setParameters(java.lang.String myLogDir,
java.lang.String myFileTemplate,
java.lang.String myConfigFile,
java.lang.String myOutFile,
java.util.Date myStartDate,
java.util.Date myEndDate,
boolean myLookUp)
myLogDir - the log file directory to be analysedmyFileTemplate - regex for log file namesmyConfigFile - config file to use for dstatmyOutFile - file to write the aggregation intomyStartDate - requested log reporting start datemyEndDate - requested log reporting end datemyLookUp - requested look up force flagpublic static void createOutput()
public static java.io.File[] getLogFiles(java.lang.String logDir)
logDir - the log directory in which to pick up filespublic static void setRegex(java.lang.String fileTemplate)
fileTemplate - the regex to be used to identify dspace log filespublic static java.lang.String getConfigFile()
public static void readConfig()
throws java.io.IOException
java.io.IOExceptionpublic static void readConfig(java.lang.String configFile)
throws java.io.IOException
configFile - the config file to read injava.io.IOExceptionpublic static java.lang.Integer increment(java.util.Map<java.lang.String,java.lang.Integer> map,
java.lang.String key)
map - the map whose value we want to increasekey - the key of the map whose value to increasepublic static java.util.Date parseDate(java.lang.String date)
date - the string representation of the datepublic static java.lang.String unParseDate(java.util.Date date)
date - the date to be convertedpublic static java.lang.String[] analyseQuery(java.lang.String query)
query - the search query to be analysedpublic static LogLine getLogLine(java.lang.String line)
line - the line to be segmentedpublic static java.lang.Integer getNumItems(Context context, java.lang.String type) throws java.sql.SQLException
context - the DSpace context for the actiontype - value for DC field 'type' (unqualified)java.sql.SQLExceptionpublic static java.lang.Integer getNumItems(Context context) throws java.sql.SQLException
context - the DSpace context the action is being performed injava.sql.SQLExceptionpublic static void usage()
Copyright © 2013 DuraSpace. All Rights Reserved.