Tabnine Logo
TopicMetadataCache
Code IndexAdd Tabnine to your IDE (free)

How to use
TopicMetadataCache
in
co.cask.cdap.messaging

Best Java code snippets using co.cask.cdap.messaging.TopicMetadataCache (Showing top 20 results out of 315)

origin: co.cask.cdap/cdap-hbase-compat-base

 @Override
 public TopicMetadataCache get() {
  return new TopicMetadataCache(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, scanBuilder);
 }
};
origin: co.cask.cdap/cdap-hbase-compat-base

@Override
protected void startUp() throws Exception {
 LOG.info("Starting TopicMetadataCache Refresh Thread.");
 startRefreshThread();
}
origin: caskdata/cdap

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));
   }
  }
 }
}
origin: caskdata/cdap

@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;
}
origin: cdapio/cdap

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",
origin: cdapio/cdap

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));
   }
  }
 }
}
origin: caskdata/cdap

        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 "
origin: co.cask.cdap/cdap-hbase-compat-base

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",
origin: cdapio/cdap

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));
   }
  }
 }
}
origin: cdapio/cdap

@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;
}
origin: cdapio/cdap

 @Override
 public TopicMetadataCache get() {
  return new TopicMetadataCache(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, scanBuilder);
 }
};
origin: cdapio/cdap

@Override
protected void startUp() throws Exception {
 LOG.info("Starting TopicMetadataCache Refresh Thread.");
 startRefreshThread();
}
origin: cdapio/cdap

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);
   }
  }
 }
}
origin: caskdata/cdap

@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;
}
origin: caskdata/cdap

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);
   }
  }
 }
}
origin: cdapio/cdap

@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;
}
origin: caskdata/cdap

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));
   }
  }
 }
}
origin: cdapio/cdap

        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 "
origin: cdapio/cdap

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));
   }
  }
 }
}
origin: caskdata/cdap

        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 "
co.cask.cdap.messagingTopicMetadataCache

Javadoc

Used in coprocessors to get the metadata of a Topic. It also provides the metadata of topics by periodically scanning the Metadata table.

Most used methods

  • getCConfiguration
  • getTopicMetadata
  • <init>
  • getMetadataTable
  • startRefreshThread
  • updateCache
    Called in unit tests and since the refresh thread might invoke cache update at the same time, we mak

Popular in Java

  • Reactive rest calls using spring rest template
  • setContentView (Activity)
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JComboBox (javax.swing)
  • JPanel (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now