Removed masters Counters class and replaced it with normal Java Atomic i...

Counters is not a thread-safe class.  The edit log didn't get dependency counts since that was a different variable.

Deleted Counters and replaced all instances with AtomicLong or Integer.
This is a shared variable in a concurrent object. Need to lock or use cas
to make sure the mutation is safe. Cas (compare and swap) should always be
done in a loop like this (java 8 with lambda). Set is unsafe because the
value might have changed
On Nov 4, 2014 6:27 PM, "David Capwell" <dcapwell@gmail.com> wrote:

> It's called a cas loop. Required to be thread safe.
> On Nov 4, 2014 6:26 PM, "Haoyuan Li" <notifications@github.com> wrote:
>
>> In core/src/main/java/tachyon/master/MasterInfo.java:
>>
>> > @@ -1766,10 +1767,15 @@ private MasterWorkerInfo getWorkerInfo(long workerId) {
>> >    }
>> >
>> >    public void init() throws IOException {
>> > -    mCheckpointInfo.updateEditTransactionCounter(mJournal.loadEditLog(this));
>> > +    long current;
>> > +    long max;
>> > +    do {
>> > +      current = mEditTransactionId.get();
>> > +      max = Math.max(current, mJournal.loadEditLog(this));
>> > +    } while (!mEditTransactionId.compareAndSet(current, max));
>>
>> why add a while loop here?
>>
>> how about:
>>
>> long current = mEditTransactionId.get();
>> current = math.Max(current, mJournal.loadEditLog(this));
>> mEditTransactionId.set(current);
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/amplab/tachyon/pull/504/files#r19851781>.
>>
>