Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Audit view on branch before base timestamp
[CDO] Audit view on branch before base timestamp [message #1696686] Wed, 27 May 2015 21:25 Go to next message
Andras Peteri is currently offline Andras PeteriFriend
Messages: 22
Registered: January 2010
Junior Member
Hi,

Given
- a repository creation timestamp t(0),
- two commits on branch "MAIN" with timestamps t(1) and t(2) and
- a branch creation point for branch "MAIN/a" with timestamp t(3),

is it expected that an audit view opened on branch "MAIN/a" with timestamp t(0) < t(1) <= t(view) < t(2) < t(3) will return CDO objects with state corresponding to timestamp t(2) (or more precisely, t(3))? Looking at the code, revision loading and the cache seem to clamp incoming timestamps to branch basepoints when they are set before the proverbial "fork in the road", and lookup requires moving up to a parent branch.

The only utility method I've seen which compensates for this behavior is CDOBranchUtil#normalizeBranchPoint(CDOBranch, long). Should client code call it before initializing the view?

Thanks,
AndrĂ¡s
Re: [CDO] Audit view on branch before base timestamp [message #1696721 is a reply to message #1696686] Thu, 28 May 2015 08:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 27.05.2015 um 23:25 schrieb Andras Peteri:
> Hi,
>
> Given - a repository creation timestamp t(0), - two commits on branch "MAIN" with timestamps t(1) and t(2) and
> - a branch creation point for branch "MAIN/a" with timestamp t(3),
> is it expected that an audit view opened on branch "MAIN/a" with timestamp t(0) < t(1) <= t(view) < t(2) < t(3) will
> return CDO objects with state corresponding to timestamp t(2) (or more precisely, t(3))? Looking at the code, revision
> loading and the cache seem to clamp incoming timestamps to branch basepoints when they are set before the proverbial
> "fork in the road", and lookup requires moving up to a parent branch.
>
> The only utility method I've seen which compensates for this behavior is CDOBranchUtil#normalizeBranchPoint(CDOBranch,
> long). Should client code call it before initializing the view?
I'm not sure what exactly you're asking. A CDOView should deliver a consistent model for any branch and any timestamp
between now and repo creation time, including timestamps before the branch creation (or better: base point).

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Audit view on branch before base timestamp [message #1696772 is a reply to message #1696721] Thu, 28 May 2015 13:45 Go to previous messageGo to next message
Andras Peteri is currently offline Andras PeteriFriend
Messages: 22
Registered: January 2010
Junior Member
Hi Eike,

Quote:
A CDOView should deliver a consistent model for any branch and any timestamp
between now and repo creation time, including timestamps before the branch creation (or better: base point).


Thanks, this is also what I was expecting. Unfortunately the actual behavior of CDOView was a bit different for me.

Consider the two similar blocks of code in CDORevisionManagerImpl#getCachedRevisionRecursively and Repository#loadRevisionTarget:

private InternalCDORevision loadRevisionTarget(CDOID id, CDOBranchPoint branchPoint, int referenceChunk,
    IStoreAccessor accessor)
{
  CDOBranch branch = branchPoint.getBranch();
  while (!branch.isMainBranch())
  {
    branchPoint = branch.getBase();
    branch = branchPoint.getBranch();

    InternalCDORevision revision = accessor.readRevision(id, branchPoint, referenceChunk, revisionManager);
    if (revision != null)
    {
      revision.freeze();
      return revision;
    }
  }

  return null;
}

For uncached loads, when loading a revision with branchPoint on a child branch set before the base point, we can be sure that the revision will not be found on the current branch, as the branch was not existing in the repository at that point in time. As a result, loadRevisionTarget gets called, where branchPoint is updated to point to the next branch base inside the while() block. When the revision is finally found on a parent, the timestamp part will no longer match the one which was passed in; it will be set to one of the base timestamps.

This way, regardless of what timestamp is chosen for the view, if it is set before the branch base, it will show the state corresponding to the base timestamp for objects that don't have a relevant revision on the view's branch.

If the view is opened on a parent branch where revisions are present, loadRevisionTarget is not invoked, the timestamp does not change and these revisions become distinguishable.
Re: [CDO] Audit view on branch before base timestamp [message #1696869 is a reply to message #1696772] Fri, 29 May 2015 07:31 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 28.05.2015 um 15:45 schrieb Andras Peteri:
> Hi Eike,
>
> Quote:
>> A CDOView should deliver a consistent model for any branch and any timestamp between now and repo creation time,
>> including timestamps before the branch creation (or better: base point).
>
>
> Thanks, this is also what I was expecting. Unfortunately the actual behavior of CDOView was a bit different for me.
>
> Consider the two similar blocks of code in CDORevisionManagerImpl#getCachedRevisionRecursively and
> Repository#loadRevisionTarget:
>
>
> private InternalCDORevision loadRevisionTarget(CDOID id, CDOBranchPoint branchPoint, int referenceChunk,
> IStoreAccessor accessor)
> {
> CDOBranch branch = branchPoint.getBranch();
> while (!branch.isMainBranch())
> {
> branchPoint = branch.getBase();
> branch = branchPoint.getBranch();
>
> InternalCDORevision revision = accessor.readRevision(id, branchPoint, referenceChunk, revisionManager);
> if (revision != null)
> {
> revision.freeze();
> return revision;
> }
> }
>
> return null;
> }
>
> For uncached loads, when loading a revision with branchPoint on a child branch set before the base point, we can be
> sure that the revision will not be found on the current branch, as the branch was not existing in the repository at
> that point in time. As a result, loadRevisionTarget gets called, where branchPoint is updated to point to the next
> branch base inside the while() block. When the revision is finally found on a parent, the timestamp part will no
> longer match the one which was passed in; it will be set to one of the base timestamps.
Correct.

>
> This way, regardless of what timestamp is chosen for the view, if it is set before the branch base, it will show the
> state corresponding to the base timestamp for objects that don't have a relevant revision on the view's branch.
Correct, if the revision in the parent branch is valid at that time.

> If the view is opened on a parent branch where revisions are present, loadRevisionTarget is not invoked, the timestamp
> does not change and these revisions become distinguishable.
What do you mean by "the timestamp does not change" and "these revisions become distinguishable"?

I have the feeling you're looking at some code and theorizing. Or are you experiencing wrong behaviour? If so, can you
please provide a test case so that I can reproduce it?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Audit view on branch before base timestamp [message #1696893 is a reply to message #1696869] Fri, 29 May 2015 09:14 Go to previous messageGo to next message
Andras Peteri is currently offline Andras PeteriFriend
Messages: 22
Registered: January 2010
Junior Member
Attaching a test case.

The assertion commented with "!" (orderDetail.price in commitTime1 on subBranch should be 5.0) fails on CDO master. The corresponding assertion a few lines earlier for MAIN passes.
Re: [CDO] Audit view on branch before base timestamp [message #1696898 is a reply to message #1696893] Fri, 29 May 2015 09:35 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 29.05.2015 um 11:14 schrieb Andras Peteri:
> Attaching a test case.
>
> The assertion commented with "!" (orderDetail.price in commitTime1 on subBranch should be 5.0) fails on CDO master. The corresponding assertion a few lines earlier for MAIN passes.
I can't apply that patch:

error: patch failed: plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java:459
error: plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java: patch does not apply

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Audit view on branch before base timestamp [message #1696899 is a reply to message #1696898] Fri, 29 May 2015 09:50 Go to previous messageGo to next message
Andras Peteri is currently offline Andras PeteriFriend
Messages: 22
Registered: January 2010
Junior Member
That's strange... I created the patch using Eclipse, and sent the output to the clipboard. It ended up with CRLF separators. Is this the problem?
Re: [CDO] Audit view on branch before base timestamp [message #1696904 is a reply to message #1696899] Fri, 29 May 2015 10:07 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 29.05.2015 um 11:50 schrieb Andras Peteri:
> That's strange... I created the patch using Eclipse, and sent the output to the clipboard. It ended up with CRLF
> separators. Is this the problem?
I don't know. Please copy the method to a new class and paste that entire class.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: [CDO] Audit view on branch before base timestamp [message #1696910 is a reply to message #1696904] Fri, 29 May 2015 10:40 Go to previous messageGo to next message
Andras Peteri is currently offline Andras PeteriFriend
Messages: 22
Registered: January 2010
Junior Member
/*
 * Copyright (c) 2010-2013 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.tests;

import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.common.revision.AbstractCDORevisionCache;
import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
import org.eclipse.emf.cdo.tests.model1.OrderDetail;
import org.eclipse.emf.cdo.tests.model1.Product1;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOView;

import org.eclipse.net4j.util.ReflectUtil;

import org.eclipse.emf.spi.cdo.InternalCDOSession;

import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;

/**
 * @author Eike Stepper
 */
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
public class BranchingAuditTest extends AbstractCDOTest
{
  protected CDOSession session1;

  @Override
  protected void doSetUp() throws Exception
  {
    super.doSetUp();

    Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
    ReflectUtil.setValue(disableGC, null, true);
  }

  @Override
  protected void doTearDown() throws Exception
  {
    session1 = null;
    Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
    ReflectUtil.setValue(disableGC, null, false);
    super.doTearDown();
  }

  protected CDOSession openSession1()
  {
    session1 = openSession();
    return session1;
  }

  protected void closeSession1()
  {
    session1.close();
    session1 = null;
  }

  protected CDOSession openSession2()
  {
    return openSession();
  }

  protected String getBranchName(String name)
  {
    // New scenarios get clean repositories, no need to disambiguate them.
    return getClass().getSimpleName() + "_" + getName() + "_" + name;
  }

  public void testAuditViewOnBranch() throws Exception
  {
    String name = getBranchName("subBranch");

    CDOSession session = openSession1();
    CDOBranchManager branchManager = session.getBranchManager();

    // Commit to main branch
    CDOBranch mainBranch = branchManager.getMainBranch();
    CDOTransaction transaction = session.openTransaction(mainBranch);
    assertEquals(mainBranch, transaction.getBranch());
    assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());

    Product1 product = getModel1Factory().createProduct1();
    product.setName("CDO");

    OrderDetail orderDetail = getModel1Factory().createOrderDetail();
    orderDetail.setProduct(product);
    orderDetail.setPrice(5.0f);

    CDOResource resource = transaction.createResource(getResourcePath("/res"));
    resource.getContents().add(product);
    resource.getContents().add(orderDetail);

    CDOCommitInfo commitInfo = transaction.commit();
    dumpAll(session);
    assertEquals(mainBranch, commitInfo.getBranch());
    long commitTime1 = commitInfo.getTimeStamp();

    // Modify main branch (change existing OrderDetail)
    orderDetail.setPrice(10.0f);
    commitInfo = transaction.commit();
    dumpAll(session);
    assertEquals(mainBranch, commitInfo.getBranch());
    long commitTime2 = commitInfo.getTimeStamp();
    transaction.close();

    // Commit to sub branch
    CDOBranch subBranch = mainBranch.createBranch(name);
    transaction = session.openTransaction(subBranch);
    assertEquals(subBranch, transaction.getBranch());
    assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());

    resource = transaction.getResource(getResourcePath("/res"));
    orderDetail = (OrderDetail)resource.getContents().get(1);
    assertEquals(10.0f, orderDetail.getPrice());
    product = orderDetail.getProduct();
    assertEquals("CDO", product.getName());

    // Modify sub branch (add new OrderDetail)
    OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
    orderDetail2.setProduct(product);
    orderDetail2.setPrice(20.0f);
    resource.getContents().add(0, orderDetail2);

    commitInfo = transaction.commit();
    dumpAll(session);
    assertEquals(subBranch, commitInfo.getBranch());
    long commitTime3 = commitInfo.getTimeStamp();

    transaction.close();
    closeSession1();

    session = openSession2();
    branchManager = session.getBranchManager();
    mainBranch = branchManager.getMainBranch();
    subBranch = mainBranch.getBranch(name);

    check(session, mainBranch, commitTime1, 5.0f, "CDO");
    check(session, mainBranch, commitTime2, 10.0f, "CDO");
    check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 10.0f, "CDO");

    check(session, subBranch, commitTime1, 5.0f, "CDO"); // !
    check(session, subBranch, commitTime2, 10.0f, "CDO");
    check(session, subBranch, commitTime3, 10.0f, 20.0f, "CDO");
    check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 10.0f, 20.0f, "CDO");

    session.close();
  }

  private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name, int size)
  {
    CDOView view = session.openView(branch, timeStamp);
    CDOResource resource = view.getResource(getResourcePath("/res"));

    int actualSize = resource.getContents().size();
    assertEquals(size, actualSize);

    dumpAll(session);
    OrderDetail orderDetail = (OrderDetail)resource.getContents().get(1);
    dumpAll(session);

    float actualPrice = orderDetail.getPrice();
    assertEquals(price, actualPrice);

    Product1 product = orderDetail.getProduct();
    dumpAll(session);

    String actualName = product.getName();
    assertEquals(name, actualName);

    view.close();
  }

  private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name)
  {
    check(session, branch, timeStamp, price, name, 2);
  }

  private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, float price2, String name)
  {
    CDOView view = session.openView(branch, timeStamp);
    CDOResource resource = view.getResource(getResourcePath("/res"));
    assertEquals(3, resource.getContents().size());

    dumpAll(session);
    OrderDetail orderDetail2 = (OrderDetail)resource.getContents().get(0);
    OrderDetail orderDetail = (OrderDetail)resource.getContents().get(2);

    dumpAll(session);
    assertEquals(price, orderDetail.getPrice());
    assertEquals(price2, orderDetail2.getPrice());

    Product1 product = orderDetail.getProduct();
    Product1 product2 = orderDetail2.getProduct();
    dumpAll(session);
    assertEquals(name, product.getName());
    assertEquals(name, product2.getName());

    view.close();
  }

  private void dumpAll(CDOSession session)
  {
    IStore store = getRepository().getStore();
    if (store instanceof MEMStore)
    {
      MEMStore memStore = (MEMStore)store;
      dump("MEMStore", memStore.getAllRevisions());
    }

    dump("ServerCache", getRepository().getRevisionManager().getCache().getAllRevisions());
    dump("ClientCache", ((InternalCDOSession)session).getRevisionManager().getCache().getAllRevisions());
  }

  public static void dump(String label, Map<CDOBranch, List<CDORevision>> revisions)
  {
    System.out.println();
    System.out.println();
    System.out.println(label);
    System.out
        .println("===============================================================================================");
    CDORevisionUtil.dumpAllRevisions(revisions, System.out);
    System.out.println();
    System.out.println();
  }

  public static void assertEquals(Object expected, Object actual)
  {
    if (expected instanceof CDOBranch && actual instanceof CDOBranch)
    {
      if (((CDOBranch)expected).getID() != ((CDOBranch)actual).getID())
      {
        failNotEquals(null, expected, actual);
      }

      return;
    }

    AbstractCDOTest.assertEquals(expected, actual);
  }
}
Re: [CDO] Audit view on branch before base timestamp [message #1696949 is a reply to message #1696910] Fri, 29 May 2015 16:14 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
I can reproduce it with your test and a fix will be in RC3:

468834: Audit views with timestamp < branch.getBase().getTimeStamp() deliver wrong revisions
https://bugs.eclipse.org/bugs/show_bug.cgi?id=468834

Good catch!

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 29.05.2015 um 12:40 schrieb Andras Peteri:
>
> /*
> * Copyright (c) 2010-2013 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.tests;
>
> import org.eclipse.emf.cdo.common.branch.CDOBranch;
> import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
> import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
> import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
> import org.eclipse.emf.cdo.common.revision.CDORevision;
> import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
> import org.eclipse.emf.cdo.eresource.CDOResource;
> import org.eclipse.emf.cdo.internal.common.revision.AbstractCDORevisionCache;
> import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
> import org.eclipse.emf.cdo.server.IStore;
> import org.eclipse.emf.cdo.session.CDOSession;
> import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
> import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
> import org.eclipse.emf.cdo.tests.model1.OrderDetail;
> import org.eclipse.emf.cdo.tests.model1.Product1;
> import org.eclipse.emf.cdo.transaction.CDOTransaction;
> import org.eclipse.emf.cdo.view.CDOView;
>
> import org.eclipse.net4j.util.ReflectUtil;
>
> import org.eclipse.emf.spi.cdo.InternalCDOSession;
>
> import java.lang.reflect.Field;
> import java.util.List;
> import java.util.Map;
>
> /**
> * @author Eike Stepper
> */
> @Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
> public class BranchingAuditTest extends AbstractCDOTest
> {
> protected CDOSession session1;
>
> @Override
> protected void doSetUp() throws Exception
> {
> super.doSetUp();
>
> Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
> ReflectUtil.setValue(disableGC, null, true);
> }
>
> @Override
> protected void doTearDown() throws Exception
> {
> session1 = null;
> Field disableGC = ReflectUtil.getField(AbstractCDORevisionCache.class, "disableGC");
> ReflectUtil.setValue(disableGC, null, false);
> super.doTearDown();
> }
>
> protected CDOSession openSession1()
> {
> session1 = openSession();
> return session1;
> }
>
> protected void closeSession1()
> {
> session1.close();
> session1 = null;
> }
>
> protected CDOSession openSession2()
> {
> return openSession();
> }
>
> protected String getBranchName(String name)
> {
> // New scenarios get clean repositories, no need to disambiguate them.
> return getClass().getSimpleName() + "_" + getName() + "_" + name;
> }
>
> public void testAuditViewOnBranch() throws Exception
> {
> String name = getBranchName("subBranch");
>
> CDOSession session = openSession1();
> CDOBranchManager branchManager = session.getBranchManager();
>
> // Commit to main branch
> CDOBranch mainBranch = branchManager.getMainBranch();
> CDOTransaction transaction = session.openTransaction(mainBranch);
> assertEquals(mainBranch, transaction.getBranch());
> assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
>
> Product1 product = getModel1Factory().createProduct1();
> product.setName("CDO");
>
> OrderDetail orderDetail = getModel1Factory().createOrderDetail();
> orderDetail.setProduct(product);
> orderDetail.setPrice(5.0f);
>
> CDOResource resource = transaction.createResource(getResourcePath("/res"));
> resource.getContents().add(product);
> resource.getContents().add(orderDetail);
>
> CDOCommitInfo commitInfo = transaction.commit();
> dumpAll(session);
> assertEquals(mainBranch, commitInfo.getBranch());
> long commitTime1 = commitInfo.getTimeStamp();
>
> // Modify main branch (change existing OrderDetail)
> orderDetail.setPrice(10.0f);
> commitInfo = transaction.commit();
> dumpAll(session);
> assertEquals(mainBranch, commitInfo.getBranch());
> long commitTime2 = commitInfo.getTimeStamp();
> transaction.close();
>
> // Commit to sub branch
> CDOBranch subBranch = mainBranch.createBranch(name);
> transaction = session.openTransaction(subBranch);
> assertEquals(subBranch, transaction.getBranch());
> assertEquals(CDOBranchPoint.UNSPECIFIED_DATE, transaction.getTimeStamp());
>
> resource = transaction.getResource(getResourcePath("/res"));
> orderDetail = (OrderDetail)resource.getContents().get(1);
> assertEquals(10.0f, orderDetail.getPrice());
> product = orderDetail.getProduct();
> assertEquals("CDO", product.getName());
>
> // Modify sub branch (add new OrderDetail)
> OrderDetail orderDetail2 = getModel1Factory().createOrderDetail();
> orderDetail2.setProduct(product);
> orderDetail2.setPrice(20.0f);
> resource.getContents().add(0, orderDetail2);
>
> commitInfo = transaction.commit();
> dumpAll(session);
> assertEquals(subBranch, commitInfo.getBranch());
> long commitTime3 = commitInfo.getTimeStamp();
>
> transaction.close();
> closeSession1();
>
> session = openSession2();
> branchManager = session.getBranchManager();
> mainBranch = branchManager.getMainBranch();
> subBranch = mainBranch.getBranch(name);
>
> check(session, mainBranch, commitTime1, 5.0f, "CDO");
> check(session, mainBranch, commitTime2, 10.0f, "CDO");
> check(session, mainBranch, CDOBranchPoint.UNSPECIFIED_DATE, 10.0f, "CDO");
>
> check(session, subBranch, commitTime1, 5.0f, "CDO"); // !
> check(session, subBranch, commitTime2, 10.0f, "CDO");
> check(session, subBranch, commitTime3, 10.0f, 20.0f, "CDO");
> check(session, subBranch, CDOBranchPoint.UNSPECIFIED_DATE, 10.0f, 20.0f, "CDO");
>
> session.close();
> }
>
> private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name, int size)
> {
> CDOView view = session.openView(branch, timeStamp);
> CDOResource resource = view.getResource(getResourcePath("/res"));
>
> int actualSize = resource.getContents().size();
> assertEquals(size, actualSize);
>
> dumpAll(session);
> OrderDetail orderDetail = (OrderDetail)resource.getContents().get(1);
> dumpAll(session);
>
> float actualPrice = orderDetail.getPrice();
> assertEquals(price, actualPrice);
>
> Product1 product = orderDetail.getProduct();
> dumpAll(session);
>
> String actualName = product.getName();
> assertEquals(name, actualName);
>
> view.close();
> }
>
> private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, String name)
> {
> check(session, branch, timeStamp, price, name, 2);
> }
>
> private void check(CDOSession session, CDOBranch branch, long timeStamp, float price, float price2, String name)
> {
> CDOView view = session.openView(branch, timeStamp);
> CDOResource resource = view.getResource(getResourcePath("/res"));
> assertEquals(3, resource.getContents().size());
>
> dumpAll(session);
> OrderDetail orderDetail2 = (OrderDetail)resource.getContents().get(0);
> OrderDetail orderDetail = (OrderDetail)resource.getContents().get(2);
>
> dumpAll(session);
> assertEquals(price, orderDetail.getPrice());
> assertEquals(price2, orderDetail2.getPrice());
>
> Product1 product = orderDetail.getProduct();
> Product1 product2 = orderDetail2.getProduct();
> dumpAll(session);
> assertEquals(name, product.getName());
> assertEquals(name, product2.getName());
>
> view.close();
> }
>
> private void dumpAll(CDOSession session)
> {
> IStore store = getRepository().getStore();
> if (store instanceof MEMStore)
> {
> MEMStore memStore = (MEMStore)store;
> dump("MEMStore", memStore.getAllRevisions());
> }
>
> dump("ServerCache", getRepository().getRevisionManager().getCache().getAllRevisions());
> dump("ClientCache", ((InternalCDOSession)session).getRevisionManager().getCache().getAllRevisions());
> }
>
> public static void dump(String label, Map<CDOBranch, List<CDORevision>> revisions)
> {
> System.out.println();
> System.out.println();
> System.out.println(label);
> System.out
> .println("===============================================================================================");
> CDORevisionUtil.dumpAllRevisions(revisions, System.out);
> System.out.println();
> System.out.println();
> }
>
> public static void assertEquals(Object expected, Object actual)
> {
> if (expected instanceof CDOBranch && actual instanceof CDOBranch)
> {
> if (((CDOBranch)expected).getID() != ((CDOBranch)actual).getID())
> {
> failNotEquals(null, expected, actual);
> }
>
> return;
> }
>
> AbstractCDOTest.assertEquals(expected, actual);
> }
> }
>


