use of org.olat.core.gui.components.panel.OncePanel in project openolat by klemens.
the class ClusterAdminControllerCluster method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == syncLong) {
// sync on a olatresourceable and hold the lock for 5 seconds.
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {
public void execute() {
sleep(5000);
}
});
// the runnable is executed within the same thread->
getWindowControl().setInfo("done syncing on the test olatresourceable for 5 seconds");
} else if (source == syncShort) {
// sync on a olatresourceable and hold the lock for 1 second.
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {
public void execute() {
sleep(1000);
}
});
// the runnable is executed within the same thread->
getWindowControl().setInfo("done syncing on the test olatresourceable for 1 second");
} else if (source == testPerf) {
// send 1000 (short) messages over the cluster bus
int cnt = 1000;
long start = System.nanoTime();
for (int i = 0; i < cnt; i++) {
clusBus.fireEventToListenersOf(new MultiUserEvent("jms-perf-test-" + i + " of " + cnt), ORES_TEST);
}
long stop = System.nanoTime();
long dur = stop - start;
double inmilis = dur / 1000000;
double avg = dur / cnt;
double avgmilis = avg / 1000000;
getWindowControl().setInfo("sending " + cnt + " messages took " + inmilis + " ms, avg per messages was " + avg + " ns = " + avgmilis + " ms");
} else if (source == testCachePut) {
CacheWrapper<String, String> cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(this.getClass().getSimpleName(), "cachetest");
// we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
cw.update("akey", "hello");
updateCacheInfo();
} else if (source == testCachePut2) {
// we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
CacheWrapper<String, String> cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(this.getClass().getSimpleName(), "cachetest");
cw.update("akey", "world");
updateCacheInfo();
} else if (source == testSFUPerf) {
// acquire a sync 1000x times (does internally a select-for-update on the database)
int cnt = 1000;
long start = System.nanoTime();
for (int i = 0; i < cnt; i++) {
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {
public void execute() {
// empty
}
});
}
long stop = System.nanoTime();
long dur = stop - start;
double inmilis = dur / 1000000;
double avg = dur / cnt;
double avgmilis = avg / 1000000;
getWindowControl().setInfo("acquiring " + cnt + " locks for syncing (using db's \"select for update\") took " + inmilis + " ms, avg per messages was " + avg + " ns = " + avgmilis + " ms");
} else if (source == releaseAllLocksFor) {
// let a user search pop up
usc = new UserSearchController(ureq, getWindowControl(), true);
listenTo(usc);
getWindowControl().pushAsModalDialog(usc.getInitialComponent());
} else if ((source == nodeInfoVc) && (event.getCommand().equals("switchToNode"))) {
String nodeIdStr = ureq.getHttpReq().getParameter("nodeId");
if (nodeIdStr.length() == 1) {
nodeIdStr = "0" + nodeIdStr;
}
Cookie[] cookies = ureq.getHttpReq().getCookies();
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
if ("JSESSIONID".equals(cookie.getName())) {
String redirectedButInvalidSessionId = cookie.getValue();
redirectedButInvalidSessionId = redirectedButInvalidSessionId.substring(0, redirectedButInvalidSessionId.length() - 2) + nodeIdStr;
logInfo("redirecting session to node " + nodeIdStr + ", new sessionid=" + redirectedButInvalidSessionId, null);
cookie.setValue(redirectedButInvalidSessionId);
replaceCookie(ureq.getHttpReq(), ureq.getHttpResp(), cookie);
// OLAT-5165: make sure we can always bypass the dmz reject mechanism (for 5min that is)
Cookie newCookie = new Cookie("bypassdmzreject", String.valueOf(System.currentTimeMillis()));
// 5min lifetime
newCookie.setMaxAge(5 * 60);
newCookie.setPath(WebappHelper.getServletContextPath());
newCookie.setSecure(ureq.getHttpReq().isSecure());
newCookie.setComment("cookie allowing olat admin users to bypass dmz rejects");
ureq.getHttpResp().addCookie(newCookie);
OncePanel oncePanel = new OncePanel("refresh");
oncePanel.setContent(createVelocityContainer("refresh"));
mainVc.put("refresh", oncePanel);
break;
}
}
} else if (source == toggleStartStop) {
clusBus.resetStats();
updatePerfInfos();
} else if (source == resetStats) {
clusBus.resetStats();
updatePerfInfos();
}
}
use of org.olat.core.gui.components.panel.OncePanel in project OpenOLAT by OpenOLAT.
the class ClusterAdminControllerCluster method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == syncLong) {
// sync on a olatresourceable and hold the lock for 5 seconds.
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {
public void execute() {
sleep(5000);
}
});
// the runnable is executed within the same thread->
getWindowControl().setInfo("done syncing on the test olatresourceable for 5 seconds");
} else if (source == syncShort) {
// sync on a olatresourceable and hold the lock for 1 second.
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {
public void execute() {
sleep(1000);
}
});
// the runnable is executed within the same thread->
getWindowControl().setInfo("done syncing on the test olatresourceable for 1 second");
} else if (source == testPerf) {
// send 1000 (short) messages over the cluster bus
int cnt = 1000;
long start = System.nanoTime();
for (int i = 0; i < cnt; i++) {
clusBus.fireEventToListenersOf(new MultiUserEvent("jms-perf-test-" + i + " of " + cnt), ORES_TEST);
}
long stop = System.nanoTime();
long dur = stop - start;
double inmilis = dur / 1000000;
double avg = dur / cnt;
double avgmilis = avg / 1000000;
getWindowControl().setInfo("sending " + cnt + " messages took " + inmilis + " ms, avg per messages was " + avg + " ns = " + avgmilis + " ms");
} else if (source == testCachePut) {
CacheWrapper<String, String> cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(this.getClass().getSimpleName(), "cachetest");
// we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
cw.update("akey", "hello");
updateCacheInfo();
} else if (source == testCachePut2) {
// we explicitly use put and not putSilent to show that a put invalidates (and thus removes) this key of this cache in all other cluster nodes.
CacheWrapper<String, String> cw = CoordinatorManager.getInstance().getCoordinator().getCacher().getCache(this.getClass().getSimpleName(), "cachetest");
cw.update("akey", "world");
updateCacheInfo();
} else if (source == testSFUPerf) {
// acquire a sync 1000x times (does internally a select-for-update on the database)
int cnt = 1000;
long start = System.nanoTime();
for (int i = 0; i < cnt; i++) {
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ORES_TEST, new SyncerExecutor() {
public void execute() {
// empty
}
});
}
long stop = System.nanoTime();
long dur = stop - start;
double inmilis = dur / 1000000;
double avg = dur / cnt;
double avgmilis = avg / 1000000;
getWindowControl().setInfo("acquiring " + cnt + " locks for syncing (using db's \"select for update\") took " + inmilis + " ms, avg per messages was " + avg + " ns = " + avgmilis + " ms");
} else if (source == releaseAllLocksFor) {
// let a user search pop up
usc = new UserSearchController(ureq, getWindowControl(), true);
listenTo(usc);
getWindowControl().pushAsModalDialog(usc.getInitialComponent());
} else if ((source == nodeInfoVc) && (event.getCommand().equals("switchToNode"))) {
String nodeIdStr = ureq.getHttpReq().getParameter("nodeId");
if (nodeIdStr.length() == 1) {
nodeIdStr = "0" + nodeIdStr;
}
Cookie[] cookies = ureq.getHttpReq().getCookies();
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
if ("JSESSIONID".equals(cookie.getName())) {
String redirectedButInvalidSessionId = cookie.getValue();
redirectedButInvalidSessionId = redirectedButInvalidSessionId.substring(0, redirectedButInvalidSessionId.length() - 2) + nodeIdStr;
logInfo("redirecting session to node " + nodeIdStr + ", new sessionid=" + redirectedButInvalidSessionId, null);
cookie.setValue(redirectedButInvalidSessionId);
replaceCookie(ureq.getHttpReq(), ureq.getHttpResp(), cookie);
// OLAT-5165: make sure we can always bypass the dmz reject mechanism (for 5min that is)
Cookie newCookie = new Cookie("bypassdmzreject", String.valueOf(System.currentTimeMillis()));
// 5min lifetime
newCookie.setMaxAge(5 * 60);
newCookie.setPath(WebappHelper.getServletContextPath());
newCookie.setSecure(ureq.getHttpReq().isSecure());
newCookie.setComment("cookie allowing olat admin users to bypass dmz rejects");
ureq.getHttpResp().addCookie(newCookie);
OncePanel oncePanel = new OncePanel("refresh");
oncePanel.setContent(createVelocityContainer("refresh"));
mainVc.put("refresh", oncePanel);
break;
}
}
} else if (source == toggleStartStop) {
clusBus.resetStats();
updatePerfInfos();
} else if (source == resetStats) {
clusBus.resetStats();
updatePerfInfos();
}
}
Aggregations