try to improve ping performance
This commit is contained in:
		
							parent
							
								
									b774235903
								
							
						
					
					
						commit
						379c786064
					
				
					 1 changed files with 14 additions and 36 deletions
				
			
		|  | @ -279,47 +279,25 @@ public class ExamAPI_V1_Controller { | |||
|             method = RequestMethod.POST, | ||||
|             consumes = MediaType.APPLICATION_FORM_URLENCODED_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, | ||||
|             @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 notifyPing = this.sebClientConnectionService | ||||
|         final String instruction = this.sebClientConnectionService | ||||
|                 .notifyPing(connectionToken, timestamp, pingNumber); | ||||
|                     if (notifyPing == null) { | ||||
|                         return EMPTY_PING_RESPONSE; | ||||
| 
 | ||||
|         if (instruction == null) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|                     return ResponseEntity | ||||
|                             .ok() | ||||
|                             .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( | ||||
|             path = API.EXAM_API_EVENT_ENDPOINT, | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 anhefti
						anhefti