Re: [CDO] Audit view on branch before base timestamp [message #1696953 is a reply to message #1696949] Fri, 29 May 2015 16:45 Go to previous messageGo to next message
Andras Peteri is currently offline Andras PeteriFriend
Messages: 22
Registered: January 2010
Junior Member
Thank you for the fix!

Returning just briefly to theories Wink I'll try to figure out an access pattern which triggers the same problem with cached reads in CDORevisionManagerImpl#getCachedRevisionRecursively, as it is a very similar looking method.
Re: [CDO] Audit view on branch before base timestamp [message #1696954 is a reply to message #1696953] Fri, 29 May 2015 16:50 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 29.05.2015 um 18:45 schrieb Andras Peteri:
> Thank you for the fix!
>
> Returning just briefly to theories ;) I'll try to figure out an access pattern which triggers the same problem with
> cached reads in CDORevisionManagerImpl#getCachedRevisionRecursively, as it is a very similar looking method.
That method is private and would see the already normalized branch point from my fix.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Previous Topic:[CDO] Problem opening a PApyrus model
Next Topic:How to register ecore file and look up for already registered ones in Eclipse
Goto Forum:
  


Current Time: Fri Oct 18 09:26:56 GMT 2019

Powered by FUDForum. Page generated in 0.02328 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top