Java Code Examples for org.apache.hadoop.ipc.Server#getRemoteAddress()

The following examples show how to use org.apache.hadoop.ipc.Server#getRemoteAddress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MRClientService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public KillJobResponse killJob(KillJobRequest request) 
  throws IOException {
  JobId jobId = request.getJobId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill job " + jobId + " received from " + callerUGI
      + " at " + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetJob(jobId, JobACL.MODIFY_JOB, false);
  appContext.getEventHandler().handle(
      new JobDiagnosticsUpdateEvent(jobId, message));
  appContext.getEventHandler().handle(
      new JobEvent(jobId, JobEventType.JOB_KILL));
  KillJobResponse response = 
    recordFactory.newRecordInstance(KillJobResponse.class);
  return response;
}
 
Example 2
Source File: MRClientService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public KillTaskResponse killTask(KillTaskRequest request) 
  throws IOException {
  TaskId taskId = request.getTaskId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill task " + taskId + " received from " + callerUGI
      + " at " + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetTask(taskId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskEvent(taskId, TaskEventType.T_KILL));
  KillTaskResponse response = 
    recordFactory.newRecordInstance(KillTaskResponse.class);
  return response;
}
 
Example 3
Source File: MRClientService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public KillTaskAttemptResponse killTaskAttempt(
    KillTaskAttemptRequest request) throws IOException {
  TaskAttemptId taskAttemptId = request.getTaskAttemptId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill task attempt " + taskAttemptId
      + " received from " + callerUGI + " at "
      + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetAttempt(taskAttemptId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskAttemptDiagnosticsUpdateEvent(taskAttemptId, message));
  appContext.getEventHandler().handle(
      new TaskAttemptEvent(taskAttemptId, 
          TaskAttemptEventType.TA_KILL));
  KillTaskAttemptResponse response = 
    recordFactory.newRecordInstance(KillTaskAttemptResponse.class);
  return response;
}
 
Example 4
Source File: MRClientService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public FailTaskAttemptResponse failTaskAttempt(
    FailTaskAttemptRequest request) throws IOException {
  TaskAttemptId taskAttemptId = request.getTaskAttemptId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Fail task attempt " + taskAttemptId
      + " received from " + callerUGI + " at "
      + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetAttempt(taskAttemptId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskAttemptDiagnosticsUpdateEvent(taskAttemptId, message));
  appContext.getEventHandler().handle(
      new TaskAttemptEvent(taskAttemptId, 
          TaskAttemptEventType.TA_FAILMSG));
  FailTaskAttemptResponse response = recordFactory.
    newRecordInstance(FailTaskAttemptResponse.class);
  return response;
}
 
Example 5
Source File: MRClientService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public KillJobResponse killJob(KillJobRequest request) 
  throws IOException {
  JobId jobId = request.getJobId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill job " + jobId + " received from " + callerUGI
      + " at " + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetJob(jobId, JobACL.MODIFY_JOB, false);
  appContext.getEventHandler().handle(
      new JobDiagnosticsUpdateEvent(jobId, message));
  appContext.getEventHandler().handle(
      new JobEvent(jobId, JobEventType.JOB_KILL));
  KillJobResponse response = 
    recordFactory.newRecordInstance(KillJobResponse.class);
  return response;
}
 
Example 6
Source File: MRClientService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public KillTaskResponse killTask(KillTaskRequest request) 
  throws IOException {
  TaskId taskId = request.getTaskId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill task " + taskId + " received from " + callerUGI
      + " at " + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetTask(taskId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskEvent(taskId, TaskEventType.T_KILL));
  KillTaskResponse response = 
    recordFactory.newRecordInstance(KillTaskResponse.class);
  return response;
}
 
Example 7
Source File: MRClientService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public KillTaskAttemptResponse killTaskAttempt(
    KillTaskAttemptRequest request) throws IOException {
  TaskAttemptId taskAttemptId = request.getTaskAttemptId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill task attempt " + taskAttemptId
      + " received from " + callerUGI + " at "
      + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetAttempt(taskAttemptId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskAttemptDiagnosticsUpdateEvent(taskAttemptId, message));
  appContext.getEventHandler().handle(
      new TaskAttemptEvent(taskAttemptId, 
          TaskAttemptEventType.TA_KILL));
  KillTaskAttemptResponse response = 
    recordFactory.newRecordInstance(KillTaskAttemptResponse.class);
  return response;
}
 
