cycle naming for simplicity

This commit is contained in:
Jonathan Shook
2021-01-25 07:37:50 -06:00
parent 7275f6567e
commit c423cf0028
12 changed files with 52 additions and 53 deletions

View File

@@ -66,11 +66,11 @@ public class CqlAction implements SyncAction, MultiPhaseAction, ActivityDefObser
}
@Override
public int runCycle(long value) {
public int runCycle(long cycle) {
// In this activity type, we use the same phase
// logic for the initial phase (runCycle(...))
// as well as subsequent phases.
return runPhase(value);
return runPhase(cycle);
}
public int runPhase(long cycleValue) {

View File

@@ -124,10 +124,10 @@ public class DiagAction implements SyncAction, ActivityDefObserver, MultiPhaseAc
}
@Override
public int runCycle(long value) {
public int runCycle(long cycle) {
if (logcycle) {
logger.trace("cycle " + value);
logger.trace("cycle " + cycle);
}
try (Timer.Context timerctx = resultTimer.time()) {
@@ -142,13 +142,13 @@ public class DiagAction implements SyncAction, ActivityDefObserver, MultiPhaseAc
if ((now - lastUpdate) > quantizedInterval) {
long delay = ((now - lastUpdate) - quantizedInterval);
logger.info("diag action interval, input=" + value + ", phase=" + completedPhase + ", report delay=" + delay + "ms");
logger.info("diag action interval, input=" + cycle + ", phase=" + completedPhase + ", report delay=" + delay + "ms");
lastUpdate += quantizedInterval;
diagActivity.delayHistogram.update(delay);
}
if ((value % reportModulo) == 0) {
logger.info("diag action modulo, input=" + value + ", phase=" + completedPhase);
if ((cycle % reportModulo) == 0) {
logger.info("diag action modulo, input=" + cycle + ", phase=" + completedPhase);
}
completedPhase++;
@@ -156,7 +156,7 @@ public class DiagAction implements SyncAction, ActivityDefObserver, MultiPhaseAc
int result = 0;
if (resultmodulo >= 0) {
if ((value % resultmodulo) == 0) {
if ((cycle % resultmodulo) == 0) {
result = 1;
} else {
result = 0;
@@ -164,14 +164,14 @@ public class DiagAction implements SyncAction, ActivityDefObserver, MultiPhaseAc
} else if (staticvalue >= 0) {
return staticvalue;
} else {
result = (byte) (value % 128);
result = (byte) (cycle % 128);
}
if (erroroncycle == value) {
if (erroroncycle == cycle) {
this.diagActivity.getActivityController().stopActivityWithReasonAsync("Diag was requested to stop on cycle " + erroroncycle);
}
if (throwoncycle == value) {
if (throwoncycle == cycle) {
throw new DiagDummyError("Diag was asked to throw an error on cycle " + throwoncycle);
}

View File

@@ -41,7 +41,7 @@ public class GraphAction implements SyncAction, ActivityDefObserver {
}
@Override
public int runCycle(long cycleValue) {
public int runCycle(long cycle) {
int tries = 0;
BindableGraphStatement readyGraphStatement;
@@ -52,11 +52,11 @@ public class GraphAction implements SyncAction, ActivityDefObserver {
try (Timer.Context bindTime = activity.bindTimer.time()) {
BindableGraphStatement bindableGraphStatement = opSequencer.get(cycleValue);
simpleGraphStatement = bindableGraphStatement.bind(cycleValue);
BindableGraphStatement bindableGraphStatement = opSequencer.get(cycle);
simpleGraphStatement = bindableGraphStatement.bind(cycle);
if (showstmts) {
logger.info("GRAPH QUERY(cycle=" + cycleValue + "):\n" + simpleGraphStatement.getQueryString());
logger.info("GRAPH QUERY(cycle=" + cycle + "):\n" + simpleGraphStatement.getQueryString());
}
}
@@ -72,7 +72,7 @@ public class GraphAction implements SyncAction, ActivityDefObserver {
GraphResultSet resultSet = resultSetFuture.get();
break; // This is normal termination of this loop, when retries aren't needed
} catch (Exception e) {
if (!graphErrorHandler.HandleError(e, simpleGraphStatement, cycleValue)) {
if (!graphErrorHandler.HandleError(e, simpleGraphStatement, cycle)) {
e.printStackTrace();
logger.error(e.toString(), e);
break;

View File

@@ -28,9 +28,9 @@ public class JMXAction implements SyncAction {
}
@Override
public int runCycle(long value) {
ReadyJmxOp readyJmxOp = sequencer.get(value);
JmxOp jmxOp = readyJmxOp.bind(value);
public int runCycle(long cycle) {
ReadyJmxOp readyJmxOp = sequencer.get(cycle);
JmxOp jmxOp = readyJmxOp.bind(cycle);
jmxOp.execute();
return 0;
}

View File

@@ -26,8 +26,8 @@ public class KafkaAction implements SyncAction {
}
@Override
public int runCycle(long cycleValue) {
sequencer.get(cycleValue).write(cycleValue);
public int runCycle(long cycle) {
sequencer.get(cycle).write(cycle);
return 1;
}

View File

@@ -1,16 +1,15 @@
package io.nosqlbench.driver.mongodb;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.codahale.metrics.Timer;
import io.nosqlbench.engine.api.activityapi.core.SyncAction;
import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bson.Document;
import org.bson.conversions.Bson;
import java.util.concurrent.TimeUnit;
public class MongoAction implements SyncAction {
private final static Logger logger = LogManager.getLogger(MongoAction.class);
@@ -31,16 +30,16 @@ public class MongoAction implements SyncAction {
}
@Override
public int runCycle(long cycleValue) {
public int runCycle(long cycle) {
ReadyMongoStatement rms;
Bson queryBson;
try (Timer.Context bindTime = activity.bindTimer.time()) {
rms = sequencer.get(cycleValue);
queryBson = rms.bind(cycleValue);
rms = sequencer.get(cycle);
queryBson = rms.bind(cycle);
// Maybe show the query in log/console - only for diagnostic use
if (activity.isShowQuery()) {
logger.info("Query(cycle={}):\n{}", cycleValue, queryBson);
logger.info("Query(cycle={}):\n{}", cycle, queryBson);
}
}
@@ -66,11 +65,11 @@ public class MongoAction implements SyncAction {
return ok == 1 ? 0 : 1;
} catch (Exception e) {
logger.error("Failed to runCommand {} on cycle {}, tries {}", queryBson, cycleValue, i, e);
logger.error("Failed to runCommand {} on cycle {}, tries {}", queryBson, cycle, i, e);
}
}
throw new RuntimeException(String.format("Exhausted max tries (%s) on cycle %s",
activity.getMaxTries(), cycleValue));
activity.getMaxTries(), cycle));
}
}

View File

@@ -45,15 +45,15 @@ public class StdoutAction implements SyncAction {
}
@Override
public int runCycle(long cycleValue) {
public int runCycle(long cycle) {
StringBindings stringBindings;
String statement = null;
try (Timer.Context bindTime = activity.bindTimer.time()) {
stringBindings = opsource.get(cycleValue);
statement = stringBindings.bind(cycleValue);
stringBindings = opsource.get(cycle);
statement = stringBindings.bind(cycle);
showstmts = activity.getShowstmts();
if (showstmts) {
logger.info("STMT(cycle=" + cycleValue + "):\n" + statement);
logger.info("STMT(cycle=" + cycle + "):\n" + statement);
}
}

View File

@@ -43,15 +43,15 @@ public class WebDriverAction implements SyncAction, ActivityDefObserver {
// As it is right now, all commands are resolved dynamically, which is still not going to be the limiting
// factor.
@Override
public int runCycle(long value) {
public int runCycle(long cycle) {
CommandTemplate commandTemplate = activity.getOpSequence().get(value);
CommandTemplate commandTemplate = activity.getOpSequence().get(cycle);
try {
WebDriverVerbs.execute(value, commandTemplate, context, dryrun);
WebDriverVerbs.execute(cycle, commandTemplate, context, dryrun);
return 0;
} catch (Exception e) {
logger.error("Error with cycle(" + value + "), statement(" + commandTemplate.getName() + "): "+e.getMessage());
logger.error("Error with cycle(" + cycle + "), statement(" + commandTemplate.getName() + "): " + e.getMessage());
if (errors.equals("stop")) {
throw e;
}

View File

@@ -24,11 +24,11 @@ public interface SyncAction extends Action {
* The meaning of status codes is activity specific, however the values Integer.MIN_VALUE,
* and Integer.MAX_VALUE are reserved.
*
* @param value a long input
* @param cycle a long input
* @return an int status
*/
default int runCycle(long value) {
return (int) value % 100;
default int runCycle(long cycle) {
return (int) cycle % 100;
}
}

View File

@@ -36,11 +36,11 @@ public class CoreAction implements SyncAction {
}
@Override
public int runCycle(long value) {
if ((value % interval) == 0) {
logger.info(activityDef.getAlias() + "[" + slot + "]: cycle=" + value);
public int runCycle(long cycle) {
if ((cycle % interval) == 0) {
logger.info(activityDef.getAlias() + "[" + slot + "]: cycle=" + cycle);
} else {
logger.trace(activityDef.getAlias() + "[" + slot + "]: cycle=" + value);
logger.trace(activityDef.getAlias() + "[" + slot + "]: cycle=" + cycle);
}
return 0;
}

View File

@@ -136,8 +136,8 @@ public class ActivityExecutorTest {
private SyncAction motorActionDelay(final long delay) {
SyncAction consumer = new SyncAction() {
@Override
public int runCycle(long value) {
System.out.println("consuming " + value + ", delaying:" + delay);
public int runCycle(long cycle) {
System.out.println("consuming " + cycle + ", delaying:" + delay);
try {
Thread.sleep(delay);
} catch (InterruptedException ignored) {

View File

@@ -79,8 +79,8 @@ public class CoreMotorTest {
return new SyncAction() {
private int offset=0;
@Override
public int runCycle(long value) {
ary.set(offset++,value);
public int runCycle(long cycle) {
ary.set(offset++, cycle);
return 0;
}
};
@@ -88,8 +88,8 @@ public class CoreMotorTest {
private SyncAction getTestConsumer(final AtomicLong atomicLong) {
return new SyncAction() {
@Override
public int runCycle(long value) {
atomicLong.set(value);
public int runCycle(long cycle) {
atomicLong.set(cycle);
return 0;
}
};