ping with executor
This commit is contained in:
parent
2a16813cd7
commit
b344ee22e5
4 changed files with 26 additions and 32 deletions
|
@ -74,15 +74,6 @@ public class AsyncServiceSpringConfig implements AsyncConfigurer {
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Bean
|
|
||||||
// public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
|
|
||||||
// final ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
|
||||||
// threadPoolTaskScheduler.setPoolSize(5);
|
|
||||||
// threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
|
|
||||||
// threadPoolTaskScheduler.setThreadNamePrefix("SEB-Server-BgTask-");
|
|
||||||
// return threadPoolTaskScheduler;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Executor getAsyncExecutor() {
|
public Executor getAsyncExecutor() {
|
||||||
return threadPoolTaskExecutor();
|
return threadPoolTaskExecutor();
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class WebserviceInfo {
|
||||||
this.distributedUpdateInterval = environment.getProperty(
|
this.distributedUpdateInterval = environment.getProperty(
|
||||||
"sebserver.webservice.distributed.updateInterval",
|
"sebserver.webservice.distributed.updateInterval",
|
||||||
Long.class,
|
Long.class,
|
||||||
3000L);
|
2000L);
|
||||||
|
|
||||||
this.activeProfiles = new HashSet<>(Arrays.asList(environment.getActiveProfiles()));
|
this.activeProfiles = new HashSet<>(Arrays.asList(environment.getActiveProfiles()));
|
||||||
|
|
||||||
|
|
|
@ -325,29 +325,32 @@ public class ExamAPI_V1_Controller {
|
||||||
method = RequestMethod.POST,
|
method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public void ping(final HttpServletRequest request, final HttpServletResponse response) {
|
public CompletableFuture<Void> ping(final HttpServletRequest request, final HttpServletResponse response) {
|
||||||
|
return CompletableFuture.runAsync(
|
||||||
|
() -> {
|
||||||
|
final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN);
|
||||||
|
//final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER);
|
||||||
|
final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM);
|
||||||
|
|
||||||
final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN);
|
final String instruction = this.sebClientSessionService
|
||||||
//final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER);
|
.notifyPing(
|
||||||
final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM);
|
connectionToken,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
instructionConfirm);
|
||||||
|
|
||||||
final String instruction = this.sebClientSessionService
|
if (instruction == null) {
|
||||||
.notifyPing(
|
response.setStatus(HttpStatus.NO_CONTENT.value());
|
||||||
connectionToken,
|
} else {
|
||||||
0,
|
try {
|
||||||
0,
|
response.setStatus(HttpStatus.OK.value());
|
||||||
instructionConfirm);
|
response.getOutputStream().write(instruction.getBytes(StandardCharsets.UTF_8));
|
||||||
|
} catch (final IOException e) {
|
||||||
if (instruction == null) {
|
log.error("Failed to send instruction as response: {}", connectionToken, e);
|
||||||
response.setStatus(HttpStatus.NO_CONTENT.value());
|
}
|
||||||
} else {
|
}
|
||||||
try {
|
},
|
||||||
response.setStatus(HttpStatus.OK.value());
|
this.executor);
|
||||||
response.getOutputStream().write(instruction.getBytes(StandardCharsets.UTF_8));
|
|
||||||
} catch (final IOException e) {
|
|
||||||
log.error("Failed to send instruction as response: {}", connectionToken, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
|
|
|
@ -40,7 +40,7 @@ sebserver.webservice.internalSecret=${sebserver.password}
|
||||||
### webservice networking
|
### webservice networking
|
||||||
sebserver.webservice.forceMaster=false
|
sebserver.webservice.forceMaster=false
|
||||||
sebserver.webservice.distributed=false
|
sebserver.webservice.distributed=false
|
||||||
sebserver.webservice.distributed.updateInterval=3000
|
sebserver.webservice.distributed.updateInterval=2000
|
||||||
sebserver.webservice.http.external.scheme=https
|
sebserver.webservice.http.external.scheme=https
|
||||||
sebserver.webservice.http.external.servername=
|
sebserver.webservice.http.external.servername=
|
||||||
sebserver.webservice.http.external.port=
|
sebserver.webservice.http.external.port=
|
||||||
|
|
Loading…
Reference in a new issue