summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntje Fuhrmann2013-05-07 04:40:54 (EDT)
committerStephan Born2013-09-05 11:15:28 (EDT)
commitdec696f9fc538532ba9726557651a50dc074f82a (patch)
treee19dc7fa71217f037957d68cdcb1ef0a64483aa2
parent630b8b5670e70c4dcc279ec85ad1883b3c62749e (diff)
downloadorg.eclipse.stardust.ide-dec696f9fc538532ba9726557651a50dc074f82a.zip
org.eclipse.stardust.ide-dec696f9fc538532ba9726557651a50dc074f82a.tar.gz
org.eclipse.stardust.ide-dec696f9fc538532ba9726557651a50dc074f82a.tar.bz2
Jira-ID: CRNT-28549
Merge changes done on b_dev_5_3_x after 5.3.19.GA (5.3.19.4-r58998) through 5.3.20.GA (5.3.20.2-r64536) to 7.2 (TRUNK) - kernel / modeler / build (CRNT-26243: Concurrent Modelling is extremely slow) git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ide@64741 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Antje Fuhrmann <antje.fuhrmann@sungard.com>
-rw-r--r--modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/LockUtil.java90
-rw-r--r--modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServer.java6
-rw-r--r--modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServerHelper.java28
3 files changed, 106 insertions, 18 deletions
diff --git a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/LockUtil.java b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/LockUtil.java
index d75cfd4..b607d16 100644
--- a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/LockUtil.java
+++ b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/LockUtil.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.stardust.modeling.core.modelserver;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -19,6 +20,8 @@ import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
@@ -33,6 +36,8 @@ import org.eclipse.stardust.modeling.core.utils.GenericUtils;
public class LockUtil
{
+ private static Map<WorkflowModelEditor, LockUtil> instances;
+
private WorkflowModelEditor editor;
private ModelType localModel;
@@ -45,8 +50,29 @@ public class LockUtil
private List<EObject> removedElements = new ArrayList<EObject>();
private List<EObject> changedElements = new ArrayList<EObject>();
private List<EObject> allElements = new ArrayList<EObject>();
+
+ private WorkflowModelManager manager;
+ private long localModelTimeStamp = 0;
- public LockUtil(WorkflowModelEditor editor)
+ public static LockUtil getLockUtil(WorkflowModelEditor editor)
+ {
+ LockUtil instance = null;
+ if(instances == null)
+ {
+ instances = new HashMap<WorkflowModelEditor, LockUtil>();
+ }
+
+ instance = instances.get(editor);
+ if(instance == null)
+ {
+ instance = new LockUtil(editor);
+ instances.put(editor, instance);
+ }
+
+ return instance;
+ }
+
+ private LockUtil(WorkflowModelEditor editor)
{
this.editor = editor;
}
@@ -58,18 +84,9 @@ public class LockUtil
monitor.subTask(Diagram_Messages.TASK_READING_LOCAL_MD);
ModelServer modelServer = editor.getModelServer();
ModelType model = modelServer.getModel();
-
- WorkflowModelManager manager = new WorkflowModelManager();
Resource resource = model.eResource();
- try
- {
- manager.load(resource.getURI());
- }
- catch (IOException e)
- {
- throw new RMSException("...", RMSException.DEFAULT); //$NON-NLS-1$
- }
- localModel = manager.getModel();
+
+ getLocalModel(resource);
monitor.subTask(Diagram_Messages.TASK_READING_REMOTE_MD);
try
@@ -138,6 +155,55 @@ public class LockUtil
}
}
}
+
+ private void getLocalModel(Resource resource) throws RMSException
+ {
+ URI uri = resource.getURI();
+ int segmentCount = uri.segmentCount();
+ String fileName = "platform:"; //$NON-NLS-1$
+ for(int i = 1; i < segmentCount; i++)
+ {
+ fileName += "/" + uri.segment(i); //$NON-NLS-1$
+ }
+
+ java.net.URI uri_ = java.net.URI.create(fileName);
+ File file = new File(uri_.getPath());
+ if (!file.isAbsolute())
+ {
+ file = new File(Platform.getLocation().toFile(), file.toString());
+ }
+
+ if(file.exists() && localModelTimeStamp != 0)
+ {
+ if(file.lastModified() > localModelTimeStamp)
+ {
+ manager = null;
+ }
+ }
+ else
+ {
+ manager = null;
+ }
+
+ if(manager == null)
+ {
+ if(file.exists())
+ {
+ localModelTimeStamp = file.lastModified();
+ }
+
+ manager = new WorkflowModelManager();
+ try
+ {
+ manager.load(resource.getURI());
+ }
+ catch (IOException e)
+ {
+ throw new RMSException("...", RMSException.DEFAULT);
+ }
+ localModel = manager.getModel();
+ }
+ }
public static String getMessageLockedAlready(Map<EObject, String> failed)
{
diff --git a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServer.java b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServer.java
index 5781011..e16b967 100644
--- a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServer.java
+++ b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServer.java
@@ -327,7 +327,7 @@ public class ModelServer extends ModelServerHelper
return;
}
- LockUtil util = new LockUtil(editor);
+ LockUtil util = LockUtil.getLockUtil(editor);
util.analyze(monitor);
String updateElements = util.checkUpdateNeeded(elements);
if(!StringUtils.isEmpty(updateElements))
@@ -610,7 +610,7 @@ public class ModelServer extends ModelServerHelper
{
ModelServerUtils.mergeElements3(updateUtil.getSelectedElementsChanged(), remoteModelHead, model);
}
- });
+ });
MergeUtils.fixDuplicateOids(model);
}
catch (Exception e)
@@ -799,7 +799,7 @@ public class ModelServer extends ModelServerHelper
{
monitor.beginTask(Diagram_Messages.TASK_LOCK_ELEMENTS, lockables.length + 5);
}
- LockUtil util = new LockUtil(editor);
+ LockUtil util = LockUtil.getLockUtil(editor);
util.analyze(monitor);
String updateElements = util.checkUpdateNeeded(Arrays.asList(lockables));
if(!StringUtils.isEmpty(updateElements))
diff --git a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServerHelper.java b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServerHelper.java
index a97af3c..372eef1 100644
--- a/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServerHelper.java
+++ b/modeling/org.eclipse.stardust.modeling.core/src/org/eclipse/stardust/modeling/core/modelserver/ModelServerHelper.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.stardust.modeling.core.modelserver;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -22,6 +23,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.stardust.model.xpdl.carnot.ModelType;
@@ -64,6 +66,7 @@ public class ModelServerHelper
protected long retryConnection;
protected boolean retry = true;
protected long lastRequest = 0;
+ private long remoteModelTimeStamp = 0;
public void setCachedModelElement(EObject cachedModelElement)
{
@@ -167,10 +170,29 @@ public class ModelServerHelper
}
private synchronized ModelType getCachedModel(IFile cacheFile) throws IOException
- {
- if(remoteModel != null)
+ {
+ String fileName = "platform:" + cacheFile.getFullPath().toString(); //$NON-NLS-1$
+ java.net.URI uri_ = java.net.URI.create(fileName);
+ File file = new File(uri_.getPath());
+ if (!file.isAbsolute())
+ {
+ file = new File(Platform.getLocation().toFile(), file.toString());
+ }
+
+ if(file.exists() && remoteModelTimeStamp != 0)
+ {
+ if(file.lastModified() == remoteModelTimeStamp)
+ {
+ if(remoteModel != null)
+ {
+ return remoteModel;
+ }
+ }
+ }
+
+ if(file.exists())
{
- //return remoteModel;
+ remoteModelTimeStamp = file.lastModified();
}
ExtendedModelManager emm = new ExtendedModelManager();