use of org.eclipse.scout.rt.shared.services.common.ping.IPingService in project scout.rt by eclipse.
the class ClientJobCancelTest method doPingRequestAsync.
/**
* Runs a 'ping-request' which gets blocked in the service implementation.
*/
protected RequestData doPingRequestAsync(final String pingRequest) throws Exception {
final BlockingCountDownLatch serviceCallSetupLatch = new BlockingCountDownLatch(1);
final BlockingCountDownLatch serviceCallCompletedLatch = new BlockingCountDownLatch(1);
final AtomicBoolean serviceCallInterrupted = new AtomicBoolean(false);
// Mock the PingService.
class PingService implements IPingService {
@Override
public String ping(String s) {
try {
assertTrue(serviceCallSetupLatch.countDownAndBlock());
} catch (java.lang.InterruptedException e) {
serviceCallInterrupted.set(true);
} finally {
serviceCallCompletedLatch.countDown();
}
return s.toUpperCase();
}
}
// Create a separate RunContext with a separate RunMonitor, so we can wait for the service result in case of cancellation.
final ClientRunContext runContext = ClientRunContexts.copyCurrent();
final RunMonitor runMonitor = BEANS.get(RunMonitor.class);
runContext.withRunMonitor(runMonitor);
IFuture<String> pingFuture = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
return runContext.call(new Callable<String>() {
@Override
public String call() throws Exception {
IBean<?> bean = TestingUtility.registerBean(new BeanMetaData(PingService.class).withInitialInstance(new PingService()).withApplicationScoped(true));
try {
return ServiceTunnelUtility.createProxy(IPingService.class).ping(pingRequest);
} finally {
TestingUtility.unregisterBeans(Arrays.asList(bean));
}
}
});
}
}, Jobs.newInput().withExceptionHandling(null, false));
// Wait for the ping request to enter service implementation.
assertTrue(serviceCallSetupLatch.await());
return new RequestData(pingFuture, runMonitor, serviceCallSetupLatch, serviceCallCompletedLatch, serviceCallInterrupted);
}
use of org.eclipse.scout.rt.shared.services.common.ping.IPingService in project scout.rt by eclipse.
the class GeneralView method createMonitoringQuickLink.
private String createMonitoringQuickLink(HtmlComponent p) {
if (!ACCESS.check(new UpdateServiceConfigurationPermission())) {
return null;
}
final ProcessInspector inst = ProcessInspector.instance();
if (inst.isEnabled()) {
p.print("Monitor is active with maximum caching of " + (inst.getTimeout() / 1000 / 60) + " minutes [ ");
p.linkAction("cache 2 min", new P_SetTimeoutAction(2));
p.print(" | ");
p.linkAction("cache 15 min", new P_SetTimeoutAction(15));
p.print(" | ");
p.linkAction("cache 60 min", new P_SetTimeoutAction(60));
p.print(" | ");
p.linkAction("deactivate", new P_EnableAction(false));
p.print(" ]");
p.br();
if (inst.acceptCall(IPingService.class.getName(), "ping")) {
p.linkAction("IPingService.ping (click to toggle)", new AbstractHtmlAction("IPingService.ignore") {
@Override
public void run() {
inst.getIgnoredCallSet().clear();
inst.getIgnoredCallSet().add(".*\\.IPingService\\.ping");
}
});
} else {
p.startLinkAction(new AbstractHtmlAction("IPingService.accept") {
@Override
public void run() {
inst.getIgnoredCallSet().clear();
}
});
p.raw("<s>");
p.printNoBreak("IPingService.ping");
p.raw("</s>");
p.printNoBreak(" (click to toggle)");
p.endLinkAction();
}
} else {
p.print("Monitor is inactive [ ");
p.linkAction("activate", new P_EnableAction(true));
p.print(" ]");
}
p.p();
if (inst.isEnabled()) {
return "<p><b>Note: Session Activity Monitor is enabled; this might affect performance and memory due to higher resource consumption during analysis.</b><p>";
}
return null;
}
Aggregations