本文整理汇总了Java中com.ociweb.pronghorn.stage.PronghornStage.run方法的典型用法代码示例。如果您正苦于以下问题:Java PronghornStage.run方法的具体用法?Java PronghornStage.run怎么用?Java PronghornStage.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ociweb.pronghorn.stage.PronghornStage
的用法示例。
在下文中一共展示了PronghornStage.run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runLoopNotNice
import com.ociweb.pronghorn.stage.PronghornStage; //导入方法依赖的package包/类
private final void runLoopNotNice(final PronghornStage stage) {
assert(!playNice);
assert(!GraphManager.isRateLimited(graphManager, stage.stageId));
setCallerId(stage.boxedStageId);
do {
stage.run();
} while (continueRunning(this, stage));
clearCallerId();
GraphManager.accumRunTimeAll(graphManager, stage.stageId);
}
示例2: runLoop
import com.ociweb.pronghorn.stage.PronghornStage; //导入方法依赖的package包/类
private final void runLoop(final PronghornStage stage) {
if (!playNice && !GraphManager.isRateLimited(graphManager, stage.stageId) ) {
runLoopNotNice(stage);
} else {
if (!GraphManager.isRateLimited(graphManager, stage.stageId)) {
int i = 0;
setCallerId(stage.boxedStageId);
do {
if (playNice && 0==(0x3&i++)){
//one out of every 8 passes we will yield to play nice since we may end up with a lot of threads
//before doing yield must push any batched up writes & reads
Thread.yield();
}
long start = System.nanoTime();
stage.run();
long now = System.nanoTime();
GraphManager.accumRunTimeNS(graphManager, stage.stageId, now-start, now);
} while (continueRunning(this, stage));
clearCallerId();
} else {
runLoopRateLimited(stage);
}
}
}
示例3: run
import com.ociweb.pronghorn.stage.PronghornStage; //导入方法依赖的package包/类
private static void run(GraphManager graphManager, PronghornStage stage, NonThreadScheduler that) {
try {
if (!GraphManager.isStageShuttingDown(graphManager, stage.stageId)) {
if (debugNonReturningStages) {
logger.info("begin run {}",stage);///for debug of hang
}
that.setCallerId(stage.boxedStageId);
//long start = System.nanoTime();
stage.run();
//long duration = System.nanoTime()-start;
//if (duration>1_000_000_000) {
// new Exception("too long "+stage).printStackTrace();
//}
that.clearCallerId();
if (debugNonReturningStages) {
logger.info("end run {}",stage);
}
} else {
if (!GraphManager.isStageTerminated(graphManager, stage.stageId)) {
GraphManager.shutdownStage(graphManager, stage);
GraphManager.setStateToShutdown(graphManager, stage.stageId);
}
}
} catch (AssertionError ae) {
recordTheException(stage, ae, that);
System.exit(-1); //hard stop due to assertion failure
} catch (Throwable t) {
recordTheException(stage, t, that);
System.exit(-1); //hard stop due to suprise
}
}
示例4: run
import com.ociweb.pronghorn.stage.PronghornStage; //导入方法依赖的package包/类
private static boolean run(GraphManager graphManager,
PronghornStage stage,
ScriptedNonThreadScheduler that) {
try {
if (!GraphManager.isStageShuttingDown(that.stateArray, stage.stageId)) {
if (debugNonReturningStages) {
logger.info("begin run {}", stage);///for debug of hang
}
that.setCallerId(stage.boxedStageId);
stage.run();
that.clearCallerId();
if (debugNonReturningStages) {
logger.info("end run {}", stage);
}
return true;
} else {
if (!GraphManager.isStageTerminated(graphManager, stage.stageId)) {
GraphManager.shutdownStage(graphManager, stage);
GraphManager.setStateToShutdown(graphManager, stage.stageId);
}
return false;
}
} catch (Throwable t) {
recordTheException(stage, t, that);
throw t;
}
}
示例5: buildRunnable
import com.ociweb.pronghorn.stage.PronghornStage; //导入方法依赖的package包/类
protected Runnable buildRunnable(final int threadId) {
return new Runnable() {
private final int id = threadId;
@Override
public String toString() {
return Integer.valueOf(threadId).toString();
}
@Override
public void run() {
while(!done()) {
try {
PronghornStage stage = nextStage(id);
while(!done()) {
// Our PronghornStage.run()
// assumes exhaustive polling.
// this is also myopic. :/
//
// the gating policy really
// should be separated out from
// Pronghorn.run(), that's
// the concern of the scheduler
// not the stage. the stage
// really should poll its queue
// for a single message at a time
// then interact with the scheduler
// to determine what to do.
//
// so we run it, then request
// the nextStage().
setCallerId(stage.boxedStageId);
stage.run();
clearCallerId();
stage = nextStage(id);
}
} catch (Throwable t) {
log.error("Unexpected error in thread {}", id);
log.error("Stacktrace",t);
}
}
}
private boolean done() {
return isShuttingDown || isShutDownNow;
}
};
}
示例6: confirmInputs
import com.ociweb.pronghorn.stage.PronghornStage; //导入方法依赖的package包/类
@Test
public void confirmInputs() {
FieldReferenceOffsetManager from = buildFROM();
assertTrue(null!=from);
PipeConfig busConfig = new PipeConfig(new MessageSchemaDynamic(from), 10, 64);
GraphManager gm = new GraphManager();
Pipe inputRing1 = pipe(busConfig);
inputRing1.initBuffers();
Pipe inputRing2 = pipe(busConfig);
inputRing2.initBuffers();
PronghornStage generator1 = new TestGenerator(gm, seed, iterations, inputRing1);
PronghornStage generator2 = new TestGenerator(gm, seed, iterations, inputRing2);
generator1.startup();
generator2.startup();
generator1.run();
generator2.run();
generator1.run();
generator2.run();
generator1.shutdown();
generator2.shutdown();
Pipe ring1 = getOutputPipe(gm, generator1);
Pipe ring2 = getOutputPipe(gm, generator2);
assertTrue(inputRing1 == ring1);
assertTrue(inputRing2 == ring2);
assertTrue(Arrays.equals(Pipe.primaryBuffer(ring1),Pipe.primaryBuffer(ring2)));
assertTrue(Arrays.equals(Pipe.byteBuffer(ring1),Pipe.byteBuffer(ring2)));
assertEquals(Pipe.headPosition(ring1),Pipe.headPosition(ring2));
assertEquals(Pipe.tailPosition(ring1),Pipe.tailPosition(ring2));
PronghornStage validateResults = new TestValidator(gm,
ring1, ring2
);
assertTrue(Pipe.tailPosition(ring1)<Pipe.headPosition(ring1));
validateResults.startup();
validateResults.run();
validateResults.shutdown();
assertTrue(Pipe.tailPosition(ring1)==Pipe.headPosition(ring1));
}