I am getting the following error when running a code with IgniteAtomicLong
counter:
Exception in thread "main" class org.apache.ignite.IgniteException: Failed
to find atomic long with given name: myCounter
at
org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:881)
at
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl.incrementAndGet(GridCacheAtomicLongImpl.java:254)
at
com.sixbell.grid.CounterApplication.lambda$main$0(CounterApplication.java:29)
at
java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
at java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:557)
at com.sixbell.grid.CounterApplication.main(CounterApplication.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to find
atomic long with given name: myCounter
at
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$3.call(GridCacheAtomicLongImpl.java:98)
at
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$3.call(GridCacheAtomicLongImpl.java:92)
at
org.apache.ignite.internal.processors.cache.GridCacheUtils$25.call(GridCacheUtils.java:1782)
at
org.apache.ignite.internal.processors.cache.GridCacheUtils.outTx(GridCacheUtils.java:970)
at
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl.incrementAndGet(GridCacheAtomicLongImpl.java:251)
... 9 more
The CounterApplication:
public class CounterApplication {
public static void main(String[] args) throws InterruptedException {
try (final Ignite ignite = Ignition.start()) {
final IgniteAtomicLong counter = ignite.atomicLong("myCounter",
0, true);
System.out.println("Waiting 5 seconds...");
sleepMillis(5_000);
System.out.println("Starting to count...");
IntStream.range(0, 10_000).forEach(n -> {
sleepMillis(1);
counter.incrementAndGet();
});
}
}
private static void sleepMillis(final int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
In order to reproduce the problem, start two instances of
CounterApplication, and after the second instance join the grid, kill the
other.
Waiting 5 seconds...
[19:53:13] Topology snapshot [ver=2, servers=2, clients=0, CPUs=4,
heap=3.5GB]
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Failed-to-find-atomic-long-with-given-name-tp1800.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.