Search in sources :

Example 1 with CoreMotor

use of io.nosqlbench.engine.api.activityimpl.motor.CoreMotor in project nosqlbench by nosqlbench.

the class ActivityExecutorTest method getActivityMotorFactory.

private MotorDispenser<?> getActivityMotorFactory(final ActivityDef ad, Action lc, final Input ls) {
    MotorDispenser<?> cmf = new MotorDispenser<>() {

        @Override
        public Motor getMotor(ActivityDef activityDef, int slotId) {
            Activity activity = new SimpleActivity(activityDef);
            Motor<?> cm = new CoreMotor(activity, slotId, ls);
            cm.setAction(lc);
            return cm;
        }
    };
    return cmf;
}
Also used : SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) CoreMotorDispenser(io.nosqlbench.engine.api.activityimpl.motor.CoreMotorDispenser) SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) CoreMotor(io.nosqlbench.engine.api.activityimpl.motor.CoreMotor)

Example 2 with CoreMotor

use of io.nosqlbench.engine.api.activityimpl.motor.CoreMotor in project nosqlbench by nosqlbench.

the class CoreMotorTest method testIteratorStride.

@Test
public void testIteratorStride() {
    BlockingSegmentInput lockstepper = new BlockingSegmentInput();
    Motor cm1 = new CoreMotor(new SimpleActivity("stride=3"), 1L, lockstepper);
    AtomicLongArray ary = new AtomicLongArray(10);
    Action a1 = getTestArrayConsumer(ary);
    cm1.setAction(a1);
    cm1.getSlotStateTracker().enterState(RunState.Starting);
    Thread t1 = new Thread(cm1);
    t1.setName("cm1");
    t1.start();
    try {
        // allow action time to be waiting in monitor for test fixture
        Thread.sleep(500);
    } catch (InterruptedException ignored) {
    }
    lockstepper.publishSegment(11L, 12L, 13L);
    boolean result = awaitAryCondition(ala -> (ala.get(2) == 13L), ary, 5000, 100);
    assertThat(ary.get(0)).isEqualTo(11L);
    assertThat(ary.get(1)).isEqualTo(12L);
    assertThat(ary.get(2)).isEqualTo(13L);
    assertThat(ary.get(3)).isEqualTo(0L);
}
Also used : BlockingSegmentInput(io.nosqlbench.engine.core.fortesting.BlockingSegmentInput) CoreMotor(io.nosqlbench.engine.api.activityimpl.motor.CoreMotor) SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray) CoreMotor(io.nosqlbench.engine.api.activityimpl.motor.CoreMotor) Test(org.junit.jupiter.api.Test)

Example 3 with CoreMotor

use of io.nosqlbench.engine.api.activityimpl.motor.CoreMotor in project nosqlbench by nosqlbench.

the class CoreMotorTest method testBasicActivityMotor.

@Test
public void testBasicActivityMotor() {
    BlockingSegmentInput lockstepper = new BlockingSegmentInput();
    Activity activity = new SimpleActivity(ActivityDef.parseActivityDef("alias=foo"));
    Motor cm = new CoreMotor(activity, 5L, lockstepper);
    AtomicLong observableAction = new AtomicLong(-3L);
    cm.setAction(getTestConsumer(observableAction));
    cm.getSlotStateTracker().enterState(RunState.Starting);
    Thread t = new Thread(cm);
    t.setName("TestMotor");
    t.start();
    try {
        // allow action time to be waiting in monitor for test fixture
        Thread.sleep(1000);
    } catch (InterruptedException ignored) {
    }
    lockstepper.publishSegment(5L);
    boolean result = awaitCondition(atomicInteger -> (atomicInteger.get() == 5L), observableAction, 5000, 100);
    assertThat(observableAction.get()).isEqualTo(5L);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BlockingSegmentInput(io.nosqlbench.engine.core.fortesting.BlockingSegmentInput) CoreMotor(io.nosqlbench.engine.api.activityimpl.motor.CoreMotor) SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) CoreMotor(io.nosqlbench.engine.api.activityimpl.motor.CoreMotor) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleActivity (io.nosqlbench.engine.api.activityimpl.SimpleActivity)3 CoreMotor (io.nosqlbench.engine.api.activityimpl.motor.CoreMotor)3 BlockingSegmentInput (io.nosqlbench.engine.core.fortesting.BlockingSegmentInput)2 Test (org.junit.jupiter.api.Test)2 ActivityDef (io.nosqlbench.engine.api.activityimpl.ActivityDef)1 CoreMotorDispenser (io.nosqlbench.engine.api.activityimpl.motor.CoreMotorDispenser)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AtomicLongArray (java.util.concurrent.atomic.AtomicLongArray)1