Beispiel #1
0
  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);
    }
  }
Beispiel #2
0
  public void testFindOne() throws Exception {
    LegContainer<SimpleEntry> container = craken.defineLeg(SimpleEntry.class);

    container.newInstance("bleujin").put("name", "bleujin").put("age", 20).save();
    container.newInstance(7756).put("name", "hero").put("age", 364).save();

    SimpleEntry found =
        container.findOneInMemory(
            new EntryFilter<SimpleEntry>() {
              public boolean filter(SimpleEntry node) {
                return node.fieldAsInt("age") > 100;
              }
            });

    assertEquals(364, found.fieldAsInt("age"));
  }
Beispiel #3
0
  public void testRET() throws Exception {
    LegContainer<SimpleEntry> container = craken.defineLeg(SimpleEntry.class);

    container.newInstance("bleujin").put("name", "bleujin").put("age", 20).save();
    container.newInstance(7756).put("name", "hero").put("age", 364).save();

    SimpleEntry bleujin = container.findByKey("bleujin");
    Debug.line(bleujin.field("age"), bleujin.fieldAsInt("age") + 1, bleujin.fieldAsString("name"));

    SimpleEntry f7756 = container.findByKey(7756);
    Debug.line(f7756.field("age"), f7756.fieldAsInt("age") + 1, f7756.fieldAsString("name"));
  }