コード例 #1
0
 @VisibleForTesting
 protected static AccessURI parseURI(String uri, boolean isLocal) throws SemanticException {
   try {
     HiveConf conf = SessionState.get().getConf();
     String warehouseDir = conf.getVar(ConfVars.METASTOREWAREHOUSE);
     return new AccessURI(PathUtils.parseURI(warehouseDir, uri, isLocal));
   } catch (Exception e) {
     throw new SemanticException("Error parsing URI " + uri + ": " + e.getMessage(), e);
   }
 }
コード例 #2
0
 // Check if this write entity needs to skipped
 private boolean filterWriteEntity(WriteEntity writeEntity) throws AuthorizationException {
   // skip URI validation for session scratch file URIs
   if (writeEntity.isTempURI()) {
     return true;
   }
   try {
     if (writeEntity.getTyp().equals(Type.DFS_DIR)
         || writeEntity.getTyp().equals(Type.LOCAL_DIR)) {
       HiveConf conf = SessionState.get().getConf();
       String warehouseDir = conf.getVar(ConfVars.METASTOREWAREHOUSE);
       URI scratchURI =
           new URI(PathUtils.parseDFSURI(warehouseDir, conf.getVar(HiveConf.ConfVars.SCRATCHDIR)));
       URI requestURI =
           new URI(PathUtils.parseDFSURI(warehouseDir, writeEntity.getLocation().getPath()));
       LOG.debug("scratchURI = " + scratchURI + ", requestURI = " + requestURI);
       if (PathUtils.impliesURI(scratchURI, requestURI)) {
         return true;
       }
       URI localScratchURI =
           new URI(PathUtils.parseLocalURI(conf.getVar(HiveConf.ConfVars.LOCALSCRATCHDIR)));
       URI localRequestURI = new URI(PathUtils.parseLocalURI(writeEntity.getLocation().getPath()));
       LOG.debug(
           "localScratchURI = " + localScratchURI + ", localRequestURI = " + localRequestURI);
       if (PathUtils.impliesURI(localScratchURI, localRequestURI)) {
         return true;
       }
     }
   } catch (Exception e) {
     throw new AuthorizationException("Failed to extract uri details", e);
   }
   return false;
 }