List of usage examples for org.apache.hadoop.fs.permission FsPermission fromShort
public void fromShort(short n)
From source file:org.elasticsearch.hadoop.HdpBootstrap.java
License:Apache License
/** * Hack to allow Hadoop client to run on windows (which otherwise fails due to some permission problem). *///from w w w . ja v a2 s . c o m public static void hackHadoopStagingOnWin() { // do the assignment only on Windows systems if (TestUtils.isWindows()) { // 0655 = -rwxr-xr-x , 0650 = -rwxr-x--- JobSubmissionFiles.JOB_DIR_PERMISSION.fromShort((short) 0650); JobSubmissionFiles.JOB_FILE_PERMISSION.fromShort((short) 0650); Field field = null; // handle distributed cache permissions on Hadoop < 2.4 try { Class<?> jl = Class.forName("org.apache.hadoop.mapred.JobLocalizer"); field = ReflectionUtils.findField(jl, "privateCachePerms"); if (field != null) { ReflectionUtils.makeAccessible(field); FsPermission perm = (FsPermission) ReflectionUtils.getField(field, null); perm.fromShort((short) 0650); } } catch (ClassNotFoundException cnfe) { // ignore } // handle jar permissions as well - temporarily disable for CDH 4 / YARN try { Class<?> tdcm = Class.forName("org.apache.hadoop.filecache.TrackerDistributedCacheManager"); field = ReflectionUtils.findField(tdcm, "PUBLIC_CACHE_OBJECT_PERM"); ReflectionUtils.makeAccessible(field); FsPermission perm = (FsPermission) ReflectionUtils.getField(field, null); perm.fromShort((short) 0650); } catch (ClassNotFoundException cnfe) { //ignore return; } catch (Exception ex) { LogFactory.getLog(TestUtils.class).warn("Cannot set permission for TrackerDistributedCacheManager", ex); } } }
From source file:org.elasticsearch.hadoop.integration.HdpBootstrap.java
License:Apache License
/** * Hack to allow Hadoop client to run on windows (which otherwise fails due to some permission problem). *///from w w w . ja v a 2 s.c o m public static void hackHadoopStagingOnWin() { // do the assignment only on Windows systems if (TestUtils.isWindows()) { // 0655 = -rwxr-xr-x JobSubmissionFiles.JOB_DIR_PERMISSION.fromShort((short) 0650); JobSubmissionFiles.JOB_FILE_PERMISSION.fromShort((short) 0650); // handle jar permissions as well - temporarily disable for CDH 4 / YARN try { Class<?> tdcm = Class.forName("org.apache.hadoop.filecache.TrackerDistributedCacheManager"); Field field = ReflectionUtils.findField(tdcm, "PUBLIC_CACHE_OBJECT_PERM"); ReflectionUtils.makeAccessible(field); FsPermission perm = (FsPermission) ReflectionUtils.getField(field, null); perm.fromShort((short) 0650); } catch (ClassNotFoundException cnfe) { //ignore return; } catch (Exception ex) { LogFactory.getLog(TestUtils.class).warn("Cannot set permission for TrackerDistributedCacheManager", ex); } } }
From source file:org.springframework.data.hadoop.util.PermissionUtils.java
License:Apache License
public static void hackHadoopStagingOnWin() { // do the assignment only on Windows systems if (System.getProperty("os.name").toLowerCase().startsWith("win")) { // 0655 = -rwxr-xr-x JobSubmissionFiles.JOB_DIR_PERMISSION.fromShort((short) 0650); JobSubmissionFiles.JOB_FILE_PERMISSION.fromShort((short) 0650); if (trackerDistributedCacheManagerClass != null) { // handle jar permissions as well Field field = ReflectionUtils.findField(trackerDistributedCacheManagerClass, "PUBLIC_CACHE_OBJECT_PERM"); ReflectionUtils.makeAccessible(field); FsPermission perm = (FsPermission) ReflectionUtils.getField(field, null); perm.fromShort((short) 0650); }//from www . j a v a2s. com } }