Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-02-02 10:46:00 +0000
committerEike Stepper2016-02-02 10:46:00 +0000
commitd3e08da88adba73c91523f97a92e90415a31af53 (patch)
tree788af882ffc71bba868e30baf7466fb88a011dae
parent36ec38fc4676c5db7e5b1fd610c07394e1ad4261 (diff)
downloadcdo-d3e08da88adba73c91523f97a92e90415a31af53.tar.gz
cdo-d3e08da88adba73c91523f97a92e90415a31af53.tar.xz
cdo-d3e08da88adba73c91523f97a92e90415a31af53.zip
486458: Provide support for optimized loading and notifying of object units
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=486458
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingUnitSupport.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java96
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnitIndication.java3
-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.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458a_Test.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458b_Test.java6
9 files changed, 107 insertions, 78 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingUnitSupport.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingUnitSupport.java
index 8c54771c86..c97e0f363b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingUnitSupport.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMappingUnitSupport.java
@@ -29,5 +29,6 @@ public interface IListMappingUnitSupport extends IListMapping
{
public ResultSet queryUnitEntries(IDBStoreAccessor accessor, IIDHandler idHandler, CDOID rootID) throws SQLException;
- public void readUnitEntries(ResultSet resultSet, MoveableList<Object> list) throws SQLException;
+ public void readUnitEntries(ResultSet resultSet, IIDHandler idHandler, CDOID id, MoveableList<Object> list)
+ throws SQLException;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
index 9c2b20d146..040285c0db 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
@@ -63,6 +63,7 @@ public class UUIDHandler extends Lifecycle implements IIDHandler
public int compare(CDOID id1, CDOID id2)
{
+ // UUIDs are not generated in strictly ordered form.
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
index 45446e29e0..9e1cdc6240 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
@@ -90,6 +90,9 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
private static final String SQL_ORDER_BY_INDEX = " ORDER BY " + LIST_IDX;
+ private static final boolean CHECK_UNIT_ENTRIES = Boolean
+ .getBoolean("org.eclipse.emf.cdo.server.db.checkUnitEntries");
+
/**
* The table of this mapping.
*/
@@ -284,7 +287,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
String listTableName = getTable().getName();
String attributesTableName = classMapping.getDBTables().get(0).getName();
- sqlSelectUnitEntries = "SELECT cdo_list." + LIST_VALUE + //
+ sqlSelectUnitEntries = "SELECT " + (CHECK_UNIT_ENTRIES ? ATTRIBUTES_ID + ", " : "") + "cdo_list." + LIST_VALUE + //
" FROM " + listTableName + " cdo_list, " + attributesTableName + ", " + UnitMappingTable.UNITS + //
" WHERE " + UnitMappingTable.UNITS_ELEM + "=" + ATTRIBUTES_ID + //
" AND " + ATTRIBUTES_ID + "=cdo_list." + LIST_REVISION_ID + //
@@ -568,14 +571,22 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
return stmt.executeQuery();
}
- public void readUnitEntries(ResultSet resultSet, MoveableList<Object> list) throws SQLException
+ public void readUnitEntries(ResultSet resultSet, IIDHandler idHandler, CDOID id, MoveableList<Object> list)
+ throws SQLException
{
int size = list.size();
for (int i = 0; i < size; i++)
{
resultSet.next();
- int xxx; // TODO Check that this is the correct revision?
+ if (CHECK_UNIT_ENTRIES)
+ {
+ CDOID checkID = idHandler.getCDOID(resultSet, 1);
+ if (checkID != id)
+ {
+ throw new IllegalStateException("Result set does not deliver expected result");
+ }
+ }
Object value = typeMapping.readValue(resultSet);
list.set(i, value);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
index 605d9d2fed..504c82dbe0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
@@ -55,8 +55,10 @@ import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.IDBResultSet;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.MoveableList;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
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;
@@ -255,6 +257,13 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder.append(ATTRIBUTES_REVISED);
builder.append("=0"); //$NON-NLS-1$
+
+ if (forUnits)
+ {
+ builder.append(" ORDER BY "); //$NON-NLS-1$
+ builder.append(ATTRIBUTES_ID);
+ }
+
strings[1] = builder.toString();
builder = new StringBuilder(strings[0]);
@@ -265,6 +274,13 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
builder.append("=0 OR "); //$NON-NLS-1$
builder.append(ATTRIBUTES_REVISED);
builder.append(">=?))"); //$NON-NLS-1$
+
+ if (forUnits)
+ {
+ builder.append(" ORDER BY "); //$NON-NLS-1$
+ builder.append(ATTRIBUTES_ID);
+ }
+
strings[2] = builder.toString();
return strings;
@@ -671,10 +687,6 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
CDOBranchPoint head = repository.getBranchManager().getMainBranch().getHead();
EClass eClass = getEClass();
- int xxx;
- long start = System.currentTimeMillis();
- System.out.print(eClass.getName() + ":\t");
-
IIDHandler idHandler = store.getIDHandler();
IDBPreparedStatement stmt = null;
int oldFetchSize = -1;
@@ -715,19 +727,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
listFiller.schedule(revision);
}
- long stop = System.currentTimeMillis();
- System.out.print(stop - start);
- start = stop;
-
listFiller.await();
-
- stop = System.currentTimeMillis() - start;
- if (stop != 0)
- {
- System.out.print("\t" + stop);
- }
-
- System.out.println();
}
finally
{
@@ -760,6 +760,8 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
private final CDORevisionHandler revisionHandler;
+ private Throwable exception;
+
public AsnychronousListFiller(IDBStoreAccessor accessor, CDOID rootID, CDORevisionHandler revisionHandler)
{
this.accessor = accessor;
@@ -787,7 +789,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
queue.offer(revision);
}
- public void await()
+ public void await() throws SQLException
{
// Schedule an end marker revision.
schedule(new StubCDORevision(getEClass()));
@@ -798,7 +800,27 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
}
catch (InterruptedException ex)
{
- //$FALL-THROUGH$
+ throw new TimeoutRuntimeException();
+ }
+
+ if (exception instanceof RuntimeException)
+ {
+ throw (RuntimeException)exception;
+ }
+
+ if (exception instanceof Error)
+ {
+ throw (Error)exception;
+ }
+
+ if (exception instanceof SQLException)
+ {
+ throw (SQLException)exception;
+ }
+
+ if (exception instanceof Exception)
+ {
+ throw WrappedException.wrap((Exception)exception);
}
}
@@ -808,38 +830,24 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
{
while (store.isActive())
{
- InternalCDORevision revision;
-
- try
+ InternalCDORevision revision = queue.poll(1, TimeUnit.SECONDS);
+ if (revision == null)
{
- revision = queue.poll(1, TimeUnit.SECONDS);
- if (revision == null)
- {
- continue;
- }
-
- if (revision instanceof StubCDORevision)
- {
- return;
- }
- }
- catch (InterruptedException ex)
- {
- return;
+ continue;
}
- try
- {
- readUnitEntries(revision);
- }
- catch (SQLException ex)
+ if (revision instanceof StubCDORevision)
{
- int xxx;
- ex.printStackTrace();
return;
}
+
+ readUnitEntries(revision);
}
}
+ catch (Throwable ex)
+ {
+ exception = ex;
+ }
finally
{
latch.countDown();
@@ -848,6 +856,8 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
private void readUnitEntries(InternalCDORevision revision) throws SQLException
{
+ CDOID id = revision.getID();
+
for (int i = 0; i < listMappings.length; i++)
{
IListMappingUnitSupport listMapping = listMappings[i];
@@ -862,7 +872,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
resultSets[i] = listMapping.queryUnitEntries(accessor, idHandler, rootID);
}
- listMapping.readUnitEntries(resultSets[i], list);
+ listMapping.readUnitEntries(resultSets[i], idHandler, id, list);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnitIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnitIndication.java
index 3ee438696c..f7046aeb34 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnitIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnitIndication.java
@@ -95,8 +95,5 @@ public class UnitIndication extends CDOServerReadIndicationWithMonitoring
out.writeCDORevision(null, CDORevision.UNCHUNKED); // No more revisions
out.writeBoolean(success);
-
- int xxx;
- System.out.println("--> DONE");
}
}
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 ccaafe45c7..f2edc097f3 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
@@ -717,9 +717,6 @@ public class TransactionCommitContext implements InternalCommitContext
protected void handleException(Throwable ex)
{
- int xxx;
- ex.printStackTrace();
-
try
{
if (TRACER.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java
index d0f64351fd..5784097cbf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458_Test.java
@@ -31,6 +31,9 @@ import org.eclipse.emf.cdo.tests.model1.Supplier;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.ConcurrentAccessException;
+import org.eclipse.emf.cdo.view.CDOUnit;
+
+import org.eclipse.emf.internal.cdo.view.CDOViewImpl.CDOUnitManagerImpl.CDOUnitImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
@@ -74,7 +77,7 @@ public class Bugzilla_486458_Test extends AbstractCDOTest
System.out.println("Prefetched: " + (stop - start));
int count = iterateResource(resource);
- assertEquals(7713, count);
+ assertEquals(7714, count);
}
public void testCreateUnit() throws Exception
@@ -92,31 +95,40 @@ public class Bugzilla_486458_Test extends AbstractCDOTest
System.out.println("Created Unit: " + (stop - start));
int count = iterateResource(resource);
- assertEquals(7713, count);
+ assertEquals(7714, count);
}
public void testOpenUnit() throws Exception
{
fillRepository();
- CDOSession session = openSession();
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.getResource(getResourcePath("test"));
- transaction.getUnitManager().createUnit(resource);
- session.close();
- clearCache(getRepository().getRevisionManager());
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
+ CDOUnit createdUnit = transaction.getUnitManager().createUnit(resource);
+ assertEquals(7714, ((CDOUnitImpl)createdUnit).getInitialElements());
+
+ session.close();
+ clearCache(getRepository().getRevisionManager());
+ }
- session = openSession();
- transaction = session.openTransaction();
- resource = transaction.getResource(getResourcePath("test"));
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource(getResourcePath("test"));
- long start = System.currentTimeMillis();
- transaction.getUnitManager().openUnit(resource);
- long stop = System.currentTimeMillis();
- System.out.println("Opened Unit: " + (stop - start));
+ long start = System.currentTimeMillis();
- int count = iterateResource(resource);
- assertEquals(7713, count);
+ CDOUnit openedUnit = transaction.getUnitManager().openUnit(resource);
+ assertEquals(7714, ((CDOUnitImpl)openedUnit).getInitialElements());
+
+ long stop = System.currentTimeMillis();
+ System.out.println("Opened Unit: " + (stop - start));
+
+ int count = iterateResource(resource);
+ assertEquals(7714, count);
+ }
}
private void fillRepository() throws ConcurrentAccessException, CommitException
@@ -132,12 +144,12 @@ public class Bugzilla_486458_Test extends AbstractCDOTest
addUnique(resource.getContents(), company);
fillCompany(company);
long stop = System.currentTimeMillis();
- System.out.println("Filled " + i + ": " + (stop - start));
+ System.out.println("Filled: " + (stop - start));
start = stop;
transaction.commit();
stop = System.currentTimeMillis();
- System.out.println("Committed " + i + ": " + (stop - start));
+ System.out.println("Committed: " + (stop - start));
start = stop;
}
@@ -218,7 +230,7 @@ public class Bugzilla_486458_Test extends AbstractCDOTest
private static int iterateResource(CDOResource resource)
{
- int count = 0;
+ int count = 1;
long start = System.currentTimeMillis();
for (Iterator<EObject> it = resource.eAllContents(); it.hasNext();)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458a_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458a_Test.java
index 243f1133ac..afadac6549 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458a_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458a_Test.java
@@ -130,7 +130,7 @@ public class Bugzilla_486458a_Test extends AbstractCDOTest
resource = transaction.getResource(getResourcePath("test"));
int count = iterateResource(resource);
- int expected = 7713 + committed[0];
+ int expected = 7714 + committed[0];
assertEquals(expected, count);
session = openSession();
@@ -334,7 +334,7 @@ public class Bugzilla_486458a_Test extends AbstractCDOTest
private static int iterateResource(CDOResource resource)
{
- int count = 0;
+ int count = 1;
long start = System.currentTimeMillis();
for (Iterator<EObject> it = resource.eAllContents(); it.hasNext();)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458b_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458b_Test.java
index 1979c22100..862d9961e8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458b_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_486458b_Test.java
@@ -119,7 +119,7 @@ public class Bugzilla_486458b_Test extends AbstractCDOTest
resource = transaction.getResource(getResourcePath("test"));
int count = iterateResource(resource);
- int expected = 7713 + committed[0];
+ int expected = 7714 + committed[0];
assertEquals(expected, count);
session = openSession();
@@ -127,7 +127,7 @@ public class Bugzilla_486458b_Test extends AbstractCDOTest
resource = transaction.getResource(getResourcePath("test"));
CDOUnit unit = transaction.getUnitManager().openUnit(resource);
- assertEquals(1 + expected, ((CDOUnitImpl)unit).getInitialElements());
+ assertEquals(expected, ((CDOUnitImpl)unit).getInitialElements());
session = openSession();
transaction = session.openTransaction();
@@ -363,7 +363,7 @@ public class Bugzilla_486458b_Test extends AbstractCDOTest
private static int iterateResource(CDOResource resource)
{
- int count = 0;
+ int count = 1;
long start = System.currentTimeMillis();
for (Iterator<EObject> it = resource.eAllContents(); it.hasNext();)

Back to the top