[jbosstools-issues] [JBoss JIRA] (JBIDE-15495) OpenShift server adapter: publish locks the whole workspace

Rob Stryker (JIRA) jira-events at lists.jboss.org
Fri Nov 8 05:53:02 EST 2013


    [ https://issues.jboss.org/browse/JBIDE-15495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12921715#comment-12921715 ] 

Rob Stryker commented on JBIDE-15495:
-------------------------------------

Try this patch, assign to andre:

{code}
diff --git a/plugins/org.jboss.tools.openshift.express.core/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftServerPublishMethod.java b/plugins/org.jboss.tools.openshift.express.core/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftServerPublishMethod.java
index 4dfa751..c6402cb 100644
--- a/plugins/org.jboss.tools.openshift.express.core/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftServerPublishMethod.java
+++ b/plugins/org.jboss.tools.openshift.express.core/src/org/jboss/tools/openshift/express/internal/core/behaviour/OpenShiftServerPublishMethod.java
@@ -15,6 +15,7 @@ import java.io.File;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceRuleFactory;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
@@ -24,6 +25,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.egit.core.op.AddToIndexOperation;
 import org.eclipse.egit.core.op.PushOperationResult;
 import org.eclipse.jgit.lib.Repository;
@@ -196,6 +199,9 @@ public class OpenShiftServerPublishMethod implements IJBossServerPublishMethod {
 	protected PushOperationResult commitAndPushProject(IProject p, IDeployableServerBehaviour behaviour,
 			IProgressMonitor monitor) throws CoreException {
 
+		// Keep a reference to the existing rule
+		ISchedulingRule existing = Job.getJobManager().currentJob().getRule();
+		
 		PushOperationResult result = null;
 		int changes = OpenShiftServerUtils.countCommitableChanges(p, behaviour.getServer(), monitor);
 		if (changes > 0) {
@@ -204,21 +210,42 @@ public class OpenShiftServerPublishMethod implements IJBossServerPublishMethod {
 					NLS.bind(OpenShiftServerMessages.commitAndPushMsg, changes, p.getName())
 			};
 			
+			// Create a workspace lock
+			IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
+			ISchedulingRule workspaceLock = ruleFactory.modifyRule(ResourcesPlugin.getWorkspace().getRoot());
+			// suspend current rule, use workspace lock instead
+			
 			Object[] ret = OpenshiftCoreUIIntegration.openMultiReturnQuestion(IQuestionHandler.COMMIT_AND_PUSH_QUESTION, data);
 			if( ret != null && ret.length > 0 && ret[0] != null && ((Boolean)ret[0]).booleanValue()) {
-				String msg = (ret.length > 1 && ret[1] != null) ? ((String)ret[1]) : null;
-				
-				monitor.beginTask("Publishing " + p.getName(), 300);
-				if( msg == null )
-					EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
-				else
-					EGitUtils.commit(p, msg, new SubProgressMonitor(monitor, 100));
+				try {
+					// Commit needs a workspace lock
+					Job.getJobManager().endRule(existing);
+					Job.getJobManager().beginRule(workspaceLock, new NullProgressMonitor());
 					
-				OpenshiftCoreUIIntegration.displayConsoleView(behaviour.getServer());
-				result = push(p, behaviour.getServer(), monitor);
+					String msg = (ret.length > 1 && ret[1] != null) ? ((String)ret[1]) : null;				
+					monitor.beginTask("Publishing " + p.getName(), 300);
+					if( msg == null )
+						EGitUtils.commit(p, new SubProgressMonitor(monitor, 100));
+					else
+						EGitUtils.commit(p, msg, new SubProgressMonitor(monitor, 100));
+					// end the workspace lock
+					Job.getJobManager().endRule(workspaceLock);
+					
+					// perform the push with no lock. Egit will capture what lock it needs
+					// and we don't fear workspace changes during a push
+					OpenshiftCoreUIIntegration.displayConsoleView(behaviour.getServer());
+					result = push(p, behaviour.getServer(), monitor);
+				} catch(CoreException ce) {
+					OpenShiftCoreActivator.pluginLog().logError(ce);
+				} finally {
+					Job.getJobManager().beginRule(existing, new NullProgressMonitor());
+				}
 			}
 		} else {
 			try {
+				// We don't fear workspace changes during a push, so end the rule
+				Job.getJobManager().endRule(existing);
+				
 				String openShiftRemoteName =
 						OpenShiftServerUtils.getExpressRemoteName(behaviour.getServer());
 				if (!EGitUtils.isAhead(p, openShiftRemoteName, monitor)) {
@@ -238,6 +265,8 @@ public class OpenShiftServerPublishMethod implements IJBossServerPublishMethod {
 				}
 			} catch (Exception e) {
 				OpenShiftCoreActivator.pluginLog().logError(e);
+			}finally {
+				Job.getJobManager().beginRule(existing, new NullProgressMonitor());
 			}
 		}
{code}
                
> OpenShift server adapter: publish locks the whole workspace
> -----------------------------------------------------------
>
>                 Key: JBIDE-15495
>                 URL: https://issues.jboss.org/browse/JBIDE-15495
>             Project: Tools (JBoss Tools)
>          Issue Type: Feature Request
>          Components: openshift, server
>    Affects Versions: 4.1.0.Final
>            Reporter: Xavier Coulon
>            Assignee: Rob Stryker
>              Labels: openshift_server_adapter
>             Fix For: LATER
>
>         Attachments: Screen Shot 2013-09-17 at 10.42.43 AM.png
>
>
> Have 2 projects in a workspace, one of them is an OpenShift application
> Deploy some changes on OpenShift, and while the publication is performed (git push, then OS restarts the server), go to the second (unrelated) project and try to move a file from a package to another package in the same project.
> The 'Publish' operation locked the whoel workspace, which means that the move operation needs to wait.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jbosstools-issues mailing list