public class LogAnalyser extends Object
| Constructor and Description |
|---|
LogAnalyser() |
| Modifier and Type | Method and Description |
|---|---|
static String[] |
analyseQuery(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 String |
createOutput()
generate the analyser's output to the specified out file
|
static String |
getConfigFile()
get the current config file name
|
static File[] |
getLogFiles(String logDir)
get an array of file objects representing the passed log directory
|
static LogLine |
getLogLine(String line)
split the given line into it's relevant segments if applicable (i.e.
|
static Integer |
getNumItems(Context context)
get the total number of items in the archive at time of execution,
ignoring all other constraints
|
static Integer |
getNumItems(Context context,
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 Integer |
increment(Map<String,Integer> map,
String key)
increment the value of the given map at the given key by one.
|
static void |
main(String[] argv)
main method to be run from command line.
|
static Date |
parseDate(String date)
Take the standard date string requested at the command line and convert
it into a Date object.
|
static String |
processLogs(Context context,
String myLogDir,
String myFileTemplate,
String myConfigFile,
String myOutFile,
Date myStartDate,
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(String configFile)
Read in the given config file and populate the class globals.
|
static void |
setParameters(String myLogDir,
String myFileTemplate,
String myConfigFile,
String myOutFile,
Date myStartDate,
Date myEndDate,
boolean myLookUp)
set the passed parameters up as global class variables.
|
static void |
setRegex(String fileTemplate)
set up the regular expressions to be used by this analyser.
|
static String |
unParseDate(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(String[] argv) throws Exception, SQLException
ExceptionSQLExceptionpublic static String processLogs(Context context, String myLogDir, String myFileTemplate, String myConfigFile, String myOutFile, Date myStartDate, Date myEndDate, boolean myLookUp) throws IOException, SQLException, SearchServiceException
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 databaseIOExceptionSQLExceptionSearchServiceExceptionpublic static void setParameters(String myLogDir, String myFileTemplate, String myConfigFile, String myOutFile, Date myStartDate, 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 String createOutput()
public static File[] getLogFiles(String logDir)
logDir - the log directory in which to pick up filespublic static void setRegex(String fileTemplate)
fileTemplate - the regex to be used to identify dspace log filespublic static String getConfigFile()
public static void readConfig()
throws IOException
IOExceptionpublic static void readConfig(String configFile) throws IOException
configFile - the config file to read inIOExceptionpublic static Integer increment(Map<String,Integer> map, String key)
map - the map whose value we want to increasekey - the key of the map whose value to increasepublic static Date parseDate(String date)
date - the string representation of the datepublic static String unParseDate(Date date)
date - the date to be convertedpublic static String[] analyseQuery(String query)
query - the search query to be analysedpublic static LogLine getLogLine(String line)
line - the line to be segmentedpublic static Integer getNumItems(Context context, String type) throws SQLException, SearchServiceException
context - the DSpace context for the actiontype - value for DC field 'type' (unqualified)SQLExceptionSearchServiceExceptionpublic static Integer getNumItems(Context context) throws SQLException, SearchServiceException
context - the DSpace context the action is being performed inSQLExceptionSearchServiceExceptionpublic static void usage()
Copyright © 2016 DuraSpace. All Rights Reserved.