Merge LOGNEON-HEAD-3D-BENCHMARK to HEAD

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13241 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2009-02-16 12:21:41 +00:00
parent 109b51fb98
commit 711e4b298e
12 changed files with 830 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -28,10 +28,18 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import java.net.URL;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cache.EhCacheAdapter;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Cache;
/**
* A description of what the remote loader should do.
@@ -54,6 +62,19 @@ public abstract class AbstractLoaderThread extends Thread
private int statCount;
private double statTotalMs;
private static EhCacheAdapter<String, NodeRef> pathCache;
static
{
System.setProperty(CacheManager.ENABLE_SHUTDOWN_HOOK_PROPERTY, "TRUE");
URL url = LoaderUploadThread.class.getResource("/org/alfresco/repo/model/filefolder/loader/loader-ehcache.xml");
CacheManager cacheManager = new CacheManager(url);
Cache cache = cacheManager.getCache("org.alfresco.LoaderUploadThread.PathCache");
pathCache = new EhCacheAdapter<String, NodeRef>();
pathCache.setCache(cache);
}
public AbstractLoaderThread(
LoaderSession session,
String loaderName,
@@ -110,6 +131,8 @@ public abstract class AbstractLoaderThread extends Thread
int nodeIndex = random.nextInt(nodeCount);
NodeRef workingRootNodeRef = session.getWorkingRootNodeRefs().get(nodeIndex);
this.doBefore(serverProxy, workingRootNodeRef);
long startTime = System.nanoTime();
String msg = doLoading(serverProxy, workingRootNodeRef);
long endTime = System.nanoTime();
@@ -137,6 +160,7 @@ public abstract class AbstractLoaderThread extends Thread
this.wait(mustWait);
}
}
this.doAfter(serverProxy, workingRootNodeRef);
}
catch (Throwable e)
{
@@ -238,4 +262,69 @@ public abstract class AbstractLoaderThread extends Thread
}
return file;
}
/**
* Creates or find the folders based on caching.
*/
protected NodeRef makeFolders(
String ticket,
LoaderServerProxy serverProxy,
NodeRef workingRootNodeRef,
List<String> folderPath) throws Exception
{
// Iterate down the path, checking the cache and populating it as necessary
NodeRef currentParentNodeRef = workingRootNodeRef;
String currentKey = workingRootNodeRef.toString();
for (String aFolderPath : folderPath)
{
currentKey += ("/" + aFolderPath);
// Is this there?
NodeRef nodeRef = pathCache.get(currentKey);
if (nodeRef != null)
{
// Found it
currentParentNodeRef = nodeRef;
// Step into the next level
continue;
}
// It is not there, so create it
try
{
FileInfo folderInfo = serverProxy.fileFolderRemote.makeFolders(
serverProxy.ticket,
currentParentNodeRef,
Collections.singletonList(aFolderPath),
ContentModel.TYPE_FOLDER);
currentParentNodeRef = folderInfo.getNodeRef();
} catch (FileExistsException e)
{
currentParentNodeRef = pathCache.get(currentKey);
}
// Cache the new node
pathCache.put(currentKey, currentParentNodeRef);
}
// Done
return currentParentNodeRef;
}
/**
* Run before record stats
*/
protected void doBefore(LoaderServerProxy loaderServerProxy, NodeRef nodeRef) throws Exception
{
}
/**
* Run after record stats
*/
protected void doAfter(LoaderServerProxy loaderServerProxy, NodeRef nodeRef) throws Exception
{
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -286,7 +286,7 @@ public class FileFolderRemoteLoader
long testTotal = 0L;
long testDepth = 1L;
boolean testVerbose = false;
long filesPerUpload = 1;
long filesPerIteration = 1;
try
{
testCount = Long.parseLong(strValues[0]);
@@ -294,13 +294,13 @@ public class FileFolderRemoteLoader
testTotal = Long.parseLong(strValues[2]);
testDepth = Long.parseLong(strValues[3]);
testVerbose = Boolean.parseBoolean(strValues[4]);
filesPerUpload = Long.parseLong(strValues[5]);
filesPerIteration = Long.parseLong(strValues[5]);
}
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]<, [filesPerUpload]>");
"The correct format is [threadCount], [period(ms)], [total], [folder depth], [verbose]<, [filesPerIteration]>");
}
// Construct
@@ -309,7 +309,7 @@ public class FileFolderRemoteLoader
AbstractLoaderThread thread = null;
if (type.equals("upload"))
{
thread = new LoaderUploadThread(session, name, testPeriod, testTotal, testDepth, testVerbose, filesPerUpload);
thread = new LoaderUploadThread(session, name, testPeriod, testTotal, testDepth, testVerbose, filesPerIteration);
}
else if (type.equals("totals"))
{
@@ -318,6 +318,20 @@ public class FileFolderRemoteLoader
else if (type.equals("listFolders"))
{
thread = new LoaderListFoldersThread(session, name, testPeriod, testTotal, testDepth, testVerbose);
}
else if(type.equals("delete"))
{
thread = new LoaderDeleteThread(session, name, testPeriod, testTotal, testDepth, testVerbose, filesPerIteration);
}
else if(type.equals("update"))
{
thread = new LoaderUpdateThread(session, name, testPeriod, testTotal, testDepth, testVerbose, filesPerIteration);
}
else if(type.equals("coci"))
{
thread = new LoaderCOCIThread(session, name, testPeriod, testTotal, testDepth, testVerbose, filesPerIteration);
}
else
{

View File

@@ -0,0 +1,113 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.model.filefolder.loader;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.model.ContentModel;
import org.springframework.util.FileCopyUtils;
import java.util.*;
import java.io.Serializable;
import java.io.File;
/**
* Loader thread that coci documents to the remote repository.
*/
public class LoaderCOCIThread extends AbstractLoaderThread
{
private int filesPerIteration;
private FileInfo[] filesInfo;
public LoaderCOCIThread(LoaderSession session, String loaderName, long testPeriod, long testTotal, long testLoadDepth, boolean verbose, long filesPerIteration)
{
super(session, loaderName, testPeriod, testTotal, testLoadDepth, verbose);
this.filesPerIteration = (int) filesPerIteration;
}
@Override
protected String doLoading(LoaderServerProxy serverProxy, NodeRef workingRootNodeRef) throws Exception
{
List<HashMap<String, Serializable>> arrVersionProp = new ArrayList<HashMap<String, Serializable>>();
byte[][] bytes = new byte[filesPerIteration][];
for (int i = 0; i < filesPerIteration; i++)
{
File file = getFile();
bytes[i] = FileCopyUtils.copyToByteArray(file);
arrVersionProp.add(new HashMap<String, Serializable>());
}
serverProxy.loaderRemote.coci(serverProxy.ticket, getNodesRef(filesInfo), bytes, arrVersionProp);
return String.format("update version %d files in folder: %s", filesPerIteration, workingRootNodeRef.toString());
}
@Override
protected void doBefore(LoaderServerProxy loaderServerProxy, NodeRef nodeRef) throws Exception
{
// Get a random folder
List<String> folderPath = super.chooseFolderPath();
//makeFolders
NodeRef folderNodeRef = makeFolders(loaderServerProxy.ticket, loaderServerProxy, nodeRef, folderPath);
String[] fileNames = new String[filesPerIteration];
NodeRef[] parentNodeRefs = new NodeRef[filesPerIteration];
QName[] types = new QName[filesPerIteration];
// Build a set of files to coci
for (int i = 0; i < filesPerIteration; i++)
{
fileNames[i] = GUID.generate();
parentNodeRefs[i] = folderNodeRef;
types[i] = ContentModel.TYPE_CONTENT;
}
filesInfo = loaderServerProxy.fileFolderRemote.create(loaderServerProxy.ticket, parentNodeRefs, fileNames, types);
}
public String getSummary()
{
String summary = super.getSummary();
summary += String.format("%d files per iteration", filesPerIteration);
return summary;
}
NodeRef[] getNodesRef(FileInfo[] filesInfoList)
{
NodeRef[] nr = new NodeRef[filesInfoList.length];
for (int i = 0; i < filesInfoList.length; i++)
{
nr[i] = (filesInfoList[i].getNodeRef());
}
return nr;
}
}

View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.model.filefolder.loader;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.util.List;
/**
* Loader thread that deletes documents to the remote repository.
*/
public class LoaderDeleteThread extends AbstractLoaderThread
{
private FileInfo[] filesInfo;
private int filesPerIteration;
public LoaderDeleteThread(
LoaderSession loaderSession,
String loaderName,
long testPeriod,
long testTotal,
long testLoadDepth,
boolean verbose,
long filesPerIteration)
{
super(loaderSession, loaderName, testPeriod, testTotal, testLoadDepth, verbose);
this.filesPerIteration = (int) filesPerIteration;
}
@Override
protected String doLoading(LoaderServerProxy loaderServerProxy, NodeRef nodeRef) throws Exception
{
// Delete it
loaderServerProxy.fileFolderRemote.delete(loaderServerProxy.ticket, getNodesRef(filesInfo));
// Done
String msg = String.format("Deleted %d files from folder: %s", filesInfo.length, nodeRef.toString());
return msg;
}
@Override
protected void doBefore(LoaderServerProxy loaderServerProxy, NodeRef workingRootNodeRef) throws Exception
{
// Get a random folder
List<String> folderPath = super.chooseFolderPath();
//makeFolders
NodeRef folderNodeRef = makeFolders(loaderServerProxy.ticket, loaderServerProxy, workingRootNodeRef, folderPath);
byte[][] bytes = new byte[filesPerIteration][];
String[] fileNames = new String[filesPerIteration];
NodeRef[] parentNodeRefs = new NodeRef[filesPerIteration];
QName[] types = new QName[filesPerIteration];
// Build a set of files to delete
for (int i = 0; i < filesPerIteration; i++)
{
File file = getFile();
bytes[i] = FileCopyUtils.copyToByteArray(file);
fileNames[i] = GUID.generate();
parentNodeRefs[i] = folderNodeRef;
types[i] = ContentModel.TYPE_CONTENT;
}
filesInfo = loaderServerProxy.fileFolderRemote.create(loaderServerProxy.ticket, parentNodeRefs, fileNames, types);
loaderServerProxy.fileFolderRemote.putContent(loaderServerProxy.ticket, getNodesRef(filesInfo), bytes, fileNames);
}
NodeRef[] getNodesRef(FileInfo[] filesInfoList)
{
NodeRef[] nr = new NodeRef[filesInfoList.length];
for (int i = 0; i < filesInfoList.length; i++)
{
nr[i] = (filesInfoList[i].getNodeRef());
}
return nr;
}
public String getSummary()
{
String summary = super.getSummary();
summary += (String.format("%d files per iteration", filesPerIteration));
return summary;
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.model.filefolder.loader;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.model.ContentModel;
import org.springframework.util.FileCopyUtils;
import java.util.List;
import java.io.File;
/**
* Loader thread that updates documents to the remote repository.
*/
public class LoaderUpdateThread extends AbstractLoaderThread
{
private FileInfo[] filesInfo;
private int filesPerIteration;
public LoaderUpdateThread(
LoaderSession session,
String loaderName,
long testPeriod,
long testTotal,
long testLoadDepth,
boolean verbose,
long filesPerIteration)
{
super(session, loaderName, testPeriod, testTotal, testLoadDepth, verbose);
this.filesPerIteration = (int)filesPerIteration;
}
@Override
protected void doBefore(LoaderServerProxy loaderServerProxy, NodeRef nodeRef) throws Exception
{
// Get a random folder
List<String> folderPath = super.chooseFolderPath();
//makeFolders
NodeRef folderNodeRef = makeFolders(loaderServerProxy.ticket, loaderServerProxy, nodeRef, folderPath);
String[] fileNames = new String[filesPerIteration];
NodeRef[] pareNodeRefs = new NodeRef[filesPerIteration];
QName[] types = new QName[filesPerIteration];
// Build a set of files to update
for (int i = 0; i < filesPerIteration; i++)
{
fileNames[i] = GUID.generate();
pareNodeRefs[i] = folderNodeRef;
types[i] = ContentModel.TYPE_CONTENT;
}
filesInfo = loaderServerProxy.fileFolderRemote.create(loaderServerProxy.ticket, pareNodeRefs, fileNames, types);
}
@Override
protected String doLoading(LoaderServerProxy loaderServerProxy, NodeRef nodeRef) throws Exception
{
byte[][] bytes = new byte[filesPerIteration][];
String[] fileNames = new String[filesPerIteration];
NodeRef[] nodeRefs = new NodeRef[filesPerIteration];
for (int i = 0; i < filesPerIteration; i++)
{
File file = getFile();
bytes[i] = FileCopyUtils.copyToByteArray(file);
fileNames[i] = filesInfo[i].getName();
nodeRefs[i] = filesInfo[i].getNodeRef();
}
//Update it
loaderServerProxy.fileFolderRemote.putContent(loaderServerProxy.ticket, nodeRefs, bytes, fileNames);
// Done
return String.format("Updated %d files in folder: %s", filesInfo.length, nodeRef.toString());
}
public String getSummary()
{
String summary = super.getSummary();
summary += (String.format("%d files per iteration", filesPerIteration));
return summary;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,21 +24,14 @@
*/
package org.alfresco.repo.model.filefolder.loader;
import java.io.File;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cache.EhCacheAdapter;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.GUID;
import org.springframework.util.FileCopyUtils;
import java.io.File;
import java.util.List;
/**
* Loader thread that puts documents to the remote repository.
*
@@ -47,18 +40,6 @@ import org.springframework.util.FileCopyUtils;
*/
public class LoaderUploadThread extends AbstractLoaderThread
{
private static EhCacheAdapter<String, NodeRef> pathCache;
static
{
System.setProperty(CacheManager.ENABLE_SHUTDOWN_HOOK_PROPERTY, "TRUE");
URL url = LoaderUploadThread.class.getResource("/org/alfresco/repo/model/filefolder/loader/loader-ehcache.xml");
CacheManager cacheManager = new CacheManager(url);
Cache cache = cacheManager.getCache("org.alfresco.LoaderUploadThread.PathCache");
pathCache = new EhCacheAdapter<String, NodeRef>();
pathCache.setCache(cache);
}
private int filesPerUpload;
@@ -75,44 +56,6 @@ public class LoaderUploadThread extends AbstractLoaderThread
this.filesPerUpload = (int) filesPerUpload;
}
/**
* Creates or find the folders based on caching.
*/
private NodeRef makeFolders(
String ticket,
LoaderServerProxy serverProxy,
NodeRef workingRootNodeRef,
List<String> folderPath) throws Exception
{
// Iterate down the path, checking the cache and populating it as necessary
NodeRef currentParentNodeRef = workingRootNodeRef;
String currentKey = workingRootNodeRef.toString();
for (String pathElement : folderPath)
{
currentKey += ("/" + pathElement);
// Is this there?
NodeRef nodeRef = pathCache.get(currentKey);
if (nodeRef != null)
{
// Found it
currentParentNodeRef = nodeRef;
// Step into the next level
continue;
}
// It is not there, so create it
FileInfo folderInfo = serverProxy.fileFolderRemote.makeFolders(
serverProxy.ticket,
currentParentNodeRef,
Collections.singletonList(pathElement),
ContentModel.TYPE_FOLDER);
currentParentNodeRef = folderInfo.getNodeRef();
// Cache the new node
pathCache.put(currentKey, currentParentNodeRef);
}
// Done
return currentParentNodeRef;
}
@Override
protected String doLoading(LoaderServerProxy serverProxy, NodeRef workingRootNodeRef) throws Exception
{