mitigated client connection update concurrency
This commit is contained in:
		
							parent
							
								
									10727e398c
								
							
						
					
					
						commit
						dbbc69e229
					
				
					 1 changed files with 12 additions and 3 deletions
				
			
		|  | @ -328,6 +328,11 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { | ||||||
|         return Result.tryCatch(() -> { |         return Result.tryCatch(() -> { | ||||||
| 
 | 
 | ||||||
|             final long millisecondsNow = Utils.getMillisecondsNow(); |             final long millisecondsNow = Utils.getMillisecondsNow(); | ||||||
|  |             // NOTE: we use nanoseconds here to get a better precision to better avoid | ||||||
|  |             //       same value of real concurrent calls on distributed systems | ||||||
|  |             // TODO: Better solution for the future would be to count this value and | ||||||
|  |             //       isolation is done via DB transaction | ||||||
|  |             final long nanosecondsNow = System.nanoTime(); | ||||||
|             final ClientConnectionRecord newRecord = new ClientConnectionRecord( |             final ClientConnectionRecord newRecord = new ClientConnectionRecord( | ||||||
|                     null, |                     null, | ||||||
|                     data.institutionId, |                     data.institutionId, | ||||||
|  | @ -340,7 +345,7 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { | ||||||
|                     BooleanUtils.toInteger(data.vdi, 1, 0, 0), |                     BooleanUtils.toInteger(data.vdi, 1, 0, 0), | ||||||
|                     data.vdiPairToken, |                     data.vdiPairToken, | ||||||
|                     millisecondsNow, |                     millisecondsNow, | ||||||
|                     millisecondsNow, |                     nanosecondsNow, | ||||||
|                     data.remoteProctoringRoomId, |                     data.remoteProctoringRoomId, | ||||||
|                     null, |                     null, | ||||||
|                     Utils.truncateText(data.sebMachineName, 255), |                     Utils.truncateText(data.sebMachineName, 255), | ||||||
|  | @ -359,7 +364,11 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { | ||||||
|     public Result<ClientConnection> save(final ClientConnection data) { |     public Result<ClientConnection> save(final ClientConnection data) { | ||||||
|         return Result.tryCatch(() -> { |         return Result.tryCatch(() -> { | ||||||
| 
 | 
 | ||||||
|             final long millisecondsNow = Utils.getMillisecondsNow(); |             // NOTE: we use nanoseconds here to get a better precision to better avoid | ||||||
|  |             //       same value of real concurrent calls on distributed systems | ||||||
|  |             // TODO: Better solution for the future would be to count this value and | ||||||
|  |             //       isolation is done via DB transaction | ||||||
|  |             final long nanosecondsNow = System.nanoTime(); | ||||||
|             final ClientConnectionRecord updateRecord = new ClientConnectionRecord( |             final ClientConnectionRecord updateRecord = new ClientConnectionRecord( | ||||||
|                     data.id, |                     data.id, | ||||||
|                     null, |                     null, | ||||||
|  | @ -372,7 +381,7 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { | ||||||
|                     BooleanUtils.toInteger(data.vdi, 1, 0, 0), |                     BooleanUtils.toInteger(data.vdi, 1, 0, 0), | ||||||
|                     data.vdiPairToken, |                     data.vdiPairToken, | ||||||
|                     null, |                     null, | ||||||
|                     millisecondsNow, |                     nanosecondsNow, | ||||||
|                     null, |                     null, | ||||||
|                     null, |                     null, | ||||||
|                     Utils.truncateText(data.sebMachineName, 255), |                     Utils.truncateText(data.sebMachineName, 255), | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 anhefti
						anhefti