@Override public <T> T doAs(NamespacedEntityId entityId, Callable<T> callable, ImpersonatedOpType impersonatedOpType) throws Exception { UserGroupInformation ugi = getUGI(entityId, impersonatedOpType); if (!UserGroupInformation.getCurrentUser().equals(ugi)) { LOG.debug("Performing doAs with UGI {} for entity {} and impersonation operation type {}", ugi, entityId, impersonatedOpType); } return ImpersonationUtils.doAs(ugi, callable); }
executor.submit(ImpersonationUtils.createImpersonatingCallable(impersonator, namespaceMeta, callable)); futures.put(tableId, future); } else if (isStateStoreTable(tableId)) { executor.submit(ImpersonationUtils.createImpersonatingCallable(impersonator, namespaceMeta, callable)); futures.put(tableId, future);
private <T> T doAs(QueryHandle queryHandle, Callable<T> callable) throws HandleNotFoundException, ExploreException, SQLException { OperationInfo operationInfo = exploreService.getOperationInfo(queryHandle); try { return ImpersonationUtils.doAs(operationInfo.getUGI(), callable); } catch (HandleNotFoundException | SQLException | ExploreException e) { throw e; } catch (Exception e) { throw Throwables.propagate(e); } }
private Map<String, Future<?>> upgradeUserTables(final NamespaceMeta namespaceMeta, final ExecutorService executor, final HBaseDDLExecutor ddlExecutor) throws Exception { Map<String, Future<?>> futures = new HashMap<>(); String hBaseNamespace = hBaseTableUtil.getHBaseNamespace(namespaceMeta); try (HBaseAdmin hAdmin = new HBaseAdmin(hConf)) { for (final HTableDescriptor desc : hAdmin.listTableDescriptorsByNamespace(HTableNameConverter.encodeHBaseEntity(hBaseNamespace))) { Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { if (isCDAPUserTable(desc)) { upgradeUserTable(desc); } else if (isStreamOrQueueTable(desc.getNameAsString())) { updateTableDesc(desc, ddlExecutor); } return null; } }; Future<?> future = executor.submit(ImpersonationUtils.createImpersonatingCallable(impersonator, namespaceMeta, callable)); futures.put(desc.getNameAsString(), future); } } return futures; }
private <T> T doAs(QueryHandle queryHandle, Callable<T> callable) throws HandleNotFoundException, ExploreException, SQLException { OperationInfo operationInfo = exploreService.getOperationInfo(queryHandle); try { return ImpersonationUtils.doAs(operationInfo.getUGI(), callable); } catch (HandleNotFoundException | SQLException | ExploreException e) { throw e; } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void run() { try { ImpersonationUtils.doAs(opInfo.getUGI(), new Callable<Void>() { @Override public Void call() throws Exception {
@Override public void run() { try { ImpersonationUtils.doAs(opInfo.getUGI(), new Callable<Void>() { @Override public Void call() throws Exception {
public void drop(final DatasetId datasetInstanceId, final DatasetTypeMeta typeMeta, final DatasetSpecification spec) throws Exception { LOG.info("Dropping dataset with spec: {}, type meta: {}", spec, typeMeta); try (DatasetClassLoaderProvider classLoaderProvider = new DirectoryClassLoaderProvider(cConf, locationFactory)) { UserGroupInformation ugi = getUgiForDataset(impersonator, datasetInstanceId); ImpersonationUtils.doAs(ugi, (Callable<Void>) () -> { DatasetType type = dsFramework.getDatasetType(typeMeta, null, classLoaderProvider); if (type == null) { throw new BadRequestException( String.format("Cannot instantiate dataset type using provided type meta: %s", typeMeta)); } DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec); try { admin.drop(); } finally { Closeables.closeQuietly(admin); } return null; }); } }
public void drop(final DatasetId datasetInstanceId, final DatasetTypeMeta typeMeta, final DatasetSpecification spec) throws Exception { LOG.info("Dropping dataset with spec: {}, type meta: {}", spec, typeMeta); try (DatasetClassLoaderProvider classLoaderProvider = new DirectoryClassLoaderProvider(cConf, locationFactory)) { UserGroupInformation ugi = getUgiForDataset(impersonator, datasetInstanceId); ImpersonationUtils.doAs(ugi, (Callable<Void>) () -> { DatasetType type = dsFramework.getDatasetType(typeMeta, null, classLoaderProvider); if (type == null) { throw new BadRequestException( String.format("Cannot instantiate dataset type using provided type meta: %s", typeMeta)); } DatasetAdmin admin = type.getAdmin(DatasetContext.from(datasetInstanceId.getNamespace()), spec); try { admin.drop(); } finally { Closeables.closeQuietly(admin); } return null; }); } }
throw new ServiceException(e, HttpResponseStatus.INTERNAL_SERVER_ERROR); Credentials credentials = ImpersonationUtils.doAs(ugiWithPrincipal.getUGI(), new Callable<Credentials>() { @Override public Credentials call() throws Exception {
throw new ServiceException(e, HttpResponseStatus.INTERNAL_SERVER_ERROR); Credentials credentials = ImpersonationUtils.doAs(ugiWithPrincipal.getUGI(), new Callable<Credentials>() { @Override public Credentials call() throws Exception {
UserGroupInformation ugi = getUgiForDataset(impersonator, datasetInstanceId); final DatasetType type = ImpersonationUtils.doAs(ugi, () -> { LOG.trace("Getting dataset type {}", typeMeta.getName()); DatasetType type1 = dsFramework.getDatasetType(typeMeta, null, classLoaderProvider); }); DatasetSpecification spec = ImpersonationUtils.doAs(ugi, () -> { LOG.trace("Configuring dataset {} of type {}", datasetInstanceId.getDataset(), typeMeta.getName()); DatasetSpecification spec1 = existing == null ? type.configure(datasetInstanceId.getEntityName(), props)
UserGroupInformation ugi = getUgiForDataset(impersonator, datasetInstanceId); final DatasetType type = ImpersonationUtils.doAs(ugi, () -> { LOG.trace("Getting dataset type {}", typeMeta.getName()); DatasetType type1 = dsFramework.getDatasetType(typeMeta, null, classLoaderProvider); }); DatasetSpecification spec = ImpersonationUtils.doAs(ugi, () -> { LOG.trace("Configuring dataset {} of type {}", datasetInstanceId.getDataset(), typeMeta.getName()); DatasetSpecification spec1 = existing == null ? type.configure(datasetInstanceId.getEntityName(), props)
ugi = impersonator.getUGI(namespace); ImpersonationUtils.doAs(ugi, (Callable<Void>) () -> { storageProviderNamespaceAdmin.get().create(metadata); return null;
ugi = impersonator.getUGI(namespace); ImpersonationUtils.doAs(ugi, new Callable<Void>() { @Override public Void call() throws Exception {
try { try { dataset = ImpersonationUtils.doAs(ugi, () -> type.getDataset(context, spec, DatasetDefinition.NO_ARGUMENTS)); } catch (Exception e) { LOG.warn("Exception while instantiating Dataset {}", datasetInstanceId, e);
try { try { dataset = ImpersonationUtils.doAs(ugi, () -> type.getDataset(context, spec, DatasetDefinition.NO_ARGUMENTS)); } catch (Exception e) { LOG.warn("Exception while instantiating Dataset {}", datasetInstanceId, e);