mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
nosqlbench-2146 verification timer should be separate from execute timer (#2147)
* nosqlbench-2146 verification timer should be separate from execute timer * remove stale TODO
This commit is contained in:
parent
8cc5bd77da
commit
bc759c0e81
@ -35,18 +35,18 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the generified version of an Action. All driver adapters us this, as opposed
|
This is the generified version of an Action. All driver adapters us this, as opposed
|
||||||
* to previous NB versions where it was implemented for each driver.
|
to previous NB versions where it was implemented for each driver.
|
||||||
* <p>
|
<p>
|
||||||
* This allows the API to be consolidated so that the internal machinery of NB
|
This allows the API to be consolidated so that the internal machinery of NB
|
||||||
* works in a very consistent and uniform way for all users and drivers.
|
works in a very consistent and uniform way for all users and drivers.
|
||||||
*
|
@param <A>
|
||||||
* @param <A>
|
The type of activity
|
||||||
* The type of activity
|
@param <R>
|
||||||
* @param <R>
|
The type of operation */
|
||||||
* The type of operation
|
public class StandardAction<A extends StandardActivity<R, ?>, R extends java.util.function.LongFunction>
|
||||||
*/
|
implements SyncAction, ActivityDefObserver
|
||||||
public class StandardAction<A extends StandardActivity<R, ?>, R extends java.util.function.LongFunction> implements SyncAction, ActivityDefObserver {
|
{
|
||||||
private final static Logger logger = LogManager.getLogger("ACTION");
|
private final static Logger logger = LogManager.getLogger("ACTION");
|
||||||
private final Timer executeTimer;
|
private final Timer executeTimer;
|
||||||
private final Histogram triesHistogram;
|
private final Histogram triesHistogram;
|
||||||
@ -73,15 +73,17 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends java.uti
|
|||||||
@Override
|
@Override
|
||||||
public int runCycle(long cycle) {
|
public int runCycle(long cycle) {
|
||||||
|
|
||||||
OpDispenser<? extends CycleOp<?>> dispenser=null;
|
OpDispenser<? extends CycleOp<?>> dispenser = null;
|
||||||
CycleOp op = null;
|
CycleOp op = null;
|
||||||
|
|
||||||
try (Timer.Context ct = bindTimer.time()) {
|
try (Timer.Context ct = bindTimer.time()) {
|
||||||
dispenser = opsequence.apply(cycle);
|
dispenser = opsequence.apply(cycle);
|
||||||
op = dispenser.getOp(cycle);
|
op = dispenser.getOp(cycle);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("while binding request in cycle " + cycle + " for op template named '" + (dispenser!=null?dispenser.getOpName():"NULL")+
|
throw new RuntimeException(
|
||||||
"': " + e.getMessage(), e);
|
"while binding request in cycle " + cycle + " for op template named '" + (
|
||||||
|
dispenser != null ? dispenser.getOpName() : "NULL") + "': " + e.getMessage(), e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = 0;
|
int code = 0;
|
||||||
@ -95,22 +97,35 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends java.uti
|
|||||||
|
|
||||||
dispenser.onStart(cycle);
|
dispenser.onStart(cycle);
|
||||||
|
|
||||||
try (Timer.Context ct = executeTimer.time()) {
|
try {
|
||||||
result = op.apply(cycle);
|
try (Timer.Context ct = executeTimer.time()) {
|
||||||
// TODO: break out validation timer from execute
|
result = op.apply(cycle);
|
||||||
|
}
|
||||||
|
|
||||||
try (Timer.Context ignored = verifierTimer.time()) {
|
try (Timer.Context ignored = verifierTimer.time()) {
|
||||||
CycleFunction<Boolean> verifier = dispenser.getVerifier();
|
CycleFunction<Boolean> verifier = dispenser.getVerifier();
|
||||||
try {
|
if (verifier != null) {
|
||||||
verifier.setVariable("result", result);
|
try {
|
||||||
verifier.setVariable("cycle",cycle);
|
verifier.setVariable("result", result);
|
||||||
Boolean isGood = verifier.apply(cycle);
|
verifier.setVariable("cycle", cycle);
|
||||||
if (!isGood) {
|
Boolean isGood = verifier.apply(cycle);
|
||||||
throw new ResultVerificationError("result verification failed", maxTries - tries, verifier.getExpressionDetails());
|
if (!isGood) {
|
||||||
|
throw new ResultVerificationError(
|
||||||
|
"result verification failed",
|
||||||
|
maxTries - tries,
|
||||||
|
verifier.getExpressionDetails()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ResultVerificationError(
|
||||||
|
e,
|
||||||
|
maxTries - tries,
|
||||||
|
verifier.getExpressionDetails()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ResultVerificationError(e, maxTries - tries, verifier.getExpressionDetails());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
error = e;
|
error = e;
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user