[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question about capsule's lifetime



Hi,tim

	You have told me,the evaluate() method can execute arbitrary java code so it will wait as long as I want.But I encountered troubles.I want to poll a log file until the data I want. So I wrote the following lines in evaluate(),

  {
    synchronized( this )
    {
    while( !file.isReady() )
      {
		this.wait(1000); // Wait one second before testing again...
      }
    next=read(file)//get the next hop addr
	node.routeForNode(cap,next);
	
    }
  }
	But it cannot always work properly.If the file is ready within the first 11 loops,everything is ok.But if it cannot,the capsule wouldnot be sent out.And no error was prompt. 	


    Later,you told me to use Node.EventHandler.So I write a class LogReader extending Node.EventHandler whose main work is polling and then reading the file.When arrives a node,the capsule inserts an instance of LogReader to the node cache.If LogReader find the information ,it calls the Node.routeForNode() method to forward the capusle according.

	class MyCapsule 
		extends Capsule {
	...
   
		class LogReader 
			extends Node.EventHandler {
			MyCapsule cap;
	
			public int collected() {
				if (File.isReady()){
 					next=read(logfile);
					Node.routeForNode(cap,next);
					return 0;
				}
				else
			    	return 1;
						
				 
			}
		 }
 	

	}
  
	But I encountered the same problem.

	So I want to know why this happened. The limitation on capsule's CPU consumption? If it is,where can I find the code? How can I solve that problem?

	thanks.


woodhead.
dcsdcs1@mail.jlu.edu.cn
2002-06-25

face-6.gif




[ Janos ] [ OSKit ] [ Network Testbed ] [ Flick ] [ Fluke ]
Flux Research Group / Department of Computer Science / University of Utah