diff --git a/driver-http/src/main/java/io/nosqlbench/activitytype/http/HttpAction.java b/driver-http/src/main/java/io/nosqlbench/activitytype/http/HttpAction.java index b97425c47..9c7464551 100644 --- a/driver-http/src/main/java/io/nosqlbench/activitytype/http/HttpAction.java +++ b/driver-http/src/main/java/io/nosqlbench/activitytype/http/HttpAction.java @@ -7,11 +7,10 @@ import io.nosqlbench.engine.api.activityapi.core.SyncAction; import io.nosqlbench.engine.api.activityapi.planning.OpSequence; import io.nosqlbench.engine.api.activityimpl.ActivityDef; import io.nosqlbench.nb.api.errors.BasicError; -import io.nosqlbench.virtdata.core.templates.StringBindings; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -import java.io.*; +import java.io.FileNotFoundException; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -28,14 +27,11 @@ public class HttpAction implements SyncAction { private final HttpActivity httpActivity; private final int slot; private final int maxTries = 1; - private boolean showstmts; private OpSequence sequencer; private HttpClient client; private final HttpResponse.BodyHandler bodyreader = HttpResponse.BodyHandlers.ofString(); - private final long timeoutMillis=30000L; - public HttpAction(ActivityDef activityDef, int slot, HttpActivity httpActivity) { this.slot = slot; @@ -54,25 +50,15 @@ public class HttpAction implements SyncAction { @Override public int runCycle(long cycleValue) { - StringBindings stringBindings; - String statement = null; - InputStream result = null; + + // The request to be used must be constructed from the template each time. + HttpOp httpOp = null; // The bind timer captures all the time involved in preparing the // operation for execution, including data generation as well as // op construction - - // The request to be used must be constructed from the template each time. - HttpOp httpOp=null; - - // A specifier for what makes a response ok. If this is provided, then it is - // either a list of valid http status codes, or if non-numeric, a regex for the body - // which must match. - // If not provided, then status code 200 is the only thing required to be matched. - String ok; - try (Timer.Context bindTime = httpActivity.bindTimer.time()) { - ReadyHttpOp readHTTPOperation = httpActivity.getSequencer().get(cycleValue); + ReadyHttpOp readHTTPOperation = sequencer.get(cycleValue); httpOp = readHTTPOperation.apply(cycleValue); } catch (Exception e) { if (httpActivity.isDiagnosticMode()) { @@ -135,98 +121,10 @@ public class HttpAction implements SyncAction { } } - -// if (ok == null) { -// if (response.statusCode() != 200) { -// throw new ResponseError("Result had status code " + -// response.statusCode() + ", but 'ok' was not set for this statement," + -// "so it is considered an error."); -// } -// } else { -// String[] oks = ok.split(","); -// for (String ok_condition : oks) { -// if (ok_condition.charAt(0)>='0' && ok_condition.charAt(0)<='9') { -// int matching_status = Integer.parseInt(ok_condition); -// } else { -// Pattern successRegex = Pattern.compile(ok); -// } -// } -//// Matcher matcher = successRegex.matcher(String.valueOf(response.statusCode())); -//// if (!matcher.matches()) { -//// throw new BasicError("status code " + response.statusCode() + " did not match " + success); -//// } -// } } return 0; } -// String body = future.body(); - - -// String[] splitStatement = statement.split("\\?"); -// String path, query; -// -// path = splitStatement[0]; -// query = ""; -// -// if (splitStatement.length >= 2) { -// query = splitStatement[1]; -// } -// -// URI uri = new URI( -// "http", -// null, -// host, -// httpActivity.getPort(), -// path, -// query, -// null); -// -// statement = uri.toString(); -// -// showstmts = httpActivity.getShowstmts(); - -// if (showstmts) { -// logger.info("STMT(cycle=" + cycleValue + "):\n" + statement); -// } -// } catch (URISyntaxException e) { -// e.printStackTrace(); -// } -// -// long nanoStartTime=System.nanoTime(); -// - -// Timer.Context resultTime = httpActivity.resultTimer.time(); -// try { -// StringBuilder res = new StringBuilder(); -// -// BufferedReader rd = new BufferedReader(new InputStreamReader(result)); -// String line; -// while ((line = rd.readLine()) != null) { -// res.append(line); -// } -// rd.close(); -// -// } catch (Exception e) { -// long resultNanos = resultTime.stop(); -// resultTime = null; -// } finally { -// if (resultTime != null) { -// resultTime.stop(); -// } -// -// } -// -// } -// long resultNanos = System.nanoTime() - nanoStartTime; -// httpActivity.resultSuccessTimer.update(resultNanos, TimeUnit.NANOSECONDS); - - -// protected HttpActivity getHttpActivity () { -// return httpActivity; -// } -// } - private HttpRequest.BodyPublisher bodySourceFrom(Map cmdMap) { if (cmdMap.containsKey("body")) { String body = cmdMap.remove("body"); diff --git a/mvn-defaults/pom.xml b/mvn-defaults/pom.xml index 42b5c62aa..3147e41cc 100644 --- a/mvn-defaults/pom.xml +++ b/mvn-defaults/pom.xml @@ -13,10 +13,9 @@ UTF-8 nosqlbench - 11 + - 4.8 1.2.0 1.14 1.20 @@ -325,7 +324,7 @@ org.antlr antlr4-runtime - ${antlr4.version} + 4.8