当前位置: 首页>>代码示例>>Java>>正文


Java TokenUtil.obtainAndCacheToken方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.security.token.TokenUtil.obtainAndCacheToken方法的典型用法代码示例。如果您正苦于以下问题:Java TokenUtil.obtainAndCacheToken方法的具体用法?Java TokenUtil.obtainAndCacheToken怎么用?Java TokenUtil.obtainAndCacheToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.security.token.TokenUtil的用法示例。


在下文中一共展示了TokenUtil.obtainAndCacheToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.hadoop.hbase.security.token.TokenUtil; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    String hbaseTable = args[0];

    System.out.println("Hello friend.");

    Configuration hconf = HBaseConnection.getCurrentHBaseConfiguration();
    if (User.isHBaseSecurityEnabled(hconf)) {
        try {
            System.out.println("--------------Getting kerberos credential for user " + UserGroupInformation.getCurrentUser().getUserName());
            TokenUtil.obtainAndCacheToken(hconf, UserGroupInformation.getCurrentUser());
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            System.out.println("--------------Error while getting kerberos credential for user " + UserGroupInformation.getCurrentUser().getUserName());
        }
    }

    Scan scan = new Scan();
    int limit = 20;

    Connection conn = null;
    Table table = null;
    ResultScanner scanner = null;
    try {
        conn = ConnectionFactory.createConnection(hconf);
        table = conn.getTable(TableName.valueOf(hbaseTable));
        scanner = table.getScanner(scan);
        int count = 0;
        for (Result r : scanner) {
            byte[] rowkey = r.getRow();
            System.out.println(Bytes.toStringBinary(rowkey));
            count++;
            if (count == limit)
                break;
        }
    } finally {
        IOUtils.closeQuietly(scanner);
        IOUtils.closeQuietly(table);
        IOUtils.closeQuietly(conn);
    }

}
 
开发者ID:apache,项目名称:kylin,代码行数:42,代码来源:PingHBaseCLI.java

示例2: main

import org.apache.hadoop.hbase.security.token.TokenUtil; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    String metadataUrl = args[0];
    String hbaseTable = args[1];

    System.out.println("Hello friend.");

    Configuration hconf = HadoopUtil.newHBaseConfiguration(metadataUrl);
    if (User.isHBaseSecurityEnabled(hconf)) {
        try {
            System.out.println("--------------Getting kerberos credential for user " + UserGroupInformation.getCurrentUser().getUserName());
            TokenUtil.obtainAndCacheToken(hconf, UserGroupInformation.getCurrentUser());
        } catch (InterruptedException e) {
            System.out.println("--------------Error while getting kerberos credential for user " + UserGroupInformation.getCurrentUser().getUserName());
        }
    }

    Scan scan = new Scan();
    int limit = 20;

    HConnection conn = null;
    HTableInterface table = null;
    ResultScanner scanner = null;
    try {
        conn = HConnectionManager.createConnection(hconf);
        table = conn.getTable(hbaseTable);
        scanner = table.getScanner(scan);
        int count = 0;
        for (Result r : scanner) {
            byte[] rowkey = r.getRow();
            System.out.println(Bytes.toStringBinary(rowkey));
            count++;
            if (count == limit)
                break;
        }
    } finally {
        if (scanner != null) {
            scanner.close();
        }
        if (table != null) {
            table.close();
        }
        if (conn != null) {
            conn.close();
        }
    }

}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:48,代码来源:PingHBaseCLI.java


注:本文中的org.apache.hadoop.hbase.security.token.TokenUtil.obtainAndCacheToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。