IDEMPIERE-522 Zk: Random Freeze of screen update
This commit is contained in:
parent
2a2c8a2e2c
commit
9a24ad651e
|
@ -553,7 +553,7 @@ public final class Adempiere
|
|||
} // startup
|
||||
|
||||
private static void createThreadPool() {
|
||||
int max = Runtime.getRuntime().availableProcessors() * 3;
|
||||
int max = Runtime.getRuntime().availableProcessors() * 20;
|
||||
int min = max / 2;
|
||||
int defaultMax = max;
|
||||
int defaultMin = min;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="WEB-INF/src"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar" sourcepath="WEB-INF/lib/src/atmosphere-compat-tomcat7-0.9-sources.jar"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/lib/atmosphere-runtime-0.9.jar" sourcepath="WEB-INF/lib/src/atmosphere-runtime-0.9-sources.jar"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/lib/calendar.jar"/>
|
||||
<classpathentry kind="output" path="WEB-INF/classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="WEB-INF/lib/atmosphere-compat-jbossweb-1.0.4.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="WEB-INF/lib/atmosphere-compat-tomcat-1.0.4.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="WEB-INF/lib/atmosphere-compat-tomcat7-1.0.4.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="WEB-INF/lib/atmosphere-runtime-1.0.4.jar" sourcepath="WEB-INF/lib/src/atmosphere-runtime-1.0.4-sources.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="WEB-INF/src"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/lib/calendar.jar"/>
|
||||
<classpathentry kind="output" path="WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -16,12 +16,13 @@ Import-Package: javax.servlet,
|
|||
org.slf4j.helpers;version="1.6.1",
|
||||
org.slf4j.spi;version="1.6.1"
|
||||
DynamicImport-Package: action.images
|
||||
Bundle-ClassPath: WEB-INF/classes/,
|
||||
WEB-INF/lib/atmosphere-runtime-0.9.jar,
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,
|
||||
WEB-INF/lib/calendar.jar
|
||||
Bundle-ClassPath: .,
|
||||
WEB-INF/classes/,
|
||||
WEB-INF/lib/calendar.jar,
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-1.0.4.jar,
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-1.0.4.jar,
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-1.0.4.jar,
|
||||
WEB-INF/lib/atmosphere-runtime-1.0.4.jar
|
||||
Export-Package: metainfo.zk,
|
||||
org.adempiere.webui,
|
||||
org.adempiere.webui.acct,
|
||||
|
|
|
@ -20,9 +20,11 @@ the License.
|
|||
package fi.jawsy.jawwa.zk.atmosphere;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.atmosphere.cpr.AtmosphereResource;
|
||||
import org.compiere.Adempiere;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.zkoss.lang.Library;
|
||||
|
@ -34,6 +36,7 @@ import org.zkoss.zk.ui.UiException;
|
|||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.impl.ExecutionCarryOver;
|
||||
import org.zkoss.zk.ui.sys.DesktopCtrl;
|
||||
import org.zkoss.zk.ui.sys.Scheduler;
|
||||
import org.zkoss.zk.ui.sys.ServerPush;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
|
@ -112,35 +115,19 @@ public class AtmosphereServerPush implements ServerPush {
|
|||
return true;
|
||||
}
|
||||
|
||||
public synchronized void clearResource(AtmosphereResource resource) {
|
||||
public void clearResource(AtmosphereResource resource) {
|
||||
this.resource.compareAndSet(resource, null);
|
||||
}
|
||||
|
||||
private synchronized void commitResponse() throws IOException {
|
||||
private boolean commitResponse() throws IOException {
|
||||
AtmosphereResource resource = this.resource.getAndSet(null);
|
||||
if (resource != null) {
|
||||
resource.resume();
|
||||
}
|
||||
if (resource != null && resource.isSuspended()) {
|
||||
resource.resume();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private synchronized void onPush() throws IOException {
|
||||
AtmosphereResource resource = this.resource.get();
|
||||
if (resource != null) {
|
||||
switch (resource.transport()) {
|
||||
case POLLING:
|
||||
case LONG_POLLING:
|
||||
if (resource.isSuspended())
|
||||
commitResponse();
|
||||
break;
|
||||
case WEBSOCKET :
|
||||
case STREAMING:
|
||||
resource.getResponse().getWriter().write("<!-- dummy -->");
|
||||
resource.getResponse().getWriter().flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deactivate(boolean stop) {
|
||||
boolean stopped = false;
|
||||
|
@ -175,11 +162,11 @@ public class AtmosphereServerPush implements ServerPush {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized <T extends Event> void schedule(EventListener<T> task, T event,
|
||||
public <T extends Event> void schedule(EventListener<T> task, T event,
|
||||
Scheduler<T> scheduler) {
|
||||
scheduler.schedule(task, event);
|
||||
try {
|
||||
onPush();
|
||||
commitResponse();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
@ -215,26 +202,53 @@ public class AtmosphereServerPush implements ServerPush {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void onRequest(AtmosphereResource resource) {
|
||||
if (this.resource.get() != null) {
|
||||
AtmosphereResource aResource = this.resource.get();
|
||||
if (aResource != resource) {
|
||||
try {
|
||||
onPush();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.resource.set(resource);
|
||||
if (log.isTraceEnabled()) {
|
||||
public void onRequest(AtmosphereResource resource) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace(resource.transport().name());
|
||||
}
|
||||
if (!resource.isSuspended()) {
|
||||
resource.suspend(-1, true);
|
||||
}
|
||||
|
||||
try {
|
||||
commitResponse();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
DesktopCtrl desktopCtrl = (DesktopCtrl) this.desktop.get();
|
||||
if (desktopCtrl == null) {
|
||||
log.error("No desktop available");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean suspend = !desktopCtrl.scheduledServerPush();
|
||||
if (suspend) {
|
||||
if (!resource.isSuspended()) {
|
||||
resource.suspend(-1, true);
|
||||
}
|
||||
this.resource.set(resource);
|
||||
|
||||
//check again, just in case task is schedule between the resource.suspend and resource.set call
|
||||
if (desktopCtrl.scheduledServerPush()) {
|
||||
scheduleCommit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleCommit() {
|
||||
Adempiere.getThreadPoolExecutor().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DesktopCtrl desktopCtrl = (DesktopCtrl) AtmosphereServerPush.this.desktop.get();
|
||||
if (desktopCtrl == null) return;
|
||||
if (desktopCtrl.scheduledServerPush()) {
|
||||
try {
|
||||
commitResponse();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 100, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private static class ThreadInfo {
|
||||
private final Thread thread;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,9 +24,8 @@
|
|||
this.timeout = timeout;
|
||||
},
|
||||
_schedule: function() {
|
||||
if (this.failures < 10) {
|
||||
var delay = this.delay * Math.pow(2, Math.min(this.failures, 7));
|
||||
setTimeout(this.proxy(this._send), delay);
|
||||
if (this.failures < 100) {
|
||||
setTimeout(this.proxy(this._send), this.delay);
|
||||
} else {
|
||||
this.stop();
|
||||
}
|
||||
|
@ -34,45 +33,36 @@
|
|||
_send: function() {
|
||||
if (!this.active)
|
||||
return;
|
||||
|
||||
|
||||
var me = this;
|
||||
var socket = $.atmosphere;
|
||||
var request = {
|
||||
url: zk.ajaxURI("/comet", {
|
||||
au: true
|
||||
}),
|
||||
logLevel : 'debug',
|
||||
transport : 'long-polling',
|
||||
fallbackTransport: 'streaming',
|
||||
method: "GET",
|
||||
cache: false,
|
||||
async: true,
|
||||
timeout: me.timeout,
|
||||
onError: function(response) {
|
||||
if (typeof console == "object") {
|
||||
console.error(response);
|
||||
}
|
||||
me.failures += 1;
|
||||
if (me.failures < 10) {
|
||||
if (response.transport == 'long-polling') {
|
||||
me._schedule();
|
||||
}
|
||||
} else {
|
||||
me.stop();
|
||||
}
|
||||
},
|
||||
onMessage: function(response) {
|
||||
zAu.cmd0.echo(me.desktop);
|
||||
me.failures = 0;
|
||||
if (response.transport == 'long-polling') {
|
||||
me._schedule();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
request.url = request.url+'?dtid='+me.desktop.id;
|
||||
socket.unsubscribe();
|
||||
socket.subscribe(request);
|
||||
var jqxhr = $.ajax({
|
||||
url: zk.ajaxURI("/comet", {
|
||||
au: true
|
||||
}),
|
||||
type: "GET",
|
||||
cache: false,
|
||||
async: true,
|
||||
global: false,
|
||||
data: {
|
||||
dtid: this.desktop.id
|
||||
},
|
||||
accepts: "text/plain",
|
||||
dataType: "text",
|
||||
timeout: me.timeout,
|
||||
error: function(jqxhr, textStatus, errorThrown) {
|
||||
if (typeof console == "object") {
|
||||
console.error(errorThrown);
|
||||
}
|
||||
me.failures += 1;
|
||||
me._schedule();
|
||||
},
|
||||
success: function(data) {
|
||||
zAu.cmd0.echo(me.desktop);
|
||||
me.failures = 0;
|
||||
me._schedule();
|
||||
}
|
||||
});
|
||||
this._req = jqxhr;
|
||||
},
|
||||
start: function() {
|
||||
this.desktop._serverpush = this;
|
||||
|
@ -88,4 +78,4 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
})();
|
|
@ -11,10 +11,6 @@ bin.includes = META-INF/,\
|
|||
timeout.zul,\
|
||||
plugin.xml,\
|
||||
WEB-INF/classes/,\
|
||||
WEB-INF/lib/atmosphere-runtime-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\
|
||||
metainfo/,\
|
||||
WEB-INF/lib/calendar.jar,\
|
||||
calendar.css,\
|
||||
|
@ -29,7 +25,11 @@ bin.includes = META-INF/,\
|
|||
OSGI-INF/jrviewerprovider.xml,\
|
||||
OSGI-INF/resourcefinder.xml,\
|
||||
OSGI-INF/defaultpaymentformfactory.xml,\
|
||||
OSGI-INF/processfactory.xml
|
||||
OSGI-INF/processfactory.xml,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-1.0.4.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-1.0.4.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-1.0.4.jar,\
|
||||
WEB-INF/lib/atmosphere-runtime-1.0.4.jar
|
||||
src.includes = WEB-INF/classes/,\
|
||||
WEB-INF/tld/,\
|
||||
WEB-INF/web.xml,\
|
||||
|
|
Loading…
Reference in New Issue