@Override public <T> T runAs(PrivilegedExceptionAction<T> action) throws IOException, InterruptedException { return ugi.doAs(action); }
@Override public TTransport getTransport(final TTransport trans) { return ugi.doAs(new PrivilegedAction<TTransport>() { @Override public TTransport run() { return wrapped.getTransport(trans); } }); } }
@Override protected Void callInternal() throws IOException, InterruptedException { return ugi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { return performDataRead(); } }); }
@Override protected Void callInternal() throws IOException, InterruptedException { return ugi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { return performDataRead(); } }); }
@Override public <T> T runAs(PrivilegedAction<T> action) { return ugi.doAs(action); }
private static <T> T doAsUser(UserGroupInformation ugi, PrivilegedExceptionAction<T> action) throws IOException { try { return ugi.doAs(action); } catch (InterruptedException ie) { throw new IOException(ie); } }
private void renameScriptFile(final Path renamedScriptPath) throws IOException, InterruptedException { appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws IOException { FileSystem fs = renamedScriptPath.getFileSystem(conf); fs.rename(new Path(jstormMasterContext.scriptPath), renamedScriptPath); return null; } }); LOG.info("User " + appSubmitterUgi.getUserName() + " added suffix(.sh/.bat) to script file as " + renamedScriptPath); }
private String queueAsUser(UserGroupInformation ugi, final List<String> args, final TempletonControllerJob controllerJob) throws IOException, InterruptedException { if(LOG.isDebugEnabled()) { LOG.debug("Launching job: " + args); } return ugi.doAs(new PrivilegedExceptionAction<String>() { public String run() throws Exception { runTempletonControllerJob(controllerJob, args); return controllerJob.getSubmittedId(); } }); }
/** * Get the subject from Hadoop so we can use it to validate the acls. There is no direct * interface from UserGroupInformation to get the subject, so do a doAs and get the context. * We could probably run everything in the doAs but for now just grab the subject. */ private Subject getHadoopUser() { Subject subj; try { subj = UserGroupInformation.getCurrentUser().doAs( new PrivilegedAction<Subject>() { @Override public Subject run() { return Subject.getSubject(AccessController.getContext()); } }); } catch (IOException e) { throw new RuntimeException("Error creating subject and logging user in!", e); } return subj; }
private <T> T doAsUser(UserGroupInformation ugi, Callable<T> task) throws Exception { return ugi.doAs(new PrivilegedExceptionAction<T>() { @Override public T run() throws Exception { return task.call(); } }); }
@Override public String run() throws IOException, TException, InterruptedException { final IMetaStoreClient client = HCatUtil.getHiveMetastoreClient(c); return ugi.doAs(new PrivilegedExceptionAction<String>() { @Override public String run() throws IOException, TException, InterruptedException { String u = ugi.getUserName(); return client.getDelegationToken(c.getUser(),u); } }); } });
/** {@inheritDoc} */ @Override protected FileSystem create(String usrName) throws IOException, InterruptedException { UserGroupInformation proxyUgi = UserGroupInformation.createProxyUser(usrName, user); return proxyUgi.doAs(new PrivilegedExceptionAction<FileSystem>() { @Override public FileSystem run() throws Exception { FileSystem fs = FileSystem.get(fullUri, cfg); if (workDir != null) fs.setWorkingDirectory(workDir); return fs; } }); }
@Override public <T> T execute(PrivilegedAction<T> action) { ensureValidAuth(); return ugi.doAs(action); }
private List<TxnToWriteId> allocateWriteIdsImpl(final IMetaStoreClient msClient, final List<Long> txnIds, UserGroupInformation ugi) throws IOException, TException, InterruptedException { if(ugi==null) { return msClient.allocateTableWriteIdsBatch(txnIds, endPt.database, endPt.table); } return (List<TxnToWriteId>) ugi.doAs(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { return msClient.allocateTableWriteIdsBatch(txnIds, endPt.database, endPt.table); } }); }
@Override public <T> T execute(PrivilegedExceptionAction<T> action) throws Exception { ensureValidAuth(); return ugi.doAs(action); }
private BlockingInterface createProxy() throws IOException { RPC.setProtocolEngine(conf, blockingInterfaceClass, ProtobufRpcEngine.class); if (ugi == null) return createProxyInternal(); try { return ugi.doAs(new PrivilegedExceptionAction<BlockingInterface>() { @Override public BlockingInterface run() throws IOException { return createProxyInternal(); } }); } catch (InterruptedException e) { throw new IOException(e); } }
private List<Long> openTxnImpl(final IMetaStoreClient msClient, final String user, final int numTxns, UserGroupInformation ugi) throws IOException, TException, InterruptedException { if(ugi==null) { return msClient.openTxns(user, numTxns).getTxn_ids(); } return (List<Long>) ugi.doAs(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { return msClient.openTxns(user, numTxns).getTxn_ids(); } }); }
public RecordWriter getRecordWriter(final HiveMapper mapper, final boolean tokenAuthEnabled) throws Exception { if (!tokenAuthEnabled) { return mapper.createRecordWriter(endPoint); } try { return ugi.doAs( new PrivilegedExceptionAction<RecordWriter>() { @Override public RecordWriter run() throws StreamingException, IOException, ClassNotFoundException { return mapper.createRecordWriter(endPoint); } } ); } catch (Exception e) { throw new ConnectFailure(endPoint, e); } }
static <R, E extends Exception> R executeActionInDoAs(UserGroupInformation userGroupInformation, GenericExceptionAction<R, E> action) throws E { return userGroupInformation.doAs((PrivilegedAction<ResultOrException<R, E>>) () -> { try { return new ResultOrException<>(action.run(), null); } catch (Throwable e) { return new ResultOrException<>(null, e); } }).get(); }
private void doSplitting() { server.metricsRegionServer.incrSplitRequest(); if (user != null && user.getUGI() != null) { user.getUGI().doAs (new PrivilegedAction<Void>() { @Override public Void run() { requestRegionSplit(); return null; } }); } else { requestRegionSplit(); } }