You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Counter init value is never used as CounterService.getOrCreateCounter() calls get() to find out if there's already exists any value for given counter and eventually use this value. However, get() always returns a value. In case counter doesn't exist, it returns 0 and thus init value is actually never used.
Example from CounterServiceDemo which initialize counter to 1
(Counter counter=counter_service.getOrCreateCounter("counter", 1);):
-- view: [A(raft-id=A)|0] (1) [A(raft-id=A)]
[1] Increment [2] Decrement [3] Compare and set [4] Dump log
[8] Snapshot [9] Increment N times [x] Exit
first-applied=0, last-applied=0, commit-index=0, log size=0b
-- view: [A(raft-id=A)|1] (2) [A(raft-id=A), C(raft-id=C)]
-- changed role to Candidate
-- changed role to Leader
-- view: [A(raft-id=A)|2] (3) [A(raft-id=A), C(raft-id=C), B(raft-id=B)]
4
index (term): command
---------------------
[1] Increment [2] Decrement [3] Compare and set [4] Dump log
[8] Snapshot [9] Increment N times [x] Exit
first-applied=0, last-applied=0, commit-index=0, log size=0b
3
expected value: 1
update: 5
failed setting counter "counter" from 1 to 5, current value is 0
The text was updated successfully, but these errors were encountered:
Counter init value is never used as
CounterService.getOrCreateCounter()
callsget()
to find out if there's already exists any value for given counter and eventually use this value. However,get()
always returns a value. In case counter doesn't exist, it returns 0 and thus init value is actually never used.Example from
CounterServiceDemo
which initialize counter to 1(
Counter counter=counter_service.getOrCreateCounter("counter", 1);
):The text was updated successfully, but these errors were encountered: