• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NonThreadScheduler类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler的典型用法代码示例。如果您正苦于以下问题:Java NonThreadScheduler类的具体用法?Java NonThreadScheduler怎么用?Java NonThreadScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

NonThreadScheduler类属于com.ociweb.pronghorn.stage.scheduling包,在下文中一共展示了NonThreadScheduler类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureStageRate

点赞 2

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
protected void configureStageRate(Object listener, ReactiveListenerStage stage) {
    //if we have a time event turn it on.
    long rate = builder.getTriggerRate();
    if (rate>0 && listener instanceof TimeListener) {
        stage.setTimeEventSchedule(rate, builder.getTriggerStart());
        //Since we are using the time schedule we must set the stage to be faster
        long customRate =   (rate*nsPerMS)/NonThreadScheduler.granularityMultiplier;// in ns and guanularityXfaster than clock trigger
        long appliedRate = Math.min(customRate,builder.getDefaultSleepRateNS());
        GraphManager.addNota(gm, GraphManager.SCHEDULE_RATE, appliedRate, stage);
    }
}
 

开发者ID:oci-pronghorn,
项目名称:GreenLightning,
代码行数:12,
代码来源:MsgRuntime.java

示例2: run

点赞 2

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
private void run(GraphManager gm, PronghornStage watch) {
	NonThreadScheduler scheduler = new NonThreadScheduler(gm);
	scheduler.startup();
	long limit = System.currentTimeMillis() + TIMEOUT;
	while (!GraphManager.isStageShuttingDown(gm, watch.stageId)) {
		scheduler.run();
		scheduler.checkForException();//will throw for unexpected exceptions discovered in the graph.
		if (System.currentTimeMillis()>limit) {
			scheduler.shutdown();
			Assert.fail("Timeout");
		}			
	}
	scheduler.shutdown();
}
 

开发者ID:oci-pronghorn,
项目名称:Pronghorn,
代码行数:15,
代码来源:SocketIOStageTest.java

示例3: createScheduler

点赞 2

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
@Override
public StageScheduler createScheduler(MsgRuntime runtime) {

    if (isInUnitTest) {
                  
        //NOTE: need to consider different schedulers in the future.
       return new NonThreadScheduler(gm);
    } else {
       return super.createScheduler(runtime);
    }
          
}
 

开发者ID:oci-pronghorn,
项目名称:FogLight,
代码行数:13,
代码来源:TestHardware.java

示例4: testApp

点赞 2

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
@Ignore
  public void testApp()
  {
  	DeviceRuntime runtime = DeviceRuntime.test(new IoTApp());	    	
  	NonThreadScheduler scheduler = (NonThreadScheduler)runtime.getScheduler();    	
  
  	scheduler.startup();
  	    	
  	TestHardware hardware = (TestHardware)runtime.getHardware();
  	
  	
  	int iterations = 10;
while (--iterations >= 0) {
	    		
		scheduler.run();
		
		//test application here
		
}
  }
 

开发者ID:oci-pronghorn,
项目名称:FogLight-Examples,
代码行数:21,
代码来源:AppTest.java

示例5: ParserStageTest

点赞 2

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
@Test
public void ParserStageTest() {
	
	GraphManager gm = new GraphManager();
	
	Pipe<RawDataSchema> input = RawDataSchema.instance.newPipe(4, 512);
	Pipe<ValveSchema> filter = ValveSchema.instance.newPipe(64, 128);
	Pipe<ValveSchema> output = ValveSchema.instance.newPipe(64, 128);

	ByteArrayOutputStream results = new ByteArrayOutputStream();
	
	ValveDataParserStage.newInstance(gm, input, filter);
	FilterStage.newInstance(gm, filter, output);
	ConsoleJSONDumpStage.newInstance(gm, output, new PrintStream(results));
	
	//MonitorConsoleStage.attach(gm);
	
	NonThreadScheduler scheduler = new NonThreadScheduler(gm);
	
	scheduler.startup();
	
	//////////////////
	////setup the test data
	//////////////////
	Pipe.addMsgIdx(input, RawDataSchema.MSG_CHUNKEDSTREAM_1);

	String message =
			"587lf5pf\"L\"vf0sp55] [" +
			"st1" +
			"sn100100" +
			"pn\"NX-DCV-SM-BLU-1-1-VO-L1-SO-OO\"" +
			"lr-100" +
			"cc184587" +
			"lf0" +
			"pf\"L\"" +
			"vf0" +
			"sp80" +
			"vf0" +
			"sp42" +
			"]";

	Pipe.addUTF8(message, input);

	Pipe.confirmLowLevelWrite(input, Pipe.sizeOf(input, RawDataSchema.MSG_CHUNKEDSTREAM_1));
	Pipe.publishWrites(input);

	//////////////////		
	
	int i = 1000;
	while (--i>=0) {
		scheduler.run();
	}
	
	scheduler.shutdown();
			
	
	////////////////
	///confirm the results
	////////////////
	
	String stringResults = new String(results.toByteArray()); 
	
	//for debug to inspect the values
	System.err.println(stringResults);
	
	assertFalse(stringResults.contains("55"));
	assertTrue(stringResults.contains("{\"PartNumber\":\"NX-DCV-SM-BLU-1-1-VO-L1-SO-OO\"}"));
	assertTrue(stringResults.contains("{\"ResidualOfDynamicAnalysis\":4294967196}"));

	int firstSP =  stringResults.indexOf("{\"SupplyPressure\":80}");
	assertTrue(firstSP != -1);
	int secondSP =  stringResults.indexOf("{\"SupplyPressure\":42}", firstSP + 1);
	assertTrue(secondSP != -1);

	int firstVP =  stringResults.indexOf("{\"ValveFault\":0}");
	assertTrue(firstVP != -1);
	int secondVP =  stringResults.indexOf("{\"ValveFault\":0}", firstVP + 1);
	assertTrue(secondVP == -1);
	
}
 

