Browse Source

GL, roll back to older design for updates test (#4853)

* [ci fw-only Java/greenlightning]

swap versions

* [ci fw-only Java/greenlightning]

go back to simple file

* [ci fw-only Java/greenlightning]

update version to add loging and track issue

* [ci fw-only Java/greenlightning]

use old update design

bump version number
Nathan Tippy 6 years ago
parent
commit
11c65199d2

+ 1 - 1
frameworks/Java/greenlightning/pom.xml

@@ -4,7 +4,7 @@
 
 
 	<groupId>com.javanut.gl.benchmark</groupId>
 	<groupId>com.javanut.gl.benchmark</groupId>
 	<artifactId>benchmark-test</artifactId>
 	<artifactId>benchmark-test</artifactId>
-	<version>1.1.2</version> 
+	<version>1.1.3</version> 
 
 
 	<properties>
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

+ 64 - 47
frameworks/Java/greenlightning/src/main/java/com/javanut/gl/benchmark/ProcessUpdate.java

@@ -59,7 +59,7 @@ public class ProcessUpdate {
 		
 		
 		if ((pause.get()<20) && DBUpdateInFlight.hasRoomFor(queries) && service.hasRoomFor(temp) ) {		
 		if ((pause.get()<20) && DBUpdateInFlight.hasRoomFor(queries) && service.hasRoomFor(temp) ) {		
 			    
 			    
-				List<Tuple> args = new ArrayList<Tuple>(queries);
+				//NEW List<Tuple> args = new ArrayList<Tuple>(queries);
 				List<ResultObject> objs = new ArrayList<ResultObject>(queries);
 				List<ResultObject> objs = new ArrayList<ResultObject>(queries);
 				int q = queries;
 				int q = queries;
 				while (--q >= 0) {
 				while (--q >= 0) {
@@ -91,28 +91,45 @@ public class ProcessUpdate {
 							        //set the new random value in this object
 							        //set the new random value in this object
 							        worldObject.setResult(randomValue());							        
 							        worldObject.setResult(randomValue());							        
 							        
 							        
-							      //  
-							      //  Use of batch updates is acceptable but not required. 
-							      //   To be clear: batches are not permissible for selecting/reading the rows,
-							      //   but batches are acceptable for writing the updates.
-							      //  
 							        
 							        
-							        //TODO: can we prep this only once and hold it?
+							        pm.pool().preparedQuery("UPDATE world SET randomnumber=$1 WHERE id=$2", 							        		
+						        			Tuple.of(worldObject.getResult(), worldObject.getId()), ar -> {							        	
+													if (ar.succeeded()) {														
+											        	worldObject.setStatus(200);			
+											        	
+													} else {	
+														System.out.println("unable to update");
+														if (ar.cause()!=null) {
+															ar.cause().printStackTrace();
+														}
+														
+														worldObject.setStatus(500);
+													}																												
+						        			});
 							        
 							        
-							        Tuple of = Tuple.of(worldObject.getResult(), worldObject.getId());
-							        args.add(of);
 							        
 							        
-							        //only call for update when we have each of the args
-							        if (args.size()==queries) {
-							        	Collections.sort(args, (a,b) -> {
-											return Integer.compare( ((Tuple)a).getInteger(0),
-															        ((Tuple)b).getInteger(0));
-										
-										});
-							        	
-							        	execUpdate(objs, args, 1);							        	
-							        	
-							        }							        
+//							      //  
+//							      //  Use of batch updates is acceptable but not required. 
+//							      //   To be clear: batches are not permissible for selecting/reading the rows,
+//							      //   but batches are acceptable for writing the updates.
+//							      //  
+//							        
+//							        //TODO: can we prep this only once and hold it?
+//							        
+//							        Tuple of = Tuple.of(worldObject.getResult(), worldObject.getId());
+//							        args.add(of);
+//							        
+//							        //only call for update when we have each of the args
+//							        if (args.size()==queries) {
+//							        	Collections.sort(args, (a,b) -> {
+//											return Integer.compare( ((Tuple)a).getInteger(0),
+//															        ((Tuple)b).getInteger(0));
+//										
+//										});
+//							        	
+//							        	execUpdate(objs, args, 1);							        	
+//							        	
+//							        }							        
 							        
 							        
 								} else {	
 								} else {	
 								
 								
@@ -142,33 +159,33 @@ public class ProcessUpdate {
 	private final AtomicInteger pause = new AtomicInteger(0);
 	private final AtomicInteger pause = new AtomicInteger(0);
 	
 	
 	
 	
-	private void execUpdate(List<ResultObject> toUpdate, List<Tuple> args, int i) {
-				
-		pm.pool().preparedBatch("UPDATE world SET randomnumber=$1 WHERE id=$2", 							        		
-				args, ar -> {	
-					
-			pause.addAndGet(i);
-			int status;		
-			if (ar.succeeded()) {
-		    	status = 200;
-		    	pause.decrementAndGet();
-			} else {
-				execUpdate(toUpdate, args, 0);
-				return;
-//				System.out.println("unable to update");
-//				if (ar.cause()!=null) {
-//					ar.cause().printStackTrace();
-//				}			
-//				status = 500;
-			}
-			toUpdate.forEach(w->{
-				w.setStatus(status);
-			});
-
-
-		});
-			
-	}
+//	private void execUpdate(List<ResultObject> toUpdate, List<Tuple> args, int i) {
+//				
+//		pm.pool().preparedBatch("UPDATE world SET randomnumber=$1 WHERE id=$2", 							        		
+//				args, ar -> {	
+//					
+//			pause.addAndGet(i);
+//			int status;		
+//			if (ar.succeeded()) {
+//		    	status = 200;
+//		    	pause.decrementAndGet();
+//			} else {
+//				execUpdate(toUpdate, args, 0);
+//				return;
+////				System.out.println("unable to update");
+////				if (ar.cause()!=null) {
+////					ar.cause().printStackTrace();
+////				}			
+////				status = 500;
+//			}
+//			toUpdate.forEach(w->{
+//				w.setStatus(status);
+//			});
+//
+//
+//		});
+//			
+//	}
 	
 	
 	private void consumeResultObjectDBUpdate(final ResultObject t) {
 	private void consumeResultObjectDBUpdate(final ResultObject t) {