Example usage for org.apache.commons.lang.reflect FieldUtils readStaticField

List of usage examples for org.apache.commons.lang.reflect FieldUtils readStaticField

Introduction

In this page you can find the example usage for org.apache.commons.lang.reflect FieldUtils readStaticField.

Prototype

public static Object readStaticField(Class cls, String fieldName, boolean forceAccess)
        throws IllegalAccessException 

Source Link

Document

Read the named static field.

Usage

From source file:org.elasticsearch.hadoop.integration.HdpBootstrap.java

/**
 * Hack to allow Hadoop client to run on windows (which otherwise fails due to some permission problem).
 *//*from  w w  w  .j  a  va  2s .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");
            FsPermission perm = (FsPermission) FieldUtils.readStaticField(tdcm, "PUBLIC_CACHE_OBJECT_PERM",
                    true);
            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.util.TestUtils.java

/**
 * Hack to allow Hadoop client to run on windows (which otherwise fails due to some permission problem).
 *//*from w ww . jav  a  2s.  com*/
public static void hackHadoopStagingOnWin() {
    // do the assignment only on Windows systems
    if (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");
            FsPermission perm = (FsPermission) FieldUtils.readStaticField(tdcm, "PUBLIC_CACHE_OBJECT_PERM",
                    true);
            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.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepositoryConcurrencyTest.java

@SuppressWarnings("unchecked")
@After/*from w  w  w.ja  v  a2  s  .  c om*/
public void cleanUp() throws Exception {
    Map<IUnifiedRepository, ?> metaMapStore = (Map<IUnifiedRepository, ?>) FieldUtils
            .readStaticField(PentahoMetadataDomainRepository.class, "metaMapStore", true);
    if (metaMapStore != null) {
        metaMapStore.remove(repository);
    }

    repository = null;
    aclNodeHelper = null;
    domainRepository = null;
}