コード例 #1
0
ファイル: TestCreate.java プロジェクト: nextjava/craken
  public void testCreate() throws Exception {
    craken
        .globalConfig()
        .transport()
        .clusterName("my-cluster")
        .addProperty("configurationFile", "resource/config/jgroups-udp.xml");
    craken.start();
    LegContainer<SimpleEntry> container =
        craken.defineLeg(
            SimpleEntry.class,
            new ConfigurationBuilder()
                .clustering()
                .cacheMode(CacheMode.REPL_SYNC)
                .jmxStatistics()
                .enable()
                .clustering()
                .invocationBatching()
                .build());
    craken.addListener(new ContainerListener());

    // container.addListener(new EntryListener()) ;

    while (true) {
      SimpleEntry node =
          container
              .newInstance("bleujin" + RandomUtil.nextInt(10))
              .put("age", RandomUtil.nextInt(100))
              .put("server", craken.getManager().getAddress().toString());
      node.save();
      Thread.sleep(1000);
    }
  }