org.apache.ignite.Ignite.atomicStamped()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.ignite.Ignite.atomicStamped()方法的一些代码示例,展示了Ignite.atomicStamped()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.atomicStamped()方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:atomicStamped

Ignite.atomicStamped介绍

[英]Will get a atomic stamped from cache and create one if it has not been created yet and create flag is true.
[中]将从缓存中获取原子标记,如果尚未创建,则创建一个原子标记,并且创建标志为true。

代码示例

代码示例来源:origin: apache/ignite

@Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, AtomicConfiguration cfg,
  @Nullable T initVal, @Nullable S initStamp, boolean create) throws IgniteException {
  checkIgnite();
  return g.atomicStamped(name, cfg, initVal, initStamp, create);
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Nullable @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name,
  @Nullable T initVal,
  @Nullable S initStamp,
  boolean create)
{
  checkIgnite();
  return g.atomicStamped(name, initVal, initStamp, create);
}

代码示例来源:origin: apache/ignite

@Override public void applyx(Ignite ignite) {
    IgniteAtomicStamped<Integer, Integer> as = ignite.atomicStamped(TEST_STAMP_NAME,
      0, 0, true);
    for (int i = 0; i < operationsPerTx; i++) {
      as.set(RAND.nextInt(MAX_INT), RAND.nextInt(MAX_INT));
      long cnt = writes.incrementAndGet();
      if (cnt % WRITE_LOG_MOD == 0)
        info("Performed " + cnt + " writes.");
    }
  }
};

代码示例来源:origin: apache/ignite

@Override public void applyx(Ignite ignite) {
    IgniteAtomicStamped<Integer, Integer> as = ignite.atomicStamped(TEST_STAMP_NAME,
      0, 0, true);
    for (int i = 0; i < operationsPerTx; i++) {
      as.get();
      long cnt = reads.incrementAndGet();
      if (cnt % READ_LOG_MOD == 0)
        info("Performed " + cnt + " reads.");
    }
  }
};

代码示例来源:origin: apache/ignite

@Override public String call() {
    IgniteAtomicStamped<String, String> stamped = ignite.atomicStamped(stampedName, val, stamp, true);
    assertEquals(val, stamped.value());
    assertEquals(stamp, stamped.stamp());
    return stamped.value();
  }
});

代码示例来源:origin: apache/ignite

@Override public String call() {
    IgniteAtomicStamped<String, String> stamped = ignite.atomicStamped(stampedName, val, stamp, true);
    assertEquals(val, stamped.value());
    assertEquals(stamp, stamped.stamp());
    return stamped.value();
  }
});

代码示例来源:origin: apache/ignite

@Override public String call() {
    IgniteAtomicStamped<String, String> stamped = ignite.atomicStamped(stampedName, val, stamp, true);
    assertEquals(newVal, stamped.value());
    assertEquals(newStamp, stamped.stamp());
    return stamped.value();
  }
});

代码示例来源:origin: apache/ignite

@Override public Object apply(Ignite ignite) {
    IgniteBiTuple<Integer, Integer> t = ignite.atomicStamped(STRUCTURE_NAME, 1, 1, false).get();
    assert t.get1() > 0;
    assert t.get2() > 0;
    return null;
  }
});

代码示例来源:origin: apache/ignite

IgniteAtomicStamped<String, Integer> atomic1 = ignite.atomicStamped("atomic1", "a", 1, true);
IgniteAtomicStamped<String, Integer> atomic2 = ignite.atomicStamped("atomic2", "b", 2, true);
IgniteAtomicStamped<String, Integer> atomic3 = ignite.atomicStamped("atomic3", cfg, "c", 3, true);
IgniteAtomicStamped<String, Integer> atomic4 = ignite.atomicStamped("atomic4", cfg, "d", 4, true);
assertNull(ignite.atomicStamped("atomic1", cfg, "a", 1, false));
assertNull(ignite.atomicStamped("atomic2", cfg, "a", 1, false));
assertNull(ignite.atomicStamped("atomic3", "a", 1, false));
assertNull(ignite.atomicStamped("atomic4", "a", 1, false));
assertTrue(atomic4.removed());
assertNull(ignite.atomicStamped("atomic2", "b", 2, false));
assertNull(ignite.atomicStamped("atomic4", cfg, "d", 4, false));
assertNotNull(ignite.atomicStamped("atomic1", "a", 1, false));
assertNotNull(ignite.atomicStamped("atomic3", cfg, "c", 3, false));

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testAtomicStampedTopologyChange() throws Exception {
  try (IgniteAtomicStamped atomic = grid(0).atomicStamped(STRUCTURE_NAME, 10, 10, true)) {
    Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME);
    IgniteBiTuple<Integer, Integer> t = g.atomicStamped(STRUCTURE_NAME, 10, 10, false).get();
    assertEquals((Integer)10, t.get1());
    assertEquals((Integer)10, t.get2());
    g.atomicStamped(STRUCTURE_NAME, 10, 10, false).set(20, 20);
    stopGrid(NEW_IGNITE_INSTANCE_NAME);
    t = grid(0).atomicStamped(STRUCTURE_NAME, 10, 10, false).get();
    assertEquals((Integer)20, t.get1());
    assertEquals((Integer)20, t.get2());
  }
}

