try to improve ping performance
This commit is contained in:
parent
b774235903
commit
379c786064
1 changed files with 14 additions and 36 deletions
|
@ -279,48 +279,26 @@ 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_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public CompletableFuture<ResponseEntity<String>> ping(
|
public void ping(
|
||||||
@RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken,
|
@RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken,
|
||||||
@RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp,
|
@RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp,
|
||||||
@RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) {
|
@RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber,
|
||||||
|
final HttpServletResponse response) {
|
||||||
|
|
||||||
return CompletableFuture.supplyAsync(
|
final String instruction = this.sebClientConnectionService
|
||||||
() -> {
|
.notifyPing(connectionToken, timestamp, pingNumber);
|
||||||
final String notifyPing = this.sebClientConnectionService
|
|
||||||
.notifyPing(connectionToken, timestamp, pingNumber);
|
|
||||||
if (notifyPing == null) {
|
|
||||||
return EMPTY_PING_RESPONSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity
|
if (instruction == null) {
|
||||||
.ok()
|
return;
|
||||||
.body(notifyPing);
|
}
|
||||||
},
|
|
||||||
this.executor);
|
try {
|
||||||
|
response.getOutputStream().write(instruction.getBytes());
|
||||||
|
} catch (final IOException e) {
|
||||||
|
log.error("Failed to send instruction as response: {}", connectionToken, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequestMapping(
|
|
||||||
// path = API.EXAM_API_PING_ENDPOINT,
|
|
||||||
// method = RequestMethod.POST,
|
|
||||||
// consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
|
|
||||||
// produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
||||||
// public ResponseEntity<String> ping(
|
|
||||||
// @RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken,
|
|
||||||
// @RequestParam(name = API.EXAM_API_PING_TIMESTAMP, required = true) final long timestamp,
|
|
||||||
// @RequestParam(name = API.EXAM_API_PING_NUMBER, required = false) final int pingNumber) {
|
|
||||||
//
|
|
||||||
// final String instruction = this.sebClientConnectionService
|
|
||||||
// .notifyPing(connectionToken, timestamp, pingNumber);
|
|
||||||
//
|
|
||||||
// if (instruction == null) {
|
|
||||||
// return EMPTY_PING_RESPONSE;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return ResponseEntity
|
|
||||||
// .ok()
|
|
||||||
// .body(instruction);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(
|
||||||
path = API.EXAM_API_EVENT_ENDPOINT,
|
path = API.EXAM_API_EVENT_ENDPOINT,
|
||||||
method = RequestMethod.POST,
|
method = RequestMethod.POST,
|
||||||
|
|
Loading…
Add table
Reference in a new issue