Esempio n. 1
0
  /**
   * Add a namenode to cluster and start it. Configuration of datanodes in the cluster is refreshed
   * to register with the new namenode.
   *
   * @return newly started namenode
   */
  public NameNodeInfo addNameNode(Configuration conf) throws IOException {
    if (!federation) {
      throw new IOException("cannot add namenode to non-federated cluster");
    }
    int nnIndex = nameNodes.length;
    int numNameNodes = nameNodes.length + 1;
    NameNodeInfo[] newlist = new NameNodeInfo[numNameNodes];
    System.arraycopy(nameNodes, 0, newlist, 0, nameNodes.length);
    nameNodes = newlist;
    nameNodes[nnIndex] = new NameNodeInfo(nnIndex);

    NameNodeInfo nni = nameNodes[nnIndex];
    nni.createAvatarDirs();
    String nameserviceId = NAMESERVICE_ID_PREFIX + nnIndex;
    String nameserviceIds = conf.get(FSConstants.DFS_FEDERATION_NAMESERVICES);
    nameserviceIds += "," + nameserviceId;
    nni.initGeneralConf(conf, nameserviceId);
    conf.set(FSConstants.DFS_FEDERATION_NAMESERVICES, nameserviceIds);

    nni.updateAvatarConf(conf);
    startAvatarNode(nni);

    // Refresh datanodes with the newly started namenode
    for (DataNodeProperties dn : dataNodes) {
      DataNode datanode = dn.datanode;
      datanode.refreshNamenodes(conf);
    }
    // Wait for new namenode to get registrations from all the datanodes
    waitDataNodesActive(nnIndex);
    return nni;
  }
Esempio n. 2
0
  private void startAvatarNode(NameNodeInfo nni) throws IOException {
    registerZooKeeperNode(nni.nn0Port, nni.nnDn0Port, nni.http0Port, nni.rpc0Port, nni);

    if (format) {
      LOG.info("formatting");
      // Start the NameNode
      String[] a0FormatArgs;
      ArrayList<String> argList = new ArrayList<String>();
      argList.add(AvatarConstants.StartupOption.NODEZERO.getName());
      argList.add(AvatarConstants.StartupOption.FORMATFORCE.getName());
      if (federation) {
        argList.add(StartupOption.SERVICE.getName());
        argList.add(nni.nameserviceId);
      }
      a0FormatArgs = new String[argList.size()];
      argList.toArray(a0FormatArgs);
      AvatarNode.createAvatarNode(
          a0FormatArgs, getServerConf(AvatarConstants.StartupOption.NODEZERO.getName(), nni));
    }
    ArrayList<AvatarInfo> avatars = new ArrayList<AvatarInfo>(2);
    {
      LOG.info("starting avatar 0");
      String[] a0Args;
      ArrayList<String> argList = new ArrayList<String>();
      argList.add(AvatarConstants.StartupOption.NODEZERO.getName());
      if (federation) {
        argList.add(StartupOption.SERVICE.getName());
        argList.add(nni.nameserviceId);
      }
      a0Args = new String[argList.size()];
      argList.toArray(a0Args);
      AvatarNode a0 =
          AvatarNode.createAvatarNode(
              a0Args, getServerConf(AvatarConstants.StartupOption.NODEZERO.getName(), nni));
      // leave safe mode manually
      a0.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_LEAVE);

      avatars.add(
          new AvatarInfo(
              a0,
              AvatarState.ACTIVE,
              nni.nn0Port,
              nni.nnDn0Port,
              nni.http0Port,
              nni.rpc0Port,
              AvatarConstants.StartupOption.NODEZERO.getName()));
    }

    {
      LOG.info("starting avatar 1");
      String[] a1Args;
      ArrayList<String> argList = new ArrayList<String>();
      argList.add(AvatarConstants.StartupOption.NODEONE.getName());
      argList.add(AvatarConstants.StartupOption.STANDBY.getName());
      argList.add(AvatarConstants.StartupOption.REGULAR.getName());
      if (federation) {
        argList.add(StartupOption.SERVICE.getName());
        argList.add(nni.nameserviceId);
      }
      a1Args = new String[argList.size()];
      argList.toArray(a1Args);
      avatars.add(
          new AvatarInfo(
              AvatarNode.createAvatarNode(
                  a1Args, getServerConf(AvatarConstants.StartupOption.NODEONE.getName(), nni)),
              AvatarState.STANDBY,
              nni.nn1Port,
              nni.nnDn1Port,
              nni.http1Port,
              nni.rpc1Port,
              AvatarConstants.StartupOption.NODEONE.getName()));
    }

    for (AvatarInfo avatar : avatars) {
      if (avatar.avatar == null) {
        throw new IOException("Cannot create avatar nodes");
      }
    }
    nni.setAvatarNodes(avatars);
    DFSUtil.setGenericConf(nni.conf, nni.nameserviceId, AvatarNode.AVATARSERVICE_SPECIFIC_KEYS);
    nni.updateAvatarConf(nni.conf);
  }
Esempio n. 3
0
 private void startAvatarNodes() throws IOException {
   for (NameNodeInfo nni : this.nameNodes) {
     nni.updateAvatarConf(this.conf);
     startAvatarNode(nni);
   }
 }