ConsistentKeyIDAuthority
来源:互联网 发布:mac unix 可执行文件 编辑:程序博客网 时间:2024/05/29 08:21
ConsistentKeyIDAuthority Architecture
IDAuthority Reference
AbstractIDAuthority
/** * Base Class for {@link IDAuthority} implementations. * Handles common aspects such as maintaining the {@link IDBlockSizer} * and shared configuration options * */public abstract class AbstractIDAuthority implements IDAuthority {
The fields in AbstractIDAuthority.
/* This value can't be changed without either * corrupting existing ID allocations or taking * some additional action to prevent such * corruption. */ protected static final long BASE_ID = 1; protected final Duration idApplicationWaitMS; protected final String uid; protected final byte[] uidBytes; protected final String metricsPrefix; private IDBlockSizer blockSizer; private volatile boolean isActive;
public AbstractIDAuthority(Configuration config) { this.uid = config.get(UNIQUE_INSTANCE_ID); this.uidBytes = uid.getBytes(); this.isActive = false; this.idApplicationWaitMS = config.get(GraphDatabaseConfiguration.IDAUTHORITY_WAIT); this.metricsPrefix = GraphDatabaseConfiguration.getSystemMetricsPrefix(); }
@Override public synchronized void setIDBlockSizer(IDBlockSizer sizer) { Preconditions.checkNotNull(sizer); if (isActive) throw new IllegalStateException("IDBlockSizer cannot be changed after IDAuthority is in use"); this.blockSizer = sizer; }
/** * Returns a byte buffer representation for the given partition id * @param partition * @return */ protected StaticBuffer getPartitionKey(int partition) { return BufferUtil.getIntBuffer(partition); }
/** * Returns the block size of the specified partition as determined by the configured {@link IDBlockSizer}. * @param idNamespace * @return */ protected long getBlockSize(final int idNamespace) { Preconditions.checkArgument(blockSizer != null, "Blocksizer has not yet been initialized"); isActive = true; long blockSize = blockSizer.getBlockSize(idNamespace); Preconditions.checkArgument(blockSize>0,"Invalid block size: %s",blockSize); Preconditions.checkArgument(blockSize<getIdUpperBound(idNamespace), "Block size [%s] cannot be larger than upper bound [%s] for partition [%s]",blockSize,getIdUpperBound(idNamespace),idNamespace); return blockSize; }
protected long getIdUpperBound(final int idNamespace) { Preconditions.checkArgument(blockSizer != null, "Blocksizer has not yet been initialized"); isActive = true; long upperBound = blockSizer.getIdUpperBound(idNamespace); Preconditions.checkArgument(upperBound>0,"Invalid upper bound: %s",upperBound); return upperBound; }
ConsistentKeyIDAuthority
/** * {@link com.baidu.hugegraph.diskstorage.IDAuthority} implementation * assuming that the backing store supports consistent key operations. * <p/> * ID blocks are allocated by first applying for an id block, waiting for a * specified period of time and then checking that the application was the first * received for that particular id block. If so, the application is considered * successful. If not, some other process won the application and a new * application is tried. * <p/> * The partition id is used as the key and since key operations are considered * consistent, this protocol guarantees unique id block assignments. * <p/> */public class ConsistentKeyIDAuthority extends AbstractIDAuthority implements BackendOperation.TransactionalProvider {
0 0
- ConsistentKeyIDAuthority
- 在IntelliJ IDEA中开发springmvc,使用tomcat遇到的问题
- Hive Beeline
- 资源网站
- C++文件输入输出
- 如何申请实用新型专利 申请需要哪些材料文件?
- ConsistentKeyIDAuthority
- linux下mysql的root密码忘记解决方法
- Hibernate 复习
- 一个想法照进现实-《IT连》创业项目:万事开头难
- C++实验2—分段函数求值
- 一图读懂JVM架构解析
- IAR平台上位变量的简单使用
- NetBeans 使用的一些小技巧
- Windows环境下jenkins +svn+android studio自动化构建(持续集成,打包)