Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-08-15 08:57:06 +0000
committerEike Stepper2010-08-15 08:57:06 +0000
commitdb6d584381dea06dd7be2cd28ace00e7718c6654 (patch)
tree0683c2682eda436795f3a3d6c895bd95577ce833 /plugins
parent50ebaf702e073ec7f3d4dea48c46c4d8d9eed017 (diff)
downloadcdo-db6d584381dea06dd7be2cd28ace00e7718c6654.tar.gz
cdo-db6d584381dea06dd7be2cd28ace00e7718c6654.tar.xz
cdo-db6d584381dea06dd7be2cd28ace00e7718c6654.zip
[322552] Provide a callback which informs about replication progress
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322552
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeMapper.java100
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java267
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java451
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepositorySynchronizer.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineRawTest.java59
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java8
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java85
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/AbstractMonitor.java10
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NotifyingMonitor.java124
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java39
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorProgress.java32
35 files changed, 974 insertions, 569 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java
index f7e35e4555..59de4df795 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.cdo.spi.common;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
import java.io.IOException;
/**
@@ -20,5 +22,8 @@ import java.io.IOException;
*/
public interface CDORawReplicationContext extends CDOReplicationInfo
{
- public void replicateRaw(CDODataInput in) throws IOException;
+ /**
+ * @since 4.0
+ */
+ public void replicateRaw(CDODataInput in, OMMonitor monitor) throws IOException;
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
index e7d23897d1..08ff5d5ca5 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
@@ -301,14 +301,14 @@ public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDO
return send(new UnsubscribeRemoteSessionsRequest(this));
}
- public void replicateRepository(CDOReplicationContext context)
+ public void replicateRepository(CDOReplicationContext context, OMMonitor monitor)
{
- send(new ReplicateRepositoryRequest(this, context));
+ send(new ReplicateRepositoryRequest(this, context, monitor));
}
- public void replicateRepositoryRaw(CDORawReplicationContext context)
+ public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor)
{
- send(new ReplicateRepositoryRawRequest(this, context));
+ send(new ReplicateRepositoryRawRequest(this, context, monitor));
}
public CDOChangeSetData[] loadChangeSets(CDOBranchPointRange... ranges)
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java
index 76423e5e76..d699c32f77 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java
@@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.spi.common.CDORawReplicationContext;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
import java.io.IOException;
/**
@@ -24,10 +26,13 @@ public class ReplicateRepositoryRawRequest extends CDOClientRequest<Boolean>
{
private CDORawReplicationContext context;
- public ReplicateRepositoryRawRequest(CDOClientProtocol protocol, CDORawReplicationContext context)
+ private OMMonitor monitor;
+
+ public ReplicateRepositoryRawRequest(CDOClientProtocol protocol, CDORawReplicationContext context, OMMonitor monitor)
{
super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW);
this.context = context;
+ this.monitor = monitor;
}
@Override
@@ -40,7 +45,7 @@ public class ReplicateRepositoryRawRequest extends CDOClientRequest<Boolean>
@Override
protected Boolean confirming(CDODataInput in) throws IOException
{
- context.replicateRaw(in);
+ context.replicateRaw(in, monitor);
return true;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java
index d5e896ce95..65063eef72 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java
@@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.spi.common.CDOReplicationContext;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
import java.io.IOException;
/**
@@ -24,10 +26,14 @@ public class ReplicateRepositoryRequest extends CDOClientRequest<Boolean>
{
private CDOReplicationContext context;
- public ReplicateRepositoryRequest(CDOClientProtocol protocol, CDOReplicationContext context)
+ @SuppressWarnings("unused")
+ private OMMonitor monitor;
+
+ public ReplicateRepositoryRequest(CDOClientProtocol protocol, CDOReplicationContext context, OMMonitor monitor)
{
super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY);
this.context = context;
+ this.monitor = monitor;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java
index 06fae87a99..bbdba0595f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java
@@ -94,8 +94,8 @@ public interface IMetaDataManager
throws IOException;
/**
- * @since 3.0
+ * @since 4.0
*/
public Collection<InternalCDOPackageUnit> rawImport(Connection connection, CDODataInput in, long fromCommitTime,
- long toCommitTime) throws IOException;
+ long toCommitTime, OMMonitor monitor) throws IOException;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeMapper.java
index 2d3e425276..facb2db073 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeMapper.java
@@ -1,49 +1,51 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - 271444: [DB] Multiple refactorings bug 271444
- */
-package org.eclipse.emf.cdo.server.db;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.io.IOException;
-import java.sql.Connection;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public interface IObjectTypeMapper
-{
- public CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id);
-
- public void putObjectType(IDBStoreAccessor accessor, long timeStamp, CDOID id, EClass type);
-
- public void removeObjectType(IDBStoreAccessor accessor, CDOID id);
-
- /**
- * Return the maximum object id managed by this cache.
- *
- * @param connection
- * the DB connection to use.
- * @return the maximum object ID.
- */
- public long getMaxID(Connection connection);
-
- public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
- throws IOException;
-
- public void rawImport(Connection connection, CDODataInput in) throws IOException;
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - 271444: [DB] Multiple refactorings bug 271444
+ */
+package org.eclipse.emf.cdo.server.db;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.io.IOException;
+import java.sql.Connection;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public interface IObjectTypeMapper
+{
+ public CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id);
+
+ public void putObjectType(IDBStoreAccessor accessor, long timeStamp, CDOID id, EClass type);
+
+ public void removeObjectType(IDBStoreAccessor accessor, CDOID id);
+
+ /**
+ * Return the maximum object id managed by this cache.
+ *
+ * @param connection
+ * the DB connection to use.
+ * @return the maximum object ID.
+ */
+ public long getMaxID(Connection connection);
+
+ public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
+ throws IOException;
+
+ public void rawImport(Connection connection, CDODataInput in, OMMonitor monitor) throws IOException;
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java
index 4437c0ac7d..ef16082728 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java
@@ -197,6 +197,13 @@ public interface IMappingStrategy
public IClassMapping getClassMapping(EClass eClass);
/**
+ * Returns all class mappings of this strategy.
+ *
+ * @since 4.0
+ */
+ public Map<EClass, IClassMapping> getClassMappings();
+
+ /**
* Query if this mapping supports revision deltas. <br>
* If this method returns <code>true</code>, it is guaranteed that all class mappings returned by
* {@link #getClassMapping(EClass)} implement {@link IClassMappingDeltaSupport}.
@@ -316,9 +323,9 @@ public interface IMappingStrategy
long lastReplicatedCommitTime, long lastCommitTime) throws IOException;
/**
- * @since 3.0
+ * @since 4.0
*/
- public void rawImport(IDBStoreAccessor accessor, CDODataInput in) throws IOException;
+ public void rawImport(IDBStoreAccessor accessor, CDODataInput in, OMMonitor monitor) throws IOException;
/**
* @since 4.0
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index b275ae87bb..febf5d4128 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -66,7 +66,6 @@ import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.collection.CloseableIterator;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -854,44 +853,71 @@ public class DBStoreAccessor extends LongIDStoreAccessor implements IDBStoreAcce
mappingStrategy.rawExport(this, out, fromBranchID, toBranchID, fromCommitTime, toCommitTime);
}
- public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
- throws IOException
+ public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException
{
- DBUtil.deserializeTable(in, connection, CDODBSchema.BRANCHES);
- DBUtil.deserializeTable(in, connection, CDODBSchema.COMMIT_INFOS);
- DBUtil.deserializeTable(in, connection, CDODBSchema.EXTERNAL_REFS);
-
- rawImportPackageUnits(in, fromCommitTime, toCommitTime);
- getStore().getMappingStrategy().rawImport(this, in);
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ int size = mappingStrategy.getClassMappings().size();
+ int commitWork = 4;
+ monitor.begin(commitWork + size + commitWork);
try
{
- connection.commit();
+ DBUtil.deserializeTable(in, connection, CDODBSchema.BRANCHES, monitor.fork());
+ DBUtil.deserializeTable(in, connection, CDODBSchema.COMMIT_INFOS, monitor.fork());
+ DBUtil.deserializeTable(in, connection, CDODBSchema.EXTERNAL_REFS, monitor.fork());
+ rawImportPackageUnits(in, fromCommitTime, toCommitTime, monitor.fork());
+
+ mappingStrategy.rawImport(this, in, monitor.fork(size));
+
+ Async async = monitor.forkAsync(commitWork);
+ try
+ {
+ connection.commit();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ async.stop();
+ }
}
- catch (SQLException ex)
+ finally
{
- throw new DBException(ex);
+ monitor.done();
}
}
- protected void rawImportPackageUnits(CDODataInput in, long fromCommitTime, long toCommitTime) throws IOException
+ protected void rawImportPackageUnits(CDODataInput in, long fromCommitTime, long toCommitTime, OMMonitor monitor)
+ throws IOException
{
- DBStore store = getStore();
- IMetaDataManager metaDataManager = store.getMetaDataManager();
- Collection<InternalCDOPackageUnit> packageUnits = metaDataManager.rawImport(getConnection(), in, fromCommitTime,
- toCommitTime);
+ monitor.begin(2);
- InternalRepository repository = store.getRepository();
- InternalCDOPackageRegistry packageRegistry = repository.getPackageRegistry(false);
+ try
+ {
+ DBStore store = getStore();
+ IMetaDataManager metaDataManager = store.getMetaDataManager();
+ Collection<InternalCDOPackageUnit> packageUnits = metaDataManager.rawImport(getConnection(), in, fromCommitTime,
+ toCommitTime, monitor.fork());
- for (InternalCDOPackageUnit packageUnit : packageUnits)
+ InternalRepository repository = store.getRepository();
+ InternalCDOPackageRegistry packageRegistry = repository.getPackageRegistry(false);
+
+ for (InternalCDOPackageUnit packageUnit : packageUnits)
+ {
+ packageRegistry.putPackageUnit(packageUnit);
+ }
+
+ IMappingStrategy mappingStrategy = store.getMappingStrategy();
+ mappingStrategy.createMapping(connection, packageUnits.toArray(new InternalCDOPackageUnit[packageUnits.size()]),
+ monitor.fork());
+ }
+ finally
{
- packageRegistry.putPackageUnit(packageUnit);
+ monitor.done();
}
-
- IMappingStrategy mappingStrategy = store.getMappingStrategy();
- mappingStrategy.createMapping(connection, packageUnits.toArray(new InternalCDOPackageUnit[packageUnits.size()]),
- new Monitor());
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
index 5ace469301..543f25b295 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
@@ -35,6 +35,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBRowHandler;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -95,7 +96,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
public Collection<InternalCDOPackageUnit> readPackageUnits(Connection connection)
{
- return readPackageUnits(connection, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE);
+ return readPackageUnits(connection, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, new Monitor());
}
public final void writePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
@@ -127,12 +128,20 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
}
public Collection<InternalCDOPackageUnit> rawImport(Connection connection, CDODataInput in, long fromCommitTime,
- long toCommitTime) throws IOException
+ long toCommitTime, OMMonitor monitor) throws IOException
{
- DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_UNITS);
- DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_INFOS);
+ monitor.begin(3);
- return readPackageUnits(connection, fromCommitTime, toCommitTime);
+ try
+ {
+ DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_UNITS, monitor.fork());
+ DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_INFOS, monitor.fork());
+ return readPackageUnits(connection, fromCommitTime, toCommitTime, monitor.fork());
+ }
+ finally
+ {
+ monitor.done();
+ }
}
protected IDBStore getStore()
@@ -303,7 +312,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
}
private Collection<InternalCDOPackageUnit> readPackageUnits(Connection connection, long fromCommitTime,
- long toCommitTime)
+ long toCommitTime, OMMonitor monitor)
{
final Map<String, InternalCDOPackageUnit> packageUnits = new HashMap<String, InternalCDOPackageUnit>();
IDBRowHandler unitRowHandler = new IDBRowHandler()
@@ -357,8 +366,19 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
}
};
- DBUtil.select(connection, infoRowHandler, CDODBSchema.PACKAGE_INFOS_UNIT, CDODBSchema.PACKAGE_INFOS_URI,
- CDODBSchema.PACKAGE_INFOS_PARENT, CDODBSchema.PACKAGE_INFOS_META_LB, CDODBSchema.PACKAGE_INFOS_META_UB);
+ monitor.begin();
+ Async async = monitor.forkAsync();
+
+ try
+ {
+ DBUtil.select(connection, infoRowHandler, CDODBSchema.PACKAGE_INFOS_UNIT, CDODBSchema.PACKAGE_INFOS_URI,
+ CDODBSchema.PACKAGE_INFOS_PARENT, CDODBSchema.PACKAGE_INFOS_META_LB, CDODBSchema.PACKAGE_INFOS_META_UB);
+ }
+ finally
+ {
+ async.stop();
+ monitor.done();
+ }
for (Entry<String, InternalCDOPackageUnit> entry : packageUnits.entrySet())
{
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 8c9ce196ff..b954f6063b 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
@@ -35,6 +35,7 @@ import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EClass;
@@ -45,6 +46,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.List;
/**
* * This abstract base class refines {@link AbstractMappingStrategy} by implementing aspects common to horizontal
@@ -157,9 +159,11 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
String attrSuffix = builder.toString();
Connection connection = accessor.getConnection();
- for (IClassMapping classMapping : getClassMappings(true).values())
+ Collection<IClassMapping> classMappings = getClassMappings(true).values();
+ out.writeInt(classMappings.size());
+
+ for (IClassMapping classMapping : classMappings)
{
- out.writeBoolean(true);
EClass eClass = classMapping.getEClass();
out.writeCDOClassifierRef(eClass);
@@ -172,7 +176,6 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
}
}
- out.writeBoolean(false);
objectTypeMapper.rawExport(connection, out, fromCommitTime, toCommitTime);
}
@@ -192,38 +195,89 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
}
}
- public void rawImport(IDBStoreAccessor accessor, CDODataInput in) throws IOException
+ public void rawImport(IDBStoreAccessor accessor, CDODataInput in, OMMonitor monitor) throws IOException
{
- Connection connection = accessor.getConnection();
-
- while (in.readBoolean())
+ int size = in.readInt();
+ if (size == 0)
{
- EClass eClass = (EClass)in.readCDOClassifierRefAndResolve();
- IClassMapping classMapping = getClassMapping(eClass);
+ return;
+ }
- IDBTable table = classMapping.getDBTables().get(0);
- DBUtil.deserializeTable(in, connection, table);
- rawImportReviseOldRevisions(connection, table);
+ int objectTypeMapperWork = 10;
+ monitor.begin(3 * size + objectTypeMapperWork);
- for (IListMapping listMapping : classMapping.getListMappings())
+ try
+ {
+ Connection connection = accessor.getConnection();
+ for (int i = 0; i < size; i++)
{
- rawImportList(in, connection, listMapping);
+ EClass eClass = (EClass)in.readCDOClassifierRefAndResolve();
+ IClassMapping classMapping = getClassMapping(eClass);
+
+ IDBTable table = classMapping.getDBTables().get(0);
+ DBUtil.deserializeTable(in, connection, table, monitor.fork());
+ rawImportReviseOldRevisions(connection, table, monitor.fork());
+
+ List<IListMapping> listMappings = classMapping.getListMappings();
+ int listSize = listMappings.size();
+ if (listSize == 0)
+ {
+ monitor.worked();
+ }
+ else
+ {
+ OMMonitor listMonitor = monitor.fork();
+ listMonitor.begin(listSize);
+
+ try
+ {
+ for (IListMapping listMapping : listMappings)
+ {
+ rawImportList(in, connection, listMapping, listMonitor.fork());
+ }
+ }
+ finally
+ {
+ listMonitor.done();
+ }
+ }
}
- }
- objectTypeMapper.rawImport(connection, in);
+ objectTypeMapper.rawImport(connection, in, monitor.fork(objectTypeMapperWork));
+ }
+ finally
+ {
+ monitor.done();
+ }
}
- protected void rawImportReviseOldRevisions(Connection connection, IDBTable table)
+ protected void rawImportReviseOldRevisions(Connection connection, IDBTable table, OMMonitor monitor)
{
throw new UnsupportedOperationException("Must be overridden");
}
- protected void rawImportList(CDODataInput in, Connection connection, IListMapping listMapping) throws IOException
+ protected void rawImportList(CDODataInput in, Connection connection, IListMapping listMapping, OMMonitor monitor)
+ throws IOException
{
- for (IDBTable table : listMapping.getDBTables())
+ Collection<IDBTable> tables = listMapping.getDBTables();
+ int size = tables.size();
+ if (size == 0)
+ {
+ return;
+ }
+
+ monitor.begin(size);
+
+ try
+ {
+ for (IDBTable table : tables)
+ {
+ DBUtil.deserializeTable(in, connection, table, monitor.fork());
+ }
+ }
+ finally
{
- DBUtil.deserializeTable(in, connection, table);
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java
index 14c09c96a8..b7211b1ee0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java
@@ -1,133 +1,134 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.IObjectTypeMapper;
-
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.io.IOException;
-import java.sql.Connection;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public abstract class DelegatingObjectTypeMapper extends AbstractObjectTypeMapper
-{
- public static final int DEFAULT_CACHE_CAPACITY = 10000000;
-
- private IObjectTypeMapper delegate;
-
- public DelegatingObjectTypeMapper()
- {
- }
-
- public IObjectTypeMapper getDelegate()
- {
- return delegate;
- }
-
- public void setDelegate(IObjectTypeMapper delegate)
- {
- this.delegate = delegate;
- }
-
- public CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id)
- {
- long longId = CDOIDUtil.getLong(id);
- Long type = doGetObjectType(longId);
- if (type != null)
- {
- long classID = type;
- EClass eClass = (EClass)getMetaDataManager().getMetaInstance(classID);
- return new CDOClassifierRef(eClass);
- }
-
- return delegate.getObjectType(accessor, id);
- }
-
- public void putObjectType(IDBStoreAccessor accessor, long timeStamp, CDOID id, EClass type)
- {
- long longId = CDOIDUtil.getLong(id);
- long classID = getMetaDataManager().getMetaID(type);
- doPutObjectType(longId, classID);
-
- delegate.putObjectType(accessor, timeStamp, id, type);
- }
-
- public void removeObjectType(IDBStoreAccessor accessor, CDOID id)
- {
- long longId = CDOIDUtil.getLong(id);
- doRemoveObjectType(longId);
-
- delegate.removeObjectType(accessor, id);
- }
-
- public long getMaxID(Connection connection)
- {
- Long maxID = doGetMaxID();
- if (maxID != null)
- {
- return maxID;
- }
-
- return delegate.getMaxID(connection);
- }
-
- public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
- throws IOException
- {
- delegate.rawExport(connection, out, fromCommitTime, toCommitTime);
- }
-
- public void rawImport(Connection connection, CDODataInput in) throws IOException
- {
- delegate.rawImport(connection, in);
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- checkState(delegate, "delegate");
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- LifecycleUtil.activate(delegate);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- LifecycleUtil.deactivate(delegate);
- super.doDeactivate();
- }
-
- protected abstract Long doGetObjectType(long id);
-
- protected abstract void doPutObjectType(long id, long type);
-
- protected abstract void doRemoveObjectType(long id);
-
- protected abstract Long doGetMaxID();
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IObjectTypeMapper;
+
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.io.IOException;
+import java.sql.Connection;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public abstract class DelegatingObjectTypeMapper extends AbstractObjectTypeMapper
+{
+ public static final int DEFAULT_CACHE_CAPACITY = 10000000;
+
+ private IObjectTypeMapper delegate;
+
+ public DelegatingObjectTypeMapper()
+ {
+ }
+
+ public IObjectTypeMapper getDelegate()
+ {
+ return delegate;
+ }
+
+ public void setDelegate(IObjectTypeMapper delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id)
+ {
+ long longId = CDOIDUtil.getLong(id);
+ Long type = doGetObjectType(longId);
+ if (type != null)
+ {
+ long classID = type;
+ EClass eClass = (EClass)getMetaDataManager().getMetaInstance(classID);
+ return new CDOClassifierRef(eClass);
+ }
+
+ return delegate.getObjectType(accessor, id);
+ }
+
+ public void putObjectType(IDBStoreAccessor accessor, long timeStamp, CDOID id, EClass type)
+ {
+ long longId = CDOIDUtil.getLong(id);
+ long classID = getMetaDataManager().getMetaID(type);
+ doPutObjectType(longId, classID);
+
+ delegate.putObjectType(accessor, timeStamp, id, type);
+ }
+
+ public void removeObjectType(IDBStoreAccessor accessor, CDOID id)
+ {
+ long longId = CDOIDUtil.getLong(id);
+ doRemoveObjectType(longId);
+
+ delegate.removeObjectType(accessor, id);
+ }
+
+ public long getMaxID(Connection connection)
+ {
+ Long maxID = doGetMaxID();
+ if (maxID != null)
+ {
+ return maxID;
+ }
+
+ return delegate.getMaxID(connection);
+ }
+
+ public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
+ throws IOException
+ {
+ delegate.rawExport(connection, out, fromCommitTime, toCommitTime);
+ }
+
+ public void rawImport(Connection connection, CDODataInput in, OMMonitor monitor) throws IOException
+ {
+ delegate.rawImport(connection, in, monitor);
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ checkState(delegate, "delegate");
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ LifecycleUtil.activate(delegate);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ LifecycleUtil.deactivate(delegate);
+ super.doDeactivate();
+ }
+
+ protected abstract Long doGetObjectType(long id);
+
+ protected abstract void doPutObjectType(long id, long type);
+
+ protected abstract void doRemoveObjectType(long id);
+
+ protected abstract Long doGetMaxID();
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
index 5f5dec3d25..4f8dc9cf2e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
@@ -18,6 +18,8 @@ import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -71,7 +73,7 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
@Override
- protected void rawImportReviseOldRevisions(Connection connection, IDBTable table)
+ protected void rawImportReviseOldRevisions(Connection connection, IDBTable table, OMMonitor monitor)
{
String sqlUpdate = "UPDATE " + table + " SET " + CDODBSchema.ATTRIBUTES_REVISED + "=? WHERE "
+ CDODBSchema.ATTRIBUTES_ID + "=? AND " + CDODBSchema.ATTRIBUTES_BRANCH + "=? AND "
@@ -91,9 +93,16 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
try
{
stmtUpdate = connection.prepareStatement(sqlUpdate);
- stmtQuery = connection.prepareStatement(sqlQuery);
+ stmtQuery = connection.prepareStatement(sqlQuery, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = stmtQuery.executeQuery();
+ int size = DBUtil.getRowCount(resultSet);
+ if (size == 0)
+ {
+ return;
+ }
+
+ monitor.begin(2 * size);
while (resultSet.next())
{
long id = resultSet.getLong(1);
@@ -106,9 +115,18 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
stmtUpdate.setInt(3, branch);
stmtUpdate.setInt(4, version);
stmtUpdate.addBatch();
+ monitor.worked();
}
- stmtUpdate.executeBatch();
+ Async async = monitor.forkAsync(size);
+ try
+ {
+ stmtUpdate.executeBatch();
+ }
+ finally
+ {
+ async.stop();
+ }
}
catch (SQLException ex)
{
@@ -119,6 +137,7 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
DBUtil.close(resultSet);
DBUtil.close(stmtQuery);
DBUtil.close(stmtUpdate);
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
index 5a32ef6638..fd7e5e9cc4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
@@ -1,225 +1,226 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Stefan Winkler - bug 259402
- * Stefan Winkler - redesign (prepared statements)
- * Stefan Winkler - bug 276926
- */
-package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
-import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
-import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
-import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
-
-import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.ddl.IDBField;
-import org.eclipse.net4j.db.ddl.IDBIndex;
-import org.eclipse.net4j.db.ddl.IDBSchema;
-import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class ObjectTypeTable extends AbstractObjectTypeMapper
-{
- private static final String SQL_STATE_UNIQUE_KEY_VIOLATION = "23001";
-
- private IDBTable table;
-
- private IDBField idField;
-
- private IDBField typeField;
-
- private IDBField timeField;
-
- private String sqlDelete;
-
- private String sqlInsert;
-
- private String sqlSelect;
-
- public ObjectTypeTable()
- {
- }
-
- public final CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id)
- {
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
-
- try
- {
- stmt = statementCache.getPreparedStatement(sqlSelect, ReuseProbability.MAX);
- stmt.setLong(1, CDOIDUtil.getLong(id));
- DBUtil.trace(stmt.toString());
- ResultSet resultSet = stmt.executeQuery();
-
- if (!resultSet.next())
- {
- DBUtil.trace("ClassID for CDOID " + id + " not found"); //$NON-NLS-1$ //$NON-NLS-2$
- return null;
- }
-
- long classID = resultSet.getLong(1);
- EClass eClass = (EClass)getMetaDataManager().getMetaInstance(classID);
- return new CDOClassifierRef(eClass);
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- finally
- {
- statementCache.releasePreparedStatement(stmt);
- }
- }
-
- public final void putObjectType(IDBStoreAccessor accessor, long timeStamp, CDOID id, EClass type)
- {
- PreparedStatement stmt = null;
-
- try
- {
- stmt = accessor.getStatementCache().getPreparedStatement(sqlInsert, ReuseProbability.MAX);
- stmt.setLong(1, CDOIDUtil.getLong(id));
- stmt.setLong(2, getMetaDataManager().getMetaID(type));
- stmt.setLong(3, timeStamp);
- DBUtil.trace(stmt.toString());
- int result = stmt.executeUpdate();
-
- if (result != 1)
- {
- throw new DBException("Object type could not be inserted: " + id); //$NON-NLS-1$
- }
- }
- catch (SQLException ex)
- {
- // Unique key violation can occur in rare cases (merging new objects from other branches)
- if (!SQL_STATE_UNIQUE_KEY_VIOLATION.equals(ex.getSQLState()))
- {
- throw new DBException(ex);
- }
- }
- finally
- {
- accessor.getStatementCache().releasePreparedStatement(stmt);
- }
- }
-
- public final void removeObjectType(IDBStoreAccessor accessor, CDOID id)
- {
- PreparedStatement stmt = null;
-
- try
- {
- stmt = accessor.getStatementCache().getPreparedStatement(sqlDelete, ReuseProbability.MAX);
- stmt.setLong(1, CDOIDUtil.getLong(id));
- DBUtil.trace(stmt.toString());
- int result = stmt.executeUpdate();
-
- if (result != 1)
- {
- throw new DBException("Object type could not be deleted: " + id); //$NON-NLS-1$
- }
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- finally
- {
- accessor.getStatementCache().releasePreparedStatement(stmt);
- }
- }
-
- public long getMaxID(Connection connection)
- {
- return DBUtil.selectMaximumLong(connection, idField);
- }
-
- public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
- throws IOException
- {
- String where = " WHERE " + timeField + " BETWEEN " + fromCommitTime + " AND " + toCommitTime;
- DBUtil.serializeTable(out, connection, table, null, where);
- }
-
- public void rawImport(Connection connection, CDODataInput in) throws IOException
- {
- DBUtil.deserializeTable(in, connection, table);
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
-
- IDBSchema schema = getMappingStrategy().getStore().getDBSchema();
- table = schema.addTable(CDODBSchema.CDO_OBJECTS);
- idField = table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT);
- typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.BIGINT);
- timeField = table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT);
- table.addIndex(IDBIndex.Type.UNIQUE, idField);
-
- IDBStoreAccessor writer = getMappingStrategy().getStore().getWriter(null);
- Connection connection = writer.getConnection();
- IDBAdapter dbAdapter = getMappingStrategy().getStore().getDBAdapter();
-
- Statement statement = null;
- try
- {
- statement = connection.createStatement();
- dbAdapter.createTable(table, statement);
- connection.commit();
- }
- catch (SQLException ex)
- {
- connection.rollback();
- throw new DBException(ex);
- }
- finally
- {
- DBUtil.close(statement);
- LifecycleUtil.deactivate(writer); // Don't let the null-context accessor go to the pool!
- }
-
- sqlSelect = "SELECT " + typeField + " FROM " + table + " WHERE " + idField + "=?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- sqlInsert = "INSERT INTO " + table + "(" + idField + "," + typeField + "," + timeField + ") VALUES (?, ?, ?)";
- sqlDelete = "DELETE FROM " + table + " WHERE " + idField + "=?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- table = null;
- idField = null;
- typeField = null;
- super.doDeactivate();
- }
-}
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Stefan Winkler - bug 259402
+ * Stefan Winkler - redesign (prepared statements)
+ * Stefan Winkler - bug 276926
+ */
+package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IPreparedStatementCache;
+import org.eclipse.emf.cdo.server.db.IPreparedStatementCache.ReuseProbability;
+import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBSchema;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class ObjectTypeTable extends AbstractObjectTypeMapper
+{
+ private static final String SQL_STATE_UNIQUE_KEY_VIOLATION = "23001";
+
+ private IDBTable table;
+
+ private IDBField idField;
+
+ private IDBField typeField;
+
+ private IDBField timeField;
+
+ private String sqlDelete;
+
+ private String sqlInsert;
+
+ private String sqlSelect;
+
+ public ObjectTypeTable()
+ {
+ }
+
+ public final CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id)
+ {
+ IPreparedStatementCache statementCache = accessor.getStatementCache();
+ PreparedStatement stmt = null;
+
+ try
+ {
+ stmt = statementCache.getPreparedStatement(sqlSelect, ReuseProbability.MAX);
+ stmt.setLong(1, CDOIDUtil.getLong(id));
+ DBUtil.trace(stmt.toString());
+ ResultSet resultSet = stmt.executeQuery();
+
+ if (!resultSet.next())
+ {
+ DBUtil.trace("ClassID for CDOID " + id + " not found"); //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
+ }
+
+ long classID = resultSet.getLong(1);
+ EClass eClass = (EClass)getMetaDataManager().getMetaInstance(classID);
+ return new CDOClassifierRef(eClass);
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ statementCache.releasePreparedStatement(stmt);
+ }
+ }
+
+ public final void putObjectType(IDBStoreAccessor accessor, long timeStamp, CDOID id, EClass type)
+ {
+ PreparedStatement stmt = null;
+
+ try
+ {
+ stmt = accessor.getStatementCache().getPreparedStatement(sqlInsert, ReuseProbability.MAX);
+ stmt.setLong(1, CDOIDUtil.getLong(id));
+ stmt.setLong(2, getMetaDataManager().getMetaID(type));
+ stmt.setLong(3, timeStamp);
+ DBUtil.trace(stmt.toString());
+ int result = stmt.executeUpdate();
+
+ if (result != 1)
+ {
+ throw new DBException("Object type could not be inserted: " + id); //$NON-NLS-1$
+ }
+ }
+ catch (SQLException ex)
+ {
+ // Unique key violation can occur in rare cases (merging new objects from other branches)
+ if (!SQL_STATE_UNIQUE_KEY_VIOLATION.equals(ex.getSQLState()))
+ {
+ throw new DBException(ex);
+ }
+ }
+ finally
+ {
+ accessor.getStatementCache().releasePreparedStatement(stmt);
+ }
+ }
+
+ public final void removeObjectType(IDBStoreAccessor accessor, CDOID id)
+ {
+ PreparedStatement stmt = null;
+
+ try
+ {
+ stmt = accessor.getStatementCache().getPreparedStatement(sqlDelete, ReuseProbability.MAX);
+ stmt.setLong(1, CDOIDUtil.getLong(id));
+ DBUtil.trace(stmt.toString());
+ int result = stmt.executeUpdate();
+
+ if (result != 1)
+ {
+ throw new DBException("Object type could not be deleted: " + id); //$NON-NLS-1$
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ accessor.getStatementCache().releasePreparedStatement(stmt);
+ }
+ }
+
+ public long getMaxID(Connection connection)
+ {
+ return DBUtil.selectMaximumLong(connection, idField);
+ }
+
+ public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
+ throws IOException
+ {
+ String where = " WHERE " + timeField + " BETWEEN " + fromCommitTime + " AND " + toCommitTime;
+ DBUtil.serializeTable(out, connection, table, null, where);
+ }
+
+ public void rawImport(Connection connection, CDODataInput in, OMMonitor monitor) throws IOException
+ {
+ DBUtil.deserializeTable(in, connection, table, monitor);
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+
+ IDBSchema schema = getMappingStrategy().getStore().getDBSchema();
+ table = schema.addTable(CDODBSchema.CDO_OBJECTS);
+ idField = table.addField(CDODBSchema.ATTRIBUTES_ID, DBType.BIGINT);
+ typeField = table.addField(CDODBSchema.ATTRIBUTES_CLASS, DBType.BIGINT);
+ timeField = table.addField(CDODBSchema.ATTRIBUTES_CREATED, DBType.BIGINT);
+ table.addIndex(IDBIndex.Type.UNIQUE, idField);
+
+ IDBStoreAccessor writer = getMappingStrategy().getStore().getWriter(null);
+ Connection connection = writer.getConnection();
+ IDBAdapter dbAdapter = getMappingStrategy().getStore().getDBAdapter();
+
+ Statement statement = null;
+ try
+ {
+ statement = connection.createStatement();
+ dbAdapter.createTable(table, statement);
+ connection.commit();
+ }
+ catch (SQLException ex)
+ {
+ connection.rollback();
+ throw new DBException(ex);
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ LifecycleUtil.deactivate(writer); // Don't let the null-context accessor go to the pool!
+ }
+
+ sqlSelect = "SELECT " + typeField + " FROM " + table + " WHERE " + idField + "=?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ sqlInsert = "INSERT INTO " + table + "(" + idField + "," + typeField + "," + timeField + ") VALUES (?, ?, ?)";
+ sqlDelete = "DELETE FROM " + table + " WHERE " + idField + "=?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ table = null;
+ idField = null;
+ typeField = null;
+ super.doDeactivate();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index cbe8b3c1a2..5b3160b2ff 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -713,8 +713,8 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
throw new UnsupportedOperationException();
}
- public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
- throws IOException
+ public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF
index f1929d161e..f7e4003433 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF
@@ -11,13 +11,13 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-ClassPath: .
-Export-Package: org.eclipse.emf.cdo.server.internal.objectivity;version="4.0.0",
- org.eclipse.emf.cdo.server.internal.objectivity.bundle;version="4.0.0",
- org.eclipse.emf.cdo.server.internal.objectivity.clustering;version="4.0.0",
- org.eclipse.emf.cdo.server.internal.objectivity.db;version="4.0.0",
- org.eclipse.emf.cdo.server.internal.objectivity.mapper;version="4.0.0",
- org.eclipse.emf.cdo.server.internal.objectivity.schema;version="4.0.0",
- org.eclipse.emf.cdo.server.internal.objectivity.utils;version="4.0.0",
+Export-Package: org.eclipse.emf.cdo.server.internal.objectivity;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.bundle;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.clustering;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.db;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.mapper;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.schema;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.utils;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
org.eclipse.emf.cdo.server.objectivity;version="4.0.0"
Import-Package: com.objy.as;version="[3.0.0,4.0.0)",
com.objy.as.app;version="[3.0.0,4.0.0)",
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
index fbb8f5bc41..ab61ce12dd 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
@@ -1231,8 +1231,11 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv
throw new UnsupportedOperationException();
}
- public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
- throws IOException
+ /**
+ * @since 4.0
+ */
+ public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java
index 94cbd8a955..49483a6b8f 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreAccessor;
import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreChunkReader;
import org.eclipse.emf.cdo.spi.server.StoreChunkReader;
@@ -25,7 +24,6 @@ import java.util.List;
public class ObjectivityStoreChunkReader extends StoreChunkReader implements IObjectivityStoreChunkReader
{
-
public ObjectivityStoreChunkReader(IStoreAccessor accessor, CDORevision revision, EStructuralFeature feature)
{
super(accessor, revision, feature);
@@ -33,9 +31,9 @@ public class ObjectivityStoreChunkReader extends StoreChunkReader implements IOb
}
@Override
- public IObjectivityStoreAccessor getAccessor()
+ public ObjectivityStoreAccessor getAccessor()
{
- return (IObjectivityStoreAccessor)super.getAccessor();
+ return (ObjectivityStoreAccessor)super.getAccessor();
}
public List<Chunk> executeRead()
@@ -52,8 +50,7 @@ public class ObjectivityStoreChunkReader extends StoreChunkReader implements IOb
int chunkSize = chunk.size();
// get the data from the feature.
- Object[] objects = objyRevision.fetch((ObjectivityStoreAccessor)getAccessor(), getFeature(), chunkStartIndex,
- chunkSize);
+ Object[] objects = objyRevision.fetch(getAccessor(), getFeature(), chunkStartIndex, chunkSize);
// although we asked for a chunkSize we might get less.
for (int i = 0; i < objects.length; i++)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java
index 50f956d7fc..b0588931ea 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/objectivity/IObjectivityStoreAccessor.java
@@ -4,16 +4,14 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Simon McDuff - initial API and implementation
* Ibrahim Sallam - code refactoring for CDO 3.0
*/
package org.eclipse.emf.cdo.server.objectivity;
-import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.server.IStoreAccessor;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -29,6 +27,4 @@ public interface IObjectivityStoreAccessor extends IStoreAccessor
* @since 2.0
*/
public IObjectivityStoreChunkReader createChunkReader(InternalCDORevision revision, EStructuralFeature feature);
-
- public ObjyObject getObject(CDOID cdoId);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
index 8d7aee9758..3d27598638 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
@@ -420,12 +420,12 @@ public class EmbeddedClientSessionProtocol extends Lifecycle implements CDOSessi
throw new UnsupportedOperationException();
}
- public void replicateRepository(CDOReplicationContext context)
+ public void replicateRepository(CDOReplicationContext context, OMMonitor monitor)
{
throw new UnsupportedOperationException();
}
- public void replicateRepositoryRaw(CDORawReplicationContext context)
+ public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor)
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
index 95f49f20d7..72ae79a532 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
@@ -346,8 +346,8 @@ public class MEMStoreAccessor extends LongIDStoreAccessor
throw new UnsupportedOperationException();
}
- public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
- throws IOException
+ public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException
{
// TODO: implement MEMStoreAccessor.rawImport(in, fromBranchID, toBranchID, fromCommitTime, toCommitTime)
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
index 065ef70e95..78ce3dea30 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/RepositorySynchronizer.java
@@ -30,6 +30,8 @@ import org.eclipse.net4j.util.concurrent.QueueRunner;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
+import org.eclipse.net4j.util.om.monitor.NotifyingMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
@@ -429,13 +431,15 @@ public class RepositorySynchronizer extends QueueRunner implements InternalRepos
localRepository.setState(CDOCommonRepository.State.SYNCING);
CDOSessionProtocol sessionProtocol = remoteSession.getSessionProtocol();
+ OMMonitor monitor = new NotifyingMonitor("Synchronizing", getListeners());
+
if (isRawReplication())
{
- sessionProtocol.replicateRepositoryRaw(localRepository);
+ sessionProtocol.replicateRepositoryRaw(localRepository, monitor);
}
else
{
- sessionProtocol.replicateRepository(localRepository);
+ sessionProtocol.replicateRepository(localRepository, monitor);
}
localRepository.setState(CDOCommonRepository.State.ONLINE);
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 d18a575b0e..7359e4adee 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
@@ -219,7 +219,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem
}
}
- public void replicateRaw(CDODataInput in) throws IOException
+ public void replicateRaw(CDODataInput in, OMMonitor monitor) throws IOException
{
try
{
@@ -230,7 +230,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem
StoreThreadLocal.setSession(replicatorSession);
IStoreAccessor accessor = StoreThreadLocal.getAccessor();
- accessor.rawImport(in, fromBranchID, toBranchID, fromCommitTime, toCommitTime);
+ accessor.rawImport(in, fromBranchID, toBranchID, fromCommitTime, toCommitTime, monitor);
replicateRawReviseRevisions();
replicateRawNotifyClients(lastReplicatedCommitTime, toCommitTime);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java
index 33ed495023..45ea7b8073 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositorySynchronizer.java
@@ -13,13 +13,13 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.event.INotifier;
/**
* @author Eike Stepper
* @since 3.0
*/
-public interface IRepositorySynchronizer extends ILifecycle
+public interface IRepositorySynchronizer extends INotifier
{
public int getRetryInterval();
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 69f1acf4d8..757270ed98 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
@@ -204,10 +204,10 @@ public interface IStoreAccessor extends IQueryHandlerProvider, BranchLoader, Com
throws IOException;
/**
- * @since 3.0
+ * @since 4.0
*/
- public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
- throws IOException;
+ public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException;
public void release();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepositorySynchronizer.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepositorySynchronizer.java
index e127d3159a..0aefe9312d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepositorySynchronizer.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalRepositorySynchronizer.java
@@ -13,13 +13,15 @@ package org.eclipse.emf.cdo.spi.server;
import org.eclipse.emf.cdo.server.IRepositorySynchronizer;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+
import org.eclipse.emf.spi.cdo.InternalCDOSession;
/**
* @author Eike Stepper
* @since 3.0
*/
-public interface InternalRepositorySynchronizer extends IRepositorySynchronizer
+public interface InternalRepositorySynchronizer extends IRepositorySynchronizer, ILifecycle
{
public InternalSynchronizableRepository getLocalRepository();
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 35067c7114..c0aea9cb7b 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
@@ -160,7 +160,7 @@ public abstract class StoreAccessor extends Lifecycle implements IStoreAccessor
try
{
monitor.begin(1 + newPackageUnits.length + 2 + newObjects.length + detachedObjects.length + dirtyCount);
- writeCommitInfo(branch, timeStamp, userID, commitComment, monitor.fork(1));
+ writeCommitInfo(branch, timeStamp, userID, commitComment, monitor.fork());
if (newPackageUnits.length != 0)
{
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
index d20f8fe856..ddf8e575a5 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
@@ -14,7 +14,7 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_319552_Test;
+import org.eclipse.emf.cdo.tests.OfflineRawTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.net4j.db.DBUtil;
@@ -71,8 +71,8 @@ public class AllTestsDBH2Offline extends DBConfigs
{
// super.initTestClasses(testClasses);
- testClasses.add(Bugzilla_319552_Test.class);
- // testClasses.add(OfflineRawTest.class);
+ // testClasses.add(Bugzilla_319552_Test.class);
+ testClasses.add(OfflineRawTest.class);
// testClasses.add(OfflineDelayedTest.class);
// testClasses.add(OfflineTest.class);
// testClasses.add(FailoverTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineRawTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineRawTest.java
index 15098d62f5..f44febc3a7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineRawTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/OfflineRawTest.java
@@ -17,10 +17,12 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.om.monitor.NotifyingMonitor.ProgressEvent;
/**
* @author Eike Stepper
@@ -167,4 +169,61 @@ public class OfflineRawTest extends OfflineTest
CDOListFeatureDelta listDelta = (CDOListFeatureDelta)delta.getFeatureDeltas().get(0);
assertEquals(2, listDelta.getListChanges().size());
}
+
+ /**
+ * @since 4.0
+ */
+ public void testSyncProgressEvents() throws Exception
+ {
+ InternalSynchronizableRepository clone = (InternalSynchronizableRepository)getRepository();
+ waitForOnline(clone);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/my/resource");
+
+ resource.getContents().add(getModel1Factory().createCompany());
+ transaction.setCommitComment("resource with one company created on clone");
+ transaction.commit();
+
+ getOfflineConfig().stopMasterTransport();
+ waitForOffline(clone);
+
+ {
+ CDOSession masterSession = openSession(clone.getName() + "_master");
+ CDOTransaction masterTransaction = masterSession.openTransaction();
+ CDOResource masterResource = masterTransaction.getResource("/my/resource");
+
+ for (int i = 0; i < 100; i++)
+ {
+ masterResource.getContents().add(getModel1Factory().createCompany());
+ masterTransaction.setCommitComment("one company added on master");
+ masterTransaction.commit();
+ }
+
+ masterTransaction.close();
+ }
+
+ final int[] workPercent = { 0 };
+ TestListener listener = new TestListener()
+ {
+ @Override
+ public void notifyEvent(IEvent event)
+ {
+ super.notifyEvent(event);
+ if (event instanceof ProgressEvent)
+ {
+ ProgressEvent e = (ProgressEvent)event;
+ workPercent[0] = (int)e.getWorkPercent();
+ msg(e.getTask() + ": " + workPercent[0] + " percent");
+ }
+ }
+ };
+
+ clone.getSynchronizer().addListener(listener);
+
+ getOfflineConfig().startMasterTransport();
+ waitForOnline(clone);
+ assertEquals(100, workPercent[0]);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index ab8f352451..0fa27b9672 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -1963,14 +1963,14 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
}
- public void replicateRepository(CDOReplicationContext context)
+ public void replicateRepository(CDOReplicationContext context, OMMonitor monitor)
{
int attempt = 0;
for (;;)
{
try
{
- delegate.replicateRepository(context);
+ delegate.replicateRepository(context, monitor);
return;
}
catch (Exception ex)
@@ -1980,14 +1980,14 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
}
- public void replicateRepositoryRaw(CDORawReplicationContext context)
+ public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor)
{
int attempt = 0;
for (;;)
{
try
{
- delegate.replicateRepositoryRaw(context);
+ delegate.replicateRepositoryRaw(context, monitor);
return;
}
catch (Exception ex)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
index e52fddd892..7d6e3986b6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
@@ -178,14 +178,14 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
public boolean unsubscribeRemoteSessions();
/**
- * @since 3.0
+ * @since 4.0
*/
- public void replicateRepository(CDOReplicationContext context);
+ public void replicateRepository(CDOReplicationContext context, OMMonitor monitor);
/**
- * @since 3.0
+ * @since 4.0
*/
- public void replicateRepositoryRaw(CDORawReplicationContext context);
+ public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor);
/**
* @since 3.0
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index 6e7fcc865d..62703b55ab 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -19,6 +19,8 @@ import org.eclipse.net4j.spi.db.DBSchema;
import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import javax.sql.DataSource;
@@ -622,6 +624,45 @@ public final class DBUtil
}
/**
+ * Returns the number of rows contained in the given result set.
+ * <p>
+ * The {@link ResultSet#getStatement() statement} of the result set must have been created with
+ * {@link ResultSet#TYPE_SCROLL_INSENSITIVE TYPE_SCROLL_INSENSITIVE}.
+ *
+ * @since 4.0
+ */
+ public static int getRowCount(ResultSet resultSet) throws DBException
+ {
+ reset(resultSet);
+
+ try
+ {
+ resultSet.last();
+ return resultSet.getRow();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ reset(resultSet);
+ }
+ }
+
+ private static void reset(ResultSet resultSet) throws DBException
+ {
+ try
+ {
+ resultSet.beforeFirst();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ /**
* @since 3.0
*/
public static void serializeTable(ExtendedDataOutput out, Connection connection, IDBTable table, String tableAlias,
@@ -666,14 +707,22 @@ public final class DBUtil
try
{
- statement = connection.createStatement();
+ statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
try
{
resultSet = statement.executeQuery(sql);
+
+ // Write resultSet size for progress monitoring
+ int size = getRowCount(resultSet);
+ out.writeInt(size);
+ if (size == 0)
+ {
+ return;
+ }
+
while (resultSet.next())
{
- out.writeBoolean(true);
for (int i = 0; i < fields.length; i++)
{
IDBField field = fields[i];
@@ -682,8 +731,6 @@ public final class DBUtil
type.writeValue(out, resultSet, i + 1, canBeNull);
}
}
-
- out.writeBoolean(false);
}
catch (SQLException ex)
{
@@ -705,10 +752,17 @@ public final class DBUtil
}
/**
- * @since 3.0
+ * @since 4.0
*/
- public static void deserializeTable(ExtendedDataInput in, Connection connection, IDBTable table) throws IOException
+ public static void deserializeTable(ExtendedDataInput in, Connection connection, IDBTable table, OMMonitor monitor)
+ throws IOException
{
+ int size = in.readInt();
+ if (size == 0)
+ {
+ return;
+ }
+
IDBField[] fields = table.getFields();
StringBuilder builder = new StringBuilder();
@@ -737,10 +791,14 @@ public final class DBUtil
String sql = trace(builder.toString());
PreparedStatement statement = null;
+ monitor.begin(1 + 2 * size);
+
try
{
statement = connection.prepareStatement(sql);
- while (in.readBoolean())
+ monitor.worked();
+
+ for (int row = 0; row < size; row++)
{
for (int i = 0; i < fields.length; i++)
{
@@ -751,9 +809,19 @@ public final class DBUtil
}
statement.addBatch();
+ monitor.worked();
}
- statement.executeBatch();
+ Async async = monitor.forkAsync(size);
+
+ try
+ {
+ statement.executeBatch();
+ }
+ finally
+ {
+ async.stop();
+ }
}
catch (SQLException ex)
{
@@ -762,6 +830,7 @@ public final class DBUtil
finally
{
close(statement);
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/AbstractMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/AbstractMonitor.java
index 91b5d66ccb..bb5f5356d4 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/AbstractMonitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/AbstractMonitor.java
@@ -114,7 +114,7 @@ public abstract class AbstractMonitor implements OMMonitor
public double getWorkPercent()
{
- return Math.min(work * OMMonitor.HUNDRED / totalWork, OMMonitor.HUNDRED);
+ return percent(work, totalWork);
}
protected OMMonitor createNestedMonitor(double work)
@@ -145,6 +145,14 @@ public abstract class AbstractMonitor implements OMMonitor
}
/**
+ * @since 3.1
+ */
+ protected static double percent(double part, double whole)
+ {
+ return Math.min(part * HUNDRED / whole, HUNDRED);
+ }
+
+ /**
* @author Eike Stepper
*/
public static class AsyncTimerTask extends TimerTask implements Async
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NotifyingMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NotifyingMonitor.java
new file mode 100644
index 0000000000..4c08e63d71
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/NotifyingMonitor.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.om.monitor;
+
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.event.INotifier;
+import org.eclipse.net4j.util.event.Notifier;
+
+/**
+ * @author Eike Stepper
+ * @since 3.1
+ */
+public class NotifyingMonitor extends Monitor implements INotifier
+{
+ private Notifier notifier = new Notifier();
+
+ private String task;
+
+ public NotifyingMonitor()
+ {
+ }
+
+ public NotifyingMonitor(String task)
+ {
+ this.task = task;
+ }
+
+ public NotifyingMonitor(String task, IListener[] listeners)
+ {
+ this(task);
+ if (listeners != null)
+ {
+ for (IListener listener : listeners)
+ {
+ addListener(listener);
+ }
+ }
+ }
+
+ public String getTask()
+ {
+ return task;
+ }
+
+ public boolean hasListeners()
+ {
+ return notifier.hasListeners();
+ }
+
+ public IListener[] getListeners()
+ {
+ return notifier.getListeners();
+ }
+
+ public void addListener(IListener listener)
+ {
+ notifier.addListener(listener);
+ }
+
+ public void removeListener(IListener listener)
+ {
+ notifier.removeListener(listener);
+ }
+
+ @Override
+ public void worked(double work) throws MonitorCanceledException
+ {
+ super.worked(work);
+
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ notifier.fireEvent(new ProgressEvent(getTotalWork(), getWork()), listeners);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public final class ProgressEvent extends Event implements OMMonitorProgress
+ {
+ private static final long serialVersionUID = 1L;
+
+ private double totalWork;
+
+ private double work;
+
+ private ProgressEvent(double totalWork, double work)
+ {
+ super(NotifyingMonitor.this);
+ this.totalWork = totalWork;
+ this.work = work;
+ }
+
+ public String getTask()
+ {
+ return NotifyingMonitor.this.getTask();
+ }
+
+ public double getTotalWork()
+ {
+ return totalWork;
+ }
+
+ public double getWork()
+ {
+ return work;
+ }
+
+ public double getWorkPercent()
+ {
+ return percent(work, totalWork);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
index 4af5466219..d31bff69c7 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitor.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
*/
@@ -13,31 +13,11 @@ package org.eclipse.net4j.util.om.monitor;
/**
* @author Eike Stepper
*/
-public interface OMMonitor
+public interface OMMonitor extends OMMonitorProgress
{
/**
* @since 2.0
*/
- public static final double ZERO = 0;
-
- /**
- * @since 2.0
- */
- public static final double ONE = 1;
-
- /**
- * @since 2.0
- */
- public static final double TEN = 10;
-
- /**
- * @since 2.0
- */
- public static final double HUNDRED = 100;
-
- /**
- * @since 2.0
- */
public static final int THOUSAND = 1000;
/**
@@ -114,21 +94,6 @@ public interface OMMonitor
public void done();
/**
- * @since 2.0
- */
- public double getTotalWork();
-
- /**
- * @since 2.0
- */
- public double getWork();
-
- /**
- * @since 2.0
- */
- public double getWorkPercent();
-
- /**
* @author Eike Stepper
* @since 2.0
*/
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorProgress.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorProgress.java
new file mode 100644
index 0000000000..228f53f356
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/monitor/OMMonitorProgress.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.om.monitor;
+
+/**
+ * @author Eike Stepper
+ * @since 3.1
+ */
+public interface OMMonitorProgress
+{
+ public static final double ZERO = 0;
+
+ public static final double ONE = 1;
+
+ public static final double TEN = 10;
+
+ public static final double HUNDRED = 100;
+
+ public double getTotalWork();
+
+ public double getWork();
+
+ public double getWorkPercent();
+}

Back to the top