当前位置: 首页>>代码示例>>Java>>正文


Java PastryIdFactory类代码示例

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


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

示例1: MyScribeClient

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
   * The constructor for this scribe client.  It will construct the ScribeApplication.
   * 
   * @param node the PastryNode
   */
  public MyScribeClient(Node node) {
    this.node = node;
    logger = node.getEnvironment().getLogManager().getLogger(MyScribeClient.class, null);
    
    // you should recognize this from lesson 3
    this.endpoint = node.buildEndpoint(this, "myinstance");

    // construct Scribe
    myScribe = new ScribeImpl(node,"myScribeInstance");

    // construct the topic
    myTopic = new Topic(new PastryIdFactory(node.getEnvironment()), "example topic");
//    System.out.println("myTopic = "+myTopic);
    
    // now we can receive messages
    endpoint.register();
  }
 
开发者ID:barnyard,项目名称:pi,代码行数:23,代码来源:MyScribeClient.java

示例2: TestHarness

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
 * Constructor which creates a TestHarness given a
 * PastryNode.
 *
 * @param pn The PastryNode this TestHarness is running on.
 */
public TestHarness(PastryNode pn) {
  factory = new PastryIdFactory(pn.getEnvironment());
  logger = pn.getEnvironment().getLogManager().getLogger(TestHarness.class,"monkey");
  endpoint = pn.buildEndpoint(this, "monkey");
  _pastryNode = pn;
  _tests = new Hashtable();
  _files = new Hashtable();
  _streams = new Hashtable();
  _testObjects = new Hashtable();
  _subscribedNodes = new Vector();

  scribe = new ScribeImpl(pn, "monkey");
  scribe.setPolicy(new LimitedScribePolicy(15, pn.getEnvironment()));
  try {
    hostname = InetAddress.getLocalHost().getHostAddress();
  } catch (java.net.UnknownHostException uhe) {
    if (logger.level <= Logger.WARNING) logger.logException("", uhe);
  }
  endpoint.register();
}
 
开发者ID:barnyard,项目名称:pi,代码行数:27,代码来源:TestHarness.java

示例3: MySplitStreamClient

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
 * The constructor for this scribe client.  It will construct the ScribeApplication.
 * 
 * @param node the PastryNode
 */
public MySplitStreamClient(Node node) {
  // you should recognize this from lesson 3
  this.endpoint = node.buildEndpoint(this, "myinstance");

  // use this to generate data
  this.random = endpoint.getEnvironment().getRandomSource();
  
  // construct Scribe
  mySplitStream = new SplitStreamImpl(node,"splitStreamTutorial");

  // The ChannelId is built from a normal PastryId
  Id temp = new PastryIdFactory(node.getEnvironment()).buildId("my channel");

  // construct the ChannelId
  myChannelId = new ChannelId(temp);
  
  // now we can receive messages
  endpoint.register();
}
 
开发者ID:barnyard,项目名称:pi,代码行数:25,代码来源:MySplitStreamClient.java

示例4: RoutingTableTest

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
   * This constructor launches numNodes PastryNodes.  They will bootstrap 
   * to an existing ring if one exists at the specified location, otherwise
   * it will start a new ring.
   * 
   * @param bindport the local port to bind to 
   * @param bootaddress the IP:port of the node to boot from
   * @param numNodes the number of nodes to create in this JVM
   * @param env the environment for these nodes
   */
  public RoutingTableTest(int numNodes, int meanSessionTime, boolean useScribe, int msgSendRate, int rtMaintTime, int tryNum, final Environment env) throws Exception {
    System.out.println("numNodes:"+numNodes+" meanSessionTime:"+meanSessionTime+" scribe:"+useScribe+" msgSendRate:"+msgSendRate+" rtMaint:"+rtMaintTime+" try:"+tryNum);
    this.env = env;
    this.numNodes = numNodes;
    this.meanSessionTime = meanSessionTime;
    this.useScribe = useScribe;
    this.msgSendRate = msgSendRate;
    this.rtMaintTime = rtMaintTime;
    this.tryNum = tryNum;
    
    idFactory = new PastryIdFactory(env);
    topic = new Topic(idFactory.buildId("test"));
    
    
    // Generate the NodeIds Randomly
    nidFactory = new RandomNodeIdFactory(env);
    
    env.getParameters().setInt("pastry_direct_gtitm_max_overlay_size",numNodes);
//    if (numNodes > 2000) {
    env.getParameters().setString("pastry_direct_gtitm_matrix_file","sample_10k");
//    env.getParameters().setString("pastry_direct_gtitm_matrix_file","sample_2k");
//    }  
    // construct the PastryNodeFactory, this is how we use rice.pastry.direct, with a Euclidean Network
//    factory = new DirectPastryNodeFactory(nidFactory, new GenericNetwork(env), env);
    factory = new DirectPastryNodeFactory(nidFactory, new EuclideanNetwork(env), env);
    
    // loop to construct the nodes/apps
    createNodes();    
  }
 
开发者ID:barnyard,项目名称:pi,代码行数:40,代码来源:RoutingTableTest.java

示例5: MyScribeClient

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
 * The constructor for this scribe client.  It will construct the ScribeApplication.
 * 
 * @param node the PastryNode
 */
