/** Restart a dead avatar node as a standby avatar. */ public void restartStandby(int nnIndex) throws IOException { AvatarInfo dead = getDeadAvatar(nnIndex); if (getPrimaryAvatar(nnIndex) == null || dead == null) { throw new IOException("cannot start standby avatar: " + "primary or dead avatar not found"); } LOG.info("restarting " + dead.startupOption + " as standby"); NameNodeInfo nni = this.nameNodes[nnIndex]; String[] args; ArrayList<String> argList = new ArrayList<String>(); argList.add(dead.startupOption); argList.add(AvatarConstants.StartupOption.STANDBY.getName()); argList.add(AvatarConstants.StartupOption.REGULAR.getName()); if (federation) { argList.add(StartupOption.SERVICE.getName()); argList.add(nni.nameserviceId); } args = new String[argList.size()]; argList.toArray(args); dead.avatar = AvatarNode.createAvatarNode(args, getServerConf(dead.startupOption, nni)); dead.state = AvatarState.STANDBY; if (dead.avatar == null) { throw new IOException("cannot start avatar node"); } }
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); }