Cleaned up a handful of uglinesses in moving AVM configuration into

Alfresco app configuration, mostly related to getting testing to
work smoothly.  Also reworked OrphanReaper to be better behaved
and nominally more efficient.  


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3419 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park 2006-07-27 00:47:56 +00:00
parent 6692c7a979
commit 4ab5a046c2
10 changed files with 113 additions and 59 deletions

View File

@ -2,29 +2,36 @@
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> <launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/> <stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/>
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:Repository}"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:Repository}"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/> <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/Repository&quot; type=&quot;4&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/Repository&quot; type=&quot;4&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType"/> <stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.launching.macosx.MacOSXType"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="compile-jibx,"/> <stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="compile-jibx,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="compile-jibx,"/> <stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="compile-jibx,"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jdk1.5.0_06"/> <stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="JVM 1.5"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> <listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_02&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_02&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.ant.ui.classpathentry.antHome&quot;&gt;&#10;&lt;memento default=&quot;true&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.ant.ui.classpathentry.antHome&quot;&gt;&#10;&lt;memento default=&quot;true&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/xpp3-1.1.3_8.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.ant.ui.classpathentry.extraClasspathEntries&quot;&gt;&#10;&lt;memento/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.ant.ui.classpathentry.extraClasspathEntries&quot;&gt;&#10;&lt;memento/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/jibx/jibx-run.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/jibx/jibx-run.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/jibx/jibx-bind.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/jibx/jibx-bind.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/bcel.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/bcel.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/3rd Party/lib/xpp3.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/> </listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Repository/project-build.xml"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/Repository/project-build.xml}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/Repository/project-build.xml}"/>
</launchConfiguration> </launchConfiguration>

View File

@ -253,7 +253,7 @@
</bean> </bean>
<bean id="orphanReaper" class="org.alfresco.repo.avm.OrphanReaper" <bean id="orphanReaper" class="org.alfresco.repo.avm.OrphanReaper"
init-method="init" destroy-method="shutDown" depends-on="avmService"> init-method="init" destroy-method="shutDown" depends-on="AVMService">
<property name="inactiveBaseSleep"> <property name="inactiveBaseSleep">
<value>4000</value> <value>4000</value>
</property> </property>
@ -268,7 +268,7 @@
</property> </property>
</bean> </bean>
<bean id="avmService" class="org.alfresco.repo.avm.AVMServiceImpl" <bean id="AVMService" class="org.alfresco.repo.avm.AVMServiceImpl"
init-method="init"> init-method="init">
<property name="storage"> <property name="storage">
<value>${avm.storage}</value> <value>${avm.storage}</value>

View File

@ -193,7 +193,7 @@
<bean id="orphanReaper" class="org.alfresco.repo.avm.OrphanReaper" <bean id="orphanReaper" class="org.alfresco.repo.avm.OrphanReaper"
init-method="init" destroy-method="shutDown" depends-on="AVMService"> init-method="init" destroy-method="shutDown" depends-on="AVMService">
<property name="inactiveBaseSleep"> <property name="inactiveBaseSleep">
<value>4000</value> <value>60000</value>
</property> </property>
<property name="activeBaseSleep"> <property name="activeBaseSleep">
<value>1000</value> <value>1000</value>
@ -201,6 +201,9 @@
<property name="batchSize"> <property name="batchSize">
<value>50</value> <value>50</value>
</property> </property>
<property name="maxQueueLength">
<value>1000</value>
</property>
<property name="retryingTransaction"> <property name="retryingTransaction">
<ref bean="retryingTransaction"/> <ref bean="retryingTransaction"/>
</property> </property>

View File

@ -12,7 +12,7 @@ hibernate.connection.isolation=4
hibernate.default_batch_fetch_size=16 hibernate.default_batch_fetch_size=16
hibernate.jdbc.batch_versioned_data=true hibernate.jdbc.batch_versioned_data=true
hibernate.cache.use_second_level_cache=true hibernate.cache.use_second_level_cache=true
hibernate.hbm2ddl.auto=create hibernate.hbm2ddl.auto=update
# AVM specific properties. # AVM specific properties.
avm.storage=build/test-results/storage avm.storage=build/test-results/storage
avm.initialize=true avm.initialize=true

View File

@ -39,7 +39,6 @@ public class AVMCrawlTest extends AVMServiceTestBase
int m = 4; // How many multiples of content to start with. int m = 4; // How many multiples of content to start with.
long runTime = 1200000; // Ten minutes long runTime = 1200000; // Ten minutes
fService.purgeAVMStore("main"); fService.purgeAVMStore("main");
fReaper.setInactiveBaseSleep(60000);
BulkLoader loader = new BulkLoader(); BulkLoader loader = new BulkLoader();
loader.setAvmService(fService); loader.setAvmService(fService);
for (int i = 0; i < m; i++) for (int i = 0; i < m; i++)

View File

@ -55,8 +55,10 @@ public class AVMServiceTestBase extends TestCase
*/ */
private long fStartTime; private long fStartTime;
/* (non-Javadoc) /**
* @see junit.framework.TestCase#setUp() * Setup for AVM tests. Note that we set the polling
* interval for the reaper to 4 seconds so that tests will
* finish reasonably quickly.
*/ */
@Override @Override
protected void setUp() throws Exception protected void setUp() throws Exception
@ -67,8 +69,9 @@ public class AVMServiceTestBase extends TestCase
fStartTime = System.currentTimeMillis(); fStartTime = System.currentTimeMillis();
} }
/* (non-Javadoc) /**
* @see junit.framework.TestCase#tearDown() * Cleanup after a test. Purge all stores. Move alf_data
* directory aside.
*/ */
@Override @Override
protected void tearDown() throws Exception protected void tearDown() throws Exception

View File

