当前位置: 首页>>代码示例>>Java>>正文


Java BalancerBandwidthCommand类代码示例

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


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

示例1: convert

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
public static DatanodeCommand convert(DatanodeCommandProto proto) {
  switch (proto.getCmdType()) {
  case BalancerBandwidthCommand:
    return PBHelper.convert(proto.getBalancerCmd());
  case BlockCommand:
    return PBHelper.convert(proto.getBlkCmd());
  case BlockRecoveryCommand:
    return PBHelper.convert(proto.getRecoveryCmd());
  case FinalizeCommand:
    return PBHelper.convert(proto.getFinalizeCmd());
  case KeyUpdateCommand:
    return PBHelper.convert(proto.getKeyUpdateCmd());
  case RegisterCommand:
    return REG_CMD;
  case BlockIdCommand:
    return PBHelper.convert(proto.getBlkIdCmd());
  default:
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:PBHelper.java

示例2: convert

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
public static DatanodeCommand convert(DatanodeCommandProto proto) {
  switch (proto.getCmdType()) {
  case BalancerBandwidthCommand:
    return PBHelper.convert(proto.getBalancerCmd());
  case BlockCommand:
    return PBHelper.convert(proto.getBlkCmd());
  case BlockRecoveryCommand:
    return PBHelper.convert(proto.getRecoveryCmd());
  case FinalizeCommand:
    return PBHelper.convert(proto.getFinalizeCmd());
  case KeyUpdateCommand:
    return PBHelper.convert(proto.getKeyUpdateCmd());
  case RegisterCommand:
    return REG_CMD;
  case BlockIdCommand:
    return PBHelper.convert(proto.getBlkIdCmd());
  case BlockECRecoveryCommand:
    return PBHelper.convert(proto.getBlkECRecoveryCmd());
  default:
    return null;
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:23,代码来源:PBHelper.java

示例3: convert

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
public static DatanodeCommand convert(DatanodeCommandProto proto) {
  switch (proto.getCmdType()) {
  case BalancerBandwidthCommand:
    return PBHelper.convert(proto.getBalancerCmd());
  case BlockCommand:
    return PBHelper.convert(proto.getBlkCmd());
  case BlockRecoveryCommand:
    return PBHelper.convert(proto.getRecoveryCmd());
  case FinalizeCommand:
    return PBHelper.convert(proto.getFinalizeCmd());
  case KeyUpdateCommand:
    return PBHelper.convert(proto.getKeyUpdateCmd());
  case RegisterCommand:
    return REG_CMD;
  }
  return null;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:18,代码来源:PBHelper.java

示例4: convert

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
public static DatanodeCommand convert(DatanodeCommandProto proto) {
  switch (proto.getCmdType()) {
    case BalancerBandwidthCommand:
      return PBHelper.convert(proto.getBalancerCmd());
    case BlockCommand:
      return PBHelper.convert(proto.getBlkCmd());
    case BlockRecoveryCommand:
      return PBHelper.convert(proto.getRecoveryCmd());
    case FinalizeCommand:
      return PBHelper.convert(proto.getFinalizeCmd());
    case KeyUpdateCommand:
      return PBHelper.convert(proto.getKeyUpdateCmd());
    case RegisterCommand:
      return REG_CMD;
  }
  return null;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:PBHelper.java

示例5: handleHeartbeat

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
/**
 * Handle heartbeat from datanodes.
 */
public DatanodeCommand[] handleHeartbeat(DatanodeRegistration nodeReg,
    final String blockPoolId, long capacity, long dfsUsed, long remaining,
    long blockPoolUsed, int xceiverCount, int maxTransfers, int failedVolumes)
    throws IOException {
  synchronized (heartbeatManager) {
    synchronized (datanodeMap) {
      DatanodeDescriptor nodeinfo = null;
      try {
        nodeinfo = getDatanode(nodeReg);
      } catch (UnregisteredNodeException e) {
        return new DatanodeCommand[]{RegisterCommand.REGISTER};
      }
      
      // Check if this datanode should actually be shutdown instead. 
      if (nodeinfo != null && nodeinfo.isDisallowed()) {
        setDatanodeDead(nodeinfo);
        throw new DisallowedDatanodeException(nodeinfo);
      }

      if (nodeinfo == null || !nodeinfo.isAlive) {
        return new DatanodeCommand[]{RegisterCommand.REGISTER};
      }

      heartbeatManager.updateHeartbeat(nodeinfo, capacity, dfsUsed, remaining,
          blockPoolUsed, xceiverCount, failedVolumes);
      
      //check lease recovery
      BlockInfoUnderConstruction[] blocks =
          nodeinfo.getLeaseRecoveryCommand(Integer.MAX_VALUE);
      if (blocks != null) {
        BlockRecoveryCommand brCommand =
            new BlockRecoveryCommand(blocks.length);
        for (BlockInfoUnderConstruction b : blocks) {
          brCommand.add(new RecoveringBlock(new ExtendedBlock(blockPoolId, b),
              getDataNodeDescriptorsTx(b), b.getBlockRecoveryId()));
        }
        return new DatanodeCommand[]{brCommand};
      }

      final List<DatanodeCommand> cmds = new ArrayList<>();
      //check pending replication
      List<BlockTargetPair> pendingList =
          nodeinfo.getReplicationCommand(maxTransfers);
      if (pendingList != null) {
        cmds.add(new BlockCommand(DatanodeProtocol.DNA_TRANSFER, blockPoolId,
            pendingList));
      }
      //check block invalidation
      Block[] blks = nodeinfo.getInvalidateBlocks(blockInvalidateLimit);
      if (blks != null) {
        cmds.add(
            new BlockCommand(DatanodeProtocol.DNA_INVALIDATE, blockPoolId,
                blks));
      }
      
      blockManager.addKeyUpdateCommand(cmds, nodeinfo);

      // check for balancer bandwidth update
      if (nodeinfo.getBalancerBandwidth() > 0) {
        cmds.add(
            new BalancerBandwidthCommand(nodeinfo.getBalancerBandwidth()));
        // set back to 0 to indicate that datanode has been sent the new value
        nodeinfo.setBalancerBandwidth(0);
      }

      if (!cmds.isEmpty()) {
        return cmds.toArray(new DatanodeCommand[cmds.size()]);
      }
    }
  }

  return new DatanodeCommand[0];
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:77,代码来源:DatanodeManager.java

示例6: handleHeartbeat

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
/**
 * The given node has reported in.  This method should:
 * 1) Record the heartbeat, so the datanode isn't timed out
 * 2) Adjust usage stats for future block allocation
 * 
 * If a substantial amount of time passed since the last datanode 
 * heartbeat then request an immediate block report.  
 * 
 * @return an array of datanode commands 
 * @throws IOException
 */
DatanodeCommand[] handleHeartbeat(DatanodeRegistration nodeReg,
    long capacity, long dfsUsed, long remaining,
    int xceiverCount, int xmitsInProgress) throws IOException {
  DatanodeCommand cmd = null;
  synchronized (heartbeats) {
    synchronized (datanodeMap) {
      DatanodeDescriptor nodeinfo = null;
      try {
        nodeinfo = getDatanode(nodeReg);
      } catch(UnregisteredDatanodeException e) {
        return new DatanodeCommand[]{DatanodeCommand.REGISTER};
      }
        
      // Check if this datanode should actually be shutdown instead. 
      if (nodeinfo != null && shouldNodeShutdown(nodeinfo)) {
        setDatanodeDead(nodeinfo);
        throw new DisallowedDatanodeException(nodeinfo);
      }

      if (nodeinfo == null || !nodeinfo.isAlive) {
        return new DatanodeCommand[]{DatanodeCommand.REGISTER};
      }

      updateStats(nodeinfo, false);
      nodeinfo.updateHeartbeat(capacity, dfsUsed, remaining, xceiverCount);
      updateStats(nodeinfo, true);
      
      //check lease recovery
      cmd = nodeinfo.getLeaseRecoveryCommand(Integer.MAX_VALUE);
      if (cmd != null) {
        return new DatanodeCommand[] {cmd};
      }
    
      ArrayList<DatanodeCommand> cmds = new ArrayList<DatanodeCommand>();
      //check pending replication
      cmd = nodeinfo.getReplicationCommand(
            maxReplicationStreams - xmitsInProgress);
      if (cmd != null) {
        cmds.add(cmd);
      }
      //check block invalidation
      cmd = nodeinfo.getInvalidateBlocks(blockInvalidateLimit);
      if (cmd != null) {
        cmds.add(cmd);
      }
      // check access key update
      if (isAccessTokenEnabled && nodeinfo.needKeyUpdate) {
        cmds.add(new KeyUpdateCommand(accessTokenHandler.exportKeys()));
        nodeinfo.needKeyUpdate = false;
      }
      // check for balancer bandwidth update
      if (nodeinfo.getBalancerBandwidth() > 0) {
        cmds.add(new BalancerBandwidthCommand(nodeinfo.getBalancerBandwidth()));
        // set back to 0 to indicate that datanode has been sent the new value
        nodeinfo.setBalancerBandwidth(0);
      }
      if (!cmds.isEmpty()) {
        return cmds.toArray(new DatanodeCommand[cmds.size()]);
      }
    }
  }

  //check distributed upgrade
  cmd = getDistributedUpgradeCommand();
  if (cmd != null) {
    return new DatanodeCommand[] {cmd};
  }
  return null;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:81,代码来源:FSNamesystem.java

示例7: processCommand

import org.apache.hadoop.hdfs.server.protocol.BalancerBandwidthCommand; //导入依赖的package包/类
/**
   * 
   * @param cmd
   * @return true if further processing may be required or false otherwise. 
   * @throws IOException
   */
private boolean processCommand(DatanodeCommand cmd) throws IOException {
  if (cmd == null)
    return true;
  final BlockCommand bcmd = cmd instanceof BlockCommand? (BlockCommand)cmd: null;

  switch(cmd.getAction()) {
  case DatanodeProtocol.DNA_TRANSFER:
    // Send a copy of a block to another datanode
    transferBlocks(bcmd.getBlocks(), bcmd.getTargets());
    myMetrics.incrBlocksReplicated(bcmd.getBlocks().length);
    break;
  case DatanodeProtocol.DNA_INVALIDATE:
    //
    // Some local block(s) are obsolete and can be 
    // safely garbage-collected.
    //
    Block toDelete[] = bcmd.getBlocks();
    try {
      if (blockScanner != null) {
        blockScanner.deleteBlocks(toDelete);
      }
      data.invalidate(toDelete);
    } catch(IOException e) {
      checkDiskError();
      throw e;
    }
    myMetrics.incrBlocksRemoved(toDelete.length);
    break;
  case DatanodeProtocol.DNA_SHUTDOWN:
    // shut down the data node
    this.shutdown();
    return false;
  case DatanodeProtocol.DNA_REGISTER:
    // namenode requested a registration - at start or if NN lost contact
    LOG.info("DatanodeCommand action: DNA_REGISTER");
    if (shouldRun) {
      register();
    }
    break;
  case DatanodeProtocol.DNA_FINALIZE:
    storage.finalizeUpgrade();
    break;
  case UpgradeCommand.UC_ACTION_START_UPGRADE:
    // start distributed upgrade here
    processDistributedUpgradeCommand((UpgradeCommand)cmd);
    break;
  case DatanodeProtocol.DNA_RECOVERBLOCK:
    recoverBlocks(bcmd.getBlocks(), bcmd.getTargets());
    break;
  case DatanodeProtocol.DNA_ACCESSKEYUPDATE:
    LOG.info("DatanodeCommand action: DNA_ACCESSKEYUPDATE");
    if (isBlockTokenEnabled) {
      blockTokenSecretManager.setKeys(((KeyUpdateCommand) cmd).getExportedKeys());
    }
    break;
  case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE:
    LOG.info("DatanodeCommand action: DNA_BALANCERBANDWIDTHUPDATE");
    int vsn = ((BalancerBandwidthCommand) cmd).getBalancerBandwidthVersion();
    if (vsn >= 1) {
      long bandwidth = 
                 ((BalancerBandwidthCommand) cmd).getBalancerBandwidthValue();
      if (bandwidth > 0) {
        DataXceiverServer dxcs =
                     (DataXceiverServer) this.dataXceiverServer.getRunnable();
        dxcs.balanceThrottler.setBandwidth(bandwidth);
      }
    }
    break;
  default:
    LOG.warn("Unknown DatanodeCommand action: " + cmd.getAction());
  }
  return true;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:80,代码来源:DataNode.java


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