ALF-11546 Tracking queries on alf_transaction table do not have an upper bound

- Part 2 - refactor API + collateral damage
- Fix tracking tests to cope with the presence of background transactions - should fix Oracle build and other intermittent build failures

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32824 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2011-12-16 19:35:21 +00:00
parent aac8f44c59
commit d7f79daba2
8 changed files with 367 additions and 244 deletions

View File

@@ -52,6 +52,12 @@
<if test="fromIdInclusive != null">
<![CDATA[and acs.id >= #{fromIdInclusive}]]>
</if>
<if test="toCommitTimeExclusive != null">
<![CDATA[acs.commit_time_ms < #{toCommitTimeExclusive}]]>
</if>
<if test="toIdExclusive != null">
<![CDATA[and acs.id < #{toIdExclusive}]]>
</if>
</where>
order by acs.commit_time_ms ASC, acs.id ASC
</select>
@@ -106,6 +112,12 @@
<if test="fromIdInclusive != null">
<![CDATA[and txn.id >= #{fromIdInclusive}]]>
</if>
<if test="toCommitTimeExclusive != null">
<![CDATA[txn.commit_time_ms < #{toCommitTimeExclusive}]]>
</if>
<if test="toIdExclusive != null">
<![CDATA[and txn.id < #{toIdExclusive}]]>
</if>
</where>
order by txn.commit_time_ms ASC, txn.id ASC
</select>

View File

@@ -38,10 +38,12 @@ public interface SOLRDAO
*
* @param minAclChangeSetId minimum ACL changeset ID - (inclusive and optional)
* @param fromCommitTime minimum ACL commit time - (inclusive and optional)
* @param maxAclChangeSetId maximum ACL changeset ID - (exclusive and optional)
* @param toCommitTime maximum ACL commit time - (exclusive and optional)
* @param maxResults limit the results (must be greater than zero and less than MAX)
* @return list of ACL changesets (no details)
*/
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, int maxResults);
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, Long maxAclChangeSetId, Long toCommitTime, int maxResults);
/**
* Get the ACLs (no rollup count) for the given ACL ChangeSets
@@ -58,10 +60,12 @@ public interface SOLRDAO
*
* @param minTxnId greater than or equal to minTxnId
* @param fromCommitTime greater than or equal to transaction commit time
* @param maxTxnId less than maxTxnId
* @param toCommitTime less than toCommitTime
* @param maxResults limit the results. 0 or Integer.MAX_VALUE does not limit the results
* @return list of transactions
*/
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, int maxResults);
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, Long maxTxnId, Long toCommitTime, int maxResults);
/**
* Get the nodes satisfying the constraints in nodeParameters

View File

@@ -64,7 +64,7 @@ public class SOLRDAOTest extends TestCase
try
{
solrDAO.getAclChangeSets(null, startTime, 0);
solrDAO.getAclChangeSets(null, startTime, null, null, 0);
fail("Must have result limit");
}
catch (IllegalArgumentException e)
@@ -76,13 +76,13 @@ public class SOLRDAOTest extends TestCase
public void testQueryChangeSets_Time()
{
long startTime = System.currentTimeMillis() + (5 * 60000L); // The future
List<AclChangeSet> results = solrDAO.getAclChangeSets(null, startTime, 50);
List<AclChangeSet> results = solrDAO.getAclChangeSets(null, startTime, null, null, 50);
assertTrue("ChangeSet count not limited", results.size() == 0);
}
public void testQueryChangeSets_Limit()
{
List<AclChangeSet> results = solrDAO.getAclChangeSets(null, 0L, 50);
List<AclChangeSet> results = solrDAO.getAclChangeSets(null, 0L, null, null, 50);
assertTrue("Transaction count not limited", results.size() <= 50);
}
@@ -116,7 +116,7 @@ public class SOLRDAOTest extends TestCase
public void testQueryAcls_All()
{
// Do a query for some changesets
List<AclChangeSet> aclChangeSets = solrDAO.getAclChangeSets(null, 0L, 50);
List<AclChangeSet> aclChangeSets = solrDAO.getAclChangeSets(null, 0L, null, null, 50);
// Choose some changesets with changes
int aclTotal = 0;
@@ -155,7 +155,7 @@ public class SOLRDAOTest extends TestCase
public void testQueryAcls_Single()
{
List<AclChangeSet> aclChangeSets = solrDAO.getAclChangeSets(null, 0L, 1000);
List<AclChangeSet> aclChangeSets = solrDAO.getAclChangeSets(null, 0L, null, null, 1000);
// Find one with multiple ALCs
AclChangeSet aclChangeSet = null;
for (AclChangeSet aclChangeSetLoop : aclChangeSets)
@@ -208,7 +208,7 @@ public class SOLRDAOTest extends TestCase
try
{
solrDAO.getTransactions(null, startTime, 0);
solrDAO.getTransactions(null, startTime, null, null, 0);
fail("Must have result limit");
}
catch (IllegalArgumentException e)
@@ -220,13 +220,13 @@ public class SOLRDAOTest extends TestCase
public void testQueryTransactions_Time()
{
long startTime = System.currentTimeMillis() + (5 * 60000L); // The future
List<Transaction> results = solrDAO.getTransactions(null, startTime, 50);
List<Transaction> results = solrDAO.getTransactions(null, startTime, null, null, 50);
assertTrue("Transaction count not limited", results.size() == 0);
}
public void testQueryTransactions_Limit()
{
List<Transaction> results = solrDAO.getTransactions(null, 0L, 50);
List<Transaction> results = solrDAO.getTransactions(null, 0L, null, null, 50);
assertTrue("Transaction count not limited", results.size() <= 50);
}
@@ -234,7 +234,7 @@ public class SOLRDAOTest extends TestCase
{
long startTime = 0L;
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 500);
List<Transaction> txns = solrDAO.getTransactions(null, startTime, null, null, 500);
List<Long> txnIds = toTxnIds(txns);
@@ -249,7 +249,7 @@ public class SOLRDAOTest extends TestCase
public void testGetNodesForStore()
{
List<Transaction> txns = solrDAO.getTransactions(null, null, 500);
List<Transaction> txns = solrDAO.getTransactions(null, null, null, null, 500);
List<Long> txnIds = toTxnIds(txns);
@@ -262,7 +262,7 @@ public class SOLRDAOTest extends TestCase
public void testGetNodesForTxnRange()
{
List<Transaction> txns = solrDAO.getTransactions(null, null, 500);
List<Transaction> txns = solrDAO.getTransactions(null, null, null, null, 500);
List<Long> txnIds = toTxnIds(txns);

View File

@@ -31,8 +31,9 @@ public class SOLRTrackingParameters
private Long fromIdInclusive;
private Long fromCommitTimeInclusive;
private List<Long> ids;
private Long fromRelatedIdInclusive;
private Long toRelatedIdExclusive;
private Long toIdExclusive;
private Long toCommitTimeExclusive;
private boolean trueOrFalse;
public Long getFromIdInclusive()
@@ -65,26 +66,6 @@ public class SOLRTrackingParameters
this.ids = ids;
}
public Long getFromRelatedIdInclusive()
{
return fromRelatedIdInclusive;
}
public void setFromRelatedIdInclusive(Long fromRelatedIdInclusive)
{
this.fromRelatedIdInclusive = fromRelatedIdInclusive;
}
public Long getToRelatedIdExclusive()
{
return toRelatedIdExclusive;
}
public void setToRelatedIdExclusive(Long toRelatedIdExclusive)
{
this.toRelatedIdExclusive = toRelatedIdExclusive;
}
/**
* Helper for cross-DB boolean support
*
@@ -121,17 +102,97 @@ public class SOLRTrackingParameters
this.trueOrFalse = trueOrFalse;
}
public Long getToIdExclusive()
{
return toIdExclusive;
}
public void setToIdExclusive(Long toIdExclusive)
{
this.toIdExclusive = toIdExclusive;
}
public Long getToCommitTimeExclusive()
{
return toCommitTimeExclusive;
}
public void setToCommitTimeExclusive(Long toCommitTimeExclusive)
{
this.toCommitTimeExclusive = toCommitTimeExclusive;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((fromCommitTimeInclusive == null) ? 0 : fromCommitTimeInclusive.hashCode());
result = prime * result + ((fromIdInclusive == null) ? 0 : fromIdInclusive.hashCode());
result = prime * result + ((ids == null) ? 0 : ids.hashCode());
result = prime * result + ((toCommitTimeExclusive == null) ? 0 : toCommitTimeExclusive.hashCode());
result = prime * result + ((toIdExclusive == null) ? 0 : toIdExclusive.hashCode());
result = prime * result + (trueOrFalse ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SOLRTrackingParameters other = (SOLRTrackingParameters) obj;
if (fromCommitTimeInclusive == null)
{
if (other.fromCommitTimeInclusive != null)
return false;
}
else if (!fromCommitTimeInclusive.equals(other.fromCommitTimeInclusive))
return false;
if (fromIdInclusive == null)
{
if (other.fromIdInclusive != null)
return false;
}
else if (!fromIdInclusive.equals(other.fromIdInclusive))
return false;
if (ids == null)
{
if (other.ids != null)
return false;
}
else if (!ids.equals(other.ids))
return false;
if (toCommitTimeExclusive == null)
{
if (other.toCommitTimeExclusive != null)
return false;
}
else if (!toCommitTimeExclusive.equals(other.toCommitTimeExclusive))
return false;
if (toIdExclusive == null)
{
if (other.toIdExclusive != null)
return false;
}
else if (!toIdExclusive.equals(other.toIdExclusive))
return false;
if (trueOrFalse != other.trueOrFalse)
return false;
return true;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder(512);
sb.append("SOLRTrackingParameters")
.append(", fromIdInclusive").append(fromIdInclusive)
.append(", ids").append(ids == null ? null : ids.size())
.append(", fromCommitTimeInclusive").append(fromCommitTimeInclusive == null ? null : new Date(fromCommitTimeInclusive))
.append(", fromRelatedIdInclusive=").append(fromRelatedIdInclusive)
.append(", toRelatedIdExclusive").append(toRelatedIdExclusive)
.append("]");
return sb.toString();
return "SOLRTrackingParameters [fromIdInclusive="
+ fromIdInclusive + ", fromCommitTimeInclusive=" + fromCommitTimeInclusive + ", ids=" + ids + ", toIdExclusive=" + toIdExclusive + ", toCommitTimeExclusive="
+ toCommitTimeExclusive + ", trueOrFalse=" + trueOrFalse + "]";
}
}

View File

@@ -72,7 +72,7 @@ public class SOLRDAOImpl implements SOLRDAO
*/
@Override
@SuppressWarnings("unchecked")
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, int maxResults)
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, Long maxAclChangeSetId, Long toCommitTime, int maxResults)
{
if (maxResults <= 0 || maxResults == Integer.MAX_VALUE)
{
@@ -82,6 +82,8 @@ public class SOLRDAOImpl implements SOLRDAO
SOLRTrackingParameters params = new SOLRTrackingParameters();
params.setFromIdInclusive(minAclChangeSetId);
params.setFromCommitTimeInclusive(fromCommitTime);
params.setToIdExclusive(maxAclChangeSetId);
params.setToCommitTimeExclusive(toCommitTime);
return (List<AclChangeSet>) template.selectList(SELECT_CHANGESETS_SUMMARY, params, new RowBounds(0, maxResults));
}
@@ -118,7 +120,7 @@ public class SOLRDAOImpl implements SOLRDAO
*/
@Override
@SuppressWarnings("unchecked")
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, int maxResults)
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, Long maxTxnId, Long toCommitTime, int maxResults)
{
if (maxResults <= 0 || maxResults == Integer.MAX_VALUE)
{
@@ -128,6 +130,8 @@ public class SOLRDAOImpl implements SOLRDAO
SOLRTrackingParameters params = new SOLRTrackingParameters();
params.setFromIdInclusive(minTxnId);
params.setFromCommitTimeInclusive(fromCommitTime);
params.setToIdExclusive(maxTxnId);
params.setToCommitTimeExclusive(toCommitTime);
return (List<Transaction>) template.selectList(SELECT_TRANSACTIONS, params, new RowBounds(0, maxResults));
}

View File

@@ -36,10 +36,12 @@ public interface SOLRTrackingComponent
*
* @param minAclChangeSetId minimum ACL changeset ID - (inclusive and optional)
* @param fromCommitTime minimum ACL commit time - (inclusive and optional)
* @param maxAclChangeSetId max ACL changeset ID - (exclusive and optional)
* @param toCommitTime max ACL commit time - (exclusive and optional)
* @param maxResults limit the results. 0 or Integer.MAX_VALUE does not limit the results
* @return list of ACL changesets
*/
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, int maxResults);
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, Long maxAclChangeSetId, Long toCommitTime, int maxResults);
/**
* Get the ACLs with paging options for a specific ACL ChangeSet
@@ -64,10 +66,12 @@ public interface SOLRTrackingComponent
*
* @param minTxnId greater than or equal to minTxnId
* @param fromCommitTime greater than or equal to transaction commit time
* @param maxTxnId less than maxTxnId
* @param toCommitTimeint less then toCommitTimeint
* @param maxResults limit the results. 0 or Integer.MAX_VALUE does not limit the results
* @return list of transactions
*/
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, int maxResults);
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, Long maxTxnId, Long toCommitTimeint, int maxResults);
/**
* Get the nodes satisfying the constraints in nodeParameters

View File

@@ -150,11 +150,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
}
@Override
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, int maxResults)
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, Long maxAclChangeSetId, Long toCommitTime, int maxResults)
{
if(enabled)
{
List<AclChangeSet> changesets = solrDAO.getAclChangeSets(minAclChangeSetId, fromCommitTime, maxResults);
List<AclChangeSet> changesets = solrDAO.getAclChangeSets(minAclChangeSetId, fromCommitTime, maxAclChangeSetId, toCommitTime, maxResults);
return changesets;
}
else
@@ -272,11 +272,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
}
@Override
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, int maxResults)
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, Long maxTxnId, Long toCommitTime, int maxResults)
{
if(enabled)
{
List<Transaction> txns = solrDAO.getTransactions(minTxnId, fromCommitTime, maxResults);
List<Transaction> txns = solrDAO.getTransactions(minTxnId, fromCommitTime, maxTxnId, toCommitTime, maxResults);
return txns;
}
else

View File

@@ -23,6 +23,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -111,7 +112,7 @@ public class SOLRTrackingComponentTest extends TestCase
public void testGetAcls_Simple()
{
List<AclChangeSet> cs = solrTrackingComponent.getAclChangeSets(null, null, 50);
List<AclChangeSet> cs = solrTrackingComponent.getAclChangeSets(null, null, null, null, 50);
assertTrue("Expected results to be limited in number", cs.size() <= 50);
List<Long> aclChangeSetIds = new ArrayList<Long>(50);
int totalAcls = 0;
@@ -141,13 +142,13 @@ public class SOLRTrackingComponentTest extends TestCase
long startTime = System.currentTimeMillis();
SOLRTest st = new SOLRTest3(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testGetNodeMetaData", true, true);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, null, null, 50);
int[] updates = new int[] {1, 1};
int[] deletes = new int[] {0, 1};
List<Long> txnIds = checkTransactions(txns, 2, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
@@ -163,13 +164,13 @@ public class SOLRTrackingComponentTest extends TestCase
long startTime = System.currentTimeMillis();
SOLRTest st = new SOLRTestResidualProperties(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testNodeMetaDataNullPropertyValue", true, true);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, null, null, 50);
int[] updates = new int[] {2};
int[] deletes = new int[] {0};
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
@@ -187,19 +188,19 @@ public class SOLRTrackingComponentTest extends TestCase
long startTime = System.currentTimeMillis();
SOLRTest st = new SOLRTest100Nodes(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testGetNodeMetaData", true, true);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, null, null, 50);
int[] updates = new int[] {100};
int[] deletes = new int[] {0};
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
getNodes(nodeParameters, st);
// assertEquals("Unxpected number of nodes", 3, nodeQueryCallback.getSuccessCount());
// assertEquals("Unxpected number of nodes", 3, nodeQueryCallback.getSuccessCount());
NodeMetaDataParameters nodeMetaDataParams = new NodeMetaDataParameters();
nodeMetaDataParams.setNodeIds(st.getNodeIds());
@@ -208,7 +209,7 @@ public class SOLRTrackingComponentTest extends TestCase
nodeMetaDataParams.setMaxResults(20);
getNodeMetaData(nodeMetaDataParams, null, st);
// assertEquals("Unxpected number of nodes", 3, bt.getSuccessCount());
// assertEquals("Unxpected number of nodes", 3, bt.getSuccessCount());
}
public void testNodeMetaDataManyNodes() throws Exception
@@ -216,13 +217,13 @@ public class SOLRTrackingComponentTest extends TestCase
long fromCommitTime = System.currentTimeMillis();
SOLRTest st = new SOLRTest4(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testNodeMetaDataManyNodes", true, false);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, fromCommitTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, fromCommitTime, null, null, 50);
int[] updates = new int[] {2001};
int[] deletes = new int[] {0};
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
@@ -273,13 +274,13 @@ public class SOLRTrackingComponentTest extends TestCase
long fromCommitTime = System.currentTimeMillis();
SOLRTest st = new SOLRTest4(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testNodeMetaDataManyNodes", true, false);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, fromCommitTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, fromCommitTime, null, null, 50);
int[] updates = new int[] {2001};
int[] deletes = new int[] {0};
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
@@ -303,13 +304,13 @@ public class SOLRTrackingComponentTest extends TestCase
long fromCommitTime = System.currentTimeMillis();
SOLRTest st = new SOLRTest5(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testNodeMetaDataNullPropertyValue", true, true);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, fromCommitTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, fromCommitTime, null, null, 50);
int[] updates = new int[] {11};
int[] deletes = new int[] {0};
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
@@ -325,13 +326,13 @@ public class SOLRTrackingComponentTest extends TestCase
long startTime = System.currentTimeMillis();
SOLRTest st = new SOLRTest1(txnHelper, fileFolderService, nodeDAO, nodeService, dictionaryService, rootNodeRef, "testFilters", true, true);
st.buildTransactions();
List<Long> createdTransactions = st.buildTransactions();
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, 50);
List<Transaction> txns = solrTrackingComponent.getTransactions(null, startTime, null, null, 50);
int[] updates = new int[] {1, 1};
int[] deletes = new int[] {0, 1};
List<Long> txnIds = checkTransactions(txns, 2, updates, deletes);
List<Long> txnIds = checkTransactions(txns, createdTransactions, updates, deletes);
NodeParameters nodeParameters = new NodeParameters();
nodeParameters.setTransactionIds(txnIds);
@@ -547,9 +548,23 @@ public class SOLRTrackingComponentTest extends TestCase
}
}
private List<Long> checkTransactions(List<Transaction> txns, int numTransactions, int[] updates, int[] deletes)
private List<Long> checkTransactions(List<Transaction> txns, List<Long> createdTransaction, int[] updates, int[] deletes)
{
assertEquals("Number of transactions is incorrect", numTransactions, txns.size());
ArrayList<Transaction> matchedTransactions = new ArrayList<Transaction>();
HashSet<Long> toMatch = new HashSet<Long>();
toMatch.addAll(createdTransaction);
for(Transaction found : txns)
{
if(found != null)
{
if(toMatch.contains(found.getId()))
{
matchedTransactions.add(found);
}
}
}
assertEquals("Number of transactions is incorrect", createdTransaction.size(), txns.size());
List<Long> txnIds = new ArrayList<Long>(txns.size());
int i = 0;
@@ -695,7 +710,7 @@ public class SOLRTrackingComponentTest extends TestCase
}
protected abstract int getExpectedNumNodes();
protected abstract void buildTransactionsInternal();
protected abstract List<Long> buildTransactionsInternal();
public NodeAssertions getNodeAssertions(NodeRef nodeRef)
{
@@ -722,9 +737,9 @@ public class SOLRTrackingComponentTest extends TestCase
}
}
void buildTransactions()
List<Long> buildTransactions()
{
buildTransactionsInternal();
return buildTransactionsInternal();
}
@Override
@@ -791,7 +806,7 @@ public class SOLRTrackingComponentTest extends TestCase
assertEquals("Properties are incorrect", actualProperties, properties);
NodeAssertions assertions = getNodeAssertions(nodeRef);
// NodeAssertions assertions = nodes.get(nodeRef);
// NodeAssertions assertions = nodes.get(nodeRef);
Set<QName> expectedAspects = assertions.getAspects();
if(expectedAspects != null)
@@ -815,9 +830,9 @@ public class SOLRTrackingComponentTest extends TestCase
}
// TODO complete path tests
// List<Path> actualPaths = nodeMetaData.getPaths();
// List<Path> expectedPaths = nodeService.getPaths(nodeRef, false);
// assertEquals("Paths are incorrect", expectedPaths, actualPaths);
// List<Path> actualPaths = nodeMetaData.getPaths();
// List<Path> expectedPaths = nodeService.getPaths(nodeRef, false);
// assertEquals("Paths are incorrect", expectedPaths, actualPaths);
boolean expectAspects = assertions.isExpectAspects();
if(expectAspects && nodeMetaData.getAspects() == null)
@@ -929,11 +944,13 @@ public class SOLRTrackingComponentTest extends TestCase
return 3;
}
protected void buildTransactionsInternal()
protected List<Long> buildTransactionsInternal()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
ArrayList<Long> txs = new ArrayList<Long>(2);
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, "Container1");
@@ -947,26 +964,27 @@ public class SOLRTrackingComponentTest extends TestCase
FileInfo contentInfo = fileFolderService.create(container, "Content1", ContentModel.TYPE_CONTENT);
content1 = contentInfo.getNodeRef();
return null;
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
}
});
}));
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
FileInfo contentInfo = fileFolderService.create(container, "Content2", ContentModel.TYPE_CONTENT);
content2 = contentInfo.getNodeRef();
fileFolderService.delete(content1);
return null;
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
}
});
}));
setExpectedNodeStatus(container, NodeStatus.UPDATED);
setExpectedNodeStatus(content1, NodeStatus.DELETED);
setExpectedNodeStatus(content2, NodeStatus.UPDATED);
return txs;
}
}
@@ -987,11 +1005,13 @@ public class SOLRTrackingComponentTest extends TestCase
return 3;
}
protected void buildTransactionsInternal()
protected List<Long> buildTransactionsInternal()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
ArrayList<Long> txs = new ArrayList<Long>(2);
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, "Container1");
@@ -1009,13 +1029,13 @@ public class SOLRTrackingComponentTest extends TestCase
aspectProperties.put(ContentModel.PROP_AUTHOR, "steve");
nodeService.addAspect(content1, ContentModel.ASPECT_AUTHOR, aspectProperties);
return null;
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
}
});
}));
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
FileInfo contentInfo = fileFolderService.create(container, "Content2", ContentModel.TYPE_CONTENT);
content2 = contentInfo.getNodeRef();
@@ -1023,13 +1043,15 @@ public class SOLRTrackingComponentTest extends TestCase
nodeService.addAspect(content2, ContentModel.ASPECT_TEMPORARY, null);
fileFolderService.delete(content1);
return null;
return nodeDAO.getNodeRefStatus(content1).getDbTxnId();
}
});
}));
setExpectedNodeStatus(container, NodeStatus.UPDATED);
setExpectedNodeStatus(content1, NodeStatus.DELETED);
setExpectedNodeStatus(content2, NodeStatus.UPDATED);
return txs;
}
}
@@ -1046,11 +1068,13 @@ public class SOLRTrackingComponentTest extends TestCase
return 100;
}
protected void buildTransactionsInternal()
protected List<Long> buildTransactionsInternal()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
ArrayList<Long> txs = new ArrayList<Long>(2);
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, "Container100Nodes");
@@ -1070,9 +1094,10 @@ public class SOLRTrackingComponentTest extends TestCase
setExpectedNodeStatus(nodeRef, NodeStatus.UPDATED);
}
return null;
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
}
});
}));
return txs;
}
}
@@ -1091,11 +1116,13 @@ public class SOLRTrackingComponentTest extends TestCase
return numContentNodes + 1;
}
public void buildTransactionsInternal()
public List<Long> buildTransactionsInternal()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
ArrayList<Long> txs = new ArrayList<Long>(2);
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, containerName);
@@ -1121,10 +1148,12 @@ public class SOLRTrackingComponentTest extends TestCase
setExpectedNodeStatus(nodeRef, NodeStatus.UPDATED);
}
return null;
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
}
});
}));
return txs;
}
}
private static class SOLRTest5 extends SOLRTest
@@ -1142,16 +1171,18 @@ public class SOLRTrackingComponentTest extends TestCase
return numContentNodes + 1;
}
public void buildTransactionsInternal()
public List<Long> buildTransactionsInternal()
{
ArrayList<Long> txs = new ArrayList<Long>(2);
final String titles[] =
{
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6",
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6"
};
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, containerName);
@@ -1183,9 +1214,11 @@ public class SOLRTrackingComponentTest extends TestCase
setExpectedNodeStatus(nodeRef, NodeStatus.UPDATED);
}
return null;
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
}
});
}));
return txs;
}
}
@@ -1206,11 +1239,13 @@ public class SOLRTrackingComponentTest extends TestCase
return 2;
}
protected void buildTransactionsInternal()
protected List<Long> buildTransactionsInternal()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
ArrayList<Long> txs = new ArrayList<Long>(2);
txs.add(txnHelper.doInTransaction(new RetryingTransactionCallback<Long>()
{
public Void execute() throws Throwable
public Long execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, "ContainerResidual");
@@ -1225,12 +1260,15 @@ public class SOLRTrackingComponentTest extends TestCase
content = contentInfo.getNodeRef();
nodeService.setProperty(content, QName.createQName("{rubbish}rubbish"), "Rubbish");
return null;
return nodeDAO.getNodeRefStatus(container).getDbTxnId();
}
});
}));
setExpectedNodeStatus(container, NodeStatus.UPDATED);
setExpectedNodeStatus(content, NodeStatus.UPDATED);
return txs;
}
}
}