mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
AVM now configures itself via Spring. Also adjusted jndi-client and catalina-virtual
to be semi-not-broken. The current limitation is that you've got to start tomcat from $TOMCAT_HOME for things to work (fix soon). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3267 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -36,10 +36,12 @@ public class AVMCrawlTest extends AVMServiceTestBase
|
||||
public void testCrawl()
|
||||
{
|
||||
int n = 4; // Number of Threads.
|
||||
int m = 1; // How many multiples of content to start with.
|
||||
int m = 4; // How many multiples of content to start with.
|
||||
long runTime = 1200000; // Ten minutes
|
||||
fService.purgeRepository("main");
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
fReaper.setInactiveBaseSleep(30000);
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
for (int i = 0; i < m; i++)
|
||||
{
|
||||
fService.createRepository("d" + i);
|
||||
|
@@ -18,6 +18,8 @@
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
@@ -25,7 +27,14 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.avm.hibernate.HibernateHelper;
|
||||
import org.alfresco.repo.avm.util.BulkLoader;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
|
||||
/**
|
||||
* An interactive console for the AVM repository.
|
||||
@@ -38,11 +47,6 @@ public class AVMInteractiveConsole
|
||||
*/
|
||||
private AVMService fService;
|
||||
|
||||
/**
|
||||
* The Orphan Cleaner Upper.
|
||||
*/
|
||||
private OrphanReaper fReaper;
|
||||
|
||||
/**
|
||||
* The reader for interaction.
|
||||
*/
|
||||
@@ -59,31 +63,38 @@ public class AVMInteractiveConsole
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (args.length != 2)
|
||||
{
|
||||
System.err.println("Usage: AVMInteractiveConsole storage (new|old)");
|
||||
System.exit(1);
|
||||
}
|
||||
AVMInteractiveConsole console = new AVMInteractiveConsole(args[0], args[1].equals("new"));
|
||||
FileSystemXmlApplicationContext context =
|
||||
new FileSystemXmlApplicationContext("config/alfresco/avm-console-context.xml");
|
||||
AVMInteractiveConsole console = (AVMInteractiveConsole)context.getBean("interactiveConsole");
|
||||
console.rep();
|
||||
context.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Make up a new console.
|
||||
* @param storage Where The backing store goes.
|
||||
* @param createNew Whether to create a new SuperRepository.
|
||||
*/
|
||||
public AVMInteractiveConsole(String storage, boolean createNew)
|
||||
public AVMInteractiveConsole()
|
||||
{
|
||||
AVMServiceImpl service = new AVMServiceImpl();
|
||||
service.setStorage(storage);
|
||||
service.init(createNew);
|
||||
fService = service;
|
||||
fReaper = new OrphanReaper();
|
||||
fReaper.init();
|
||||
fLoader = new BulkLoader(fService);
|
||||
fIn = new BufferedReader(new InputStreamReader(System.in));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the AVMService.
|
||||
* @param service The AVMService instance.
|
||||
*/
|
||||
public void setAvmService(AVMService service)
|
||||
{
|
||||
fService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bulk loader.
|
||||
* @param loader
|
||||
*/
|
||||
public void setBulkLoader(BulkLoader loader)
|
||||
{
|
||||
fLoader = loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Read-Eval-Print loop.
|
||||
@@ -402,7 +413,6 @@ public class AVMInteractiveConsole
|
||||
}
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
}
|
||||
fReaper.shutDown();
|
||||
}
|
||||
|
||||
private void recursiveList(AVMNodeDescriptor dir, int indent)
|
||||
|
@@ -30,7 +30,6 @@ import org.alfresco.repo.avm.hibernate.HibernateHelper;
|
||||
import org.alfresco.repo.avm.hibernate.HibernateTxn;
|
||||
import org.alfresco.repo.avm.hibernate.HibernateTxnCallback;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
|
||||
/**
|
||||
@@ -39,11 +38,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
*/
|
||||
public class AVMServiceImpl implements AVMService
|
||||
{
|
||||
/**
|
||||
* The Hibernate SessionFactory.
|
||||
*/
|
||||
private SessionFactory fSessionFactory;
|
||||
|
||||
/**
|
||||
* The HibernateTxn.
|
||||
*/
|
||||
@@ -74,26 +68,33 @@ public class AVMServiceImpl implements AVMService
|
||||
*/
|
||||
private Issuer fLayerIssuer;
|
||||
|
||||
/**
|
||||
* Whether the tables should be dropped and created.
|
||||
*/
|
||||
private boolean fCreateTables;
|
||||
|
||||
/**
|
||||
* The HibernateHelper.
|
||||
*/
|
||||
private HibernateHelper fHibernateHelper;
|
||||
|
||||
/**
|
||||
* Basic constructor for the service.
|
||||
*/
|
||||
public AVMServiceImpl()
|
||||
{
|
||||
fSessionFactory = HibernateHelper.GetSessionFactory();
|
||||
fTransaction = new HibernateTxn(fSessionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Final initialization of the service. Must be called only on a
|
||||
* fully initialized instance.
|
||||
* @param createTables Whether we should create tables, and a default
|
||||
* repository.
|
||||
*/
|
||||
public void init(boolean createTables)
|
||||
public void init()
|
||||
{
|
||||
if (createTables)
|
||||
fTransaction = new HibernateTxn(fHibernateHelper.getSessionFactory());
|
||||
if (fCreateTables)
|
||||
{
|
||||
SchemaExport se = new SchemaExport(HibernateHelper.GetConfiguration());
|
||||
SchemaExport se = new SchemaExport(fHibernateHelper.getConfiguration());
|
||||
se.drop(false, true);
|
||||
se.create(false, true);
|
||||
File storage = new File(fStorage);
|
||||
@@ -135,8 +136,30 @@ public class AVMServiceImpl implements AVMService
|
||||
fStorage = storage;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMService#getFileInputStream(int, java.lang.String)
|
||||
/**
|
||||
* Set whether we should drop and create tables.
|
||||
* @param createTables
|
||||
*/
|
||||
public void setCreateTables(boolean createTables)
|
||||
{
|
||||
fCreateTables = createTables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HibernateHelper.
|
||||
* @param helper
|
||||
*/
|
||||
public void setHibernateHelper(HibernateHelper helper)
|
||||
{
|
||||
fHibernateHelper = helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an InputStream from a file.
|
||||
* @param version The version to look under.
|
||||
* @param path The absolute path.
|
||||
* @return An InputStream
|
||||
* @throws AVMNotFoundException When the path is invalid.
|
||||
*/
|
||||
public InputStream getFileInputStream(final int version, final String path)
|
||||
{
|
||||
|
@@ -1847,7 +1847,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
try
|
||||
{
|
||||
ArrayList<Long> times = new ArrayList<Long>();
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
||||
times.add(System.currentTimeMillis());
|
||||
fService.createSnapshot("main");
|
||||
|
@@ -25,6 +25,7 @@ import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.repo.avm.hibernate.HibernateHelper;
|
||||
import org.hibernate.stat.Statistics;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -38,6 +39,16 @@ public class AVMServiceTestBase extends TestCase
|
||||
* The AVMService we are testing.
|
||||
*/
|
||||
protected AVMService fService;
|
||||
|
||||
/**
|
||||
* The reaper thread.
|
||||
*/
|
||||
protected OrphanReaper fReaper;
|
||||
|
||||
/**
|
||||
* The application context.
|
||||
*/
|
||||
protected FileSystemXmlApplicationContext fContext;
|
||||
|
||||
/**
|
||||
* The start time of actual work for a test.
|
||||
@@ -51,11 +62,10 @@ public class AVMServiceTestBase extends TestCase
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
// HibernateHelper.GetSessionFactory().getStatistics().setStatisticsEnabled(true);
|
||||
AVMServiceImpl service = new AVMServiceImpl();
|
||||
service.setStorage("build/test-results/storage");
|
||||
service.init(true);
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/avm-test-context.xml");
|
||||
fService = (AVMService)fContext.getBean("avmService");
|
||||
fReaper = (OrphanReaper)fContext.getBean("orphanReaper");
|
||||
fStartTime = System.currentTimeMillis();
|
||||
fService = service;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -69,7 +79,7 @@ public class AVMServiceTestBase extends TestCase
|
||||
// Statistics stats = HibernateHelper.GetSessionFactory().getStatistics();
|
||||
// stats.logSummary();
|
||||
// stats.clear();
|
||||
HibernateHelper.Reset();
|
||||
fContext.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -35,9 +35,11 @@ public class AVMStressTest extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
fReaper.setInactiveBaseSleep(30000);
|
||||
int nCopies = 4;
|
||||
int nThreads = 8;
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < nCopies; i++)
|
||||
{
|
||||
|
@@ -30,7 +30,7 @@ import org.hibernate.Session;
|
||||
* in the AVM repository. These orphans arise from purge operations.
|
||||
* @author britt
|
||||
*/
|
||||
class OrphanReaper implements Runnable
|
||||
public class OrphanReaper implements Runnable
|
||||
{
|
||||
/**
|
||||
* The HibernateTxn instance.
|
||||
@@ -68,12 +68,16 @@ class OrphanReaper implements Runnable
|
||||
*/
|
||||
private Thread fThread;
|
||||
|
||||
/**
|
||||
* The Hibernate helper to use.
|
||||
*/
|
||||
private HibernateHelper fHibernateHelper;
|
||||
|
||||
/**
|
||||
* Create one with default parameters.
|
||||
*/
|
||||
public OrphanReaper()
|
||||
{
|
||||
fTransaction = new HibernateTxn(HibernateHelper.GetSessionFactory());
|
||||
fInactiveBaseSleep = 30000;
|
||||
fActiveBaseSleep = 1000;
|
||||
fBatchSize = 50;
|
||||
@@ -110,11 +114,21 @@ class OrphanReaper implements Runnable
|
||||
fBatchSize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HibernateHelper to use.
|
||||
* @param helper The helper to use.
|
||||
*/
|
||||
public void setHibernateHelper(HibernateHelper helper)
|
||||
{
|
||||
fHibernateHelper = helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start things up after configuration is complete.
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
fTransaction = new HibernateTxn(fHibernateHelper.getSessionFactory());
|
||||
fThread = new Thread(this);
|
||||
fThread.start();
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import org.alfresco.repo.avm.hibernate.HibernateHelper;
|
||||
import org.alfresco.repo.avm.util.BulkLoader;
|
||||
|
||||
/**
|
||||
@@ -32,18 +33,17 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
OrphanReaper reaper = new OrphanReaper();
|
||||
reaper.init();
|
||||
setupBasicTree();
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
loader.recursiveLoad("source/web", "main:/");
|
||||
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.createSnapshot("main");
|
||||
System.err.println("Load time + snapshot: " + (System.currentTimeMillis() - start) + "ms");
|
||||
fService.purgeVersion(2, "main");
|
||||
reaper.activate();
|
||||
while (reaper.isActive())
|
||||
fReaper.activate();
|
||||
while (fReaper.isActive())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -54,7 +54,6 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
reaper.shutDown();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -70,10 +69,9 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
OrphanReaper reaper = new OrphanReaper();
|
||||
reaper.init();
|
||||
setupBasicTree();
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
loader.recursiveLoad("source", "main:/");
|
||||
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
|
||||
@@ -82,8 +80,8 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
fService.removeNode("main:/source/java/org/alfresco", "repo");
|
||||
fService.createSnapshot("main");
|
||||
fService.purgeVersion(2, "main");
|
||||
reaper.activate();
|
||||
while (reaper.isActive())
|
||||
fReaper.activate();
|
||||
while (fReaper.isActive())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -94,7 +92,6 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
reaper.shutDown();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -110,10 +107,9 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
OrphanReaper reaper = new OrphanReaper();
|
||||
reaper.init();
|
||||
setupBasicTree();
|
||||
BulkLoader loader = new BulkLoader(fService);
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
long start = System.currentTimeMillis();
|
||||
loader.recursiveLoad("source", "main:/");
|
||||
System.err.println("Load time: " + (System.currentTimeMillis() - start) + "ms");
|
||||
@@ -124,8 +120,8 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
fService.createFile("main:/layer/java/org/alfresco", "goofy").close();
|
||||
fService.createSnapshot("main");
|
||||
fService.purgeRepository("main");
|
||||
reaper.activate();
|
||||
while (reaper.isActive())
|
||||
fReaper.activate();
|
||||
while (fReaper.isActive())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -136,7 +132,6 @@ public class PurgeTest extends AVMServiceTestBase
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
reaper.shutDown();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -32,8 +32,9 @@ public class SimultaneousLoadTest extends AVMServiceTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
int n = 1;
|
||||
int m = 8;
|
||||
int n = 8;
|
||||
int m = 1;
|
||||
fReaper.setInactiveBaseSleep(30000);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
fService.createDirectory("main:/", "d" + i);
|
||||
@@ -87,7 +88,8 @@ public class SimultaneousLoadTest extends AVMServiceTestBase
|
||||
*/
|
||||
public Loader(String source, String destination, int count)
|
||||
{
|
||||
fLoader = new BulkLoader(fService);
|
||||
fLoader = new BulkLoader();
|
||||
fLoader.setAvmService(fService);
|
||||
fSource = source;
|
||||
fDestination = destination;
|
||||
fCount = count;
|
||||
|
@@ -21,39 +21,51 @@ import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
/**
|
||||
* Like 83.7 gazillion others, a HibernateHelper. This will go away.
|
||||
* @author britt
|
||||
*/
|
||||
public class HibernateHelper
|
||||
{
|
||||
private static Configuration fgCfg = null;
|
||||
private static SessionFactory fgFactory = null;
|
||||
/**
|
||||
* The single instance of this.
|
||||
*/
|
||||
private static HibernateHelper fgInstance = null;
|
||||
|
||||
static
|
||||
/**
|
||||
* The Hibernate Configuration object.
|
||||
*/
|
||||
private Configuration fCfg;
|
||||
|
||||
/**
|
||||
* The Hibernate SessionFactory;
|
||||
*/
|
||||
private SessionFactory fFactory;
|
||||
|
||||
public HibernateHelper()
|
||||
{
|
||||
Reset();
|
||||
fCfg = null;
|
||||
fFactory = null;
|
||||
setup();
|
||||
fgInstance = this;
|
||||
}
|
||||
|
||||
public static SessionFactory GetSessionFactory()
|
||||
public SessionFactory getSessionFactory()
|
||||
{
|
||||
return fgFactory;
|
||||
return fFactory;
|
||||
}
|
||||
|
||||
public static Configuration GetConfiguration()
|
||||
public Configuration getConfiguration()
|
||||
{
|
||||
return fgCfg;
|
||||
return fCfg;
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
public void setup()
|
||||
{
|
||||
if (fgFactory != null)
|
||||
{
|
||||
fgFactory.close();
|
||||
}
|
||||
try
|
||||
{
|
||||
fgCfg = new Configuration();
|
||||
fgCfg.configure();
|
||||
fgFactory = fgCfg.buildSessionFactory();
|
||||
fCfg = new Configuration();
|
||||
fCfg.configure();
|
||||
fFactory = fCfg.buildSessionFactory();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -61,4 +73,14 @@ public class HibernateHelper
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
fFactory.close();
|
||||
}
|
||||
|
||||
public static HibernateHelper GetInstance()
|
||||
{
|
||||
return fgInstance;
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import java.io.OutputStream;
|
||||
import org.alfresco.repo.avm.AVMException;
|
||||
import org.alfresco.repo.avm.AVMService;
|
||||
import org.alfresco.repo.avm.AVMServiceImpl;
|
||||
import org.alfresco.repo.avm.hibernate.HibernateHelper;
|
||||
|
||||
/**
|
||||
* This takes a filesystem directory path and a repository path and name
|
||||
@@ -36,31 +37,18 @@ public class BulkLoader
|
||||
{
|
||||
private AVMService fService;
|
||||
|
||||
/**
|
||||
* Bulk load from a filesystem directory.
|
||||
* Syntax : BulkLoad storagepath (new|old) fspath reppath name
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (args.length != 4)
|
||||
{
|
||||
System.err.println("Syntax: BulkLoad storagepath (new|old) fspath reppath");
|
||||
System.exit(1);
|
||||
}
|
||||
AVMServiceImpl service = new AVMServiceImpl();
|
||||
service.setStorage(args[0]);
|
||||
service.init(args[1].equals("new"));
|
||||
BulkLoader loader = new BulkLoader(service);
|
||||
loader.recursiveLoad(args[2], args[3]);
|
||||
service.createSnapshot("main");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new one.
|
||||
*/
|
||||
public BulkLoader()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the AVMService.
|
||||
* @param service
|
||||
*/
|
||||
public BulkLoader(AVMService service)
|
||||
public void setAvmService(AVMService service)
|
||||
{
|
||||
fService = service;
|
||||
}
|
||||
|
Reference in New Issue
Block a user