All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.astyanax.recipes.locks.StringRowLockColumnStrategy Maven / Gradle / Ivy

There is a newer version: 3.10.2
Show newest version
package com.netflix.astyanax.recipes.locks;

import com.netflix.astyanax.model.ByteBufferRange;
import com.netflix.astyanax.util.RangeBuilder;

public class StringRowLockColumnStrategy implements LockColumnStrategy {
    public static final String   DEFAULT_LOCK_PREFIX             = "_LOCK_";

    private String lockId     = null;
    private String prefix     = DEFAULT_LOCK_PREFIX;
    
    public StringRowLockColumnStrategy() {
        
    }
    
    public String getLockId() {
        return lockId;
    }

    public void setLockId(String lockId) {
        this.lockId = lockId;
    }

    public StringRowLockColumnStrategy withLockId(String lockId) {
        this.lockId = lockId;
        return this;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }
    
    public StringRowLockColumnStrategy withPrefix(String prefix) {
        this.prefix = prefix;
        return this;
    }
    
    @Override
    public boolean isLockColumn(String c) {
        return c.startsWith(prefix);
    }

    @Override
    public ByteBufferRange getLockColumnRange() {
        return new RangeBuilder().setStart(prefix + "\u0000").setEnd(prefix + "\uFFFF").build();
    }

    @Override
    public String generateLockColumn() {
        return prefix + lockId;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy