mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-01-26 15:36:33 -06:00
progress on cqld4
This commit is contained in:
parent
ca7fb7b839
commit
50d9fc43ec
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<artifactId>mvn-defaults</artifactId>
|
||||
<version>4.15.20-SNAPSHOT</version>
|
||||
<version>4.15.31-SNAPSHOT</version>
|
||||
<relativePath>../mvn-defaults</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -23,13 +23,13 @@
|
||||
<dependency>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<artifactId>engine-api</artifactId>
|
||||
<version>4.15.20-SNAPSHOT</version>
|
||||
<version>4.15.31-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<artifactId>drivers-api</artifactId>
|
||||
<version>4.15.20-SNAPSHOT</version>
|
||||
<version>4.15.31-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<artifactId>virtdata-lib-basics</artifactId>
|
||||
<version>4.15.20-SNAPSHOT</version>
|
||||
<version>4.15.31-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
import io.nosqlbench.engine.api.activityapi.core.SyncAction;
|
||||
|
||||
public class Cqld4Action implements SyncAction {
|
||||
|
||||
private final Cqld4Activity activity;
|
||||
|
||||
public Cqld4Action(int slot, Cqld4Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int runCycle(long cycle) {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package io.nosqlbench.driver.cqld4;
|
||||
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.Timer;
|
||||
import io.nosqlbench.engine.api.activityapi.core.ActivityDefObserver;
|
||||
import io.nosqlbench.engine.api.activityapi.core.SyncAction;
|
||||
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.ErrorDetail;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Cqld4Action implements SyncAction, ActivityDefObserver {
|
||||
|
||||
/**
|
||||
* The thread number within the activity instance
|
||||
**/
|
||||
private final int slot;
|
||||
private final Cqld4Activity activity;
|
||||
|
||||
private Timer bindTimer;
|
||||
private Timer executeTimer;
|
||||
private Timer resultTimer;
|
||||
private Timer resultSuccessTimer;
|
||||
private Histogram triesHisto;
|
||||
private int maxTries;
|
||||
|
||||
|
||||
public Cqld4Action(int slot, Cqld4Activity activity) {
|
||||
this.slot = slot;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.bindTimer = activity.getInstrumentation().getOrCreateBindTimer();
|
||||
this.executeTimer = activity.getInstrumentation().getOrCreateExecuteTimer();
|
||||
this.resultTimer = activity.getInstrumentation().getOrCreateResultTimer();
|
||||
this.resultSuccessTimer = activity.getInstrumentation().getOrCreateResultSuccessTimer();
|
||||
this.triesHisto = activity.getInstrumentation().getOrCreateTriesHistogram();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int runCycle(long cycle) {
|
||||
|
||||
Cqld4Op cql4op;
|
||||
try (Timer.Context ctx = bindTimer.time()) {
|
||||
OpDispenser<Cqld4Op> opDispenser = activity.getSequence().get(cycle);
|
||||
cql4op = opDispenser.apply(cycle);
|
||||
}
|
||||
|
||||
int tries = 0;
|
||||
int result = 0;
|
||||
Exception error=null;
|
||||
while (tries < maxTries) {
|
||||
tries++;
|
||||
long startat = System.nanoTime();
|
||||
try {
|
||||
try (Timer.Context ctx = executeTimer.time()) {
|
||||
cql4op.run();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
error=e;
|
||||
} finally {
|
||||
long nanos = System.nanoTime() - startat;
|
||||
resultTimer.update(nanos, TimeUnit.NANOSECONDS);
|
||||
|
||||
if (error==null) {
|
||||
resultSuccessTimer.update(nanos, TimeUnit.NANOSECONDS);
|
||||
break;
|
||||
} else {
|
||||
ErrorDetail detail = activity.getErrorhandler().handleError(error,cycle,nanos);
|
||||
result = detail.resultCode;
|
||||
if (!detail.isRetryable()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
triesHisto.update(tries);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityDefUpdate(ActivityDef activityDef) {
|
||||
this.maxTries = activity.getActivityDef().getParams().getOptionalInteger("maxtries").orElse(10);
|
||||
}
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
package io.nosqlbench.driver.cqld4;
|
||||
|
||||
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.NBErrorHandler;
|
||||
import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
@ -13,6 +16,7 @@ public class Cqld4Activity extends SimpleActivity {
|
||||
private final static Logger logger = LogManager.getLogger(Cqld4Activity.class);
|
||||
|
||||
private OpSequence<OpDispenser<Cqld4Op>> sequence;
|
||||
private NBErrorHandler errorhandler;
|
||||
|
||||
public Cqld4Activity(ActivityDef activityDef) {
|
||||
super(activityDef);
|
||||
@ -23,5 +27,22 @@ public class Cqld4Activity extends SimpleActivity {
|
||||
super.initActivity();
|
||||
Function<OpTemplate,OpDispenser<Cqld4Op>> f = Cqld4ReadyOp::new;
|
||||
sequence = createOpSequence(f);
|
||||
this.errorhandler = new NBErrorHandler(
|
||||
() -> activityDef.getParams().getOptionalString("errors").orElse("stop"),
|
||||
this::getExceptionMetrics
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public NBErrorHandler getErrorhandler() {
|
||||
return errorhandler;
|
||||
}
|
||||
|
||||
public OpSequence<OpDispenser<Cqld4Op>> getSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public int getMaxTries() {
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user