Package org.apache.hadoop.hdfs.server.protocol

Examples of org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol


    InetSocketAddress dnAddress = nn.getNameNodeDNAddress();
    InetSocketAddress clientAddress = nn.getNameNodeAddress();

    assertNotSame(clientAddress, dnAddress);

    DatanodeProtocol dnProtocol = (DatanodeProtocol) RPC.waitForProxy(
        DatanodeProtocol.class, DatanodeProtocol.versionID, dnAddress, conf);
    // perform a dummy call
    dnProtocol.getProtocolVersion(DatanodeProtocol.class.getName(),
        DatanodeProtocol.versionID);

    try {
      dnProtocol = (DatanodeProtocol) RPC.waitForProxy(DatanodeProtocol.class,
          DatanodeProtocol.versionID, clientAddress, conf);
      // perform a dummy call
      dnProtocol.getProtocolVersion(DatanodeProtocol.class.getName(),
          DatanodeProtocol.versionID);
    } catch (IOException ex) {
      System.out.println("ERROR: " + ex.getMessage());
      assertTrue(ex.getMessage().startsWith(ERROR_MSG_PREFIX));
    }
View Full Code Here


 
  private void handleDiskError(String errMsgr) throws IOException{
    boolean hasEnoughResource = data.hasEnoughResource();
    myMetrics.volumeFailures.inc();
    for(Integer namespaceId : namespaceManager.getAllNamespaces()){
      DatanodeProtocol nn = getNSNamenode(namespaceId);
      LOG.warn("DataNode.handleDiskError: Keep Running: " + hasEnoughResource);
     
      //if hasEnoughtResource = true - more volumes are available, so we don't want
      // to shutdown DN completely and don't want NN to remove it.
      int dp_error = DatanodeProtocol.DISK_ERROR;
      if(hasEnoughResource == false) {
        // DN will be shutdown and NN should remove it
        dp_error = DatanodeProtocol.FATAL_DISK_ERROR;
      }
      //inform NameNode
      try {
        nn.errorReport(getDNRegistrationForNS(namespaceId), dp_error, errMsgr);
      } catch(IOException ignored) {             
      }
     
     
      if(hasEnoughResource) {
View Full Code Here

    }
  }
 
  private void transferBlock(int namespaceId, Block block,
      DatanodeInfo xferTargets[]) throws IOException {
    DatanodeProtocol nn = getNSNamenode(namespaceId);
    DatanodeRegistration nsReg = getDNRegistrationForNS(namespaceId);

    if (!data.isValidBlock(namespaceId, block, true)) {
      // block does not exist or is under-construction
      String errStr = "Can't send invalid block " + block;
      LOG.info(errStr);
      nn.errorReport(nsReg, DatanodeProtocol.INVALID_BLOCK, errStr);
      return;
    }

    // Check if NN recorded length matches on-disk length
    long onDiskLength = data.getFinalizedBlockLength(namespaceId, block);
    if (block.getNumBytes() > onDiskLength) {
      // Shorter on-disk len indicates corruption so report NN the corrupt block
      nn.reportBadBlocks(new LocatedBlock[] { new LocatedBlock(block,
          new DatanodeInfo[] { new DatanodeInfo(nsReg) }) });
      LOG.info("Can't replicate block " + block + " because on-disk length "
          + onDiskLength + " is shorter than NameNode recorded length "
          + block.getNumBytes());
      return;
View Full Code Here

    }

    void setupNS(Configuration conf, AbstractList<File> dataDirs)
    throws IOException {
      // get NN proxy
      DatanodeProtocol dnp =
        (DatanodeProtocol)RPC.waitForProxy(DatanodeProtocol.class,
            DatanodeProtocol.versionID, nnAddr, conf);
      setNameNode(dnp);

      // handshake with NN
View Full Code Here

    // Shutdown and wait for datanode to be marked dead
    dn.shutdown();
    waitForDatanodeState(reg, false, 20000);

    DatanodeProtocol dnp = cluster.getNameNode();
    Block bia[] = new Block[]{new Block(0)};
    // Ensure blockReceived call from dead datanode is rejected with IOException
    try {
      dnp.blockReceivedAndDeleted(reg, bia);
      Assert.fail("Expected IOException is not thrown");
    } catch (IOException ex) {
      // Expected
    }

    // Ensure blockReport from dead datanode is rejected with IOException
    long[] blockReport = new long[] { 0L, 0L, 0L };
    try {
      dnp.blockReport(reg, blockReport);
      Assert.fail("Expected IOException is not thrown");
    } catch (IOException ex) {
      // Expected
    }

    // Ensure heartbeat from dead datanode is rejected with a command
    // that asks datanode to register again
    DatanodeCommand[] cmd = dnp.sendHeartbeat(reg, 0, 0, 0, 0, 0, 0);
    Assert.assertEquals(1, cmd.length);
    Assert.assertEquals(cmd[0].getAction(), DatanodeCommand.REGISTER
        .getAction());
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.