Search in sources :

Example 76 with Method

use of java.lang.reflect.Method in project titan by thinkaurelius.

the class HBaseAuthHelper method setHBaseAuthToken.

public static void setHBaseAuthToken(Configuration configuration, Job job) throws IOException {
    // Get HBase authentication token (when configured)
    String hbaseAuthentication = configuration.get("hbase.security.authentication");
    if (null != hbaseAuthentication && hbaseAuthentication.equals("kerberos")) {
        String quorumCfgKey = "hbase.zookeeper.quorum";
        log.info("Obtaining HBase Auth Token from ZooKeeper quorum " + configuration.get(quorumCfgKey));
        final String className = "org.apache.hadoop.hbase.security.User";
        try {
            Class<?> clazz = HBaseAuthHelper.class.getClassLoader().loadClass(className);
            Method getCurrent = clazz.getMethod("getCurrent");
            Object user = getCurrent.invoke(null);
            Method obtainAuthTokenForJob = clazz.getMethod("obtainAuthTokenForJob", Configuration.class, Job.class);
            obtainAuthTokenForJob.invoke(user, configuration, job);
            log.info("Obtained HBase Auth Token from ZooKeeper quorum {} for job {}", configuration.get(quorumCfgKey), job.getJobName());
        } catch (ClassNotFoundException e) {
            log.error("Failed to generate or store HBase auth token", e);
        } catch (InvocationTargetException e) {
            log.error("Failed to generate or store HBase auth token", e);
        } catch (NoSuchMethodException e) {
            log.error("Failed to generate or store HBase auth token", e);
        } catch (IllegalAccessException e) {
            log.error("Failed to generate or store HBase auth token", e);
        } catch (Throwable t) {
            log.error("Failed to generate or store HBase auth token", t);
        }
    } else {
        log.info("Not obtaining HBase Auth Token for MapReduce job " + job.getJobName());
    }
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 77 with Method

use of java.lang.reflect.Method in project titan by thinkaurelius.

the class HBaseBinaryInputFormat method setConf.

@Override
public void setConf(final Configuration config) {
    super.setConf(config);
    //config.set(TableInputFormat.SCAN_COLUMN_FAMILY, Backend.EDGESTORE_NAME);
    config.set(TableInputFormat.INPUT_TABLE, titanConf.get(HBaseStoreManager.HBASE_TABLE));
    //config.set(HConstants.ZOOKEEPER_QUORUM, config.get(TITAN_HADOOP_GRAPH_INPUT_TITAN_STORAGE_HOSTNAME));
    config.set(HConstants.ZOOKEEPER_QUORUM, titanConf.get(GraphDatabaseConfiguration.STORAGE_HOSTS)[0]);
    //        if (basicConf.get(TITAN_HADOOP_GRAPH_INPUT_TITAN_STORAGE_PORT, null) != null)
    if (titanConf.has(GraphDatabaseConfiguration.STORAGE_PORT))
        config.set(HConstants.ZOOKEEPER_CLIENT_PORT, String.valueOf(titanConf.get(GraphDatabaseConfiguration.STORAGE_PORT)));
    config.set("autotype", "none");
    log.debug("hbase.security.authentication={}", config.get("hbase.security.authentication"));
    Scan scanner = new Scan();
    String cfName = mrConf.get(TitanHadoopConfiguration.COLUMN_FAMILY_NAME);
    // TODO the space-saving short name mapping leaks from HBaseStoreManager here
    if (titanConf.get(HBaseStoreManager.SHORT_CF_NAMES)) {
        try {
            cfName = HBaseStoreManager.shortenCfName(cfName);
        } catch (PermanentBackendException e) {
            throw new RuntimeException(e);
        }
    }
    scanner.addFamily(cfName.getBytes());
    inputCFBytes = Bytes.toBytes(cfName);
    //scanner.setFilter(getColumnFilter(titanSetup.inputSlice(this.vertexQuery))); // TODO
    //TODO (minor): should we set other options in http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html for optimization?
    Method converter;
    try {
        converter = TableMapReduceUtil.class.getDeclaredMethod("convertScanToString", Scan.class);
        converter.setAccessible(true);
        config.set(TableInputFormat.SCAN, (String) converter.invoke(null, scanner));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    this.tableInputFormat.setConf(config);
}
Also used : TableMapReduceUtil(org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil) PermanentBackendException(com.thinkaurelius.titan.diskstorage.PermanentBackendException) Scan(org.apache.hadoop.hbase.client.Scan) Method(java.lang.reflect.Method) PermanentBackendException(com.thinkaurelius.titan.diskstorage.PermanentBackendException) IOException(java.io.IOException)

Example 78 with Method

use of java.lang.reflect.Method in project blueprints by tinkerpop.

the class WritethroughGraphTest method doTestSuite.

public void doTestSuite(final TestSuite testSuite) throws Exception {
    for (Method method : testSuite.getClass().getDeclaredMethods()) {
        if (method.getName().startsWith("test")) {
            System.out.println("Testing " + method.getName() + "...");
            method.invoke(testSuite);
        }
    }
}
Also used : Method(java.lang.reflect.Method)

Example 79 with Method

use of java.lang.reflect.Method in project blueprints by tinkerpop.

the class IdGraphTest method doTestSuite.

public void doTestSuite(final TestSuite testSuite) throws Exception {
    for (Method method : testSuite.getClass().getDeclaredMethods()) {
        if (method.getName().startsWith("test")) {
            System.out.println("Testing " + method.getName() + "...");
            method.invoke(testSuite);
        }
    }
}
Also used : Method(java.lang.reflect.Method)

Example 80 with Method

use of java.lang.reflect.Method in project blueprints by tinkerpop.

the class EventGraphTest method doTestSuite.

public void doTestSuite(final TestSuite testSuite) throws Exception {
    for (Method method : testSuite.getClass().getDeclaredMethods()) {
        if (method.getName().startsWith("test")) {
            System.out.println("Testing " + method.getName() + "...");
            method.invoke(testSuite);
        }
    }
}
Also used : Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)8797 Test (org.junit.Test)1772 InvocationTargetException (java.lang.reflect.InvocationTargetException)1084 ArrayList (java.util.ArrayList)665 Field (java.lang.reflect.Field)611 IOException (java.io.IOException)549 HashMap (java.util.HashMap)352 Map (java.util.Map)290 List (java.util.List)275 PropertyDescriptor (java.beans.PropertyDescriptor)253 Annotation (java.lang.annotation.Annotation)212 Type (java.lang.reflect.Type)202 HashSet (java.util.HashSet)199 File (java.io.File)173 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)170 BeanInfo (java.beans.BeanInfo)166 ParameterizedType (java.lang.reflect.ParameterizedType)132 Constructor (java.lang.reflect.Constructor)131 SimpleBeanInfo (java.beans.SimpleBeanInfo)128 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)128