/** * Check that a request to change this node's HA state is valid. In particular, verifies that, if * auto failover is enabled, non-forced requests from the HAAdmin CLI are rejected, and vice * versa. * * @param req the request to check * @throws AccessControlException if the request is disallowed */ private void checkHaStateChange(StateChangeRequestInfo req) throws AccessControlException { switch (req.getSource()) { case REQUEST_BY_USER: if (autoFailoverEnabled) { throw new AccessControlException( "Manual failover for this ResourceManager is disallowed, " + "because automatic failover is enabled."); } break; case REQUEST_BY_USER_FORCED: if (autoFailoverEnabled) { LOG.warn( "Allowing manual failover from " + org.apache.hadoop.ipc.Server.getRemoteAddress() + " even though automatic failover is enabled, because the user " + "specified the force flag"); } break; case REQUEST_BY_ZKFC: if (!autoFailoverEnabled) { throw new AccessControlException( "Request from ZK failover controller at " + org.apache.hadoop.ipc.Server.getRemoteAddress() + " denied " + "since automatic failover is not enabled"); } break; } }
private static String getClientMachine() { String clientMachine = NamenodeWebHdfsMethods.getRemoteAddress(); if (clientMachine == null) { // not a web client clientMachine = Server.getRemoteAddress(); } if (clientMachine == null) { // not a RPC client clientMachine = ""; } return clientMachine; }