Example 8
Source File: MRClientService.java    From big-c with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public FailTaskAttemptResponse failTaskAttempt(
    FailTaskAttemptRequest request) throws IOException {
  TaskAttemptId taskAttemptId = request.getTaskAttemptId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Fail task attempt " + taskAttemptId
      + " received from " + callerUGI + " at "
      + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetAttempt(taskAttemptId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskAttemptDiagnosticsUpdateEvent(taskAttemptId, message));
  appContext.getEventHandler().handle(
      new TaskAttemptEvent(taskAttemptId, 
          TaskAttemptEventType.TA_FAILMSG));
  FailTaskAttemptResponse response = recordFactory.
    newRecordInstance(FailTaskAttemptResponse.class);
  return response;
}
 
Example 9
Source File: OzoneManager.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
private static String getClientAddress() {
  String clientMachine = Server.getRemoteAddress();
  if (clientMachine == null) { //not a RPC client
    clientMachine = "";
  }
  return clientMachine;
}
 
Example 10
Source File: NameNode.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
void checkHaStateChange(StateChangeRequestInfo req)
    throws AccessControlException {
  boolean autoHaEnabled = conf.getBoolean(DFS_HA_AUTO_FAILOVER_ENABLED_KEY,
      DFS_HA_AUTO_FAILOVER_ENABLED_DEFAULT);
  switch (req.getSource()) {
  case REQUEST_BY_USER:
    if (autoHaEnabled) {
      throw new AccessControlException(
          "Manual HA control for this NameNode is disallowed, because " +
          "automatic HA is enabled.");
    }
    break;
  case REQUEST_BY_USER_FORCED:
    if (autoHaEnabled) {
      LOG.warn("Allowing manual HA control from " +
          Server.getRemoteAddress() +
          " even though automatic HA is enabled, because the user " +
          "specified the force flag");
    }
    break;
  case REQUEST_BY_ZKFC:
    if (!autoHaEnabled) {
      throw new AccessControlException(
          "Request from ZK failover controller at " +
          Server.getRemoteAddress() + " denied since automatic HA " +
          "is not enabled"); 
    }
    break;
  }
}
 
Example 11
Source File: NameNodeRpcServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: DFSZKFailoverController.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void checkRpcAdminAccess() throws IOException, AccessControlException {
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
  UserGroupInformation zkfcUgi = UserGroupInformation.getLoginUser();
  if (adminAcl.isUserAllowed(ugi) ||
      ugi.getShortUserName().equals(zkfcUgi.getShortUserName())) {
    LOG.info("Allowed RPC access from " + ugi + " at " + Server.getRemoteAddress());
    return;
  }
  String msg = "Disallowed RPC access from " + ugi + " at " +
      Server.getRemoteAddress() + ". Not listed in " + DFSConfigKeys.DFS_ADMIN; 
  LOG.warn(msg);
  throw new AccessControlException(msg);
}
 
Example 13
Source File: NameNode.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
void checkHaStateChange(StateChangeRequestInfo req)
    throws AccessControlException {
  boolean autoHaEnabled = conf.getBoolean(DFS_HA_AUTO_FAILOVER_ENABLED_KEY,
      DFS_HA_AUTO_FAILOVER_ENABLED_DEFAULT);
  switch (req.getSource()) {
  case REQUEST_BY_USER:
    if (autoHaEnabled) {
      throw new AccessControlException(
          "Manual HA control for this NameNode is disallowed, because " +
          "automatic HA is enabled.");
    }
    break;
  case REQUEST_BY_USER_FORCED:
    if (autoHaEnabled) {
      LOG.warn("Allowing manual HA control from " +
          Server.getRemoteAddress() +
          " even though automatic HA is enabled, because the user " +
          "specified the force flag");
    }
    break;
  case REQUEST_BY_ZKFC:
    if (!autoHaEnabled) {
      throw new AccessControlException(
          "Request from ZK failover controller at " +
          Server.getRemoteAddress() + " denied since automatic HA " +
          "is not enabled"); 
    }
    break;
  }
}
 
Example 14
Source File: NameNodeRpcServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 15
Source File: DFSZKFailoverController.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void checkRpcAdminAccess() throws IOException, AccessControlException {
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
  UserGroupInformation zkfcUgi = UserGroupInformation.getLoginUser();
  if (adminAcl.isUserAllowed(ugi) ||
      ugi.getShortUserName().equals(zkfcUgi.getShortUserName())) {
    LOG.info("Allowed RPC access from " + ugi + " at " + Server.getRemoteAddress());
    return;
  }
  String msg = "Disallowed RPC access from " + ugi + " at " +
      Server.getRemoteAddress() + ". Not listed in " + DFSConfigKeys.DFS_ADMIN; 
  LOG.warn(msg);
  throw new AccessControlException(msg);
}
 
Example 16
Source File: DAGClientHandler.java    From tez with Apache License 2.0 5 votes vote down vote up
private String getClientInfo() throws TezException {
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw new TezException(ie);
  }
  String message = callerUGI.toString();
  if(null != Server.getRemoteAddress()) {
    message += " at " + Server.getRemoteAddress();
  }
  return message;
}