Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 77950 Details for
Bug 202064
More client-side intelligence (SmartReadAhead Thread)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
New version - Detect different rules for different graph of instances at the same time
CDODynamicAnalyzer.patch (text/plain), 75.50 KB, created by
Simon Mc Duff
on 2007-09-09 10:05:33 EDT
(
hide
)
Description:
New version - Detect different rules for different graph of instances at the same time
Filename:
MIME Type:
Creator:
Simon Mc Duff
Created:
2007-09-09 10:05:33 EDT
Size:
75.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.cdo.protocol >Index: src/org/eclipse/emf/cdo/protocol/analyzer/IFetchRuleManager.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/protocol/analyzer/IFetchRuleManager.java >diff -N src/org/eclipse/emf/cdo/protocol/analyzer/IFetchRuleManager.java >--- src/org/eclipse/emf/cdo/protocol/analyzer/IFetchRuleManager.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,31 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.protocol.analyzer; >- >-import java.util.Collection; >-import java.util.List; >- >-import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >-import org.eclipse.emf.cdo.internal.protocol.analyzer.NOOPFetchRuleManager; >-import org.eclipse.emf.cdo.protocol.CDOID; >- >-/** >- * @author Eike Stepper >- */ >-public interface IFetchRuleManager >-{ >- public static final IFetchRuleManager NOOP = new NOOPFetchRuleManager(); >- >- public CDOID getContext(); >- >- public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids); >-} >Index: src/org/eclipse/emf/cdo/protocol/analyzer/IFeatureAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/protocol/analyzer/IFeatureAnalyzer.java >diff -N src/org/eclipse/emf/cdo/protocol/analyzer/IFeatureAnalyzer.java >--- src/org/eclipse/emf/cdo/protocol/analyzer/IFeatureAnalyzer.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,28 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.protocol.analyzer; >- >-import org.eclipse.emf.cdo.internal.protocol.analyzer.NOOPFeatureAnalyzer; >-import org.eclipse.emf.cdo.protocol.model.CDOFeature; >-import org.eclipse.emf.cdo.protocol.revision.CDORevision; >- >-/** >- * @author Eike Stepper >- */ >-public interface IFeatureAnalyzer >-{ >- public static final IFeatureAnalyzer NOOP = new NOOPFeatureAnalyzer(); >- >- public void preTraverseFeature(CDORevision revision, CDOFeature feature, int index); >- >- public void postTraverseFeature(CDORevision revision, CDOFeature feature, int index); >-} >Index: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureRule.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureRule.java >diff -N src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureRule.java >--- src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureRule.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,115 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.internal.protocol.analyzer; >- >-import org.eclipse.emf.cdo.internal.protocol.bundle.OM; >-import org.eclipse.emf.cdo.protocol.model.CDOClass; >-import org.eclipse.emf.cdo.protocol.model.CDOFeature; >- >-import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >- >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.Map; >- >-/** >- * @author Eike Stepper >- */ >-public class CDOFeatureRule >-{ >- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOFeatureRule.class); >- >- private CDOClass cdoClass; >- >- private CDOFeature cdoFeature; >- >- private Map<CDOFeature, CDOFetchFeatureStat> featureStats = new HashMap<CDOFeature, CDOFetchFeatureStat>(); >- >- private Map<CDOClass, CDOFetchRule> fetchRules = new HashMap<CDOClass, CDOFetchRule>(); >- >- public CDOFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >- { >- this.cdoClass = cdoClass; >- this.cdoFeature = cdoFeature; >- } >- >- public CDOClass getCDOClass() >- { >- return cdoClass; >- } >- >- public CDOFeature getCDOFeature() >- { >- return cdoFeature; >- } >- >- public Iterator<CDOFetchRule> iterator() >- { >- return fetchRules.values().iterator(); >- } >- >- public synchronized CDOFetchFeatureStat getFeatureStat(CDOFeature cdoFeature) >- { >- CDOFetchFeatureStat featureRule = featureStats.get(cdoFeature); >- if (featureRule == null) >- { >- featureRule = new CDOFetchFeatureStat(); >- featureStats.put(cdoFeature, featureRule); >- } >- >- return featureRule; >- } >- >- public synchronized CDOFetchRule addFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >- { >- if (TRACER.isEnabled()) >- { >- TRACER.format("Adding new fetch rule : {0}.{1} from root {2}.{3}", cdoClass.getName(), cdoFeature.getName(), >- this.cdoClass.getName(), this.cdoFeature.getName()); >- } >- >- CDOFetchRule fetchRule = getFetchRule(cdoClass); >- fetchRule.addFeature(cdoFeature); >- return fetchRule; >- >- } >- >- public synchronized CDOFetchRule removeFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >- { >- if (TRACER.isEnabled()) >- { >- TRACER.format("Adding new fetch rule : {0}.{1} from root {2}.{3}", cdoClass.getName(), cdoFeature.getName(), >- this.cdoClass.getName(), this.cdoFeature.getName()); >- } >- >- CDOFetchRule fetchRule = getFetchRule(cdoClass); >- fetchRule.removeFeature(cdoFeature); >- if (fetchRule.isEmpty()) >- { >- fetchRules.remove(cdoClass); >- } >- >- return fetchRule; >- } >- >- public synchronized CDOFetchRule getFetchRule(CDOClass cdoFeature) >- { >- CDOFetchRule featureRule = fetchRules.get(cdoFeature); >- if (featureRule == null) >- { >- featureRule = new CDOFetchRule(cdoFeature); >- fetchRules.put(cdoFeature, featureRule); >- } >- >- return featureRule; >- } >-} >Index: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchRuleManager.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchRuleManager.java >diff -N src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchRuleManager.java >--- src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchRuleManager.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,38 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.internal.protocol.analyzer; >- >-import java.util.Collection; >-import java.util.List; >- >-import org.eclipse.emf.cdo.protocol.CDOID; >-import org.eclipse.emf.cdo.protocol.analyzer.IFetchRuleManager; >- >-/** >- * @author Eike Stepper >- */ >-public class CDOFetchRuleManager implements IFetchRuleManager >-{ >- public CDOFetchRuleManager() >- { >- } >- >- public CDOID getContext() >- { >- return CDOFeatureAnalyzer.getCurrent().getContext(); >- } >- >- public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >- { >- return CDOFeatureAnalyzer.getCurrent().getFetchRules(ids); >- } >-} >Index: src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFeatureAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFeatureAnalyzer.java >diff -N src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFeatureAnalyzer.java >--- src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFeatureAnalyzer.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,34 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.internal.protocol.analyzer; >- >-import org.eclipse.emf.cdo.protocol.analyzer.IFeatureAnalyzer; >-import org.eclipse.emf.cdo.protocol.model.CDOFeature; >-import org.eclipse.emf.cdo.protocol.revision.CDORevision; >- >-/** >- * @author Eike Stepper >- */ >-public class NOOPFeatureAnalyzer implements IFeatureAnalyzer >-{ >- public NOOPFeatureAnalyzer() >- { >- } >- >- public void preTraverseFeature(CDORevision cdoClass, CDOFeature feature, int index) >- { >- } >- >- public void postTraverseFeature(CDORevision cdoClass, CDOFeature feature, int index) >- { >- } >-} >Index: src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFetchRuleManager.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFetchRuleManager.java >diff -N src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFetchRuleManager.java >--- src/org/eclipse/emf/cdo/internal/protocol/analyzer/NOOPFetchRuleManager.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,41 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.internal.protocol.analyzer; >- >-import java.util.Collection; >-import java.util.List; >- >-import org.eclipse.emf.cdo.internal.protocol.CDOIDNull; >-import org.eclipse.emf.cdo.protocol.CDOID; >-import org.eclipse.emf.cdo.protocol.analyzer.IFetchRuleManager; >- >-/** >- * @author Eike Stepper >- */ >-public class NOOPFetchRuleManager implements IFetchRuleManager >-{ >- public CDOID getContext() >- { >- return CDOIDNull.NULL; >- } >- >- public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >- { >- return null; >- } >- >- @Deprecated >- public List<CDOFetchRule> getFetchRules(CDOID id) >- { >- return null; >- } >-} >Index: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchFeatureStat.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchFeatureStat.java >diff -N src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchFeatureStat.java >--- src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFetchFeatureStat.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,63 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.internal.protocol.analyzer; >- >-/** >- * @author Eike Stepper >- */ >-public class CDOFetchFeatureStat >-{ >- private CDOFetchRule fetchRule; >- >- private long timeBeforeUsed; >- >- private long latencyTime; >- >- public CDOFetchFeatureStat() >- { >- } >- >- public boolean isValid() >- { >- return fetchRule != null; >- } >- >- public long getTimeBeforeUsed() >- { >- return timeBeforeUsed; >- } >- >- public void setTimeBeforeUsed(long timeBeforeUsed) >- { >- this.timeBeforeUsed = timeBeforeUsed; >- } >- >- public long getLatencyTime() >- { >- return latencyTime; >- } >- >- public void setLatencyTime(long latencyTime) >- { >- this.latencyTime = latencyTime; >- } >- >- public CDOFetchRule getFetchRule() >- { >- return fetchRule; >- } >- >- public void setFetchRule(CDOFetchRule fetchRule) >- { >- this.fetchRule = fetchRule; >- } >-} >Index: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureAnalyzer.java >diff -N src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureAnalyzer.java >--- src/org/eclipse/emf/cdo/internal/protocol/analyzer/CDOFeatureAnalyzer.java 7 Sep 2007 08:27:43 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,163 +0,0 @@ >-/*************************************************************************** >- * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >- * 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: >- * Simon McDuff - initial API and implementation >- * Eike Stepper - maintenance >- **************************************************************************/ >-package org.eclipse.emf.cdo.internal.protocol.analyzer; >- >-import org.eclipse.emf.cdo.internal.protocol.bundle.OM; >-import org.eclipse.emf.cdo.protocol.CDOID; >-import org.eclipse.emf.cdo.protocol.analyzer.IFeatureAnalyzer; >-import org.eclipse.emf.cdo.protocol.analyzer.IFetchRuleManager; >-import org.eclipse.emf.cdo.protocol.model.CDOClass; >-import org.eclipse.emf.cdo.protocol.model.CDOFeature; >-import org.eclipse.emf.cdo.protocol.revision.CDORevision; >- >-import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >- >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.List; >-import java.util.Map; >- >-/** >- * @author Eike Stepper >- */ >-public class CDOFeatureAnalyzer implements IFeatureAnalyzer, IFetchRuleManager >-{ >- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOFeatureAnalyzer.class); >- >- private static final long ELAPSE_TIME = 400L; >- >- private static final ThreadLocal<CDOFeatureAnalyzer> threadLocal = new ThreadLocal<CDOFeatureAnalyzer>(); >- >- private Map<CDOFeature, CDOFeatureRule> featureRules = new HashMap<CDOFeature, CDOFeatureRule>(); >- >- private CDOFeatureRule lastFeatureRule; >- >- private long lastAccessTime; >- >- private boolean inUse; >- >- private CDORevision lastRevision; >- >- public CDOFeatureAnalyzer() >- { >- } >- >- public CDOFeatureRule getCurrentFeatureRule() >- { >- return lastFeatureRule; >- } >- >- public static CDOFeatureAnalyzer getCurrent() >- { >- return threadLocal.get(); >- } >- >- public void preTraverseFeature(CDORevision revision, CDOFeature feature, int index) >- { >- CDOClass cdoClass = revision.getCDOClass(); >- threadLocal.set(this); >- lastRevision = revision; >- >- if (TRACER.isEnabled()) >- { >- TRACER.format("preTraverseFeature : {0}.{1}", cdoClass.getName(), feature.getName()); >- } >- >- // Do not handle these cases >- long currentTime = System.currentTimeMillis(); >- if (!feature.isReference() || feature.isContainment() || feature.isMany() && index != 0) >- { >- lastAccessTime = currentTime; >- return; >- } >- >- long elapseTimeBeforeLastRequest = currentTime - lastAccessTime; >- if (elapseTimeBeforeLastRequest > ELAPSE_TIME || lastFeatureRule == null) >- { >- CDOFeatureRule featureRule = getFeatureRule(cdoClass, feature); >- lastFeatureRule = featureRule; >- } >- >- CDOFetchFeatureStat stat = lastFeatureRule.getFeatureStat(feature); >- if (stat.getTimeBeforeUsed() != 0) >- { >- stat.setTimeBeforeUsed((stat.getTimeBeforeUsed() + elapseTimeBeforeLastRequest) / 2); >- } >- else >- { >- stat.setTimeBeforeUsed(elapseTimeBeforeLastRequest); >- } >- >- if (!stat.isValid() && stat.getTimeBeforeUsed() < CDOFeatureAnalyzer.ELAPSE_TIME) >- { >- CDOFetchRule fetchRule = lastFeatureRule.addFeatureRule(cdoClass, feature); >- stat.setFetchRule(fetchRule); >- } >- else if (stat.isValid() && stat.getTimeBeforeUsed() > CDOFeatureAnalyzer.ELAPSE_TIME) >- { >- // Unregister rules >- lastFeatureRule.removeFeatureRule(cdoClass, feature); >- stat.setFetchRule(null); >- } >- >- lastAccessTime = currentTime; >- inUse = true; >- } >- >- public void postTraverseFeature(CDORevision revision, CDOFeature feature, int index) >- { >- if (TRACER.isEnabled()) >- { >- TRACER.format("postTraverseFeature : {0}.{1}", revision.getCDOClass(), feature.getName()); >- } >- >- lastAccessTime = System.currentTimeMillis(); >- inUse = false; >- threadLocal.set(null); >- } >- >- public CDOID getContext() >- { >- return lastRevision.getID(); >- } >- >- public synchronized CDOFeatureRule getFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >- { >- CDOFeatureRule featureRule = featureRules.get(cdoFeature); >- if (featureRule == null) >- { >- featureRule = new CDOFeatureRule(cdoClass, cdoFeature); >- featureRules.put(cdoFeature, featureRule); >- } >- >- return featureRule; >- } >- >- public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >- { >- if (!inUse || lastFeatureRule == null) >- { >- return null; >- } >- >- List<CDOFetchRule> list = new ArrayList<CDOFetchRule>(); >- for (Iterator<CDOFetchRule> it = lastFeatureRule.iterator(); it.hasNext();) >- { >- CDOFetchRule fetchRule = it.next(); >- list.add(fetchRule); >- } >- >- return list; >- } >-} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.protocol/META-INF/MANIFEST.MF,v >retrieving revision 1.18 >diff -u -r1.18 MANIFEST.MF >--- META-INF/MANIFEST.MF 7 Sep 2007 08:27:43 -0000 1.18 >+++ META-INF/MANIFEST.MF 9 Sep 2007 13:59:01 -0000 >@@ -15,7 +15,6 @@ > org.eclipse.emf.cdo.internal.protocol.model.resource;version="0.8.0", > org.eclipse.emf.cdo.internal.protocol.revision;version="0.8.0", > org.eclipse.emf.cdo.protocol;version="0.8.0", >- org.eclipse.emf.cdo.protocol.analyzer;version="0.8.0", > org.eclipse.emf.cdo.protocol.model;version="0.8.0", > org.eclipse.emf.cdo.protocol.model.core;version="0.8.0", > org.eclipse.emf.cdo.protocol.model.resource;version="0.8.0", >#P org.eclipse.emf.cdo.server >Index: src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java,v >retrieving revision 1.11 >diff -u -r1.11 LoadRevisionIndication.java >--- src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java 7 Sep 2007 10:28:42 -0000 1.11 >+++ src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java 9 Sep 2007 13:59:03 -0000 >@@ -28,8 +28,10 @@ > import org.eclipse.net4j.util.io.ExtendedDataOutputStream; > > import java.io.IOException; >+import java.util.ArrayList; > import java.util.HashMap; > import java.util.HashSet; >+import java.util.List; > import java.util.Map; > import java.util.Set; > >@@ -79,39 +81,60 @@ > if (fetchSize > 0) > { > contextID = CDOIDImpl.read(in); >+ >+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading fetch rules for context {0}", contextID); >+ > for (int i = 0; i < fetchSize; i++) > { > CDOFetchRule fetchRule = new CDOFetchRule(in, getPackageManager()); > fetchRules.put(fetchRule.getCDOClass(), fetchRule); >+ > } >+ > } > } > > @Override > protected void responding(ExtendedDataOutputStream out) throws IOException > { >+ > Session session = getSession(); >- Map<CDOID, CDORevisionImpl> containedRevisions = new HashMap<CDOID, CDORevisionImpl>(0); >- >+ >+ List<CDORevisionImpl> additionalRevisions = new ArrayList<CDORevisionImpl>(); >+ >+ HashSet<CDOID> revisions = new HashSet<CDOID>(); >+ > if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing {0} revisions", ids.length); >- for (CDOID id : ids) >+ >+ >+ // Need to fetch the rule first. >+ if (!contextID.isNull() && fetchRules.size() > 0) > { >- CDORevisionImpl revision = getRevision(id); >- revision.write(out, session, referenceChunk); >- session.collectContainedRevisions(revision, referenceChunk, containedRevisions); >+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Collecting more objects based on rules"); >+ //System.out.println("Collecting more objects based on rules"); >+ // Should be more benefits to have referenceChunk more than 1. >+ // Hope the consumer thought about that !!! >+ CDORevisionImpl revisionContext = getRevision(contextID); >+ >+ collectRevisionsByRule(revisionContext, referenceChunk, revisions, additionalRevisions, new HashSet<CDOFetchRule>()); > } > >- if (!contextID.isNull() && fetchRules.size() > 0) >+ >+ >+ for (CDOID id : ids) > { >- // TODO What is this good for? Why 1000? >- int newReferenceChunk = Math.max(referenceChunk, 1000); >- CDORevisionImpl revisionContext = getRevision(contextID); >- collectRevisionsByRule(revisionContext, newReferenceChunk, containedRevisions, new HashSet<CDOFetchRule>()); >+ CDORevisionImpl revision = getRevision(id); >+ revision.write(out, session, referenceChunk); >+ revisions.add( revision.getID() ); >+ session.collectContainedRevisions(revision, referenceChunk, revisions, additionalRevisions); > } > >- out.writeInt(containedRevisions.size()); >- if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing {0} additional revisions", containedRevisions.size()); >- for (CDORevisionImpl revision : containedRevisions.values()) >+ >+ out.writeInt(additionalRevisions.size()); >+ >+ if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing {0} additional revisions", additionalRevisions.size()); >+ //System.out.println("ADDITIONAL REVISION" + additionalRevisions.size()); >+ for (CDORevisionImpl revision : additionalRevisions) > { > revision.write(out, session, referenceChunk); > } >@@ -123,7 +146,8 @@ > } > > private void collectRevisionsByRule(CDORevisionImpl revision, int referenceChunk, >- Map<CDOID, CDORevisionImpl> containedRevisions, Set<CDOFetchRule> workingFetchRules) >+ Set<CDOID> revisions, List<CDORevisionImpl> additionalRevisions, >+ Set<CDOFetchRule> workingFetchRules) > { > CDOFetchRule fetchRule = fetchRules.get(revision.getCDOClass()); > if (fetchRule == null || workingFetchRules.contains(fetchRule)) >@@ -132,6 +156,7 @@ > } > > workingFetchRules.add(fetchRule); >+ > RevisionManager revisionManager = getSessionManager().getRepository().getRevisionManager(); > for (CDOFeature feature : fetchRule.getFeatures()) > { >@@ -145,11 +170,15 @@ > if (value instanceof CDOID) > { > CDOID id = (CDOID)value; >- // TODO Missing here? if (!id.isNull() && >- // !containedRevisions.containsKey(id)) >- CDORevisionImpl containedRevision = revisionManager.getRevision(id, referenceChunk); >- containedRevisions.put(containedRevision.getID(), containedRevision); >- collectRevisionsByRule(containedRevision, referenceChunk, containedRevisions, workingFetchRules); >+ if (!id.isNull() && !revisions.contains(id)) >+ { >+ CDORevisionImpl containedRevision = revisionManager.getRevision(id, referenceChunk); >+ >+ revisions.add(containedRevision.getID()); >+ additionalRevisions.add(containedRevision); >+ >+ collectRevisionsByRule(containedRevision, referenceChunk, revisions, additionalRevisions, workingFetchRules); >+ } > } > } > } >@@ -159,11 +188,14 @@ > if (value instanceof CDOID) > { > CDOID id = (CDOID)value; >- if (!id.isNull() && !containedRevisions.containsKey(id)) >+ if (!id.isNull() && !revisions.contains(id)) > { > CDORevisionImpl containedRevision = revisionManager.getRevision(id, referenceChunk); >- containedRevisions.put(containedRevision.getID(), containedRevision); >- collectRevisionsByRule(containedRevision, referenceChunk, containedRevisions, workingFetchRules); >+ >+ revisions.add(containedRevision.getID()); >+ additionalRevisions.add(containedRevision); >+ >+ collectRevisionsByRule(containedRevision, referenceChunk, revisions, additionalRevisions, workingFetchRules); > } > } > } >Index: src/org/eclipse/emf/cdo/internal/server/Session.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java,v >retrieving revision 1.19 >diff -u -r1.19 Session.java >--- src/org/eclipse/emf/cdo/internal/server/Session.java 7 Sep 2007 08:27:47 -0000 1.19 >+++ src/org/eclipse/emf/cdo/internal/server/Session.java 9 Sep 2007 13:59:03 -0000 >@@ -34,6 +34,7 @@ > > import java.text.MessageFormat; > import java.util.HashSet; >+import java.util.List; > import java.util.Map; > import java.util.Set; > import java.util.concurrent.ConcurrentHashMap; >@@ -170,24 +171,25 @@ > { > return id; > } >- >+ > if (knownObjects.contains(id)) > { > // TODO On client-side add a check if the id is really known! > return id; > } >- >+ > knownObjects.add(id); > Repository repository = sessionManager.getRepository(); > CDOClassRef type = repository.getTypeManager().getObjectType(StoreUtil.getReader(), id); > return CDOIDImpl.create(id.getValue(), type); >+ > } > > /** > * TODO I can't see how recursion is controlled/limited > */ > public void collectContainedRevisions(CDORevisionImpl revision, int referenceChunk, >- Map<CDOID, CDORevisionImpl> containedRevisions) >+ Set<CDOID> revisions, List<CDORevisionImpl> additionalRevisions) > { > RevisionManager revisionManager = getSessionManager().getRepository().getRevisionManager(); > CDOClassImpl cdoClass = revision.getCDOClass(); >@@ -201,14 +203,13 @@ > if (value instanceof CDOID) > { > CDOID id = (CDOID)value; >- if (!id.isNull()) >+ if (!id.isNull() && !revisions.contains(id)) > { >- if (containedRevisions.get(id) == null) >- { > CDORevisionImpl containedRevision = revisionManager.getRevision(id, referenceChunk); >- containedRevisions.put(id, containedRevision); >- collectContainedRevisions(containedRevision, referenceChunk, containedRevisions); >- } >+ revisions.add(id); >+ additionalRevisions.add(containedRevision); >+ >+ collectContainedRevisions(containedRevision, referenceChunk, revisions, additionalRevisions); > } > } > } >#P org.eclipse.emf.cdo >Index: src/org/eclipse/emf/internal/cdo/CDOViewImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java,v >retrieving revision 1.70 >diff -u -r1.70 CDOViewImpl.java >--- src/org/eclipse/emf/internal/cdo/CDOViewImpl.java 7 Sep 2007 08:27:45 -0000 1.70 >+++ src/org/eclipse/emf/internal/cdo/CDOViewImpl.java 9 Sep 2007 13:59:06 -0000 >@@ -13,10 +13,18 @@ > **************************************************************************/ > package org.eclipse.emf.internal.cdo; > >+import java.text.MessageFormat; >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+import java.util.Set; >+ > import org.eclipse.emf.cdo.CDOState; > import org.eclipse.emf.cdo.CDOView; > import org.eclipse.emf.cdo.CDOViewEvent; > import org.eclipse.emf.cdo.CDOViewResourcesEvent; >+import org.eclipse.emf.cdo.analyzer.CDOFeatureAnalyzer; > import org.eclipse.emf.cdo.eresource.CDOResource; > import org.eclipse.emf.cdo.eresource.EresourceFactory; > import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; >@@ -25,18 +33,12 @@ > import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; > import org.eclipse.emf.cdo.protocol.CDOID; > import org.eclipse.emf.cdo.protocol.CDOIDTyped; >-import org.eclipse.emf.cdo.protocol.analyzer.IFeatureAnalyzer; > import org.eclipse.emf.cdo.protocol.model.CDOClass; > import org.eclipse.emf.cdo.protocol.model.CDOClassRef; > import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver; > import org.eclipse.emf.cdo.protocol.util.TransportException; > import org.eclipse.emf.cdo.util.CDOUtil; > import org.eclipse.emf.cdo.util.ReadOnlyException; >- >-import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >-import org.eclipse.net4j.signal.IFailOverStrategy; >-import org.eclipse.net4j.util.ImplementationError; >- > import org.eclipse.emf.common.notify.Adapter; > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.common.notify.Notifier; >@@ -52,13 +54,9 @@ > import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest; > import org.eclipse.emf.internal.cdo.util.FSMUtil; > import org.eclipse.emf.internal.cdo.util.ModelUtil; >- >-import java.text.MessageFormat; >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.List; >-import java.util.Map; >-import java.util.Set; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+import org.eclipse.net4j.signal.IFailOverStrategy; >+import org.eclipse.net4j.util.ImplementationError; > > /** > * @author Eike Stepper >@@ -78,7 +76,7 @@ > > private int loadRevisionCollectionChunkSize = 1; > >- private IFeatureAnalyzer featureAnalyzer = IFeatureAnalyzer.NOOP; >+ private CDOFeatureAnalyzer featureAnalyzer = CDOFeatureAnalyzer.NOOP; > > private Map<CDOID, InternalCDOObject> objects = new HashMap<CDOID, InternalCDOObject>(); > >@@ -144,14 +142,14 @@ > this.loadRevisionCollectionChunkSize = loadRevisionCollectionChunkSize; > } > >- public IFeatureAnalyzer getFeatureAnalyzer() >+ public CDOFeatureAnalyzer getFeatureAnalyzer() > { > return featureAnalyzer; > } > >- public void setFeatureAnalyzer(IFeatureAnalyzer featureAnalyzer) >+ public void setFeatureAnalyzer(CDOFeatureAnalyzer featureAnalyzer) > { >- this.featureAnalyzer = featureAnalyzer == null ? IFeatureAnalyzer.NOOP : featureAnalyzer; >+ this.featureAnalyzer = featureAnalyzer == null ? CDOFeatureAnalyzer.NOOP : featureAnalyzer; > } > > public CDOTransactionImpl toTransaction() >Index: src/org/eclipse/emf/internal/cdo/CDOStore.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java,v >retrieving revision 1.29 >diff -u -r1.29 CDOStore.java >--- src/org/eclipse/emf/internal/cdo/CDOStore.java 7 Sep 2007 08:27:45 -0000 1.29 >+++ src/org/eclipse/emf/internal/cdo/CDOStore.java 9 Sep 2007 13:59:06 -0000 >@@ -10,15 +10,16 @@ > **************************************************************************/ > package org.eclipse.emf.internal.cdo; > >+import java.text.MessageFormat; >+import java.util.HashSet; >+import java.util.Set; >+ > import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl; > import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; > import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList; > import org.eclipse.emf.cdo.protocol.CDOID; > import org.eclipse.emf.cdo.protocol.model.CDOFeature; > import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy; >- >-import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >- > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EStructuralFeature; >@@ -27,10 +28,7 @@ > import org.eclipse.emf.internal.cdo.bundle.OM; > import org.eclipse.emf.internal.cdo.util.FSMUtil; > import org.eclipse.emf.internal.cdo.util.ModelUtil; >- >-import java.text.MessageFormat; >-import java.util.HashSet; >-import java.util.Set; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; > > /** > * @author Eike Stepper >@@ -106,7 +104,7 @@ > TRACER.format("get({0}, {1}, {2})", cdoObject, cdoFeature, index); > } > >- view.getFeatureAnalyzer().preTraverseFeature(cdoObject.cdoRevision(), cdoFeature, index); >+ view.getFeatureAnalyzer().preTraverseFeature(cdoObject, cdoFeature, index); > CDORevisionImpl revision = getRevisionForReading(cdoObject); > Object value = get(revision, cdoFeature, index); > if (cdoFeature.isReference()) >@@ -116,11 +114,11 @@ > CDOID id = (CDOID)value; > loadAhead(revision, cdoFeature, id, index); > } >- >+ > value = view.convertIDToObject(value); > } >- >- view.getFeatureAnalyzer().postTraverseFeature(cdoObject.cdoRevision(), cdoFeature, index); >+ >+ view.getFeatureAnalyzer().postTraverseFeature(cdoObject, cdoFeature, index, value); > return value; > } > >Index: src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java,v >retrieving revision 1.15 >diff -u -r1.15 CDORevisionManagerImpl.java >--- src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java 7 Sep 2007 08:27:45 -0000 1.15 >+++ src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java 9 Sep 2007 13:59:05 -0000 >@@ -15,7 +15,7 @@ > import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl; > import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList; > import org.eclipse.emf.cdo.protocol.CDOID; >-import org.eclipse.emf.cdo.protocol.analyzer.IFetchRuleManager; >+import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; > import org.eclipse.emf.cdo.protocol.model.CDOFeature; > import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy; > import org.eclipse.emf.cdo.protocol.util.TransportException; >@@ -39,7 +39,7 @@ > { > private CDOSessionImpl session; > >- private IFetchRuleManager ruleManager = IFetchRuleManager.NOOP; >+ private CDOFetchRuleManager ruleManager = CDOFetchRuleManager.NOOP; > > public CDORevisionManagerImpl(CDOSessionImpl session) > { >@@ -251,12 +251,12 @@ > } > } > >- public IFetchRuleManager getRuleManager() >+ public CDOFetchRuleManager getRuleManager() > { > return ruleManager; > } > >- public void setRuleManager(IFetchRuleManager ruleManager) >+ public void setRuleManager(CDOFetchRuleManager ruleManager) > { > this.ruleManager = ruleManager; > } >Index: src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java,v >retrieving revision 1.10 >diff -u -r1.10 LoadRevisionRequest.java >--- src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java 7 Sep 2007 08:27:46 -0000 1.10 >+++ src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java 9 Sep 2007 13:59:06 -0000 >@@ -10,28 +10,26 @@ > **************************************************************************/ > package org.eclipse.emf.internal.cdo.protocol; > >+import java.io.IOException; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; > import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; > import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; > import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; > import org.eclipse.emf.cdo.protocol.CDOID; > import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; >-import org.eclipse.emf.cdo.protocol.analyzer.IFetchRuleManager; >- >-import org.eclipse.net4j.IChannel; >-import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >-import org.eclipse.net4j.util.io.ExtendedDataInputStream; >-import org.eclipse.net4j.util.io.ExtendedDataOutputStream; >- > import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; > import org.eclipse.emf.internal.cdo.CDOSessionImpl; > import org.eclipse.emf.internal.cdo.CDOSessionPackageManager; > import org.eclipse.emf.internal.cdo.bundle.OM; >- >-import java.io.IOException; >-import java.util.ArrayList; >-import java.util.Collection; >-import java.util.Collections; >-import java.util.List; >+import org.eclipse.net4j.IChannel; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+import org.eclipse.net4j.util.io.ExtendedDataInputStream; >+import org.eclipse.net4j.util.io.ExtendedDataOutputStream; > > /** > * @author Eike Stepper >@@ -77,24 +75,22 @@ > CDOIDImpl.write(out, id); > } > >- IFetchRuleManager ruleManager = getSession().getRevisionManager().getRuleManager(); >+ CDOFetchRuleManager ruleManager = getSession().getRevisionManager().getRuleManager(); > List<CDOFetchRule> fetchRules = ruleManager.getFetchRules(ids); >- if (fetchRules == null || fetchRules.size() == 0) >+ if (fetchRules == null || fetchRules.size() <= 0) > { > out.writeInt(0); > } > else > { >+ // At this point, fetch size is more than one. > int fetchSize = fetchRules.size(); > out.writeInt(fetchSize); >- if (fetchSize > 0) >+ CDOID contextID = ruleManager.getContext(); >+ CDOIDImpl.write(out, contextID); >+ for (CDOFetchRule fetchRule : fetchRules) > { >- CDOID contextID = ruleManager.getContext(); >- CDOIDImpl.write(out, contextID); >- for (CDOFetchRule fetchRule : fetchRules) >- { >- fetchRule.write(out); >- } >+ fetchRule.write(out); > } > } > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF,v >retrieving revision 1.7 >diff -u -r1.7 MANIFEST.MF >--- META-INF/MANIFEST.MF 31 Aug 2007 15:13:31 -0000 1.7 >+++ META-INF/MANIFEST.MF 9 Sep 2007 13:59:05 -0000 >@@ -13,11 +13,13 @@ > org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)", > org.eclipse.emf.cdo.protocol;bundle-version="[0.8.0,0.9.0)";visibility:=reexport > Export-Package: org.eclipse.emf.cdo;version="0.8.0", >+ org.eclipse.emf.cdo.analyzer;version="0.8.0", > org.eclipse.emf.cdo.eresource;version="0.8.0", > org.eclipse.emf.cdo.eresource.impl;version="0.8.0", > org.eclipse.emf.cdo.eresource.util;version="0.8.0", > org.eclipse.emf.cdo.util;version="0.8.0", > org.eclipse.emf.internal.cdo;version="0.8.0", >+ org.eclipse.emf.internal.cdo.analyzer;version="0.8.0", > org.eclipse.emf.internal.cdo.protocol;version="0.8.0", > org.eclipse.emf.internal.cdo.util;version="0.8.0" > Eclipse-LazyStart: true >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDOFetchFeatureInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.internal.cdo.bundle.OM; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+ >+/** >+ * @author Eike Stepper >+ */ >+public class CDOFetchFeatureInfo >+{ >+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOFetchFeatureInfo.class); >+ >+ private long timeBeforeUsed; >+ >+ private long latencyTime; >+ >+ private boolean active; >+ >+ public CDOFetchFeatureInfo() >+ { >+ active = false; >+ latencyTime = -1; >+ } >+ >+ public boolean isActive() >+ { >+ return active; >+ } >+ public void setActive(boolean isActive) >+ { >+ active = isActive; >+ } >+ >+ public long getTimeBeforeUsed() >+ { >+ return timeBeforeUsed; >+ } >+ >+ public void setTimeBeforeUsed(long timeBeforeUsed) >+ { >+ this.timeBeforeUsed = timeBeforeUsed; >+ } >+ >+ public long getLatencyTime() >+ { >+ return latencyTime; >+ } >+ /** >+ * >+ * @param latencyTime >+ */ >+ public void updateLatencyTime(long latencyTime) >+ { >+ if (this.latencyTime == -1) >+ this.latencyTime = latencyTime; >+ else >+ this.latencyTime = (latencyTime + this.latencyTime) / 2; >+ } >+ /** >+ * >+ * @param latencyTime >+ */ >+ public void setLatencyTime(long latencyTime) >+ { >+ this.latencyTime = latencyTime; >+ } >+ /** >+ * >+ * @param elapseTimeBeforeLastRequest >+ */ >+ public void updateTimeInfo(long elapseTimeBeforeLastRequest) >+ { >+ if (this.getTimeBeforeUsed() != 0) >+ { >+ this.setTimeBeforeUsed((this.getTimeBeforeUsed() + elapseTimeBeforeLastRequest) / 2); >+ } >+ else >+ { >+ this.setTimeBeforeUsed(elapseTimeBeforeLastRequest); >+ } >+ } >+ >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleAnalyzer.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleAnalyzer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleAnalyzer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,238 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.emf.cdo.CDOView; >+import org.eclipse.emf.cdo.analyzer.CDOFeatureAnalyzer; >+import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.cdo.protocol.CDOID; >+import org.eclipse.emf.cdo.protocol.model.CDOClass; >+import org.eclipse.emf.cdo.protocol.model.CDOFeature; >+import org.eclipse.emf.internal.cdo.InternalCDOObject; >+import org.eclipse.emf.internal.cdo.bundle.OM; >+import org.eclipse.emf.internal.cdo.util.FSMUtil; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+ >+/** >+ * @author Eike Stepper >+ */ >+public class CDODynamicFetchRuleAnalyzer implements CDOFeatureAnalyzer, CDOFetchRuleManager >+{ >+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDODynamicFetchRuleAnalyzer.class); >+ >+ private static final long ELAPSE_TIME = 400L; >+ >+ private Map<CDOFeature, CDOClusterOfFetchRule> featureRules = new HashMap<CDOFeature, CDOClusterOfFetchRule>(); >+ >+ private CDOGraphAnalyzer graphAnalyzer = new CDOGraphAnalyzer(); >+ >+ private CDOGraph currentGraph; >+ >+ private long lastAccessTime; >+ >+ private boolean inUse; >+ >+ private InternalCDOObject lastRevision; >+ >+ private CDOView cdoView; >+ >+ private boolean doesFetch; >+ >+ >+ /** >+ * >+ * @param view >+ */ >+ public CDODynamicFetchRuleAnalyzer(CDOView view) >+ { >+ cdoView = view; >+ } >+ >+ /** >+ * >+ * @return >+ */ >+ public CDOClusterOfFetchRule getCurrentFeatureRule() >+ { >+ return currentGraph.getFeatureRule(); >+ } >+ >+ >+ public CDOGraph getCurrentGraph() >+ { >+ return this.currentGraph; >+ } >+ /** >+ * >+ */ >+ public void preTraverseFeature(InternalCDOObject cdoObject, CDOFeature feature, int index) >+ { >+ CDOClass cdoClass = cdoObject.cdoClass(); >+ >+ doesFetch = false; >+ >+ CDODynamicFetchRuleManager.join(this); >+ >+ lastRevision = cdoObject; >+ >+ if (TRACER.isEnabled()) >+ { >+ TRACER.format("preTraverseFeature : {0}.{1}", cdoClass.getName(), feature.getName()); >+ } >+ >+ // Do not handle these cases >+ long currentTime = System.currentTimeMillis(); >+ long elapseTimeBeforeLastRequest = currentTime - lastAccessTime; >+ lastAccessTime = currentTime; >+ >+ // Don`t handle containment relationship >+ if (!feature.isReference()) //|| feature.isContainment()) >+ return; >+ >+ >+ if (elapseTimeBeforeLastRequest > ELAPSE_TIME) >+ { >+ graphAnalyzer.clear(); >+ } >+ >+ // Purge old graph that we didn't update for specific elapse time >+ graphAnalyzer.purge(ELAPSE_TIME * 2, ELAPSE_TIME * 2); >+ >+ CDOClusterOfFetchRule featureRule = this.getFeatureRule(cdoClass, feature); >+ >+ // Get the graph <cdoObject> belongs to >+ this.currentGraph = graphAnalyzer.getGraph(cdoObject.cdoID(), featureRule); >+ lastAccessTime = System.currentTimeMillis(); >+ >+ if (currentGraph.getFeatureRule().getRootFeature() == feature) >+ { >+ if (graphAnalyzer.isTimeToRemove(currentGraph, lastAccessTime, ELAPSE_TIME)) >+ { >+ // Clean it!! >+ currentGraph.clean(); >+ return; >+ } >+ } >+ >+ // need to calculate currentFeature to calculate the connected graph >+ if ( feature.isMany() && index != 0) >+ { >+ return; >+ } >+ >+ // Get the cluster of rule for that feature >+ CDOClusterOfFetchRule currentFeatureRule = currentGraph.getFeatureRule(); >+ >+ CDOFetchFeatureInfo infoOfFeature = currentFeatureRule.getFeatureStat(feature); >+ >+ infoOfFeature.updateTimeInfo(elapseTimeBeforeLastRequest); >+ >+ // Detect a new rule >+ if (!infoOfFeature.isActive() && infoOfFeature.getTimeBeforeUsed() < CDODynamicFetchRuleAnalyzer.ELAPSE_TIME) >+ { >+ currentFeatureRule.addFeatureRule(cdoClass, feature); >+ infoOfFeature.setActive(true); >+ } >+ // Detect if the rule is still good! >+ else if (infoOfFeature.isActive() && infoOfFeature.getTimeBeforeUsed() > CDODynamicFetchRuleAnalyzer.ELAPSE_TIME) >+ { >+ // Unregister rules >+ currentFeatureRule.removeFeatureRule(cdoClass, feature); >+ infoOfFeature.setActive(false); >+ } >+ >+ lastAccessTime = currentTime; >+ inUse = true; >+ } >+ >+ public void postTraverseFeature(InternalCDOObject cdoObject, CDOFeature feature, int index, Object object) >+ { >+ >+ if (TRACER.isEnabled()) >+ { >+ TRACER.format("postTraverseFeature : {0}.{1}", cdoObject.cdoClass(), feature.getName()); >+ } >+ if (currentGraph != null) >+ { >+ // Adding return object to the link graph >+ InternalCDOObject dstCdoObject = FSMUtil.adapt(object, cdoView); >+ currentGraph.add(cdoObject.cdoID(), feature, dstCdoObject.cdoID()); >+ >+ // calculate latency time >+ if (doesFetch == true) >+ { >+ CDOClusterOfFetchRule currentFeatureRule = currentGraph.getFeatureRule(); >+ CDOFetchFeatureInfo infoOfFeature = currentFeatureRule.getFeatureStat(feature); >+ infoOfFeature.updateLatencyTime( System.currentTimeMillis() - lastAccessTime); >+ } >+ } >+ >+ lastAccessTime = System.currentTimeMillis(); >+ inUse = false; >+ >+ CDODynamicFetchRuleManager.leave(); >+ } >+ >+ public CDOID getContext() >+ { >+ return lastRevision.cdoID(); >+ } >+ >+ /** >+ * >+ * @param cdoClass >+ * @param cdoFeature >+ * @return >+ */ >+ public synchronized CDOClusterOfFetchRule getFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >+ { >+ CDOClusterOfFetchRule featureRule = featureRules.get(cdoFeature); >+ if (featureRule == null) >+ { >+ featureRule = new CDOClusterOfFetchRule(cdoFeature); >+ featureRules.put(cdoFeature, featureRule); >+ } >+ >+ return featureRule; >+ } >+ >+ /** >+ * Called when from LoadRevisionRequest >+ */ >+ public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >+ { >+ doesFetch = true; >+ >+ if (!inUse || currentGraph == null) >+ { >+ return null; >+ } >+ >+ List<CDOFetchRule> list = new ArrayList<CDOFetchRule>(); >+ >+ for (Iterator<CDOFetchRule> it = currentGraph.getFeatureRule().iterator(); it.hasNext();) >+ { >+ CDOFetchRule fetchRule = it.next(); >+ list.add(fetchRule); >+ } >+ >+ return list; >+ } >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/NOOPFetchRuleManager.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/NOOPFetchRuleManager.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/NOOPFetchRuleManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/NOOPFetchRuleManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,36 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.Collection; >+import java.util.List; >+ >+import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; >+import org.eclipse.emf.cdo.internal.protocol.CDOIDNull; >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.cdo.protocol.CDOID; >+ >+/** >+ * @author Eike Stepper >+ */ >+public class NOOPFetchRuleManager implements CDOFetchRuleManager >+{ >+ public CDOID getContext() >+ { >+ return CDOIDNull.NULL; >+ } >+ >+ public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >+ { >+ return null; >+ } >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleManager.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleManager.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDODynamicFetchRuleManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.Collection; >+import java.util.List; >+ >+import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.cdo.protocol.CDOID; >+import org.eclipse.emf.internal.cdo.bundle.OM; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+ >+/** >+ * @author Eike Stepper >+ */ >+public class CDODynamicFetchRuleManager implements CDOFetchRuleManager >+{ >+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDODynamicFetchRuleManager.class); >+ >+ private static final ThreadLocal<CDOFetchRuleManager> threadLocal = new ThreadLocal<CDOFetchRuleManager>(); >+ >+ public CDODynamicFetchRuleManager() >+ { >+ >+ } >+ >+ /** >+ * >+ * @param fetchRulemanager >+ */ >+ public static void join(CDOFetchRuleManager fetchRulemanager) >+ { >+ threadLocal.set(fetchRulemanager); >+ } >+ /** >+ * >+ * @return >+ */ >+ public static CDOFetchRuleManager getCurrent() >+ { >+ return threadLocal.get(); >+ } >+ /** >+ * >+ */ >+ public static void leave() >+ { >+ threadLocal.set(null); >+ } >+ >+ public CDOID getContext() >+ { >+ CDOFetchRuleManager analyzer = CDODynamicFetchRuleManager.getCurrent(); >+ return analyzer != null? analyzer.getContext() : null; >+ } >+ >+ public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >+ { >+ CDOFetchRuleManager analyzer = CDODynamicFetchRuleManager.getCurrent(); >+ return analyzer != null ? analyzer.getFetchRules(ids) : null; >+ } >+} >Index: src/org/eclipse/emf/cdo/analyzer/CDOFetchRuleManager.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/analyzer/CDOFetchRuleManager.java >diff -N src/org/eclipse/emf/cdo/analyzer/CDOFetchRuleManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/cdo/analyzer/CDOFetchRuleManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.cdo.analyzer; >+ >+import java.util.Collection; >+import java.util.List; >+ >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.cdo.protocol.CDOID; >+import org.eclipse.emf.internal.cdo.analyzer.NOOPFetchRuleManager; >+ >+/** >+ * @author Eike Stepper >+ */ >+public interface CDOFetchRuleManager >+{ >+ public static final CDOFetchRuleManager NOOP = new NOOPFetchRuleManager(); >+ >+ public CDOID getContext(); >+ >+ public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids); >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDOClusterOfFetchRule.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,156 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+ >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.cdo.protocol.model.CDOClass; >+import org.eclipse.emf.cdo.protocol.model.CDOFeature; >+import org.eclipse.emf.internal.cdo.bundle.OM; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+ >+/** >+ * @author Eike Stepper >+ */ >+public class CDOClusterOfFetchRule >+{ >+ public static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOClusterOfFetchRule.class); >+ >+ private Map<CDOFeature, CDOFetchFeatureInfo> featureStats = new HashMap<CDOFeature, CDOFetchFeatureInfo>(); >+ >+ private Map<CDOClass, CDOFetchRule> fetchRules = new HashMap<CDOClass, CDOFetchRule>(); >+ >+ private long lastUpdate; >+ >+ private CDOFeature rootFeature; >+ /** >+ * >+ * @param cdoClass >+ * @param cdoFeature >+ */ >+ public CDOClusterOfFetchRule(CDOFeature rootFeature) >+ { >+ lastUpdate = System.currentTimeMillis(); >+ this.rootFeature = rootFeature; >+ } >+ >+ public boolean isActive() >+ { >+ return !fetchRules.isEmpty(); >+ } >+ /** >+ * >+ * @return >+ */ >+ public Iterator<CDOFetchRule> iterator() >+ { >+ return fetchRules.values().iterator(); >+ } >+ >+ /** >+ * >+ * @param cdoFeature >+ * @return >+ */ >+ public synchronized CDOFetchFeatureInfo getFeatureStat(CDOFeature cdoFeature) >+ { >+ CDOFetchFeatureInfo featureRule = featureStats.get(cdoFeature); >+ if (featureRule == null) >+ { >+ featureRule = new CDOFetchFeatureInfo(); >+ featureStats.put(cdoFeature, featureRule); >+ } >+ >+ return featureRule; >+ } >+ >+ /** >+ * >+ * @param cdoClass >+ * @param cdoFeature >+ * @return >+ */ >+ public synchronized CDOFetchRule addFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >+ { >+ if (TRACER.isEnabled()) >+ { >+ TRACER.format("Adding new fetch rule : {0}.{1} from root feature {2}", cdoClass.getName(), cdoFeature.getName(), rootFeature); >+ } >+ lastUpdate = System.currentTimeMillis(); >+ CDOFetchRule fetchRule = getFetchRule(cdoClass); >+ fetchRule.addFeature(cdoFeature); >+ return fetchRule; >+ >+ } >+ >+ /** >+ * >+ * @param cdoClass >+ * @param cdoFeature >+ * @return >+ */ >+ public synchronized CDOFetchRule removeFeatureRule(CDOClass cdoClass, CDOFeature cdoFeature) >+ { >+ if (TRACER.isEnabled()) >+ { >+ TRACER.format("Removing fetch rule : {0}.{1} from root feature {2}", cdoClass.getName(), cdoFeature.getName(),rootFeature); >+ } >+ >+ lastUpdate = System.currentTimeMillis(); >+ >+ CDOFetchRule fetchRule = getFetchRule(cdoClass); >+ fetchRule.removeFeature(cdoFeature); >+ if (fetchRule.isEmpty()) >+ { >+ fetchRules.remove(cdoClass); >+ } >+ return fetchRule; >+ } >+ >+ /** >+ * >+ * @param cdoFeature >+ * @return >+ */ >+ public synchronized CDOFetchRule getFetchRule(CDOClass cdoFeature) >+ { >+ CDOFetchRule featureRule = fetchRules.get(cdoFeature); >+ if (featureRule == null) >+ { >+ featureRule = new CDOFetchRule(cdoFeature); >+ fetchRules.put(cdoFeature, featureRule); >+ } >+ >+ return featureRule; >+ } >+ >+ /** >+ * >+ * @return >+ */ >+ public long getLastUpdate() >+ { >+ return lastUpdate; >+ } >+ >+ /** >+ * >+ * @return >+ */ >+ public CDOFeature getRootFeature() >+ { >+ return rootFeature; >+ } >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/NOOPFeatureAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/NOOPFeatureAnalyzer.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/NOOPFeatureAnalyzer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/NOOPFeatureAnalyzer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import org.eclipse.emf.cdo.analyzer.CDOFeatureAnalyzer; >+import org.eclipse.emf.cdo.protocol.model.CDOFeature; >+import org.eclipse.emf.internal.cdo.InternalCDOObject; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public class NOOPFeatureAnalyzer implements CDOFeatureAnalyzer >+{ >+ public NOOPFeatureAnalyzer() >+ { >+ } >+ >+ public void preTraverseFeature(InternalCDOObject cdoClass, CDOFeature feature, int index) >+ { >+ } >+ >+ public void postTraverseFeature(InternalCDOObject cdoClass, CDOFeature feature, int index, Object value) >+ { >+ } >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDOGraph.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDOGraph.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDOGraph.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDOGraph.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,137 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * >+ **************************************************************************/ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.emf.cdo.protocol.CDOID; >+import org.eclipse.emf.cdo.protocol.model.CDOFeature; >+import org.eclipse.emf.internal.cdo.bundle.OM; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+ >+/** >+ * >+ * @author Eike Stepper >+ * >+ */ >+public class CDOGraph >+{ >+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOGraph.class); >+ >+ private CDOClusterOfFetchRule featureRule; >+ >+ private List<CDOID> clusterOfObjects = new ArrayList<CDOID>(); >+ >+ private long lastUpdated; >+ >+ private long creationTime; >+ >+ private CDOGraphAnalyzer analyzer; >+ >+ /** >+ * >+ * @param analyzer >+ * @param rootID >+ * @param featureRule >+ */ >+ public CDOGraph(CDOGraphAnalyzer analyzer, CDOID rootID, CDOClusterOfFetchRule featureRule) >+ { >+ this.featureRule = featureRule; >+ this.analyzer = analyzer; >+ // Adding the root element >+ add(rootID, null, rootID); >+ creationTime = System.currentTimeMillis(); >+ } >+ >+ /** >+ * >+ */ >+ public void clean() >+ { >+ Iterator<CDOID> itr = clusterOfObjects.iterator(); >+ itr.next(); // Skip the Root! >+ while(itr.hasNext()) >+ { >+ analyzer.removeTrackingID(itr.next()); >+ } >+ creationTime = System.currentTimeMillis(); >+ } >+ >+ /** >+ * >+ */ >+ public void update() >+ { >+ lastUpdated = System.currentTimeMillis(); >+ } >+ /** >+ * >+ * @param cdoID >+ */ >+ public void add(CDOID fromId, CDOFeature feature, CDOID cdoID) >+ { >+ // For now .. we do not need to calculate the path.. later we will do!! >+ clusterOfObjects.add(cdoID); >+ analyzer.addTrackingID(cdoID, this); >+ } >+ public CDOID getRoot() >+ { >+ return getObjects().get(0); >+ } >+ /** >+ * >+ * @return >+ */ >+ public List<CDOID> getObjects() >+ { >+ return this.clusterOfObjects; >+ } >+ /*** >+ * >+ * @return >+ */ >+ public CDOClusterOfFetchRule getFeatureRule() >+ { >+ return featureRule; >+ } >+ >+ /** >+ * >+ */ >+ public void remove() >+ { >+ if (TRACER.isEnabled()) >+ { >+ TRACER.format("Removing CDOGraph {0}", this); >+ } >+ >+ for (CDOID cdoId : this.clusterOfObjects) >+ { >+ analyzer.removeTrackingID(cdoId); >+ } >+ analyzer.removeTracking(this); >+ } >+ /** >+ * >+ * @return >+ */ >+ public long getLastUpdated() >+ { >+ return lastUpdated; >+ } >+ >+ public long getCreationTime() { >+ return creationTime; >+ } >+}; >Index: src/org/eclipse/emf/cdo/analyzer/CDOFeatureAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/analyzer/CDOFeatureAnalyzer.java >diff -N src/org/eclipse/emf/cdo/analyzer/CDOFeatureAnalyzer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/cdo/analyzer/CDOFeatureAnalyzer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * Eike Stepper - maintenance >+ **************************************************************************/ >+package org.eclipse.emf.cdo.analyzer; >+ >+import org.eclipse.emf.cdo.protocol.model.CDOFeature; >+import org.eclipse.emf.internal.cdo.InternalCDOObject; >+import org.eclipse.emf.internal.cdo.analyzer.NOOPFeatureAnalyzer; >+ >+ >+/** >+ * @author Eike Stepper >+ */ >+public interface CDOFeatureAnalyzer >+{ >+ public static final CDOFeatureAnalyzer NOOP = new NOOPFeatureAnalyzer(); >+ >+ public void preTraverseFeature(InternalCDOObject revision, CDOFeature feature, int index); >+ >+ public void postTraverseFeature(InternalCDOObject revision, CDOFeature feature, int index, Object value); >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDOReadAhead.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDOReadAhead.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDOReadAhead.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDOReadAhead.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,99 @@ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; >+import org.eclipse.emf.cdo.internal.protocol.analyzer.CDOFetchRule; >+import org.eclipse.emf.cdo.protocol.CDOID; >+import org.eclipse.emf.internal.cdo.CDOSessionImpl; >+import org.eclipse.emf.internal.cdo.CDOViewImpl; >+import org.eclipse.net4j.internal.util.concurrent.QueueWorkerWorkSerializer; >+ >+public class CDOReadAhead >+{ >+ QueueWorkerWorkSerializer workerWork = new QueueWorkerWorkSerializer(); >+ CDOViewImpl session; >+ >+ public CDOReadAhead(CDOViewImpl session) >+ { >+ this.session = session; >+ } >+ >+ /** >+ * >+ * @return >+ */ >+ public CDOViewImpl getSession() >+ { >+ return session; >+ } >+ >+ /** >+ * >+ * @param cdoID >+ */ >+ public void addID(Set<CDOID> cdoID) >+ { >+ CDODynamicFetchRuleAnalyzer dynamic = ((CDODynamicFetchRuleAnalyzer)getSession().getFeatureAnalyzer()); >+ >+ if ( dynamic.getCurrentGraph().getFeatureRule().isActive()) >+ { >+ workerWork.addWork( new ReceiverWork(cdoID)); >+ } >+ >+ } >+ >+ >+ /** >+ * >+ * @author Simon McDuff >+ * >+ */ >+ private final class ReceiverWork implements Runnable >+ { >+ private final class Test implements CDOFetchRuleManager >+ { >+ >+ public CDOID getContext() >+ { >+ // TODO Auto-generated method stub >+ return context; >+ } >+ >+ public List<CDOFetchRule> getFetchRules(Collection<CDOID> ids) >+ { >+ // TODO Auto-generated method stub >+ List<CDOFetchRule> list = new ArrayList<CDOFetchRule>(); >+ >+ for (Iterator<CDOFetchRule> it = graph.getFeatureRule().iterator(); it.hasNext();) >+ { >+ CDOFetchRule fetchRule = it.next(); >+ list.add(fetchRule); >+ } >+ return list; >+ } >+ } >+ private Set<CDOID> cdoID; >+ private CDODynamicFetchRuleAnalyzer dynamic; >+ private CDOGraph graph; >+ private CDOID context; >+ private Test test = new Test(); >+ private ReceiverWork(Set<CDOID> cdoID) >+ { >+ this.cdoID = cdoID; >+ dynamic = ((CDODynamicFetchRuleAnalyzer)getSession().getFeatureAnalyzer()); >+ graph = dynamic.getCurrentGraph(); >+ this.context = ((CDODynamicFetchRuleAnalyzer)getSession().getFeatureAnalyzer()).getContext(); >+ } >+ public void run() >+ { >+ CDODynamicFetchRuleManager.join(test); >+ getSession().getSession().getRevisionManager().getRevisions(cdoID, getSession().getSession().getReferenceChunkSize()); >+ } >+ } >+ >+} >Index: src/org/eclipse/emf/internal/cdo/analyzer/CDOGraphAnalyzer.java >=================================================================== >RCS file: src/org/eclipse/emf/internal/cdo/analyzer/CDOGraphAnalyzer.java >diff -N src/org/eclipse/emf/internal/cdo/analyzer/CDOGraphAnalyzer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/internal/cdo/analyzer/CDOGraphAnalyzer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,126 @@ >+/*************************************************************************** >+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany. >+ * 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: >+ * Simon McDuff - initial API and implementation >+ * >+ **************************************************************************/ >+ >+package org.eclipse.emf.internal.cdo.analyzer; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.HashSet; >+import java.util.Map; >+ >+import org.eclipse.emf.cdo.protocol.CDOID; >+import org.eclipse.emf.internal.cdo.bundle.OM; >+import org.eclipse.net4j.internal.util.om.trace.ContextTracer; >+/** >+ * @author Eike Stepper >+ */ >+public class CDOGraphAnalyzer >+{ >+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOGraphAnalyzer.class); >+ >+ private Map<CDOID, CDOGraph> fromIdToGraphMaps = new HashMap<CDOID, CDOGraph>(); >+ >+ private HashSet<CDOGraph> uniqueGraphSet = new HashSet<CDOGraph>(); >+ private long lastPurgeOperation; >+ >+ public CDOGraphAnalyzer() >+ { >+ lastPurgeOperation = System.currentTimeMillis(); >+ } >+ /** >+ * >+ * @param fromID >+ * @return >+ */ >+ public CDOGraph getGraph(CDOID fromID, CDOClusterOfFetchRule featureRule) >+ { >+ CDOGraph graph = fromIdToGraphMaps.get(fromID); >+ >+ if (graph == null) >+ { >+ graph = new CDOGraph(this, fromID, featureRule); >+ uniqueGraphSet.add( graph ); >+ } >+ >+ // Update is time value >+ graph.update(); >+ >+ return graph; >+ } >+ >+ >+ /** >+ * >+ * @param elapseTimeForPurging >+ * @param elapseTimeToClear >+ */ >+ public void purge(long elapseTimeForPurging, long elapseTimeToClear) >+ { >+ long time = System.currentTimeMillis(); >+ if (time - lastPurgeOperation > elapseTimeForPurging) >+ { >+ if (TRACER.isEnabled()) >+ { >+ TRACER.format("Purging graph {0}", this); >+ } >+ ArrayList<CDOGraph> listToRemove = new ArrayList<CDOGraph>(); >+ for (CDOGraph graph : this.uniqueGraphSet) >+ { >+ if (isTimeToRemove(graph, time, elapseTimeToClear)) >+ listToRemove.add(graph); >+ } >+ >+ for (CDOGraph graph : listToRemove) >+ { >+ graph.remove(); >+ } >+ >+ lastPurgeOperation = System.currentTimeMillis(); >+ } >+ } >+ public boolean isTimeToRemove(CDOGraph cdoGraph, long currentTimestamp, long elapseTimeToClear) >+ { >+ return (currentTimestamp - cdoGraph.getLastUpdated() > elapseTimeToClear || >+ (currentTimestamp - cdoGraph.getFeatureRule().getLastUpdate() > elapseTimeToClear && >+ currentTimestamp - cdoGraph.getCreationTime() > elapseTimeToClear)); >+ } >+ /** >+ * >+ * @param cdoID >+ */ >+ public void addTrackingID(CDOID cdoID, CDOGraph cdoGraph) >+ { >+ fromIdToGraphMaps.put(cdoID, cdoGraph); >+ cdoGraph.update(); >+ } >+ /** >+ * >+ * @param cdoID >+ */ >+ public void removeTrackingID(CDOID cdoID) >+ { >+ fromIdToGraphMaps.remove(cdoID); >+ } >+ /** >+ * >+ * @param graph >+ */ >+ public void removeTracking(CDOGraph graph ) >+ { >+ uniqueGraphSet.remove(graph); >+ } >+ public void clear() >+ { >+ fromIdToGraphMaps.clear(); >+ uniqueGraphSet.clear(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 202064
:
77860
|
77861
|
77950
|
77969
|
78135
|
78236
|
78242
|
78243
|
78395