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


Java Daemon.interrupt方法代码示例

本文整理汇总了Java中org.apache.hadoop.util.Daemon.interrupt方法的典型用法代码示例。如果您正苦于以下问题:Java Daemon.interrupt方法的具体用法?Java Daemon.interrupt怎么用?Java Daemon.interrupt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.util.Daemon的用法示例。


在下文中一共展示了Daemon.interrupt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _processEvent

import org.apache.hadoop.util.Daemon; //导入方法依赖的package包/类
@Override
protected void _processEvent(InjectionEventI event, Object... args) {
  if (event == InjectionEvent.FSNAMESYSTEM_STOP_MONITOR) {
    Daemon monitor = (Daemon) args[0];
    if (monitor != null && monitor.isAlive()) {
      monitor.interrupt();
    }
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:10,代码来源:TestNameNodeMetrics.java

示例2: receiveBlock

import org.apache.hadoop.util.Daemon; //导入方法依赖的package包/类
void receiveBlock(
    DataOutputStream mirrOut, // output to next datanode
    DataInputStream mirrIn,   // input from next datanode
    DataOutputStream replyOut,  // output to previous datanode
    String mirrAddr, DataTransferThrottler throttlerArg,
    DatanodeInfo[] downstreams) throws IOException {

    syncOnClose = datanode.getDnConf().syncOnClose;
    boolean responderClosed = false;
    mirrorOut = mirrOut;
    mirrorAddr = mirrAddr;
    throttler = throttlerArg;

  try {
    if (isClient && !isTransfer) {
      responder = new Daemon(datanode.threadGroup, 
          new PacketResponder(replyOut, mirrIn, downstreams));
      responder.start(); // start thread to processes responses
    }

    /* 
     * Receive until the last packet.
     */
    while (receivePacket() >= 0) {}

    // wait for all outstanding packet responses. And then
    // indicate responder to gracefully shutdown.
    // Mark that responder has been closed for future processing
    if (responder != null) {
      ((PacketResponder)responder.getRunnable()).close();
      responderClosed = true;
    }

    // If this write is for a replication or transfer-RBW/Finalized,
    // then finalize block or convert temporary to RBW.
    // For client-writes, the block is finalized in the PacketResponder.
    if (isDatanode || isTransfer) {
      // close the block/crc files
      close();
      block.setNumBytes(replicaInfo.getNumBytes());

      if (stage == BlockConstructionStage.TRANSFER_RBW) {
        // for TRANSFER_RBW, convert temporary to RBW
        datanode.data.convertTemporaryToRbw(block);
      } else {
        // for isDatnode or TRANSFER_FINALIZED
        // Finalize the block.
        datanode.data.finalizeBlock(block);
      }
      datanode.metrics.incrBlocksWritten();
    }

  } catch (IOException ioe) {
    LOG.info("Exception for " + block, ioe);
    throw ioe;
  } finally {
    if (!responderClosed) { // Abnormal termination of the flow above
      IOUtils.closeStream(this);
      if (responder != null) {
        responder.interrupt();
      }
      cleanupBlock();
    }
    if (responder != null) {
      try {
        responder.join(datanode.getDnConf().getXceiverStopTimeout());
        if (responder.isAlive()) {
          String msg = "Join on responder thread " + responder
              + " timed out";
          LOG.warn(msg + "\n" + StringUtils.getStackTrace(responder));
          throw new IOException(msg);
        }
      } catch (InterruptedException e) {
        responder.interrupt();
        throw new IOException("Interrupted receiveBlock");
      }
      responder = null;
    }
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:81,代码来源:BlockReceiver.java

示例3: receiveBlock

import org.apache.hadoop.util.Daemon; //导入方法依赖的package包/类
void receiveBlock(DataOutputStream mirrOut, // output to next datanode
    DataInputStream mirrIn,   // input from next datanode
    DataOutputStream replyOut,  // output to previous datanode
    String mirrAddr, DataTransferThrottler throttlerArg,
    DatanodeInfo[] downstreams) throws IOException {

  syncOnClose = datanode.getDnConf().syncOnClose;
  boolean responderClosed = false;
  mirrorOut = mirrOut;
  mirrorAddr = mirrAddr;
  throttler = throttlerArg;

  try {
    if (isClient && !isTransfer) {
      responder = new Daemon(datanode.threadGroup,
          new PacketResponder(replyOut, mirrIn, downstreams));
      responder.start(); // start thread to processes responses
    }

    /* 
     * Receive until the last packet.
     */
    while (receivePacket() >= 0) {
    }

    // wait for all outstanding packet responses. And then
    // indicate responder to gracefully shutdown.
    // Mark that responder has been closed for future processing
    if (responder != null) {
      ((PacketResponder) responder.getRunnable()).close();
      responderClosed = true;
    }

    // If this write is for a replication or transfer-RBW/Finalized,
    // then finalize block or convert temporary to RBW.
    // For client-writes, the block is finalized in the PacketResponder.
    if (isDatanode || isTransfer) {
      // close the block/crc files
      close();
      block.setNumBytes(replicaInfo.getNumBytes());

      if (stage == BlockConstructionStage.TRANSFER_RBW) {
        // for TRANSFER_RBW, convert temporary to RBW
        datanode.data.convertTemporaryToRbw(block);
      } else {
        // for isDatnode or TRANSFER_FINALIZED
        // Finalize the block.
        datanode.data.finalizeBlock(block);
      }
      datanode.metrics.incrBlocksWritten();
    }

  } catch (IOException ioe) {
    LOG.info("Exception for " + block, ioe);
    throw ioe;
  } finally {
    if (!responderClosed) { // Abnormal termination of the flow above
      IOUtils.closeStream(this);
      if (responder != null) {
        responder.interrupt();
      }
      cleanupBlock();
    }
    if (responder != null) {
      try {
        responder.join();
      } catch (InterruptedException e) {
        responder.interrupt();
        throw new IOException("Interrupted receiveBlock");
      }
      responder = null;
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:75,代码来源:BlockReceiver.java

示例4: receiveBlock

import org.apache.hadoop.util.Daemon; //导入方法依赖的package包/类
void receiveBlock(
    DataOutputStream mirrOut, // output to next datanode
    DataInputStream mirrIn,   // input from next datanode
    DataOutputStream replyOut,  // output to previous datanode
    String mirrAddr, DataTransferThrottler throttlerArg,
    int numTargets) throws IOException {

    boolean responderClosed = false;
    mirrorOut = mirrOut;
    mirrorAddr = mirrAddr;
    throttler = throttlerArg;

  try {
    if (clientName.length() > 0) {
      responder = new Daemon(datanode.threadGroup, 
                             new PacketResponder(this, block, mirrIn, 
                                                 replyOut, numTargets,
                                                 Thread.currentThread()));
      responder.start(); // start thread to processes reponses
    }

    /* 
     * Receive until the last packet.
     */
    while (receivePacket() >= 0) {}

    // wait for all outstanding packet responses. And then
    // indicate responder to gracefully shutdown.
    // Mark that responder has been closed for future processing
    if (responder != null) {
      ((PacketResponder)responder.getRunnable()).close();
      responderClosed = true;
    }

    // if this write is for a replication request (and not
    // from a client), then finalize block. For client-writes, 
    // the block is finalized in the PacketResponder.
    if (clientName.length() == 0) {
      // close the block/crc files
      close();

      // Finalize the block. Does this fsync()?
      block.setNumBytes(replicaInfo.getNumBytes());
      datanode.data.finalizeBlock(block);
      datanode.myMetrics.blocksWritten.inc();
    }

  } catch (IOException ioe) {
    LOG.info("Exception in receiveBlock for block " + block + 
             " " + ioe);
    throw ioe;
  } finally {
    if (!responderClosed) { // Abnormal termination of the flow above
      IOUtils.closeStream(this);
      if (responder != null) {
        responder.interrupt();
      }
      cleanupBlock();
    }
    if (responder != null) {
      try {
        responder.join();
      } catch (InterruptedException e) {
        throw new IOException("Interrupted receiveBlock");
      }
      responder = null;
    }
  }
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:70,代码来源:BlockReceiver.java


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