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