SEBSERV-182 updateErrors
This commit is contained in:
		
							parent
							
								
									5724a750b7
								
							
						
					
					
						commit
						03c05c7372
					
				
					 2 changed files with 50 additions and 35 deletions
				
			
		|  | @ -174,7 +174,7 @@ public class MonitoringRunningExam implements TemplateComposer { | |||
|         this.serverPushService.runServerPush( | ||||
|                 new ServerPushContext( | ||||
|                         content, | ||||
|                         Utils.truePredicate(), | ||||
|                         context -> clientTable.getUpdateErrors() > 5, | ||||
|                         createServerPushUpdateErrorHandler(this.pageService, pageContext)), | ||||
|                 this.pollInterval, | ||||
|                 context -> clientTable.updateValues(), | ||||
|  |  | |||
|  | @ -116,6 +116,8 @@ public final class ClientConnectionTable { | |||
|     private boolean forceUpdateAll = false; | ||||
|     private boolean updateInProgress = false; | ||||
| 
 | ||||
|     private int updateErrors = 0; | ||||
| 
 | ||||
|     public ClientConnectionTable( | ||||
|             final PageService pageService, | ||||
|             final Composite tableRoot, | ||||
|  | @ -188,6 +190,10 @@ public final class ClientConnectionTable { | |||
|         this.table.layout(); | ||||
|     } | ||||
| 
 | ||||
|     public int getUpdateErrors() { | ||||
|         return this.updateErrors; | ||||
|     } | ||||
| 
 | ||||
|     public WidgetFactory getWidgetFactory() { | ||||
|         return this.pageService.getWidgetFactory(); | ||||
|     } | ||||
|  | @ -320,44 +326,53 @@ public final class ClientConnectionTable { | |||
|     } | ||||
| 
 | ||||
|     private void updateValuesAsync() { | ||||
|         if (this.statusFilterChanged || this.forceUpdateAll) { | ||||
|             this.toDelete.clear(); | ||||
|             this.toDelete.addAll(this.tableMapping.keySet()); | ||||
|         } | ||||
|         this.restCallBuilder | ||||
|                 .withHeader(API.EXAM_MONITORING_STATE_FILTER, this.statusFilterParam) | ||||
|                 .call() | ||||
|                 .get(error -> { | ||||
|                     log.error("Unexpected error while trying to get client connection table data: ", error); | ||||
|                     recoverFromDisposedRestTemplate(error); | ||||
|                     return Collections.emptyList(); | ||||
|                 }) | ||||
|                 .forEach(data -> { | ||||
|                     final UpdatableTableItem tableItem = this.tableMapping.computeIfAbsent( | ||||
|                             data.getConnectionId(), | ||||
|                             UpdatableTableItem::new); | ||||
|                     tableItem.push(data); | ||||
|                     if (this.statusFilterChanged || this.forceUpdateAll) { | ||||
|                         this.toDelete.remove(data.getConnectionId()); | ||||
| 
 | ||||
|         try { | ||||
| 
 | ||||
|             if (this.statusFilterChanged || this.forceUpdateAll) { | ||||
|                 this.toDelete.clear(); | ||||
|                 this.toDelete.addAll(this.tableMapping.keySet()); | ||||
|             } | ||||
|             this.restCallBuilder | ||||
|                     .withHeader(API.EXAM_MONITORING_STATE_FILTER, this.statusFilterParam) | ||||
|                     .call() | ||||
|                     .get(error -> { | ||||
|                         log.error("Unexpected error while trying to get client connection table data: ", error); | ||||
|                         recoverFromDisposedRestTemplate(error); | ||||
|                         return Collections.emptyList(); | ||||
|                     }) | ||||
|                     .forEach(data -> { | ||||
|                         final UpdatableTableItem tableItem = this.tableMapping.computeIfAbsent( | ||||
|                                 data.getConnectionId(), | ||||
|                                 UpdatableTableItem::new); | ||||
|                         tableItem.push(data); | ||||
|                         if (this.statusFilterChanged || this.forceUpdateAll) { | ||||
|                             this.toDelete.remove(data.getConnectionId()); | ||||
|                         } | ||||
|                     }); | ||||
| 
 | ||||
|             if (!this.toDelete.isEmpty()) { | ||||
|                 this.toDelete.forEach(id -> { | ||||
|                     final UpdatableTableItem item = this.tableMapping.remove(id); | ||||
|                     if (item != null) { | ||||
|                         final List<Long> list = this.sessionIds.get(item.connectionData.clientConnection.userSessionId); | ||||
|                         if (list != null) { | ||||
|                             list.remove(id); | ||||
|                         } | ||||
|                     } | ||||
|                 }); | ||||
|                 this.statusFilterChanged = false; | ||||
|                 this.toDelete.clear(); | ||||
|             } | ||||
| 
 | ||||
|         if (!this.toDelete.isEmpty()) { | ||||
|             this.toDelete.forEach(id -> { | ||||
|                 final UpdatableTableItem item = this.tableMapping.remove(id); | ||||
|                 if (item != null) { | ||||
|                     final List<Long> list = this.sessionIds.get(item.connectionData.clientConnection.userSessionId); | ||||
|                     if (list != null) { | ||||
|                         list.remove(id); | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
|             this.statusFilterChanged = false; | ||||
|             this.toDelete.clear(); | ||||
|             this.forceUpdateAll = false; | ||||
|             this.updateInProgress = false; | ||||
|             this.updateErrors = 0; | ||||
| 
 | ||||
|         } catch (final Exception e) { | ||||
|             log.error("Unexpected error while updating client connection table: ", e); | ||||
|             this.updateErrors++; | ||||
|         } | ||||
| 
 | ||||
|         this.forceUpdateAll = false; | ||||
|         this.updateInProgress = false; | ||||
|     } | ||||
| 
 | ||||
|     public void updateGUI() { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 anhefti
						anhefti