mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-23 18:05:32 +00:00
Moved the verbose option onto the individual thread declarations e.g.
session.name=TEST session.folderProfile=1, 10, 10, 10, 10, 10 session.rmiUrls=rmi://localhost:50500/ session.sourceDir=c:/temp session.storeIdentifiers=TEST-01, TEST-02, TEST-03, TEST-04, TEST-05 test.load.upload.fast=2, 0, 10000, 6, true test.load.totals.basic=1, 15000, 0, 0, true Neatened up the output to be fixed width. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6814 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
9d40827835
commit
989a9b0a50
@ -44,6 +44,7 @@ public abstract class AbstractLoaderThread extends Thread
|
|||||||
protected final long testPeriod;
|
protected final long testPeriod;
|
||||||
protected final long testTotal;
|
protected final long testTotal;
|
||||||
protected final long testLoadDepth;
|
protected final long testLoadDepth;
|
||||||
|
protected final boolean verbose;
|
||||||
|
|
||||||
private AtomicBoolean mustStop;
|
private AtomicBoolean mustStop;
|
||||||
private Random random;
|
private Random random;
|
||||||
@ -51,14 +52,14 @@ public abstract class AbstractLoaderThread extends Thread
|
|||||||
// Statistics
|
// Statistics
|
||||||
private int statCount;
|
private int statCount;
|
||||||
private double statTotalMs;
|
private double statTotalMs;
|
||||||
private double statAverageMs;
|
|
||||||
|
|
||||||
public AbstractLoaderThread(
|
public AbstractLoaderThread(
|
||||||
LoaderSession session,
|
LoaderSession session,
|
||||||
String loaderName,
|
String loaderName,
|
||||||
long testPeriod,
|
long testPeriod,
|
||||||
long testTotal,
|
long testTotal,
|
||||||
long testLoadDepth)
|
long testLoadDepth,
|
||||||
|
boolean verbose)
|
||||||
{
|
{
|
||||||
super(LoaderSession.THREAD_GROUP, "LoaderThread-" + loaderName);
|
super(LoaderSession.THREAD_GROUP, "LoaderThread-" + loaderName);
|
||||||
|
|
||||||
@ -67,13 +68,13 @@ public abstract class AbstractLoaderThread extends Thread
|
|||||||
this.testPeriod = testPeriod;
|
this.testPeriod = testPeriod;
|
||||||
this.testTotal = testTotal < 1 ? Integer.MAX_VALUE : testTotal;
|
this.testTotal = testTotal < 1 ? Integer.MAX_VALUE : testTotal;
|
||||||
this.testLoadDepth = testLoadDepth;
|
this.testLoadDepth = testLoadDepth;
|
||||||
|
this.verbose = verbose;
|
||||||
|
|
||||||
this.mustStop = new AtomicBoolean(false);
|
this.mustStop = new AtomicBoolean(false);
|
||||||
this.random = new Random();
|
this.random = new Random();
|
||||||
|
|
||||||
this.statCount = 0;
|
this.statCount = 0;
|
||||||
this.statTotalMs = 0.0D;
|
this.statTotalMs = 0.0D;
|
||||||
this.statAverageMs = 0.0D;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,23 +85,6 @@ public abstract class AbstractLoaderThread extends Thread
|
|||||||
mustStop.set(true);
|
mustStop.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* name, average,
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @return Returns the summary of the results, in the same format as the verbose output
|
|
||||||
*/
|
|
||||||
public String getSummary()
|
|
||||||
{
|
|
||||||
// Summarize the results
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(loaderName).append("\t")
|
|
||||||
.append(String.format("%5.1f", statAverageMs)).append("\t")
|
|
||||||
.append("");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
@ -161,18 +145,54 @@ public abstract class AbstractLoaderThread extends Thread
|
|||||||
double delta = ((double)(endTime - startTime) / 1000.0 / 1000.0);
|
double delta = ((double)(endTime - startTime) / 1000.0 / 1000.0);
|
||||||
// Now recalculate the average
|
// Now recalculate the average
|
||||||
statTotalMs += delta;
|
statTotalMs += delta;
|
||||||
statAverageMs = (statTotalMs / (double)statCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* NAME+36\tCOUNT \tTIME \tAVERAGE TIME \tPER SECOND \tDESCRIPTION
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
private void logVerbose(long startTime, long endTime, String msg)
|
private void logVerbose(long startTime, long endTime, String msg)
|
||||||
{
|
{
|
||||||
double delta = ((double)(endTime - startTime) / 1000.0 / 1000.0 );
|
double delta = ((double)(endTime - startTime) / 1000.0 / 1000.0 / 1000.0);
|
||||||
|
|
||||||
|
double statTotalSec = statTotalMs / 1000.0;
|
||||||
|
double statPerSec = statCount / statTotalSec;
|
||||||
|
double statAveSec = statTotalSec / statCount;
|
||||||
|
// Summarize the results
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(loaderName).append("\t")
|
sb
|
||||||
.append(String.format("%5.1f", delta)).append("\t")
|
.append(String.format("%40s", loaderName)).append("\t")
|
||||||
.append(msg);
|
.append(String.format("%15.0f", (float)statCount)).append("\t")
|
||||||
session.logVerbose(sb.toString());
|
.append(String.format("%15.3f", delta)).append("\t")
|
||||||
|
.append(String.format("%15.3f", statPerSec)).append("\t")
|
||||||
|
.append(String.format("%15.3f", statAveSec)).append("\t")
|
||||||
|
.append(msg);
|
||||||
|
session.logVerbose(sb.toString(), verbose);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* NAME+36\tCOUNT \tTOTAL TIME \tAVERAGE TIME \tPER SECOND \tDESCRIPTION
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @return Returns the summary of the results
|
||||||
|
*/
|
||||||
|
public String getSummary()
|
||||||
|
{
|
||||||
|
double statTotalSec = statTotalMs / 1000.0;
|
||||||
|
double statPerSec = statCount / statTotalSec;
|
||||||
|
double statAveSec = statTotalSec / statCount;
|
||||||
|
// Summarize the results
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb
|
||||||
|
.append(String.format("%40s", loaderName)).append("\t")
|
||||||
|
.append(String.format("%15.0f", (float)statCount)).append("\t")
|
||||||
|
.append(String.format("%15.3f", statTotalSec)).append("\t")
|
||||||
|
.append(String.format("%15.3f", statPerSec)).append("\t")
|
||||||
|
.append(String.format("%15.3f", statAveSec)).append("\t")
|
||||||
|
.append("");
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,17 +77,24 @@ public class FileFolderRemoteLoader
|
|||||||
|
|
||||||
// Log the initial summaries
|
// Log the initial summaries
|
||||||
String summary = session.getSummary();
|
String summary = session.getSummary();
|
||||||
session.logVerbose(summary);
|
session.logVerbose(summary, true);
|
||||||
session.logSummary(summary);
|
session.logSummary(summary);
|
||||||
session.logError(summary);
|
session.logError(summary);
|
||||||
|
|
||||||
// Header the outputs
|
// Header the outputs
|
||||||
|
session.logVerbose(LoaderSession.getLineEnding(), true);
|
||||||
|
session.logVerbose(COLUMNS_VERBOSE, true);
|
||||||
session.logSummary(LoaderSession.getLineEnding());
|
session.logSummary(LoaderSession.getLineEnding());
|
||||||
session.logSummary("NAME\tTIME\tDESCRIPTION");
|
session.logSummary(COLUMNS_SUMMARY);
|
||||||
session.logVerbose(LoaderSession.getLineEnding());
|
|
||||||
session.logVerbose("NAME\tTIME\tDESCRIPTION");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String COLUMNS_VERBOSE =
|
||||||
|
String.format("%40s\t%15s\t%15s\t%15s\t%15s\t%15s",
|
||||||
|
"NAME", "COUNT", "TIME", "AVERAGE TIME", "PER SECOND", "DESCRIPTION");
|
||||||
|
private static final String COLUMNS_SUMMARY =
|
||||||
|
String.format("%40s\t%15s\t%15s\t%15s\t%15s\t%15s",
|
||||||
|
"NAME", "COUNT", "TOTAL TIME", "AVERAGE TIME", "PER SECOND", "DESCRIPTION");
|
||||||
|
|
||||||
public synchronized void start()
|
public synchronized void start()
|
||||||
{
|
{
|
||||||
if (session == null || threads == null)
|
if (session == null || threads == null)
|
||||||
@ -134,6 +141,7 @@ public class FileFolderRemoteLoader
|
|||||||
public void dumpThreadSummaries()
|
public void dumpThreadSummaries()
|
||||||
{
|
{
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
|
System.out.println(COLUMNS_SUMMARY);
|
||||||
// Dump each thread's summary
|
// Dump each thread's summary
|
||||||
for (AbstractLoaderThread thread : threads)
|
for (AbstractLoaderThread thread : threads)
|
||||||
{
|
{
|
||||||
@ -143,7 +151,6 @@ public class FileFolderRemoteLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String PROP_SESSION_NAME = "session.name";
|
public static final String PROP_SESSION_NAME = "session.name";
|
||||||
public static final String PROP_SESSION_VERBOSE = "session.verbose";
|
|
||||||
public static final String PROP_SESSION_SOURCE_DIR = "session.sourceDir";
|
public static final String PROP_SESSION_SOURCE_DIR = "session.sourceDir";
|
||||||
public static final String PROP_SESSION_STORE_IDENTIFIERS = "session.storeIdentifiers";
|
public static final String PROP_SESSION_STORE_IDENTIFIERS = "session.storeIdentifiers";
|
||||||
public static final String PROP_SESSION_RMI_URLS = "session.rmiUrls";
|
public static final String PROP_SESSION_RMI_URLS = "session.rmiUrls";
|
||||||
@ -158,10 +165,6 @@ public class FileFolderRemoteLoader
|
|||||||
String name = properties.getProperty(PROP_SESSION_NAME);
|
String name = properties.getProperty(PROP_SESSION_NAME);
|
||||||
FileFolderRemoteLoader.checkProperty(PROP_SESSION_STORE_IDENTIFIERS, name);
|
FileFolderRemoteLoader.checkProperty(PROP_SESSION_STORE_IDENTIFIERS, name);
|
||||||
|
|
||||||
// Verbose
|
|
||||||
String verboseStr = properties.getProperty(PROP_SESSION_VERBOSE);
|
|
||||||
boolean verbose = verboseStr == null ? false : Boolean.parseBoolean(verboseStr);
|
|
||||||
|
|
||||||
// Source files
|
// Source files
|
||||||
String sourceDirStr = properties.getProperty(PROP_SESSION_SOURCE_DIR);
|
String sourceDirStr = properties.getProperty(PROP_SESSION_SOURCE_DIR);
|
||||||
File sourceDir = new File(sourceDirStr);
|
File sourceDir = new File(sourceDirStr);
|
||||||
@ -222,7 +225,6 @@ public class FileFolderRemoteLoader
|
|||||||
name,
|
name,
|
||||||
rmiUrls,
|
rmiUrls,
|
||||||
storeRefs,
|
storeRefs,
|
||||||
verbose,
|
|
||||||
sourceDir,
|
sourceDir,
|
||||||
folderProfiles);
|
folderProfiles);
|
||||||
|
|
||||||
@ -263,23 +265,41 @@ public class FileFolderRemoteLoader
|
|||||||
String valuesStr = properties.getProperty(propertyName);
|
String valuesStr = properties.getProperty(propertyName);
|
||||||
FileFolderRemoteLoader.checkProperty(propertyName, valuesStr);
|
FileFolderRemoteLoader.checkProperty(propertyName, valuesStr);
|
||||||
// Parse it into the well-known values
|
// Parse it into the well-known values
|
||||||
long[] values = new long[] {1, 0, -1, 1};
|
String[] strValues = new String[] {"1", "0", "0", "1", "false"};
|
||||||
int index = 0;
|
int index = 0;
|
||||||
StringTokenizer tokenizer = new StringTokenizer(valuesStr, ",");
|
StringTokenizer tokenizer = new StringTokenizer(valuesStr, ",");
|
||||||
while (tokenizer.hasMoreTokens())
|
while (tokenizer.hasMoreTokens())
|
||||||
{
|
{
|
||||||
String value = tokenizer.nextToken().trim();
|
String value = tokenizer.nextToken().trim();
|
||||||
values[index] = Integer.parseInt(value);
|
if (value.length() > 0)
|
||||||
|
{
|
||||||
|
strValues[index] = value;
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
if (index >= values.length)
|
if (index >= strValues.length)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long testCount = values[0];
|
long testCount = 1L;
|
||||||
long testPeriod = values[1];
|
long testPeriod = 0L;
|
||||||
long testTotal = values[2];
|
long testTotal = 0L;
|
||||||
long testDepth = values[3];
|
long testDepth = 1L;
|
||||||
|
boolean testVerbose = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
testCount = Long.parseLong(strValues[0]);
|
||||||
|
testPeriod = Long.parseLong(strValues[1]);
|
||||||
|
testTotal = Long.parseLong(strValues[2]);
|
||||||
|
testDepth = Long.parseLong(strValues[3]);
|
||||||
|
testVerbose = Boolean.parseBoolean(strValues[4]);
|
||||||
|
}
|
||||||
|
catch (Throwable e)
|
||||||
|
{
|
||||||
|
throw new LoaderClientException(
|
||||||
|
"Unable to parse the loader configuration for '" + name + "'. " + LoaderSession.getLineEnding() +
|
||||||
|
"The correct format is [threadCount], [period(ms)], [total], [folder depth], [verbose]");
|
||||||
|
}
|
||||||
|
|
||||||
// Construct
|
// Construct
|
||||||
for (int i = 0; i < testCount; i++)
|
for (int i = 0; i < testCount; i++)
|
||||||
@ -287,15 +307,15 @@ public class FileFolderRemoteLoader
|
|||||||
AbstractLoaderThread thread = null;
|
AbstractLoaderThread thread = null;
|
||||||
if (type.equals("upload"))
|
if (type.equals("upload"))
|
||||||
{
|
{
|
||||||
thread = new LoaderUploadThread(session, name, testPeriod, testTotal, testDepth);
|
thread = new LoaderUploadThread(session, name, testPeriod, testTotal, testDepth, testVerbose);
|
||||||
}
|
}
|
||||||
else if (type.equals("totals"))
|
else if (type.equals("totals"))
|
||||||
{
|
{
|
||||||
thread = new LoaderTotalsThread(session, name, testPeriod, testTotal, testDepth);
|
thread = new LoaderTotalsThread(session, name, testPeriod, testTotal, testDepth, testVerbose);
|
||||||
}
|
}
|
||||||
else if (type.equals("listFolders"))
|
else if (type.equals("listFolders"))
|
||||||
{
|
{
|
||||||
thread = new LoaderListFoldersThread(session, name, testPeriod, testTotal, testDepth);
|
thread = new LoaderListFoldersThread(session, name, testPeriod, testTotal, testDepth, testVerbose);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -44,9 +44,10 @@ public class LoaderListFoldersThread extends AbstractLoaderThread
|
|||||||
String loaderName,
|
String loaderName,
|
||||||
long testPeriod,
|
long testPeriod,
|
||||||
long testTotal,
|
long testTotal,
|
||||||
long testLoadDepth)
|
long testLoadDepth,
|
||||||
|
boolean verbose)
|
||||||
{
|
{
|
||||||
super(session, loaderName, testPeriod, testTotal, testLoadDepth);
|
super(session, loaderName, testPeriod, testTotal, testLoadDepth, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,7 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -57,7 +58,6 @@ public class LoaderSession
|
|||||||
private String name;
|
private String name;
|
||||||
private Set<String> rmiUrls;
|
private Set<String> rmiUrls;
|
||||||
private Set<StoreRef> storeRefs;
|
private Set<StoreRef> storeRefs;
|
||||||
private boolean verbose;
|
|
||||||
private File outputFile;
|
private File outputFile;
|
||||||
private File sourceDir;
|
private File sourceDir;
|
||||||
private int[] folderProfiles;
|
private int[] folderProfiles;
|
||||||
@ -68,6 +68,7 @@ public class LoaderSession
|
|||||||
private OutputStream outVerbose;
|
private OutputStream outVerbose;
|
||||||
private OutputStream outSummary;
|
private OutputStream outSummary;
|
||||||
private OutputStream outError;
|
private OutputStream outError;
|
||||||
|
private long startTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -78,7 +79,6 @@ public class LoaderSession
|
|||||||
String name,
|
String name,
|
||||||
Set<String> rmiUrls,
|
Set<String> rmiUrls,
|
||||||
Set<StoreRef> storeRefs,
|
Set<StoreRef> storeRefs,
|
||||||
boolean verbose,
|
|
||||||
File sourceDir,
|
File sourceDir,
|
||||||
int[] folderProfiles)
|
int[] folderProfiles)
|
||||||
{
|
{
|
||||||
@ -87,7 +87,6 @@ public class LoaderSession
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.rmiUrls = rmiUrls;
|
this.rmiUrls = rmiUrls;
|
||||||
this.storeRefs = storeRefs;
|
this.storeRefs = storeRefs;
|
||||||
this.verbose = verbose;
|
|
||||||
this.sourceDir = sourceDir;
|
this.sourceDir = sourceDir;
|
||||||
this.folderProfiles = folderProfiles;
|
this.folderProfiles = folderProfiles;
|
||||||
}
|
}
|
||||||
@ -161,6 +160,9 @@ public class LoaderSession
|
|||||||
outVerbose = new BufferedOutputStream(new FileOutputStream(fileVerbose));
|
outVerbose = new BufferedOutputStream(new FileOutputStream(fileVerbose));
|
||||||
outSummary = new BufferedOutputStream(new FileOutputStream(fileSummary));
|
outSummary = new BufferedOutputStream(new FileOutputStream(fileSummary));
|
||||||
outError = new BufferedOutputStream(new FileOutputStream(fileError));
|
outError = new BufferedOutputStream(new FileOutputStream(fileError));
|
||||||
|
|
||||||
|
// Record the start time
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void close()
|
public synchronized void close()
|
||||||
@ -345,25 +347,10 @@ public class LoaderSession
|
|||||||
|
|
||||||
public static String getLineEnding()
|
public static String getLineEnding()
|
||||||
{
|
{
|
||||||
try
|
return System.getProperty("line.separator", "\n");
|
||||||
{
|
|
||||||
if (File.separatorChar == '/')
|
|
||||||
{
|
|
||||||
// It's unix
|
|
||||||
return "\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "\r\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable e)
|
|
||||||
{
|
|
||||||
return "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void logVerbose(String msg)
|
public synchronized void logVerbose(String msg, boolean verbose)
|
||||||
{
|
{
|
||||||
if (!verbose || outVerbose == null)
|
if (!verbose || outVerbose == null)
|
||||||
{
|
{
|
||||||
@ -452,8 +439,8 @@ public class LoaderSession
|
|||||||
sb.append("Session name: ").append(name).append(getLineEnding())
|
sb.append("Session name: ").append(name).append(getLineEnding())
|
||||||
.append("RMI URLS: ").append(rmiUrls).append(getLineEnding())
|
.append("RMI URLS: ").append(rmiUrls).append(getLineEnding())
|
||||||
.append("Store References: ").append(storeRefs).append(getLineEnding())
|
.append("Store References: ").append(storeRefs).append(getLineEnding())
|
||||||
.append("Verbose: ").append(Boolean.toString(verbose)).append(getLineEnding())
|
.append("Folder Profiles: ").append(folderProfilesAsList)
|
||||||
.append("Folder Profiles: ").append(folderProfilesAsList);
|
.append("Start Time: ").append(new Date(startTime));
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,10 @@ public class LoaderTotalsThread extends AbstractLoaderThread
|
|||||||
String loaderName,
|
String loaderName,
|
||||||
long testPeriod,
|
long testPeriod,
|
||||||
long testTotal,
|
long testTotal,
|
||||||
long testLoadDepth)
|
long testLoadDepth,
|
||||||
|
boolean verbose)
|
||||||
{
|
{
|
||||||
super(session, loaderName, testPeriod, testTotal, testLoadDepth);
|
super(session, loaderName, testPeriod, testTotal, testLoadDepth, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +63,10 @@ public class LoaderUploadThread extends AbstractLoaderThread
|
|||||||
String loaderName,
|
String loaderName,
|
||||||
long testPeriod,
|
long testPeriod,
|
||||||
long testTotal,
|
long testTotal,
|
||||||
long testLoadDepth)
|
long testLoadDepth,
|
||||||
|
boolean verbose)
|
||||||
{
|
{
|
||||||
super(session, loaderName, testPeriod, testTotal, testLoadDepth);
|
super(session, loaderName, testPeriod, testTotal, testLoadDepth, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user