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

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


    ArrayList<File> dirs = new ArrayList<File>();
    File dataDir = new File(DATA_DIR);
    FileUtil.fullyDelete(dataDir);
    dataDir.mkdirs();
    dirs.add(dataDir);
    DatanodeProtocol namenode = mock(DatanodeProtocol.class);
    when(namenode.versionRequest()).thenReturn(new NamespaceInfo
        (1, CLUSTER_ID, POOL_ID, 1L, 1));
    when(namenode.sendHeartbeat(any(DatanodeRegistration.class), anyLong(),
        anyLong(), anyLong(), anyLong(), anyInt(), anyInt(), anyInt()))
        .thenReturn(new DatanodeCommand[0]);
    dn = new DataNode(conf, dirs, null);
   
    DataNodeTestUtils.setBPNamenodeByIndex(dn, nsifno, POOL_ID, namenode);
View Full Code Here


    doReturn(new ReplicaRecoveryInfo(block.getBlockId(), 0,
        block.getGenerationStamp(), ReplicaState.FINALIZED)).when(spyDN).
        initReplicaRecovery(any(RecoveringBlock.class));
    Daemon d = spyDN.recoverBlocks(initRecoveringBlocks());
    d.join();
    DatanodeProtocol dnP = dn.getBPNamenode(POOL_ID);
    verify(dnP).commitBlockSynchronization(
        block, RECOVERY_ID, 0, true, true, DatanodeID.EMPTY_ARRAY);
  }
View Full Code Here

      dn.syncBlock(rBlock, initBlockRecords(dn));
      fail("Sync should fail");
    } catch (IOException e) {
      e.getMessage().startsWith("Cannot recover ");
    }
    DatanodeProtocol namenode = dn.getBPNamenode(POOL_ID);
    verify(namenode, never()).commitBlockSynchronization(
        any(ExtendedBlock.class), anyLong(), anyLong(), anyBoolean(),
        anyBoolean(), any(DatanodeID[].class));
  }
View Full Code Here

        dn.syncBlock(rBlock, initBlockRecords(dn));
        fail("Sync should fail");
      } catch (IOException e) {
        e.getMessage().startsWith("Cannot recover ");
      }
      DatanodeProtocol namenode = dn.getBPNamenode(POOL_ID);
      verify(namenode, never()).commitBlockSynchronization(
          any(ExtendedBlock.class), anyLong(), anyLong(), anyBoolean(),
          anyBoolean(), any(DatanodeID[].class));
    } finally {
      streams.close();
View Full Code Here

    myMockBPOS.bpRegistration = mock(DatanodeRegistration.class);
    when(myMockBPOS.bpRegistration.getStorageID()).thenReturn("myTestStorageID");
   
    NamespaceInfo fakeNSInfo = mock(NamespaceInfo.class);
    when(fakeNSInfo.getBuildVersion()).thenReturn("NSBuildVersion");
    DatanodeProtocol fakeDNProt = mock(DatanodeProtocol.class);
    when(fakeDNProt.versionRequest()).thenReturn(fakeNSInfo);
    doCallRealMethod().when(myMockBPOS).setNameNode(fakeDNProt);
    myMockBPOS.setNameNode( fakeDNProt );
    try {  
      myMockBPOS.register();
      fail("register() did not throw exception! " +
View Full Code Here

    return version;
  }

  public void doUpgrade() throws IOException {
    this.status = (short)100;
    DatanodeProtocol nn = getNamenode();
    nn.processUpgradeCommand(
        new UpgradeCommand(UpgradeCommand.UC_ACTION_REPORT_STATUS,
            getVersion(), getUpgradeStatus()));
  }
View Full Code Here

        // reply with the broadcast command
        assert currentUpgrades == null :
          "UpgradeManagerDatanode.currentUpgrades is not null.";
        assert upgradeDaemon == null :
          "UpgradeManagerDatanode.upgradeDaemon is not null.";
        DatanodeProtocol nn = dataNode.getActiveNamenodeForBP(bpid);
        nn.processUpgradeCommand(broadcastCommand);
        return true;
      }
    }
    if(currentUpgrades == null)
      currentUpgrades = getDistributedUpgrades();
View Full Code Here

    ArrayList<File> dirs = new ArrayList<File>();
    File dataDir = new File(DATA_DIR);
    FileUtil.fullyDelete(dataDir);
    dataDir.mkdirs();
    dirs.add(dataDir);
    DatanodeProtocol namenode = mock(DatanodeProtocol.class);
    when(namenode.versionRequest()).thenReturn(new NamespaceInfo(1, 1L, 1));
    when(namenode.sendHeartbeat(any(DatanodeRegistration.class), anyLong(),
        anyLong(), anyLong(), anyInt(), anyInt(), anyInt())).thenReturn(
            new DatanodeCommand[0]);
    dn = new DataNode(conf, dirs, namenode, null);
  }
View Full Code Here

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

    DatanodeProtocol dnp = cluster.getNameNode();
    Block block = new Block(0);
    Block[] blocks = new Block[] { block };
    String[] delHints = new String[] { "" };
   
    // Ensure blockReceived call from dead datanode is rejected with IOException
    try {
      dnp.blockReceived(reg, blocks, delHints);
      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

    }

    void setupBP(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

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.