Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-02-19 09:32:24 +0000
committerEike Stepper2016-02-19 09:32:24 +0000
commit91d41fb91e4f69e4d048709aaef679f03faa3a10 (patch)
tree740b92188db4cc16d1b5c8b2495f498194f1f201 /plugins
parent72aa51d99b8dbc33e012e6d9c87b02beca196e4c (diff)
downloadcdo-91d41fb91e4f69e4d048709aaef679f03faa3a10.tar.gz
cdo-91d41fb91e4f69e4d048709aaef679f03faa3a10.tar.xz
cdo-91d41fb91e4f69e4d048709aaef679f03faa3a10.zip
[488074] Revert most of Bug 441136 (Avoid useless MonitorProgress when IProgressMonitor is not used)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=488074
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java26
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java97
4 files changed, 63 insertions, 73 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java
index 9b5209005c..f473dc75c7 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
-import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import java.io.IOException;
@@ -57,11 +56,6 @@ public class LoadMergeDataRequest extends CDOClientRequestWithMonitoring<Set<CDO
@Override
protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
{
- if (monitor == null)
- {
- monitor = new EclipseMonitor();
- }
-
out.writeInt(infos);
monitor.begin(infos);
@@ -114,11 +108,6 @@ public class LoadMergeDataRequest extends CDOClientRequestWithMonitoring<Set<CDO
@Override
protected Set<CDOID> confirming(CDODataInput in, OMMonitor monitor) throws IOException
{
- if (monitor == null)
- {
- monitor = new EclipseMonitor();
- }
-
Set<CDOID> result = new HashSet<CDOID>();
int size = in.readInt();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java
index f2f613bd4e..e7d85f6c4b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java
@@ -224,6 +224,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
{
xaContext.setProgressMonitor(new SynchronizedSubProgressMonitor(progressMonitor, 1));
}
+
Future<Object> future = executorService.submit(xaContext);
futures.put(future, xaContext);
}
@@ -266,6 +267,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
{
progressMonitor.done();
}
+
for (InternalCDOXACommitContext xaContext : xaContexts)
{
xaContext.setProgressMonitor(null);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
index b3d34179b0..b0a8cb9349 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/IndicationWithMonitoring.java
@@ -16,7 +16,6 @@ import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.monitor.TimeoutMonitor;
@@ -33,7 +32,7 @@ import java.util.concurrent.ExecutorService;
*/
public abstract class IndicationWithMonitoring extends IndicationWithResponse
{
- private Monitor monitor;
+ private ReportingMonitor monitor;
/**
* @since 2.0
@@ -79,30 +78,19 @@ public abstract class IndicationWithMonitoring extends IndicationWithResponse
@Override
protected final void indicating(ExtendedDataInputStream in) throws Exception
{
- OMMonitor subMonitor = null;
- boolean useMonitor = in.readBoolean();
- if (useMonitor)
- {
- int monitorProgressSeconds = in.readInt();
- int monitorTimeoutSeconds = in.readInt();
- monitor = new ReportingMonitor(monitorProgressSeconds, monitorTimeoutSeconds);
- }
- else
- {
- int monitorTimeoutSeconds = in.readInt();
- monitor = new TimeoutMonitor(1000L * monitorTimeoutSeconds);
- }
+ int monitorProgressSeconds = in.readInt();
+ int monitorTimeoutSeconds = in.readInt();
+ monitor = new ReportingMonitor(monitorProgressSeconds, monitorTimeoutSeconds);
monitor.begin(OMMonitor.HUNDRED);
- subMonitor = monitor.fork(getIndicatingWorkPercent());
- indicating(in, subMonitor);
+
+ indicating(in, monitor.fork(getIndicatingWorkPercent()));
}
@Override
protected final void responding(ExtendedDataOutputStream out) throws Exception
{
- OMMonitor subMonitor = monitor != null ? monitor.fork(OMMonitor.HUNDRED - getIndicatingWorkPercent()) : null;
- responding(out, subMonitor);
+ responding(out, monitor.fork(OMMonitor.HUNDRED - getIndicatingWorkPercent()));
}
protected abstract void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
index 6441478aa3..72de6e6318 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RequestWithMonitoring.java
@@ -16,6 +16,7 @@ import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.internal.net4j.bundle.OM;
@@ -52,6 +53,8 @@ public abstract class RequestWithMonitoring<RESULT> extends RequestWithConfirmat
private Object monitorLock = new Object();
+ private boolean isMonitoring;
+
/**
* @since 2.0
*/
@@ -79,100 +82,103 @@ public abstract class RequestWithMonitoring<RESULT> extends RequestWithConfirmat
@Override
public Future<RESULT> sendAsync()
{
+ initMainMonitor(null);
return super.sendAsync();
}
public Future<RESULT> sendAsync(OMMonitor monitor)
{
- mainMonitor = monitor;
+ initMainMonitor(monitor);
return super.sendAsync();
}
@Override
public RESULT send() throws Exception, RemoteException
{
+ initMainMonitor(null);
return super.send();
}
@Override
public RESULT send(long timeout) throws Exception, RemoteException
{
+ initMainMonitor(null);
return super.send(timeout);
}
public RESULT send(OMMonitor monitor) throws Exception, RemoteException
{
- mainMonitor = monitor;
+ initMainMonitor(monitor);
return super.send();
}
public RESULT send(long timeout, OMMonitor monitor) throws Exception, RemoteException
{
- mainMonitor = monitor;
+ initMainMonitor(monitor);
return super.send(timeout);
}
@Override
protected final void requesting(ExtendedDataOutputStream out) throws Exception
{
- OMMonitor fork = null;
- boolean useMonitor = mainMonitor != null;
- out.writeBoolean(useMonitor);
- if (useMonitor)
+ double remoteWork = OMMonitor.HUNDRED - getRequestingWorkPercent() - getConfirmingWorkPercent();
+ if (remoteWork < OMMonitor.ZERO)
{
- double remoteWork = OMMonitor.HUNDRED - getRequestingWorkPercent() - getConfirmingWorkPercent();
- if (remoteWork < OMMonitor.ZERO)
- {
- throw new ImplementationError("Remote work must not be negative: " + remoteWork); //$NON-NLS-1$
- }
+ throw new ImplementationError("Remote work must not be negative: " + remoteWork); //$NON-NLS-1$
+ }
- mainMonitor.begin(OMMonitor.HUNDRED);
- OMMonitor subMonitor = mainMonitor.fork(remoteWork);
- synchronized (monitorLock)
- {
- remoteMonitor = subMonitor;
- }
+ mainMonitor.begin(OMMonitor.HUNDRED);
+ OMMonitor subMonitor = mainMonitor.fork(remoteWork);
+ synchronized (monitorLock)
+ {
+ remoteMonitor = subMonitor;
+ }
- ExecutorService executorService = getCancelationExecutorService();
- if (executorService != null)
+ ExecutorService executorService = getCancelationExecutorService();
+ if (executorService != null)
+ {
+ executorService.execute(new Runnable()
{
- executorService.execute(new Runnable()
+ public void run()
{
- public void run()
+ while (mainMonitor != null)
{
- while (mainMonitor != null)
+ ConcurrencyUtil.sleep(getCancelationPollInterval());
+ if (mainMonitor != null && mainMonitor.isCanceled())
{
- ConcurrencyUtil.sleep(getCancelationPollInterval());
- if (mainMonitor != null && mainMonitor.isCanceled())
+ try
{
- try
- {
- new MonitorCanceledRequest(getProtocol(), getCorrelationID()).sendAsync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
-
- return;
+ new MonitorCanceledRequest(getProtocol(), getCorrelationID()).sendAsync();
}
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+
+ return;
}
}
- });
- }
+ }
+ });
+ }
- out.writeInt(getMonitorProgressSeconds());
- fork = mainMonitor.fork(getRequestingWorkPercent());
+ int monitorTimeoutSeconds = getMonitorTimeoutSeconds();
+ int monitorProgressSeconds = getMonitorProgressSeconds();
+
+ if (!isMonitoring)
+ {
+ monitorProgressSeconds = Math.max(monitorProgressSeconds, (int)Math.floor(monitorTimeoutSeconds * 0.8));
}
- out.writeInt(getMonitorTimeoutSeconds());
- requesting(out, fork);
+
+ out.writeInt(monitorProgressSeconds);
+ out.writeInt(monitorTimeoutSeconds);
+ requesting(out, mainMonitor.fork(getRequestingWorkPercent()));
}
@Override
protected final RESULT confirming(ExtendedDataInputStream in) throws Exception
{
- OMMonitor monitor = mainMonitor != null ? mainMonitor.fork(getConfirmingWorkPercent()) : null;
- return confirming(in, monitor);
+ return confirming(in, mainMonitor.fork(getConfirmingWorkPercent()));
}
protected abstract void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception;
@@ -301,4 +307,9 @@ public abstract class RequestWithMonitoring<RESULT> extends RequestWithConfirmat
}
}
+ private void initMainMonitor(OMMonitor monitor)
+ {
+ isMonitoring = monitor != null;
+ mainMonitor = isMonitoring ? monitor : new Monitor();
+ }
}

Back to the top