• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CacheDirective类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hdfs.protocol.CacheDirective的典型用法代码示例。如果您正苦于以下问题:Java CacheDirective类的具体用法?Java CacheDirective怎么用?Java CacheDirective使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CacheDirective类属于org.apache.hadoop.hdfs.protocol包,在下文中一共展示了CacheDirective类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createFromInfoAndDefaults

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
/**
 * Factory method that makes a new CacheDirectiveInfo by applying fields in a
 * CacheDirectiveInfo to an existing CacheDirective.
 * 
 * @param info with some or all fields set.
 * @param defaults directive providing default values for unset fields in
 *          info.
 * 
 * @return new CacheDirectiveInfo of the info applied to the defaults.
 */
private static CacheDirectiveInfo createFromInfoAndDefaults(
    CacheDirectiveInfo info, CacheDirective defaults) {
  // Initialize the builder with the default values
  CacheDirectiveInfo.Builder builder =
      new CacheDirectiveInfo.Builder(defaults.toInfo());
  // Replace default with new value if present
  if (info.getPath() != null) {
    builder.setPath(info.getPath());
  }
  if (info.getReplication() != null) {
    builder.setReplication(info.getReplication());
  }
  if (info.getPool() != null) {
    builder.setPool(info.getPool());
  }
  if (info.getExpiration() != null) {
    builder.setExpiration(info.getExpiration());
  }
  return builder.build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:CacheManager.java


示例2: removeInternal

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
private void removeInternal(CacheDirective directive)
    throws InvalidRequestException {
  assert namesystem.hasWriteLock();
  // Remove the corresponding entry in directivesByPath.
  String path = directive.getPath();
  List<CacheDirective> directives = directivesByPath.get(path);
  if (directives == null || !directives.remove(directive)) {
    throw new InvalidRequestException("Failed to locate entry " +
        directive.getId() + " by path " + directive.getPath());
  }
  if (directives.size() == 0) {
    directivesByPath.remove(path);
  }
  // Fix up the stats from removing the pool
  final CachePool pool = directive.getPool();
  directive.addBytesNeeded(-directive.getBytesNeeded());
  directive.addFilesNeeded(-directive.getFilesNeeded());

  directivesById.remove(directive.getId());
  pool.getDirectiveList().remove(directive);
  assert directive.getPool() == null;

  setNeedsRescan();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:CacheManager.java


示例3: loadDirectives

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
/**
 * Load cache directives from the fsimage
 */
private void loadDirectives(DataInput in) throws IOException {
  StartupProgress prog = NameNode.getStartupProgress();
  Step step = new Step(StepType.CACHE_ENTRIES);
  prog.beginStep(Phase.LOADING_FSIMAGE, step);
  int numDirectives = in.readInt();
  prog.setTotal(Phase.LOADING_FSIMAGE, step, numDirectives);
  Counter counter = prog.getCounter(Phase.LOADING_FSIMAGE, step);
  for (int i = 0; i < numDirectives; i++) {
    CacheDirectiveInfo info = FSImageSerialization.readCacheDirectiveInfo(in);
    // Get pool reference by looking it up in the map
    final String poolName = info.getPool();
    CacheDirective directive =
        new CacheDirective(info.getId(), info.getPath().toUri().getPath(),
            info.getReplication(), info.getExpiration().getAbsoluteMillis());
    addCacheDirective(poolName, directive);
    counter.increment();
  }
  prog.endStep(Phase.LOADING_FSIMAGE, step);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:CacheManager.java


示例4: getById

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
/**
 * Get a CacheDirective by ID, validating the ID and that the directive
 * exists.
 */
private CacheDirective getById(long id) throws InvalidRequestException {
  // Check for invalid IDs.
  if (id <= 0) {
    throw new InvalidRequestException("Invalid negative ID.");
  }
  // Find the directive.
  CacheDirective directive = directivesById.get(id);
  if (directive == null) {
    throw new InvalidRequestException("No directive with ID " + id
        + " found.");
  }
  return directive;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:CacheManager.java


示例5: addDirectiveFromEditLog

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
/**
 * Adds a directive, skipping most error checking. This should only be called
 * internally in special scenarios like edit log replay.
 */
CacheDirectiveInfo addDirectiveFromEditLog(CacheDirectiveInfo directive)
    throws InvalidRequestException {
  long id = directive.getId();
  CacheDirective entry = new CacheDirective(directive);
  CachePool pool = cachePools.get(directive.getPool());
  addInternal(entry, pool);
  if (nextDirectiveId <= id) {
    nextDirectiveId = id + 1;
  }
  return entry.toInfo();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:CacheManager.java


示例6: modifyDirectiveFromEditLog

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
/**
 * Modifies a directive, skipping most error checking. This is for careful
 * internal use only. modifyDirective can be non-deterministic since its error
 * checking depends on current system time, which poses a problem for edit log
 * replay.
 */
void modifyDirectiveFromEditLog(CacheDirectiveInfo info)
    throws InvalidRequestException {
  // Check for invalid IDs.
  Long id = info.getId();
  if (id == null) {
    throw new InvalidRequestException("Must supply an ID.");
  }
  CacheDirective prevEntry = getById(id);
  CacheDirectiveInfo newInfo = createFromInfoAndDefaults(info, prevEntry);
  removeInternal(prevEntry);
  addInternal(new CacheDirective(newInfo), getCachePool(newInfo.getPool()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:CacheManager.java


示例7: saveDirectives

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
private void saveDirectives(DataOutputStream out, String sdPath)
    throws IOException {
  StartupProgress prog = NameNode.getStartupProgress();
  Step step = new Step(StepType.CACHE_ENTRIES, sdPath);
  prog.beginStep(Phase.SAVING_CHECKPOINT, step);
  prog.setTotal(Phase.SAVING_CHECKPOINT, step, directivesById.size());
  Counter counter = prog.getCounter(Phase.SAVING_CHECKPOINT, step);
  out.writeInt(directivesById.size());
  for (CacheDirective directive : directivesById.values()) {
    FSImageSerialization.writeCacheDirectiveInfo(out, directive.toInfo());
    counter.increment();
  }
  prog.endStep(Phase.SAVING_CHECKPOINT, step);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:CacheManager.java


示例8: resetStatistics

import org.apache.hadoop.hdfs.protocol.CacheDirective; //导入依赖的package包/类
private void resetStatistics() {
  for (CachePool pool: cacheManager.getCachePools()) {
    pool.resetStatistics();
  }
  for (CacheDirective directive: cacheManager.getCacheDirectives()) {
    directive.resetStatistics();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:CacheReplicationMonitor.java



注:本文中的org.apache.hadoop.hdfs.protocol.CacheDirective类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultBucketSettings类代码示例发布时间:2022-05-23
下一篇:
Java EntityExperienceOrb类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap