Merged V2.1 to HEAD

6950: Fix for forum issue (6111) when using xsl:include
   6951: Partial fix for WCM-862
   6952: Merged V1.4 to V2.1
      6921: Reindex tracking refactoring.
   6954: Merged V1.4 to V2.1
      6927: Config and startup changes for index tracking


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7369 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-11-12 23:52:46 +00:00
parent 209dd85a0d
commit e82c2cd946
22 changed files with 824 additions and 456 deletions

View File

@@ -294,14 +294,31 @@ public interface NodeDaoService
public int getNodeCount(final StoreRef storeRef);
public Transaction getTxnById(long txnId);
public Transaction getLastTxn();
public Transaction getLastRemoteTxn();
public Transaction getLastTxnForStore(final StoreRef storeRef);
/**
* Get all transactions in a given time range. Since time-based retrieval doesn't guarantee uniqueness
* for any given millisecond, a list of optional exclusions may be provided.
*
* @param excludeTxnIds a list of txn IDs to ignore. <tt>null</tt> is allowed.
*/
public List<Transaction> getTxnsByCommitTimeAscending(
long fromTimeInclusive,
long toTimeExclusive,
int count,
List<Long> excludeTxnIds);
/**
* Get all transactions in a given time range. Since time-based retrieval doesn't guarantee uniqueness
* for any given millisecond, a list of optional exclusions may be provided.
*
* @param excludeTxnIds a list of txn IDs to ignore. <tt>null</tt> is allowed.
*/
public List<Transaction> getTxnsByCommitTimeDescending(
long fromTimeInclusive,
long toTimeExclusive,
int count,
List<Long> excludeTxnIds);
public int getTxnUpdateCount(final long txnId);
public int getTxnDeleteCount(final long txnId);
public int getTransactionCount();
public List<Transaction> getNextTxns(final long lastTxnId, final int count);
public List<Transaction> getNextRemoteTxns(final long lastTxnId, final int count);
public List<NodeRef> getTxnChangesForStore(final StoreRef storeRef, final long txnId);
public List<NodeRef> getTxnChanges(final long txnId);
}

View File

@@ -287,6 +287,20 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
return transaction;
}
/**
* Ensure that any transaction that might be present is updated to reflect the current time.
*/
public void beforeCommit()
{
Serializable txnId = (Serializable) AlfrescoTransactionSupport.getResource(RESOURCE_KEY_TRANSACTION_ID);
if (txnId != null)
{
// A write was done during the current transaction
Transaction transaction = (Transaction) getHibernateTemplate().get(TransactionImpl.class, txnId);
transaction.setCommitTimeMs(System.currentTimeMillis());
}
}
/**
* Does this <tt>Session</tt> contain any changes which must be
* synchronized with the store?
@@ -1417,14 +1431,11 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
/*
* Queries for transactions
*/
private static final String QUERY_GET_LAST_TXN_ID = "txn.GetLastTxnId";
private static final String QUERY_GET_LAST_REMOTE_TXN_ID = "txn.GetLastRemoteTxnId";
private static final String QUERY_GET_LAST_TXN_ID_FOR_STORE = "txn.GetLastTxnIdForStore";
private static final String QUERY_GET_TXNS_BY_COMMIT_TIME_ASC = "txn.GetTxnsByCommitTimeAsc";
private static final String QUERY_GET_TXNS_BY_COMMIT_TIME_DESC = "txn.GetTxnsByCommitTimeDesc";
private static final String QUERY_GET_TXN_UPDATE_COUNT_FOR_STORE = "txn.GetTxnUpdateCountForStore";
private static final String QUERY_GET_TXN_DELETE_COUNT_FOR_STORE = "txn.GetTxnDeleteCountForStore";
private static final String QUERY_COUNT_TRANSACTIONS = "txn.CountTransactions";
private static final String QUERY_GET_NEXT_TXNS = "txn.GetNextTxns";
private static final String QUERY_GET_NEXT_REMOTE_TXNS = "txn.GetNextRemoteTxns";
private static final String QUERY_GET_TXN_CHANGES_FOR_STORE = "txn.GetTxnChangesForStore";
private static final String QUERY_GET_TXN_CHANGES = "txn.GetTxnChanges";
@@ -1433,78 +1444,6 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
return (Transaction) getSession().get(TransactionImpl.class, new Long(txnId));
}
@SuppressWarnings("unchecked")
public Transaction getLastTxn()
{
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(QUERY_GET_LAST_TXN_ID);
query.setMaxResults(1)
.setReadOnly(true);
return query.uniqueResult();
}
};
Long txnId = (Long) getHibernateTemplate().execute(callback);
Transaction txn = null;
if (txnId != null)
{
txn = (Transaction) getSession().get(TransactionImpl.class, txnId);
}
// done
return txn;
}
@SuppressWarnings("unchecked")
public Transaction getLastRemoteTxn()
{
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(QUERY_GET_LAST_REMOTE_TXN_ID);
query.setString("serverIpAddress", ipAddress)
.setMaxResults(1)
.setReadOnly(true);
return query.uniqueResult();
}
};
Long txnId = (Long) getHibernateTemplate().execute(callback);
Transaction txn = null;
if (txnId != null)
{
txn = (Transaction) getSession().get(TransactionImpl.class, txnId);
}
// done
return txn;
}
@SuppressWarnings("unchecked")
public Transaction getLastTxnForStore(final StoreRef storeRef)
{
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(QUERY_GET_LAST_TXN_ID_FOR_STORE);
query.setString("protocol", storeRef.getProtocol())
.setString("identifier", storeRef.getIdentifier())
.setMaxResults(1)
.setReadOnly(true);
return query.uniqueResult();
}
};
Long txnId = (Long) getHibernateTemplate().execute(callback);
Transaction txn = null;
if (txnId != null)
{
txn = (Transaction) getSession().get(TransactionImpl.class, txnId);
}
// done
return txn;
}
@SuppressWarnings("unchecked")
public int getTxnUpdateCount(final long txnId)
{
@@ -1559,15 +1498,32 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
return count.intValue();
}
private static final Long TXN_ID_DUD = Long.valueOf(-1L);
@SuppressWarnings("unchecked")
public List<Transaction> getNextTxns(final long lastTxnId, final int count)
public List<Transaction> getTxnsByCommitTimeAscending(
final long fromTimeInclusive,
final long toTimeExclusive,
final int count,
List<Long> excludeTxnIds)
{
// Make sure that we have at least one entry in the exclude list
final List<Long> excludeTxnIdsInner = new ArrayList<Long>(excludeTxnIds == null ? 1 : excludeTxnIds.size());
if (excludeTxnIds == null || excludeTxnIds.isEmpty())
{
excludeTxnIdsInner.add(TXN_ID_DUD);
}
else
{
excludeTxnIdsInner.addAll(excludeTxnIds);
}
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(QUERY_GET_NEXT_TXNS);
query.setLong("lastTxnId", lastTxnId)
Query query = session.getNamedQuery(QUERY_GET_TXNS_BY_COMMIT_TIME_ASC);
query.setLong("fromTimeInclusive", fromTimeInclusive)
.setLong("toTimeExclusive", toTimeExclusive)
.setParameterList("excludeTxnIds", excludeTxnIdsInner)
.setMaxResults(count)
.setReadOnly(true);
return query.list();
@@ -1579,15 +1535,30 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
}
@SuppressWarnings("unchecked")
public List<Transaction> getNextRemoteTxns(final long lastTxnId, final int count)
public List<Transaction> getTxnsByCommitTimeDescending(
final long fromTimeInclusive,
final long toTimeExclusive,
final int count,
List<Long> excludeTxnIds)
{
// Make sure that we have at least one entry in the exclude list
final List<Long> excludeTxnIdsInner = new ArrayList<Long>(excludeTxnIds == null ? 1 : excludeTxnIds.size());
if (excludeTxnIds == null || excludeTxnIds.isEmpty())
{
excludeTxnIdsInner.add(TXN_ID_DUD);
}
else
{
excludeTxnIdsInner.addAll(excludeTxnIds);
}
HibernateCallback callback = new HibernateCallback()
{
public Object doInHibernate(Session session)
{
Query query = session.getNamedQuery(QUERY_GET_NEXT_REMOTE_TXNS);
query.setLong("lastTxnId", lastTxnId)
.setString("serverIpAddress", ipAddress)
Query query = session.getNamedQuery(QUERY_GET_TXNS_BY_COMMIT_TIME_DESC);
query.setLong("fromTimeInclusive", fromTimeInclusive)
.setLong("toTimeExclusive", toTimeExclusive)
.setParameterList("excludeTxnIds", excludeTxnIdsInner)
.setMaxResults(count)
.setReadOnly(true);
return query.list();