@ -35,7 +35,6 @@ public class AVMStressTest extends AVMServiceTestBase
{ {
try try
{ {
fReaper.setInactiveBaseSleep(30000);
int nCopies = 4; int nCopies = 4;
int nThreads = 8; int nThreads = 8;
BulkLoader loader = new BulkLoader(); BulkLoader loader = new BulkLoader();

View File

@ -17,6 +17,7 @@
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -66,6 +67,16 @@ class OrphanReaper implements Runnable
*/ */
private Thread fThread; private Thread fThread;
/**
* The maximum length of the queue.
*/
private int fQueueLength;
/**
* The linked list containing ids of nodes that are purgable.
*/
private LinkedList<Long> fPurgeQueue;
/** /**
* Create one with default parameters. * Create one with default parameters.
*/ */
@ -74,6 +85,7 @@ class OrphanReaper implements Runnable
fInactiveBaseSleep = 30000; fInactiveBaseSleep = 30000;
fActiveBaseSleep = 1000; fActiveBaseSleep = 1000;
fBatchSize = 50; fBatchSize = 50;
fQueueLength = 1000;
fActive = false; fActive = false;
fDone = false; fDone = false;
} }
@ -116,6 +128,15 @@ class OrphanReaper implements Runnable
fTransaction = transaction; fTransaction = transaction;
} }
/**
* Set the maximum size of the queue of purgeable nodes.
* @param queueLength The max length.
*/
public void setMaxQueueLength(int queueLength)
{
fQueueLength = queueLength;
}
/** /**
* Start things up after configuration is complete. * Start things up after configuration is complete.
*/ */
@ -131,7 +152,11 @@ class OrphanReaper implements Runnable
*/ */
void shutDown() void shutDown()
{ {
fDone = true; synchronized (this)
{
fDone = true;
notify();
}
try try
{ {
fThread.join(); fThread.join();
@ -150,15 +175,18 @@ class OrphanReaper implements Runnable
{ {
while (!fDone) while (!fDone)
{ {
try synchronized (this)
{ {
Thread.sleep(fActive ? fActiveBaseSleep : fInactiveBaseSleep); try
{
wait(fActive? fActiveBaseSleep : fInactiveBaseSleep);
}
catch (InterruptedException ie)
{
// Do nothing.
}
doBatch();
} }
catch (InterruptedException ie)
{
// Do nothing.
}
doBatch();
} }
} }
@ -189,15 +217,29 @@ class OrphanReaper implements Runnable
{ {
public void perform() public void perform()
{ {
List<AVMNode> nodes = AVMContext.fgInstance.fAVMNodeDAO.getOrphans(fBatchSize); if (fPurgeQueue == null)
if (nodes.size() == 0)
{ {
fActive = false; List<AVMNode> nodes = AVMContext.fgInstance.fAVMNodeDAO.getOrphans(fQueueLength);
return; if (nodes.size() == 0)
{
fActive = false;
return;
}
fPurgeQueue = new LinkedList<Long>();
for (AVMNode node : nodes)
{
fPurgeQueue.add(node.getId());
}
} }
fActive = true; fActive = true;
for (AVMNode node : nodes) for (int i = 0; i < fBatchSize; i++)
{ {
if (fPurgeQueue.size() == 0)
{
fPurgeQueue = null;
return;
}
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(fPurgeQueue.removeFirst());
// Save away the ancestor and merged from fields from this node. // Save away the ancestor and merged from fields from this node.
HistoryLink hlink = AVMContext.fgInstance.fHistoryLinkDAO.getByDescendent(node); HistoryLink hlink = AVMContext.fgInstance.fHistoryLinkDAO.getByDescendent(node);
AVMNode ancestor = null; AVMNode ancestor = null;

View File

@ -49,6 +49,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
{ {
super(store.getAVMRepository().issueID(), store); super(store.getAVMRepository().issueID(), store);
fContent = new FileContentImpl(AVMRepository.GetInstance().issueContentID()); fContent = new FileContentImpl(AVMRepository.GetInstance().issueContentID());
// AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInAVMStoreDAO.save(new NewInAVMStoreImpl(store, this)); AVMContext.fgInstance.fNewInAVMStoreDAO.save(new NewInAVMStoreImpl(store, this));

View File

@ -91,7 +91,7 @@
</class> </class>
<!-- Contents are objects to hang actual bytestreams off. They are explicitly reference <!-- Contents are objects to hang actual bytestreams off. They are explicitly reference
counted. --> counted. -->
<class table="contents" name="FileContentImpl" proxy="FileContent" <class table="avm_contents" name="FileContentImpl" proxy="FileContent"
optimistic-lock="version"> optimistic-lock="version">
<cache usage="read-write" /> <cache usage="read-write" />
<id name="id" column="id" type="long"/> <id name="id" column="id" type="long"/>
@ -119,7 +119,7 @@
column="current_root_id" unique="true" cascade="save-update"> column="current_root_id" unique="true" cascade="save-update">
</many-to-one> </many-to-one>
</class> </class>
<class name="VersionRootImpl" proxy="VersionRoot" table="version_roots"> <class name="VersionRootImpl" proxy="VersionRoot" table="avm_version_roots">
<!-- <cache usage="read-write"/> --> <!-- <cache usage="read-write"/> -->
<id column="id" type="long"> <id column="id" type="long">
<generator class="native"></generator> <generator class="native"></generator>
@ -139,7 +139,7 @@
column="root_id" not-null="true"> column="root_id" not-null="true">
</many-to-one> </many-to-one>
</class> </class>
<class name="ChildEntryImpl" proxy="ChildEntry" table="child_entries" optimistic-lock="version"> <class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries" optimistic-lock="version">
<cache usage="read-write"/> <cache usage="read-write"/>
<composite-id> <composite-id>
<key-property name="name" type="string" column="name"> <key-property name="name" type="string" column="name">
@ -152,7 +152,7 @@
not-null="true"> not-null="true">
</many-to-one> </many-to-one>
</class> </class>
<class table="deleted_children" name="DeletedChildImpl" proxy="DeletedChild"> <class table="avm_deleted_children" name="DeletedChildImpl" proxy="DeletedChild">
<cache usage="read-write"/> <cache usage="read-write"/>
<composite-id> <composite-id>
<key-property name="name" column="name" type="string"/> <key-property name="name" column="name" type="string"/>
@ -160,13 +160,13 @@
column="parent_id"/> column="parent_id"/>
</composite-id> </composite-id>
</class> </class>
<class name="HistoryLinkImpl" proxy="HistoryLink" table="history_links"> <class name="HistoryLinkImpl" proxy="HistoryLink" table="avm_history_links">
<composite-id> <composite-id>
<key-many-to-one name="ancestor" class="AVMNodeImpl" column="ancestor"/> <key-many-to-one name="ancestor" class="AVMNodeImpl" column="ancestor"/>
<key-many-to-one name="descendent" class="AVMNodeImpl" column="descendent"/> <key-many-to-one name="descendent" class="AVMNodeImpl" column="descendent"/>
</composite-id> </composite-id>
</class> </class>
<class name="MergeLinkImpl" proxy="MergeLink" table="merge_links"> <class name="MergeLinkImpl" proxy="MergeLink" table="avm_merge_links">
<composite-id> <composite-id>
<key-many-to-one name="mfrom" class="AVMNodeImpl" column="mfrom"/> <key-many-to-one name="mfrom" class="AVMNodeImpl" column="mfrom"/>
<key-many-to-one name="mto" class="AVMNodeImpl" column="mto"/> <key-many-to-one name="mto" class="AVMNodeImpl" column="mto"/>