Package org.apache.hadoop.hdfs.server.namenode

Examples of org.apache.hadoop.hdfs.server.namenode.NameNode$StartupOptionAndService


  private void createFederatedNameNode(int nnIndex, Configuration conf,
      int numDataNodes, boolean manageNameDfsDirs, boolean format,
      StartupOption operation, String nameserviceId)
      throws IOException {
    conf.set(FSConstants.DFS_FEDERATION_NAMESERVICE_ID, nameserviceId);
    NameNode nn = createNameNode(nnIndex, conf, numDataNodes, manageNameDfsDirs,
        format, operation, nameserviceId);
    DFSUtil.setGenericConf(conf, nameserviceId,
        NameNode.NAMESERVICE_SPECIFIC_KEYS);
    conf.set(DFSUtil.getNameServiceIdKey(
        FSConstants.DFS_NAMENODE_HTTP_ADDRESS_KEY, nameserviceId), NameNode
        .getHostPortString(nn.getHttpAddress()));
    conf.set(DFSUtil.getNameServiceIdKey(
        NameNode.DATANODE_PROTOCOL_ADDRESS, nameserviceId), NameNode
        .getHostPortString(nn.getNameNodeDNAddress()));
    nameNodes[nnIndex] = new NameNodeInfo(nn, new Configuration(conf));
  }
View Full Code Here


   */
  public void shutdown(boolean remove) {
    System.out.println("Shutting down the Mini HDFS Cluster");
    shutdownDataNodes(remove);
    for (NameNodeInfo nnInfo : nameNodes) {
      NameNode nameNode = nnInfo.nameNode;
      if (nameNode != null) {
        nameNode.stop();
        nameNode.join();
        nameNode = null;
      }
    }
  }
View Full Code Here

  /**
   * Shutdown one namenode
   */
  public synchronized void shutdownNameNode(int nnIndex) {
    NameNode nn = nameNodes[nnIndex].nameNode;
    if (nn != null) {
      System.out.println("Shutting down the namenode");
      nn.stop();
      nn.join();
      Configuration conf = nameNodes[nnIndex].conf;
      nameNodes[nnIndex] = new NameNodeInfo(null, conf);
    }
  }
View Full Code Here

  }

  public synchronized void restartNameNode(int nnIndex, String[] argv, boolean waitActive) throws IOException {
    shutdownNameNode(nnIndex);
    Configuration conf = nameNodes[nnIndex].conf;
    NameNode nn = NameNode.createNameNode(argv, conf);
    nameNodes[nnIndex] = new NameNodeInfo(nn, conf);
    if (!waitActive) {
      return;
    }
    waitClusterUp();
View Full Code Here

  /**
   * Returns true if the NameNode is running and is out of Safe Mode
   * or if waiting for safe mode is disabled.
   */
  public boolean isNameNodeUp(int nnIndex) {
    NameNode nn = nameNodes[nnIndex].nameNode;
    if (nn == null) {
      return false;
    }
    try {
      long[] sizes = nn.getStats();
      boolean isUp = false;
      synchronized (this) {
        isUp = ((!nn.isInSafeMode() || !waitSafeMode) && sizes[0] != 0);
      }
      return isUp;
    } catch (IOException ie) {
      return false;
    }
View Full Code Here

   */
  public void waitActive(boolean waitHeartbeats, int nnIndex) throws IOException {
    if (nnIndex < 0 || nnIndex >= nameNodes.length || nameNodes[nnIndex] == null) {
      return;
    }
    NameNode nn = nameNodes[nnIndex].nameNode;
    if (nn == null) {
      return;
    }
    InetSocketAddress addr = nn.getNameNodeAddress();
    // Wait for the client server to start if we have two configured
    while (addr == null) {
      try {
        Thread.sleep(100);
      } catch (Exception e) {
      }
      addr = nn.getNameNodeAddress();
    }
    addr = nn.getNameNodeDNAddress();
    DFSClient client = new DFSClient(addr, nn.getConf());

    // make sure all datanodes are alive and sent heartbeat
    while (shouldWait(client.datanodeReport(DatanodeReportType.LIVE),
                      waitHeartbeats, addr)) {
      try {
View Full Code Here

  /**
   * Set the softLimit and hardLimit of client lease periods
   */
  void setLeasePeriod(long soft, long hard) {
    checkSingleNameNode();
    NameNode nn = getNameNode(0);
    nn.namesystem.leaseManager.setLeasePeriod(soft, hard);
    nn.namesystem.lmthread.interrupt();
  }
View Full Code Here

      MiniDFSCluster cluster = null;
      try {
        cluster = new MiniDFSCluster(conf, numDataNode, true, null);
        cluster.waitActive();
        FileSystem fs = cluster.getFileSystem();
        NameNode preSpyNN = cluster.getNameNode();
        NameNode spyNN = spy(preSpyNN);
       
        DFSClient client = new DFSClient(null, spyNN, conf, null);
 
        DFSTestUtil.createFile(fs, file, fileSize,
            (short)numDataNode, 12345L /*seed*/);
 
View Full Code Here

    // Not available in 0.20 hdfs.  Use reflection to make it happen.
   
    // private NameNode nameNode;
    Field field = this.dfsCluster.getClass().getDeclaredField("nameNode");
    field.setAccessible(true);
    NameNode nn = (NameNode)field.get(this.dfsCluster);
    nn.namesystem.leaseManager.setLeasePeriod(100, 50000);
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testIsInSafemode() throws Exception {
    // Check for the standby nn without client failover.
    NameNode nn2 = cluster.getNameNode(1);
    assertTrue("nn2 should be in standby state", nn2.isStandbyState());

    InetSocketAddress nameNodeAddress = nn2.getNameNodeAddress();
    Configuration conf = new Configuration();
    DistributedFileSystem dfs = new DistributedFileSystem();
    try {
      dfs.initialize(
          URI.create("hdfs://" + nameNodeAddress.getHostName() + ":"
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.namenode.NameNode$StartupOptionAndService

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.