Search in sources :

Example 11 with Token

use of com.cinchapi.concourse.server.concurrent.Token in project concourse by cinchapi.

the class AtomicOperation method contains.

@Override
public final boolean contains(long record) {
    checkState();
    Token token = Token.wrap(record);
    source.addVersionChangeListener(token, this);
    reads2Lock.add(token);
    wideReads.put(record, token);
    return super.contains(record);
}
Also used : RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Token(com.cinchapi.concourse.server.concurrent.Token)

Example 12 with Token

use of com.cinchapi.concourse.server.concurrent.Token in project concourse by cinchapi.

the class AtomicOperation method select.

@Override
public final Map<String, Set<TObject>> select(long record) throws AtomicStateException {
    checkState();
    Token token = Token.wrap(record);
    source.addVersionChangeListener(token, this);
    reads2Lock.add(token);
    wideReads.put(record, token);
    return super.select(record);
}
Also used : RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Token(com.cinchapi.concourse.server.concurrent.Token)

Example 13 with Token

use of com.cinchapi.concourse.server.concurrent.Token in project concourse by cinchapi.

the class AtomicOperation method select.

@Override
public final Set<TObject> select(String key, long record) throws AtomicStateException {
    checkState();
    Token token = Token.wrap(key, record);
    source.addVersionChangeListener(token, this);
    reads2Lock.add(token);
    return super.select(key, record);
}
Also used : RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Token(com.cinchapi.concourse.server.concurrent.Token)

Example 14 with Token

use of com.cinchapi.concourse.server.concurrent.Token in project concourse by cinchapi.

the class AtomicOperation method add.

@Override
protected final boolean add(Write write, Sync sync, Verify verify) throws AtomicStateException {
    checkState();
    String key = write.getKey().toString();
    long record = write.getRecord().longValue();
    Token token = Token.wrap(key, record);
    RangeToken rangeToken = RangeToken.forWriting(write.getKey(), write.getValue());
    Token wide = wideReads.get(record);
    if (wide != null) {
        wide.upgrade();
        writes2Lock.add(wide);
    } else {
        source.addVersionChangeListener(token, this);
        writes2Lock.add(token);
        // CON-669: Prevent a
        writes2Lock.add(Token.shareable(record));
    // conflicting wide read,
    // but don't listen for
    // wide version change
    }
    writes2Lock.add(rangeToken);
    return super.add(write, sync, verify);
}
Also used : RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Token(com.cinchapi.concourse.server.concurrent.Token)

Example 15 with Token

use of com.cinchapi.concourse.server.concurrent.Token in project concourse by cinchapi.

the class AtomicOperation method review.

@Override
public final Map<Long, List<String>> review(long record) throws AtomicStateException {
    checkState();
    Token token = Token.wrap(record);
    source.addVersionChangeListener(token, this);
    reads2Lock.add(token);
    wideReads.put(record, token);
    return super.review(record);
}
Also used : RangeToken(com.cinchapi.concourse.server.concurrent.RangeToken) Token(com.cinchapi.concourse.server.concurrent.Token)

Aggregations

Token (com.cinchapi.concourse.server.concurrent.Token)18 RangeToken (com.cinchapi.concourse.server.concurrent.RangeToken)17 PriorityReadWriteLock (com.cinchapi.concourse.server.concurrent.PriorityReadWriteLock)3 Lock (java.util.concurrent.locks.Lock)3 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)3 DoNotInvoke (com.cinchapi.concourse.annotate.DoNotInvoke)1 LockType (com.cinchapi.concourse.server.concurrent.LockType)1 Text (com.cinchapi.concourse.server.model.Text)1 Value (com.cinchapi.concourse.server.model.Value)1 TObject (com.cinchapi.concourse.thrift.TObject)1 Range (com.google.common.collect.Range)1 RangeSet (com.google.common.collect.RangeSet)1 TreeRangeSet (com.google.common.collect.TreeRangeSet)1