public MyScribeClient(Node node) {
  // you should recognize this from lesson 3
  this.endpoint = node.buildEndpoint(this, "myinstance");

  // construct Scribe
  myScribe = new ScribeImpl(node,"myScribeInstance");

  // construct the topic
  myTopic = new Topic(new PastryIdFactory(node.getEnvironment()), "example topic");
  System.out.println("myTopic = "+myTopic);
  
  // now we can receive messages
  endpoint.register();
}
 
开发者ID:barnyard,项目名称:pi,代码行数:20,代码来源:MyScribeClient.java

示例6: MultiringRegrTest

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
 * Constructor, which takes no arguments and sets up the
 * factories in preparation for node creation.
 */
public MultiringRegrTest(Environment env) throws IOException {
  this.environment = env;
  
  if (PROTOCOL == PROTOCOL_DIRECT) {
    if (SIMULATOR == SIMULATOR_SPHERE) {
      simulator = new SphereNetwork(env);
    } else {
      simulator = new EuclideanNetwork(env);
    }
    factory = new DirectPastryNodeFactory(new RandomNodeIdFactory(environment), simulator, env);
  } else {
    factory = DistPastryNodeFactory.getFactory(new RandomNodeIdFactory(environment),
                                               PROTOCOL,
                                               PORT,
                                               env);
  }
  
  NUM_GATEWAY_NODES = NUM_GLOBAL_NODES / NUM_ORGANIZATIONS;
  NUM_ORGANIZATIONAL_NODES = NUM_GATEWAY_NODES + NUM_INTERNAL_NODES;
  
  idFactory = new PastryIdFactory(env);
  globalRingId = idFactory.buildId(new byte[20]);
  ringIds = new Id[NUM_ORGANIZATIONS];
  globalNodes = new MultiringNode[NUM_GLOBAL_NODES];
  organizationalNodes = new MultiringNode[NUM_ORGANIZATIONS][NUM_ORGANIZATIONAL_NODES];
  globalApps = new MultiringTestApp[NUM_GLOBAL_NODES];
  organizationalApps = new MultiringTestApp[NUM_ORGANIZATIONS][NUM_ORGANIZATIONAL_NODES];
}
 
开发者ID:barnyard,项目名称:pi,代码行数:33,代码来源:MultiringRegrTest.java

示例7: MyScribeClient

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
 * @param node the PastryNode
 */
public MyScribeClient(PastryNode node) {
  this.node = node;
  this.environment = node.getEnvironment();
  // you should recognize this from lesson 3
  this.endpoint = node.buildEndpoint(this, "myinstance");
  // construct Scribe
  myScribe = new ScribeImpl(node,"lesson6instance");
  // construct the topic
  myTopic = new Topic(new PastryIdFactory(node.getEnvironment()), "example topic");
  endpoint.register();
  System.out.println("myTopic = "+myTopic);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:16,代码来源:MyScribeClient.java

示例8: before

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
@Before
public void before() {
    byteMaterial = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    pastryIdFactory = new PastryIdFactory(new Environment());
    idFactory = new KoalaIdFactory();
    idFactory.setKoalaPiEntityFactory(new KoalaPiEntityFactory());
    scopedEntity = mock(PiLocation.class);
    when(scopedEntity.getUrl()).thenReturn("scopedEntity");
}
 
开发者ID:barnyard,项目名称:pi,代码行数:10,代码来源:KoalaIdFactoryTest.java

示例9: PastryPushSum

import rice.pastry.commonapi.PastryIdFactory; //导入依赖的package包/类
/**
 * Constructs and registers a new {@link PastryPushSum} application.
 * 
 * @param node
 *            the node at which this application will be registered.
 * @param stepSize
 *            the time between sending messages to the node to signal the
 *            start of the next step.
 * @param updateInterval
 *            the number of steps between updating node value. If set to 0
 *            the node values will never be updated.
 * @param valueReader
 *            the {@link ValueReader} instance from which the node obtains
 *            its true value.
 * @param min
 *            the domain-specific minimum possible value, used as a lower
 *            bound for the estimates.
 * @param max
 *            the domain-specific maximum possible value, used as an upper
 *            bound for the estimates.
 * @param trace
 *            if set to {@code true}, the node will print a notice about all
 *            sent and received messages to the standard output.
 */
public PastryPushSum(Node node, int stepSize, int updateInterval, ValueReader valueReader, double min, double max, boolean trace)
{
	this.node = node;
	this.stepSize = stepSize;
	this.updateInterval = updateInterval;
	this.valueReader = valueReader;
	this.min = min;
	this.max = max;
	this.trace = trace;

	// obtain true value from the value reader
	trueValue = valueReader.getCurrentValue();

	value = trueValue;
	valueBuffer = trueValue;
	weight = 1.;
	weightBuffer = 1.;

	// register application
	endpoint = node.buildEndpoint(this, INSTANCE);
	endpoint.register();

	// schedule timer messages
	timer = endpoint.scheduleMessage(new TimerMessage(), 0, stepSize);
	active = true;

	// subscribe to a Scribe topic for reset notifications
	scribe = new ScribeImpl(node, SCRIBE_INSTANCE);
	resetTopic = new Topic(new PastryIdFactory(node.getEnvironment()), SCRIBE_TOPIC);
	scribe.subscribe(resetTopic, this, null, null);
}
 
开发者ID:darioseidl,项目名称:pastry-push-sum,代码行数:56,代码来源:PastryPushSum.java


注:本文中的rice.pastry.commonapi.PastryIdFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。