mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
misc code cleanups
This commit is contained in:
parent
ff6492763d
commit
0b03da159c
@ -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.activityapi.planning.OpSequence;
|
||||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||||
import io.nosqlbench.nb.api.errors.BasicError;
|
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.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
@ -28,14 +27,11 @@ public class HttpAction implements SyncAction {
|
|||||||
private final HttpActivity httpActivity;
|
private final HttpActivity httpActivity;
|
||||||
private final int slot;
|
private final int slot;
|
||||||
private final int maxTries = 1;
|
private final int maxTries = 1;
|
||||||
private boolean showstmts;
|
|
||||||
|
|
||||||
private OpSequence<ReadyHttpOp> sequencer;
|
private OpSequence<ReadyHttpOp> sequencer;
|
||||||
private HttpClient client;
|
private HttpClient client;
|
||||||
|
|
||||||
private final HttpResponse.BodyHandler<String> bodyreader = HttpResponse.BodyHandlers.ofString();
|
private final HttpResponse.BodyHandler<String> bodyreader = HttpResponse.BodyHandlers.ofString();
|
||||||
private final long timeoutMillis=30000L;
|
|
||||||
|
|
||||||
|
|
||||||
public HttpAction(ActivityDef activityDef, int slot, HttpActivity httpActivity) {
|
public HttpAction(ActivityDef activityDef, int slot, HttpActivity httpActivity) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
@ -54,25 +50,15 @@ public class HttpAction implements SyncAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int runCycle(long cycleValue) {
|
public int runCycle(long cycleValue) {
|
||||||
StringBindings stringBindings;
|
|
||||||
String statement = null;
|
// The request to be used must be constructed from the template each time.
|
||||||
InputStream result = null;
|
HttpOp httpOp = null;
|
||||||
|
|
||||||
// The bind timer captures all the time involved in preparing the
|
// The bind timer captures all the time involved in preparing the
|
||||||
// operation for execution, including data generation as well as
|
// operation for execution, including data generation as well as
|
||||||
// op construction
|
// 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()) {
|
try (Timer.Context bindTime = httpActivity.bindTimer.time()) {
|
||||||
ReadyHttpOp readHTTPOperation = httpActivity.getSequencer().get(cycleValue);
|
ReadyHttpOp readHTTPOperation = sequencer.get(cycleValue);
|
||||||
httpOp = readHTTPOperation.apply(cycleValue);
|
httpOp = readHTTPOperation.apply(cycleValue);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (httpActivity.isDiagnosticMode()) {
|
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;
|
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<String, String> cmdMap) {
|
private HttpRequest.BodyPublisher bodySourceFrom(Map<String, String> cmdMap) {
|
||||||
if (cmdMap.containsKey("body")) {
|
if (cmdMap.containsKey("body")) {
|
||||||
String body = cmdMap.remove("body");
|
String body = cmdMap.remove("body");
|
||||||
|
@ -13,10 +13,9 @@
|
|||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<javadoc.name>nosqlbench</javadoc.name>
|
<javadoc.name>nosqlbench</javadoc.name>
|
||||||
|
|
||||||
<java.target.version>11</java.target.version>
|
<!-- <java.target.version>11</java.target.version>-->
|
||||||
|
|
||||||
<!-- properties for package versions -->
|
<!-- properties for package versions -->
|
||||||
<antlr4.version>4.8</antlr4.version>
|
|
||||||
<ascii.data.version>1.2.0</ascii.data.version>
|
<ascii.data.version>1.2.0</ascii.data.version>
|
||||||
<commons.codec.version>1.14</commons.codec.version>
|
<commons.codec.version>1.14</commons.codec.version>
|
||||||
<commons.compress.version>1.20</commons.compress.version>
|
<commons.compress.version>1.20</commons.compress.version>
|
||||||
@ -325,7 +324,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.antlr</groupId>
|
<groupId>org.antlr</groupId>
|
||||||
<artifactId>antlr4-runtime</artifactId>
|
<artifactId>antlr4-runtime</artifactId>
|
||||||
<version>${antlr4.version}</version>
|
<version>4.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
Loading…
Reference in New Issue
Block a user