Example #1
0
  private Configuration getServerConf(String startupOption, NameNodeInfo nni) {
    // namenode should use DFS, not DAFS

    if (startupOption.equals(AvatarConstants.StartupOption.NODEZERO.getName())) {
      return new Configuration(nni.a0Conf);
    } else if (startupOption.equals(AvatarConstants.StartupOption.NODEONE.getName())) {
      return new Configuration(nni.a1Conf);
    } else {
      throw new IllegalArgumentException("invalid avatar");
    }
  }
Example #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);
  }