代码示例来源:origin: apache/ignite

/**
 *
 */
private void testAtomicStamped() {
  info("Test atomic stamped");
  IgniteAtomicStamped<Person, PersonKey> stamped = ignite.atomicStamped("s1", null, null, true);
  stamped.set(person("p1"), key(1));
  checkStamped(stamped, "p1", 1);
  assertTrue(stamped.compareAndSet(person("p1"), person("p2"), key(1), key(2)));
  checkStamped(stamped, "p2", 2);
  assertFalse(stamped.compareAndSet(person("p1"), person("p3"), key(1), key(3)));
  checkStamped(stamped, "p2", 2);
  assertFalse(stamped.compareAndSet(person("p2"), person("p3"), key(1), key(3)));
  checkStamped(stamped, "p2", 2);
  assertTrue(stamped.compareAndSet(person("p2"), null, key(2), key(3)));
  checkStamped(stamped, null, 3);
  assertTrue(stamped.compareAndSet(null, person("p2"), key(3), key(4)));
  checkStamped(stamped, "p2", 4);
  stamped.close();
  stamped = ignite.atomicStamped("s2", person("p5"), key(5), true);
  checkStamped(stamped, "p5", 5);
}

代码示例来源:origin: apache/ignite

log.info("Create atomic stamped, grid: " + ignite.name());
res = ignite.atomicStamped(name, 0, true, true);

代码示例来源:origin: apache/ignite

final IgniteAtomicStamped clientAtomicStamped = client.atomicStamped("atomicStampedRemoved", 0, 0, true);
assertEquals(1, clientAtomicStamped.stamp());
final IgniteAtomicStamped srvAtomicStamped = srv.atomicStamped("atomicStampedRemoved", 0, 0, false);
IgniteAtomicStamped newClientAtomicStamped = client.atomicStamped("atomicStampedRemoved", 0, 0, true);
assertEquals(1, newClientAtomicStamped.stamp());
IgniteAtomicStamped newSrvAtomicStamped = srv.atomicStamped("atomicStampedRemoved", 0, 0, false);

代码示例来源:origin: apache/ignite

final IgniteAtomicStamped<Integer, Integer> atomicStamped = client.atomicStamped("atomicStamped", 1, 1, true);
final IgniteCountDownLatch latch = client.countDownLatch("latch", 1, true, true);
final IgniteAtomicSequence seq = client.atomicSequence("seq", 1L, true);

代码示例来源:origin: apache/ignite

IgniteAtomicStamped clientAtomicStamped = client.atomicStamped("atomicStamped", 0, 0, true);
assertEquals(1, clientAtomicStamped.stamp());
final IgniteAtomicStamped srvAtomicStamped = srv.atomicStamped("atomicStamped", 0, 0, false);

代码示例来源:origin: apache/ignite

IgniteBiTuple<Integer, Integer> t = g.atomicStamped(STRUCTURE_NAME, 1, 1, false).get();

代码示例来源:origin: apache/ignite

String initStamp = "asdf";
IgniteAtomicStamped<String, String> atomicStamped = ignite.atomicStamped(atomicName,
  initVal,
  initStamp,

代码示例来源:origin: apache/ignite

final IgniteAtomicStamped clientAtomicStamped = client.atomicStamped("atomicStampedInProgress", 0, 0, true);
assertEquals(1, clientAtomicStamped.stamp());
IgniteAtomicStamped srvAtomicStamped = srv.atomicStamped("atomicStampedInProgress", 0, 0, false);

代码示例来源:origin: org.apache.ignite/ignite-spring

/** {@inheritDoc} */
@Nullable @Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name,
  @Nullable T initVal,
  @Nullable S initStamp,
  boolean create)
{
  checkIgnite();
  return g.atomicStamped(name, initVal, initStamp, create);
}

代码示例来源:origin: org.apache.ignite/ignite-spring

@Override public <T, S> IgniteAtomicStamped<T, S> atomicStamped(String name, AtomicConfiguration cfg,
  @Nullable T initVal, @Nullable S initStamp, boolean create) throws IgniteException {
  checkIgnite();
  return g.atomicStamped(name, cfg, initVal, initStamp, create);
}

相关文章