/// <exception cref="System.IO.IOException"/> private void ParseConfAndFindOtherNN() { Configuration conf = GetConf(); nsId = DFSUtil.GetNamenodeNameServiceId(conf); if (!HAUtil.IsHAEnabled(conf, nsId)) { throw new HadoopIllegalArgumentException("HA is not enabled for this namenode."); } nnId = HAUtil.GetNameNodeId(conf, nsId); NameNode.InitializeGenericKeys(conf, nsId, nnId); if (!HAUtil.UsesSharedEditsDir(conf)) { throw new HadoopIllegalArgumentException("Shared edits storage is not enabled for this namenode." ); } Configuration otherNode = HAUtil.GetConfForOtherNode(conf); otherNNId = HAUtil.GetNameNodeId(otherNode, nsId); otherIpcAddr = NameNode.GetServiceAddress(otherNode, true); Preconditions.CheckArgument(otherIpcAddr.Port != 0 && !otherIpcAddr.Address.IsAnyLocalAddress (), "Could not determine valid IPC address for other NameNode (%s)" + ", got: %s" , otherNNId, otherIpcAddr); string scheme = DFSUtil.GetHttpClientScheme(conf); otherHttpAddr = DFSUtil.GetInfoServerWithDefaultHost(otherIpcAddr.GetHostName(), otherNode, scheme).ToURL(); dirsToFormat = FSNamesystem.GetNamespaceDirs(conf); editUrisToFormat = FSNamesystem.GetNamespaceEditsDirs(conf, false); sharedEditsUris = FSNamesystem.GetSharedEditsDirs(conf); }
internal static bool IsValidRequestor(ServletContext context, string remoteUser, Configuration conf) { if (remoteUser == null) { // This really shouldn't happen... Log.Warn("Received null remoteUser while authorizing access to getImage servlet"); return(false); } ICollection <string> validRequestors = new HashSet <string>(); validRequestors.AddItem(SecurityUtil.GetServerPrincipal(conf.Get(DFSConfigKeys.DfsNamenodeKerberosPrincipalKey ), NameNode.GetAddress(conf).GetHostName())); try { validRequestors.AddItem(SecurityUtil.GetServerPrincipal(conf.Get(DFSConfigKeys.DfsSecondaryNamenodeKerberosPrincipalKey ), SecondaryNameNode.GetHttpAddress(conf).GetHostName())); } catch (Exception e) { // Don't halt if SecondaryNameNode principal could not be added. Log.Debug("SecondaryNameNode principal could not be added", e); string msg = string.Format("SecondaryNameNode principal not considered, %s = %s, %s = %s" , DFSConfigKeys.DfsSecondaryNamenodeKerberosPrincipalKey, conf.Get(DFSConfigKeys .DfsSecondaryNamenodeKerberosPrincipalKey), DFSConfigKeys.DfsNamenodeSecondaryHttpAddressKey , conf.GetTrimmed(DFSConfigKeys.DfsNamenodeSecondaryHttpAddressKey, DFSConfigKeys .DfsNamenodeSecondaryHttpAddressDefault)); Log.Warn(msg); } if (HAUtil.IsHAEnabled(conf, DFSUtil.GetNamenodeNameServiceId(conf))) { Configuration otherNnConf = HAUtil.GetConfForOtherNode(conf); validRequestors.AddItem(SecurityUtil.GetServerPrincipal(otherNnConf.Get(DFSConfigKeys .DfsNamenodeKerberosPrincipalKey), NameNode.GetAddress(otherNnConf).GetHostName( ))); } foreach (string v in validRequestors) { if (v != null && v.Equals(remoteUser)) { Log.Info("ImageServlet allowing checkpointer: " + remoteUser); return(true); } } if (HttpServer2.UserHasAdministratorAccess(context, remoteUser)) { Log.Info("ImageServlet allowing administrator: " + remoteUser); return(true); } Log.Info("ImageServlet rejecting: " + remoteUser); return(false); }
/// <summary> /// Determine the address of the NN we are checkpointing /// as well as our own HTTP address from the configuration. /// </summary> /// <exception cref="System.IO.IOException"></exception> private void SetNameNodeAddresses(Configuration conf) { // Look up our own address. myNNAddress = GetHttpAddress(conf); // Look up the active node's address Configuration confForActive = HAUtil.GetConfForOtherNode(conf); activeNNAddress = GetHttpAddress(confForActive); // Sanity-check. Preconditions.CheckArgument(CheckAddress(activeNNAddress), "Bad address for active NN: %s" , activeNNAddress); Preconditions.CheckArgument(CheckAddress(myNNAddress), "Bad address for standby NN: %s" , myNNAddress); }
private IPEndPoint GetActiveNodeAddress() { Configuration activeConf = HAUtil.GetConfForOtherNode(conf); return(NameNode.GetServiceAddress(activeConf, true)); }