Java Code Examples for org.apache.hadoop.security.SecurityUtil#doAsLoginUserOrFatal()

The following examples show how to use org.apache.hadoop.security.SecurityUtil#doAsLoginUserOrFatal() . 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: BootstrapStandby.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public int run(String[] args) throws Exception {
  parseArgs(args);
  parseConfAndFindOtherNN();
  NameNode.checkAllowFormat(conf);

  InetSocketAddress myAddr = NameNode.getAddress(conf);
  SecurityUtil.login(conf, DFS_NAMENODE_KEYTAB_FILE_KEY,
      DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY, myAddr.getHostName());

  return SecurityUtil.doAsLoginUserOrFatal(new PrivilegedAction<Integer>() {
    @Override
    public Integer run() {
      try {
        return doRun();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  });
}
 
Example 2
Source File: BootstrapStandby.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Override
public int run(String[] args) throws Exception {
  parseArgs(args);
  parseConfAndFindOtherNN();
  NameNode.checkAllowFormat(conf);

  InetSocketAddress myAddr = NameNode.getAddress(conf);
  SecurityUtil.login(conf, DFS_NAMENODE_KEYTAB_FILE_KEY,
      DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY, myAddr.getHostName());

  return SecurityUtil.doAsLoginUserOrFatal(new PrivilegedAction<Integer>() {
    @Override
    public Integer run() {
      try {
        return doRun();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  });
}
 
Example 3
Source File: EditLogTailer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  SecurityUtil.doAsLoginUserOrFatal(
      new PrivilegedAction<Object>() {
      @Override
      public Object run() {
        doWork();
        return null;
      }
    });
}
 
Example 4
Source File: StandbyCheckpointer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  // We have to make sure we're logged in as far as JAAS
  // is concerned, in order to use kerberized SSL properly.
  SecurityUtil.doAsLoginUserOrFatal(
      new PrivilegedAction<Object>() {
      @Override
      public Object run() {
        doWork();
        return null;
      }
    });
}
 
Example 5
Source File: SecondaryNameNode.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  SecurityUtil.doAsLoginUserOrFatal(
      new PrivilegedAction<Object>() {
      @Override
      public Object run() {
        doWork();
        return null;
      }
    });
}
 
Example 6
Source File: ZKFailoverController.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public int run(final String[] args) throws Exception {
  if (!localTarget.isAutoFailoverEnabled()) {
    LOG.fatal("Automatic failover is not enabled for " + localTarget + "." +
        " Please ensure that automatic failover is enabled in the " +
        "configuration before running the ZK failover controller.");
    return ERR_CODE_AUTO_FAILOVER_NOT_ENABLED;
  }
  loginAsFCUser();
  try {
    return SecurityUtil.doAsLoginUserOrFatal(new PrivilegedAction<Integer>() {
      @Override
      public Integer run() {
        try {
          return doRun(args);
        } catch (Exception t) {
          throw new RuntimeException(t);
        } finally {
          if (elector != null) {
            elector.terminateConnection();
          }
        }
      }
    });
  } catch (RuntimeException rte) {
    throw (Exception)rte.getCause();
  }
}
 
Example 7
Source File: EditLogTailer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  SecurityUtil.doAsLoginUserOrFatal(
      new PrivilegedAction<Object>() {
      @Override
      public Object run() {
        doWork();
        return null;
      }
    });
}
 
Example 8
Source File: StandbyCheckpointer.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  // We have to make sure we're logged in as far as JAAS
  // is concerned, in order to use kerberized SSL properly.
  SecurityUtil.doAsLoginUserOrFatal(
      new PrivilegedAction<Object>() {
      @Override
      public Object run() {
        doWork();
        return null;
      }
    });
}
 
Example 9
Source File: SecondaryNameNode.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
  SecurityUtil.doAsLoginUserOrFatal(
      new PrivilegedAction<Object>() {
      @Override
      public Object run() {
        doWork();
        return null;
      }
    });
}
 
Example 10
Source File: ZKFailoverController.java    From big-c with Apache License 2.0 5 votes vote down vote up
public int run(final String[] args) throws Exception {
  if (!localTarget.isAutoFailoverEnabled()) {
    LOG.fatal("Automatic failover is not enabled for " + localTarget + "." +
        " Please ensure that automatic failover is enabled in the " +
        "configuration before running the ZK failover controller.");
    return ERR_CODE_AUTO_FAILOVER_NOT_ENABLED;
  }
  loginAsFCUser();
  try {
    return SecurityUtil.doAsLoginUserOrFatal(new PrivilegedAction<Integer>() {
      @Override
      public Integer run() {
        try {
          return doRun(args);
        } catch (Exception t) {
          throw new RuntimeException(t);
        } finally {
          if (elector != null) {
            elector.terminateConnection();
          }
        }
      }
    });
  } catch (RuntimeException rte) {
    throw (Exception)rte.getCause();
  }
}