开发者ID:oci-pronghorn,
项目名称:FogLight-Examples,
代码行数:81,
代码来源:UARTDataParserTest.java

示例6: runGraph

点赞 2

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
private String runGraph(Pipe<PersistedBlobStoreSchema> perStore, boolean encryption, boolean telemetry) {
	///////////////////////////////
	
	
	GraphManager gm = new GraphManager();
	
	if (telemetry) {
		gm.enableTelemetry(8089);
	}
	
	byte multi = 3;
	byte bits = 16;
	short inFlightCount = 20;
	int largestBlock = 1<<12;
	File dir=null;

	byte[] cypher = null;
	if (encryption) {
		cypher = new byte[16];
		new Random(123).nextBytes(cypher);
	}
	
	long rate = 2400;
	Pipe<PersistedBlobLoadSchema> perLoad = FileGraphBuilder.buildSequentialReplayer(gm, perStore, multi, bits, inFlightCount,
			largestBlock, dir, cypher,rate, null);
	
	StringBuilder result = new StringBuilder();
	ConsoleJSONDumpStage watch = ConsoleJSONDumpStage.newInstance(gm, perLoad, result);
	
	/////////////////////////////////////////
	/////////////////////////////////////////
	
	NonThreadScheduler scheduler = new NonThreadScheduler(gm);
	scheduler.startup();
	
	while (!GraphManager.isStageTerminated(gm, watch.stageId) ) {
		scheduler.run();
		Thread.yield();
	}
	
	while (telemetry) {
		scheduler.run();
	}
	
	scheduler.shutdown();
	
	
	///////////////////////
	return result.toString();
}
 

开发者ID:oci-pronghorn,
项目名称:Pronghorn,
代码行数:51,
代码来源:SequentialReplayerStageTest.java

示例7: fileBlobWriteTest

