mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user