@Override public TopicMetadataCache get() { return new TopicMetadataCache(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, scanBuilder); } };
@Override protected void startUp() throws Exception { LOG.info("Starting TopicMetadataCache Refresh Thread."); startRefreshThread(); }
private void initializePruneState(RegionCoprocessorEnvironment env) { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { pruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (Boolean.TRUE.equals(pruneEnable)) { String pruneTable = conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE); long pruneFlushInterval = TimeUnit.SECONDS.toMillis(conf.getLong( TxConstants.TransactionPruning.PRUNE_FLUSH_INTERVAL, TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL)); compactionState = new CompactionState(env, TableName.valueOf(pruneTable), pruneFlushInterval); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Automatic invalid list pruning is enabled for table %s. Compaction state " + "will be recorded in table %s", env.getRegionInfo().getTable().getNameWithNamespaceInclAsString(), pruneTable)); } } } }
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { int rowKeyOffset = cell.getRowOffset() + prefixLength; int sizeOfRowKey = cell.getRowLength() - prefixLength; long publishTimestamp = MessagingUtils.getPublishTimestamp(cell.getRowArray(), rowKeyOffset, sizeOfRowKey); int topicIdLength = MessagingUtils.getTopicLengthMessageEntry(sizeOfRowKey) - Bytes.SIZEOF_INT; int generationId = Bytes.toInt(cell.getRowArray(), rowKeyOffset + topicIdLength); if (prevTopicIdBytes == null || currentTTL == null || currentGen == null || (!Bytes.equals(prevTopicIdBytes, 0, prevTopicIdBytes.length, cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegion().getRegionNameAsString() + ", could not get properties of topicId " + MessagingUtils.toTopicId(prevTopicIdBytes)); return ReturnCode.INCLUDE; } currentTTL = Long.parseLong(properties.get(MessagingUtils.Constants.TTL_KEY)); currentGen = Integer.parseInt(properties.get(MessagingUtils.Constants.GENERATION_KEY)); } // Old Generation (or deleted current generation) cleanup if (MessagingUtils.isOlderGeneration(generationId, currentGen)) { return ReturnCode.SKIP; } // TTL expiration cleanup only if the generation of metadata and row key are the same if ((generationId == currentGen) && ((timestamp - publishTimestamp) > currentTTL)) { return ReturnCode.SKIP; } return ReturnCode.INCLUDE; }
String tableName = cConf.get(Constants.MessagingSystem.METADATA_TABLE_NAME); metadataTable = getMetadataTable(tableName); if (metadataTable == null) { LOG.warn(String.format("Could not find HTableInterface of metadataTable %s:%s. Cannot update metadata cache",
private void initializePruneState(RegionCoprocessorEnvironment env) { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { pruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (Boolean.TRUE.equals(pruneEnable)) { String pruneTable = conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE); long pruneFlushInterval = TimeUnit.SECONDS.toMillis(conf.getLong( TxConstants.TransactionPruning.PRUNE_FLUSH_INTERVAL, TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL)); compactionState = new CompactionState(env, TableName.valueOf(pruneTable), pruneFlushInterval); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Automatic invalid list pruning is enabled for table %s. Compaction state " + "will be recorded in table %s", env.getRegionInfo().getTable().getNameWithNamespaceInclAsString(), pruneTable)); } } } }
cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegionInfo().getRegionNameAsString() + ", could not get properties of topicId "
String tableName = cConf.get(Constants.MessagingSystem.METADATA_TABLE_NAME); metadataTable = getMetadataTable(tableName); if (metadataTable == null) { LOG.warn(String.format("Could not find HTableInterface of metadataTable %s:%s. Cannot update metadata cache",
private void initializePruneState(RegionCoprocessorEnvironment env) { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { pruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (Boolean.TRUE.equals(pruneEnable)) { String pruneTable = conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE); long pruneFlushInterval = TimeUnit.SECONDS.toMillis(conf.getLong( TxConstants.TransactionPruning.PRUNE_FLUSH_INTERVAL, TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL)); compactionState = new CompactionState(env, TableName.valueOf(pruneTable), pruneFlushInterval); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Automatic invalid list pruning is enabled for table %s. Compaction state " + "will be recorded in table %s", env.getRegionInfo().getTable().getNameWithNamespaceInclAsString(), pruneTable)); } } } }
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { int rowKeyOffset = cell.getRowOffset() + prefixLength; int sizeOfRowKey = cell.getRowLength() - prefixLength; long publishTimestamp = MessagingUtils.getPublishTimestamp(cell.getRowArray(), rowKeyOffset, sizeOfRowKey); int topicIdLength = MessagingUtils.getTopicLengthMessageEntry(sizeOfRowKey) - Bytes.SIZEOF_INT; int generationId = Bytes.toInt(cell.getRowArray(), rowKeyOffset + topicIdLength); if (prevTopicIdBytes == null || currentTTL == null || currentGen == null || (!Bytes.equals(prevTopicIdBytes, 0, prevTopicIdBytes.length, cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegionInfo().getRegionNameAsString() + ", could not get properties of topicId " + MessagingUtils.toTopicId(prevTopicIdBytes)); return ReturnCode.INCLUDE; } currentTTL = Long.parseLong(properties.get(MessagingUtils.Constants.TTL_KEY)); currentGen = Integer.parseInt(properties.get(MessagingUtils.Constants.GENERATION_KEY)); } // Old Generation (or deleted current generation) cleanup if (MessagingUtils.isOlderGeneration(generationId, currentGen)) { return ReturnCode.SKIP; } // TTL expiration cleanup only if the generation of metadata and row key are the same if ((generationId == currentGen) && ((timestamp - publishTimestamp) > currentTTL)) { return ReturnCode.SKIP; } return ReturnCode.INCLUDE; }
@Override public TopicMetadataCache get() { return new TopicMetadataCache(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, scanBuilder); } };
@Override protected void startUp() throws Exception { LOG.info("Starting TopicMetadataCache Refresh Thread."); startRefreshThread(); }
private void reloadPruneState(RegionCoprocessorEnvironment env) { if (pruneEnable == null) { // If prune enable has never been initialized, try to do so now initializePruneState(env); } else { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { boolean newPruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (newPruneEnable != pruneEnable) { // pruning enable has been changed, resetting prune state if (LOG.isDebugEnabled()) { LOG.debug(String.format("Transaction Invalid List pruning feature is set to %s now for region %s.", newPruneEnable, env.getRegionInfo().getRegionNameAsString())); } resetPruneState(); initializePruneState(env); } } } }
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { int rowKeyOffset = cell.getRowOffset() + prefixLength; int sizeOfRowKey = cell.getRowLength() - prefixLength; long publishTimestamp = MessagingUtils.getPublishTimestamp(cell.getRowArray(), rowKeyOffset, sizeOfRowKey); int topicIdLength = MessagingUtils.getTopicLengthMessageEntry(sizeOfRowKey) - Bytes.SIZEOF_INT; int generationId = Bytes.toInt(cell.getRowArray(), rowKeyOffset + topicIdLength); if (prevTopicIdBytes == null || currentTTL == null || currentGen == null || (!Bytes.equals(prevTopicIdBytes, 0, prevTopicIdBytes.length, cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegion().getRegionNameAsString() + ", could not get properties of topicId " + MessagingUtils.toTopicId(prevTopicIdBytes)); return ReturnCode.INCLUDE; } currentTTL = Long.parseLong(properties.get(MessagingUtils.Constants.TTL_KEY)); currentGen = Integer.parseInt(properties.get(MessagingUtils.Constants.GENERATION_KEY)); } // Old Generation (or deleted current generation) cleanup if (MessagingUtils.isOlderGeneration(generationId, currentGen)) { return ReturnCode.SKIP; } // TTL expiration cleanup only if the generation of metadata and row key are the same if ((generationId == currentGen) && ((timestamp - publishTimestamp) > currentTTL)) { return ReturnCode.SKIP; } return ReturnCode.INCLUDE; }
private void reloadPruneState(RegionCoprocessorEnvironment env) { if (pruneEnable == null) { // If prune enable has never been initialized, try to do so now initializePruneState(env); } else { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { boolean newPruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (newPruneEnable != pruneEnable) { // pruning enable has been changed, resetting prune state if (LOG.isDebugEnabled()) { LOG.debug(String.format("Transaction Invalid List pruning feature is set to %s now for region %s.", newPruneEnable, env.getRegionInfo().getRegionNameAsString())); } resetPruneState(); initializePruneState(env); } } } }
@Override public ReturnCode filterKeyValue(Cell cell) throws IOException { int rowKeyOffset = cell.getRowOffset() + prefixLength; int sizeOfRowKey = cell.getRowLength() - prefixLength; long publishTimestamp = MessagingUtils.getPublishTimestamp(cell.getRowArray(), rowKeyOffset, sizeOfRowKey); int topicIdLength = MessagingUtils.getTopicLengthMessageEntry(sizeOfRowKey) - Bytes.SIZEOF_INT; int generationId = Bytes.toInt(cell.getRowArray(), rowKeyOffset + topicIdLength); if (prevTopicIdBytes == null || currentTTL == null || currentGen == null || (!Bytes.equals(prevTopicIdBytes, 0, prevTopicIdBytes.length, cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegionInfo().getRegionNameAsString() + ", could not get properties of topicId " + MessagingUtils.toTopicId(prevTopicIdBytes)); return ReturnCode.INCLUDE; } currentTTL = Long.parseLong(properties.get(MessagingUtils.Constants.TTL_KEY)); currentGen = Integer.parseInt(properties.get(MessagingUtils.Constants.GENERATION_KEY)); } // Old Generation (or deleted current generation) cleanup if (MessagingUtils.isOlderGeneration(generationId, currentGen)) { return ReturnCode.SKIP; } // TTL expiration cleanup only if the generation of metadata and row key are the same if ((generationId == currentGen) && ((timestamp - publishTimestamp) > currentTTL)) { return ReturnCode.SKIP; } return ReturnCode.INCLUDE; }
private void initializePruneState(RegionCoprocessorEnvironment env) { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { pruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (Boolean.TRUE.equals(pruneEnable)) { String pruneTable = conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE); long pruneFlushInterval = TimeUnit.SECONDS.toMillis(conf.getLong( TxConstants.TransactionPruning.PRUNE_FLUSH_INTERVAL, TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL)); compactionState = new CompactionState(env, TableName.valueOf(pruneTable), pruneFlushInterval); if (LOG.isDebugEnabled()) { TableName tableName = env.getRegion().getRegionInfo().getTable(); LOG.debug(String.format("Automatic invalid list pruning is enabled for table %s:%s. Compaction state " + "will be recorded in table %s", tableName.getNamespaceAsString(), tableName.getNameAsString(), pruneTable)); } } } }
cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegionInfo().getRegionNameAsString() + ", could not get properties of topicId "
private void initializePruneState(RegionCoprocessorEnvironment env) { CConfiguration conf = topicMetadataCache.getCConfiguration(); if (conf != null) { pruneEnable = conf.getBoolean(TxConstants.TransactionPruning.PRUNE_ENABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_ENABLE); if (Boolean.TRUE.equals(pruneEnable)) { String pruneTable = conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE, TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE); long pruneFlushInterval = TimeUnit.SECONDS.toMillis(conf.getLong( TxConstants.TransactionPruning.PRUNE_FLUSH_INTERVAL, TxConstants.TransactionPruning.DEFAULT_PRUNE_FLUSH_INTERVAL)); compactionState = new CompactionState(env, TableName.valueOf(pruneTable), pruneFlushInterval); if (LOG.isDebugEnabled()) { TableName tableName = env.getRegion().getRegionInfo().getTable(); LOG.debug(String.format("Automatic invalid list pruning is enabled for table %s:%s. Compaction state " + "will be recorded in table %s", tableName.getNamespaceAsString(), tableName.getNameAsString(), pruneTable)); } } } }
cell.getRowArray(), rowKeyOffset, topicIdLength))) { prevTopicIdBytes = Arrays.copyOfRange(cell.getRowArray(), rowKeyOffset, rowKeyOffset + topicIdLength); Map<String, String> properties = metadataCache.getTopicMetadata(ByteBuffer.wrap(prevTopicIdBytes)); if (properties == null) { LOG.debug("Region " + env.getRegion().getRegionNameAsString() + ", could not get properties of topicId "