点赞 1

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
@Test
public void fileBlobWriteTest() {
    
    try {
    
        GraphManager gm = new GraphManager();
        
        PipeConfig<RawDataSchema> config = new PipeConfig<RawDataSchema>(RawDataSchema.instance, 10, 65536);
        Pipe<RawDataSchema> inputPipe = new Pipe<RawDataSchema>(config);
        
        File f2 = File.createTempFile("roundTipTestB", "dat");
        f2.deleteOnExit();
        
        boolean append = false;
        new ByteArrayProducerStage(gm, rawData, inputPipe);
        FileBlobWriteStage lastStage = new FileBlobWriteStage(gm, inputPipe, append, f2.getAbsolutePath()); //TODO: need a FileBlobRead that can tail a file
                    
        GraphManager.enableBatching(gm);
        
        
        NonThreadScheduler scheduler= new NonThreadScheduler(gm);
        scheduler.startup();
        
        while (!GraphManager.isStageTerminated(gm, lastStage.stageId)) {
        	scheduler.run();
        }
        scheduler.shutdown();
     
                    
        confirmFileContentsMatchTestData(f2);
        
    
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
 

开发者ID:oci-pronghorn,
项目名称:Pronghorn,
代码行数:38,
代码来源:FileBlobRoundTripTest.java

示例8: testReadWriteStage

点赞 1

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
@Test
  public void testReadWriteStage() {
  	
      File file = null;
  	 
try {
	file = File.createTempFile("testReadWriteStageTest", "dat");
} catch (IOException e) {
	e.printStackTrace();
}
  	
  	 
  	 
  	 String[] paths = new String[] {file.getAbsolutePath()};
  	 GraphManager gm = new GraphManager();

  	 
  	 Pipe<SequentialCtlSchema>[] control = new Pipe[]{SequentialCtlSchema.instance.newPipe(10, 1000)};
 Pipe<RawDataSchema>[] input = new Pipe[]{RawDataSchema.instance.newPipe(10, 1000)};
 
 Pipe<RawDataSchema>[] output = new Pipe[]{RawDataSchema.instance.newPipe(10, 1000)};
 Pipe<SequentialRespSchema>[] response = new Pipe[]{SequentialRespSchema.instance.newPipe(10, 1000)};

 
 control[0].initBuffers();
 input[0].initBuffers();
 
 //data to be written
 Pipe.addMsgIdx(input[0], 0);
 Pipe.addByteArray("hello".getBytes(), input[0]);
 Pipe.confirmLowLevelWrite(input[0]);
 Pipe.publishWrites(input[0]);
 
 SequentialCtlSchema.publishIdToSave(control[0], 123);
 
 //this replay command is expected to only happen after the data is written since pipe has data.
 SequentialCtlSchema.publishReplay(control[0]);
 SequentialCtlSchema.publishMetaRequest(control[0]);
 
 PipeWriter.publishEOF(control[0]);
 
 
 SequentialFileReadWriteStage readWriteStage = new SequentialFileReadWriteStage(gm, control, response, input, output, paths);
  	
 StringBuilder outputData = new StringBuilder();
 StringBuilder responseData = new StringBuilder();
 
 ConsoleJSONDumpStage watch = ConsoleJSONDumpStage.newInstance(gm, output[0],outputData);
 ConsoleJSONDumpStage.newInstance(gm, response[0], responseData);
 
       NonThreadScheduler scheduler= new NonThreadScheduler(gm);
       scheduler.startup();
       while (    (!GraphManager.isStageTerminated(gm, watch.stageId)) ) {
       	scheduler.run();
       }
       scheduler.shutdown();
  	
       String responseString = responseData.toString();
       assertTrue(responseString, responseString.indexOf("WriteAck")>=0);
       assertTrue(responseString, responseString.indexOf("{\"Size\":5}")>=0);
       
       String outputString = outputData.toString();
       assertTrue(outputString, outputString.indexOf("0x68,0x65,0x6c,0x6c,0x6f")>=0);
               
  }
 

开发者ID:oci-pronghorn,
项目名称:Pronghorn,
代码行数:66,
代码来源:FileBlobRoundTripTest.java

示例9: roundTripTest

点赞 1

import com.ociweb.pronghorn.stage.scheduling.NonThreadScheduler; //导入依赖的package包/类
@Test
public void roundTripTest() {
    
             
    try {            
        ///////////////////////// 
        //create test file with known random data
        /////////////////////////
        File f = fileFullOfTestData();
        
        File f2 = File.createTempFile("roundTipTest", "dat");
        f2.deleteOnExit();
                    
        GraphManager gm = new GraphManager();
        
        PipeConfig<RawDataSchema> config = new PipeConfig<RawDataSchema>(RawDataSchema.instance, 10, 65536);
        
        Pipe<RawDataSchema> inputPipe = new Pipe<RawDataSchema>(config);      
        Pipe<RawDataSchema> midCheckPipe = new Pipe<RawDataSchema>(config.grow2x());
        Pipe<RawDataSchema> outputPipe = new Pipe<RawDataSchema>(config.grow2x());
        
        new FileBlobReadStage(gm, inputPipe,f.getAbsolutePath());
        new ReplicatorStage(gm, inputPipe, midCheckPipe, outputPipe);
        
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream(testSize);
        ToOutputStreamStage lastStage1 = new ToOutputStreamStage(gm, midCheckPipe, outputStream, false);
        
       // ConsoleStage cs = new ConsoleStage(gm, midCheckPipe);
        
        boolean append = false;
        FileBlobWriteStage lastStage2 = new FileBlobWriteStage(gm, outputPipe, append, f2.getAbsolutePath());
                    
        //MonitorConsoleStage.attach(gm);

       // gm.enableTelemetry(8089);
        
        NonThreadScheduler scheduler= new NonThreadScheduler(gm);
        scheduler.startup();
        while (    (!GraphManager.isStageTerminated(gm, lastStage1.stageId))
        		|| (!GraphManager.isStageTerminated(gm, lastStage2.stageId))) {
        	scheduler.run();
        }
        scheduler.shutdown();
        
        
        //when done check the captured bytes from teh middle to ensure they match
        assertArrayEquals(rawData, outputStream.toByteArray());
       
        //when done read the file from disk one more time and confirm its the same            
        confirmFileContentsMatchTestData(f2);
        
        
    } catch (IOException e) {
        fail(e.getMessage());
    }
       
    
}
 

开发者ID:oci-pronghorn,
项目名称:Pronghorn,
代码行数:59,
代码来源:FileBlobRoundTripTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)