Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-06-13 06:47:16 +0000
committerEike Stepper2010-06-13 06:47:16 +0000
commit60e972eecdad05bd01a0b05ebf752ffe4cd62bed (patch)
tree1f206b64f978c4eefd9c8df41b7b4a7139cabb1d
parent24b69d6c0f81543447c18f2de918d921c713fcb7 (diff)
downloadcdo-60e972eecdad05bd01a0b05ebf752ffe4cd62bed.tar.gz
cdo-60e972eecdad05bd01a0b05ebf752ffe4cd62bed.tar.xz
cdo-60e972eecdad05bd01a0b05ebf752ffe4cd62bed.zip
[312632] Local repository was not gracefully shut down
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312632
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/Store.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java1
-rw-r--r--plugins/org.gastro.server/src/org/gastro/internal/server/OM.java2
13 files changed, 100 insertions, 26 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index d3bca47ffb..ded9774a24 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -84,6 +84,8 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
private static final String PROP_LAST_COMMITTIME = "org.eclipse.emf.cdo.server.db.lastCommitTime"; //$NON-NLS-1$
+ private static final String PROP_LAST_NONLOCAL_COMMITTIME = "org.eclipse.emf.cdo.server.db.lastNonLocalCommitTime"; //$NON-NLS-1$
+
private static final String PROP_GRACEFULLY_SHUT_DOWN = "org.eclipse.emf.cdo.server.db.gracefullyShutDown"; //$NON-NLS-1$
private long creationTime;
@@ -487,6 +489,7 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
map.put(PROP_LAST_BRANCHID, Integer.toString(getLastBranchID()));
map.put(PROP_LAST_LOCAL_BRANCHID, Integer.toString(getLastLocalBranchID()));
map.put(PROP_LAST_COMMITTIME, Long.toString(getLastCommitTime()));
+ map.put(PROP_LAST_NONLOCAL_COMMITTIME, Long.toString(getLastNonLocalCommitTime()));
setPropertyValues(map);
readerPool.dispose();
@@ -528,6 +531,7 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
names.add(PROP_LAST_BRANCHID);
names.add(PROP_LAST_LOCAL_BRANCHID);
names.add(PROP_LAST_COMMITTIME);
+ names.add(PROP_LAST_NONLOCAL_COMMITTIME);
map = getPropertyValues(names);
setNextLocalObjectID(Long.valueOf(map.get(PROP_NEXT_LOCAL_CDOID)));
@@ -536,6 +540,7 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
setLastBranchID(Integer.valueOf(map.get(PROP_LAST_BRANCHID)));
setLastLocalBranchID(Integer.valueOf(map.get(PROP_LAST_LOCAL_BRANCHID)));
setLastCommitTime(Long.valueOf(map.get(PROP_LAST_COMMITTIME)));
+ setLastNonLocalCommitTime(Long.valueOf(map.get(PROP_LAST_NONLOCAL_COMMITTIME)));
}
else
{
@@ -558,6 +563,7 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
setLastLocalBranchID(localBranchID < 0 ? localBranchID : 0);
setLastCommitTime(result[2]);
+ setLastNonLocalCommitTime(result[3]);
OM.LOG.info(MessageFormat.format(Messages.getString("DBStore.10"), getLastObjectID(), getLastMetaID())); //$NON-NLS-1$
}
catch (SQLException e)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
index 7cfc649e94..f89e709464 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
@@ -11,6 +11,7 @@
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
@@ -79,9 +80,9 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
{
long minLocalID = getMinLocalID(connection);
long maxID = objectTypeCache.getMaxID(connection);
- long maxTime = getMaxTime(connection);
+ long[] maxTimes = getMaxTimes(connection);
- long[] result = { minLocalID, maxID, maxTime };
+ long[] result = { minLocalID, maxID, maxTimes[0], maxTimes[1] };
return result;
}
@@ -302,9 +303,12 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
return min;
}
- private long getMaxTime(Connection connection)
+ private long[] getMaxTimes(Connection connection)
{
long max = CDORevision.UNSPECIFIED_DATE;
+ long maxNonLocal = CDORevision.UNSPECIFIED_DATE;
+ final String where = CDODBSchema.ATTRIBUTES_BRANCH + ">=" + CDOBranch.MAIN_BRANCH_ID;
+
for (IClassMapping classMapping : getClassMappings().values())
{
IDBTable table = classMapping.getDBTables().get(0);
@@ -314,8 +318,14 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
{
max = timeStamp;
}
+
+ timeStamp = DBUtil.selectMaximumLong(connection, field, where);
+ if (timeStamp > maxNonLocal)
+ {
+ maxNonLocal = timeStamp;
+ }
}
- return max;
+ return new long[] { max, maxNonLocal };
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index 8b67652285..0579da9631 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -34,6 +34,7 @@ import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.internal.common.commit.CDOCommitDataImpl;
import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.emf.cdo.server.IRepository.Props;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
@@ -624,7 +625,7 @@ public class TransactionCommitContext implements InternalCommitContext
private boolean isAutoLockNewTargetsEnabled(InternalRepository repository)
{
- String value = repository.getProperties().get(PROP_AUTO_LOCK_NEW_TARGETS);
+ String value = repository.getProperties().get(Props.AUTO_LOCK_NEW_TARGETS);
return value == null ? false : Boolean.valueOf(value);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
index feb6acb30b..3ff1e04ed8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
@@ -245,22 +245,22 @@ public abstract class SynchronizableRepository extends Repository.Default implem
Map<String, String> map = store.getPropertyValues(Collections.singleton(PROP_GRACEFULLY_SHUT_DOWN));
if (!map.containsKey(PROP_GRACEFULLY_SHUT_DOWN))
{
- throw new IllegalStateException("Local repository was not gracefully shut down");
+ setReplicationCountersToLatest();
}
+ else
+ {
+ Set<String> names = new HashSet<String>();
+ names.add(PROP_LAST_REPLICATED_BRANCH_ID);
+ names.add(PROP_LAST_REPLICATED_COMMIT_TIME);
- Set<String> names = new HashSet<String>();
- names.add(PROP_LAST_REPLICATED_BRANCH_ID);
- names.add(PROP_LAST_REPLICATED_COMMIT_TIME);
-
- map = store.getPropertyValues(names);
- setLastReplicatedBranchID(Integer.valueOf(map.get(PROP_LAST_REPLICATED_BRANCH_ID)));
- setLastReplicatedCommitTime(Long.valueOf(map.get(PROP_LAST_REPLICATED_COMMIT_TIME)));
- }
- else
- {
- store.removePropertyValues(Collections.singleton(PROP_GRACEFULLY_SHUT_DOWN));
+ map = store.getPropertyValues(names);
+ setLastReplicatedBranchID(Integer.valueOf(map.get(PROP_LAST_REPLICATED_BRANCH_ID)));
+ setLastReplicatedCommitTime(Long.valueOf(map.get(PROP_LAST_REPLICATED_COMMIT_TIME)));
+ }
}
+ store.removePropertyValues(Collections.singleton(PROP_GRACEFULLY_SHUT_DOWN));
+
if (getType() != MASTER)
{
startSynchronization();
@@ -303,7 +303,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem
protected void setReplicationCountersToLatest()
{
setLastReplicatedBranchID(getStore().getLastBranchID());
- setLastReplicatedCommitTime(getLastCommitTimeStamp());
+ setLastReplicatedCommitTime(getStore().getLastNonLocalCommitTime());
}
protected void doInitRootResource()
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
index c5f96b9d70..4cd9283278 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
@@ -182,6 +182,7 @@ public interface IRepository extends CDOCommonRepository, IQueryHandlerProvider,
/**
* @author Eike Stepper
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface Props
{
@@ -201,13 +202,20 @@ public interface IRepository extends CDOCommonRepository, IQueryHandlerProvider,
public static final String SUPPORTING_BRANCHES = "supportingBranches"; //$NON-NLS-1$
/**
+ * @since 3.0
+ */
+ public static final String AUTO_LOCK_NEW_TARGETS = "autoLockNewTargets"; //$NON-NLS-1$
+
+ /**
* @since 2.0
*/
+ @Deprecated
public static final String CURRENT_LRU_CAPACITY = "currentLRUCapacity"; //$NON-NLS-1$
/**
* @since 2.0
*/
+ @Deprecated
public static final String REVISED_LRU_CAPACITY = "revisedLRUCapacity"; //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
index 3f9ad41bf1..7af133a3f3 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.server;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.net4j.util.om.monitor.ProgressDistributor;
@@ -100,6 +101,13 @@ public interface IStore
public long getLastCommitTime();
/**
+ * Returns the time stamp of the last successful commit operation to a non-local {@link CDOBranch branch}.
+ *
+ * @since 3.0
+ */
+ public long getLastNonLocalCommitTime();
+
+ /**
* Returns the id of the last {@link EModelElement} that has been committed to this store.
*
* @since 3.0
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
index 17344f51b9..3c29d63745 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
@@ -218,11 +218,6 @@ public interface IStoreAccessor extends IQueryHandlerProvider, BranchLoader, Com
public interface CommitContext
{
/**
- * @since 3.0
- */
- public static final String PROP_AUTO_LOCK_NEW_TARGETS = "autoLockNewTargets";
-
- /**
* Returns the ID of the transactional view (<code>ITransaction</code>) which is the scope of the commit operation
* represented by this <code>CommitContext</code>.
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalStore.java
index 62c450c8cd..0d7eac7e80 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalStore.java
@@ -42,5 +42,7 @@ public interface InternalStore extends IStore, ILifecycle
public void setLastCommitTime(long lastCommitTime);
+ public void setLastNonLocalCommitTime(long lastNonLocalCommitTime);
+
public void setLastMetaID(long lastMetaID);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/Store.java
index 4b2fe09122..089ecfe1e3 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/Store.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/Store.java
@@ -97,6 +97,12 @@ public abstract class Store extends Lifecycle implements InternalStore
@ExcludeFromDump
private transient Object lastCommitTimeLock = new Object();
+ @ExcludeFromDump
+ private transient long lastNonLocalCommitTime;
+
+ @ExcludeFromDump
+ private transient Object lastNonLocalCommitTimeLock = new Object();
+
/**
* @since 3.0
*/
@@ -304,6 +310,31 @@ public abstract class Store extends Lifecycle implements InternalStore
}
}
+ /**
+ * @since 3.0
+ */
+ public long getLastNonLocalCommitTime()
+ {
+ synchronized (lastNonLocalCommitTimeLock)
+ {
+ return lastNonLocalCommitTime;
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ public void setLastNonLocalCommitTime(long lastNonLocalCommitTime)
+ {
+ synchronized (lastNonLocalCommitTimeLock)
+ {
+ if (this.lastNonLocalCommitTime < lastNonLocalCommitTime)
+ {
+ this.lastNonLocalCommitTime = lastNonLocalCommitTime;
+ }
+ }
+ }
+
public IStoreAccessor getReader(ISession session)
{
IStoreAccessor reader = null;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
index f320ebb180..35067c7114 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
@@ -206,16 +206,29 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
doCommit(monitor);
long latest = CDORevision.UNSPECIFIED_DATE;
+ long latestNonLocal = CDORevision.UNSPECIFIED_DATE;
for (CommitContext commitContext : commitContexts)
{
- long timeStamp = commitContext.getBranchPoint().getTimeStamp();
+ CDOBranchPoint branchPoint = commitContext.getBranchPoint();
+ long timeStamp = branchPoint.getTimeStamp();
if (timeStamp > latest)
{
latest = timeStamp;
}
+
+ CDOBranch branch = branchPoint.getBranch();
+ if (!branch.isLocal())
+ {
+ if (timeStamp > latestNonLocal)
+ {
+ latestNonLocal = timeStamp;
+ }
+ }
}
store.setLastCommitTime(latest);
+ store.setLastNonLocalCommitTime(latestNonLocal);
+
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
index 9068c47fdc..20f7641e93 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
@@ -79,6 +79,7 @@ public class ImportXML
connector.close();
}
+ @SuppressWarnings("deprecation")
private static IRepository createRepository()
{
Map<String, String> props = new HashMap<String, String>();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index 0ef54e2ea0..260e03247c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -118,6 +118,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
return repository;
}
+ @SuppressWarnings("deprecation")
protected void initRepositoryProperties(Map<String, String> props)
{
props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!!
diff --git a/plugins/org.gastro.server/src/org/gastro/internal/server/OM.java b/plugins/org.gastro.server/src/org/gastro/internal/server/OM.java
index a018ada24d..6f6a588e80 100644
--- a/plugins/org.gastro.server/src/org/gastro/internal/server/OM.java
+++ b/plugins/org.gastro.server/src/org/gastro/internal/server/OM.java
@@ -82,8 +82,6 @@ public abstract class OM
Map<String, String> props = new HashMap<String, String>();
props.put(IRepository.Props.OVERRIDE_UUID, "gastro");
props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
- props.put(IRepository.Props.CURRENT_LRU_CAPACITY, "100000");
- props.put(IRepository.Props.REVISED_LRU_CAPACITY, "10000");
repository = CDOServerUtil.createRepository("gastro", store, props);
CDOServerUtil.addRepository(IPluginContainer.INSTANCE, repository);

Back to the top