Examples of HCatClient


Examples of org.apache.hcatalog.api.HCatClient

    }

    public static synchronized HCatClient get(String metastoreUrl) throws FalconException {

        if (!CACHE.containsKey(metastoreUrl)) {
            HCatClient hCatClient = getHCatClient(metastoreUrl);
            LOG.info("Caching HCatalog client object for " + metastoreUrl);
            CACHE.putIfAbsent(metastoreUrl, hCatClient);
        }

        return CACHE.get(metastoreUrl);
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

    @Override
    public boolean isAlive(String catalogBaseUrl) throws FalconException {
        LOG.info("Checking if the service is alive for: " + catalogBaseUrl);

        try {
            HCatClient client = get(catalogBaseUrl);
            client.close();
            HCatDatabase database = client.getDatabase("default");
            return database != null;
        } catch (HCatException e) {
            throw new FalconException(e);
        }
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

    public boolean tableExists(String catalogUrl, String database, String tableName)
        throws FalconException {
        LOG.info("Checking if the table exists: " + tableName);

        try {
            HCatClient client = get(catalogUrl);
            HCatTable table = client.getTable(database, tableName);
            return table != null;
        } catch (HCatException e) {
            throw new FalconException(e);
        }
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

    public boolean isTableExternal(String catalogUrl, String database, String tableName)
        throws FalconException {
        LOG.info("Returns a list of table properties for:" + tableName);

        try {
            HCatClient client = get(catalogUrl);
            HCatTable table = client.getTable(database, tableName);
            return !table.getTabletype().equals("MANAGED_TABLE");
        } catch (HCatException e) {
            throw new FalconException(e);
        }
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

        LOG.info("List partitions for : " + tableName + ", partition filter: " + filter);

        try {
            List<CatalogPartition> catalogPartitionList = new ArrayList<CatalogPartition>();

            HCatClient client = get(catalogUrl);
            List<HCatPartition> hCatPartitions = client.listPartitionsByFilter(database, tableName, filter);
            for (HCatPartition hCatPartition : hCatPartitions) {
                CatalogPartition partition = createCatalogPartition(hCatPartition);
                catalogPartitionList.add(partition);
            }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

                                  String tableName, Map<String, String> partitions)
        throws FalconException {
        LOG.info("Dropping partitions for : " + tableName + ", partitions: " + partitions);

        try {
            HCatClient client = get(catalogUrl);
            client.dropPartitions(database, tableName, partitions, true);
        } catch (HCatException e) {
            throw new FalconException(e);
        }

        return true;
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

    public CatalogPartition getPartition(String catalogUrl, String database, String tableName,
                                         Map<String, String> partitionSpec) throws FalconException {
        LOG.info("List partitions for : " + tableName + ", partition spec: " + partitionSpec);

        try {
            HCatClient client = get(catalogUrl);
            HCatPartition hCatPartition = client.getPartition(database, tableName, partitionSpec);
            return createCatalogPartition(hCatPartition);
        } catch (HCatException e) {
            throw new FalconException(e);
        }
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

    private HiveTestUtils() {
    }

    public static void createDatabase(String metaStoreUrl,
                                      String databaseName) throws Exception {
        HCatClient client = HiveCatalogService.get(metaStoreUrl);
        HCatCreateDBDesc dbDesc = HCatCreateDBDesc.create(databaseName)
                .ifNotExists(true).build();
        client.createDatabase(dbDesc);
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

                .ifNotExists(true).build();
        client.createDatabase(dbDesc);
    }

    public static  void dropDatabase(String metaStoreUrl, String databaseName) throws Exception {
        HCatClient client = HiveCatalogService.get(metaStoreUrl);
        client.dropDatabase(databaseName, true, HCatClient.DropDBMode.CASCADE);
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

        client.dropDatabase(databaseName, true, HCatClient.DropDBMode.CASCADE);
    }

    public static void createTable(String metaStoreUrl, String databaseName,
                                   String tableName) throws Exception {
        HCatClient client = HiveCatalogService.get(metaStoreUrl);
        ArrayList<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>();
        cols.add(new HCatFieldSchema("id", HCatFieldSchema.Type.INT, "id comment"));
        cols.add(new HCatFieldSchema("value", HCatFieldSchema.Type.STRING, "value comment"));

        HCatCreateTableDesc tableDesc = HCatCreateTableDesc
                .create(databaseName, tableName, cols)
                .ifNotExists(true)
                .comments("falcon integration test")
                .build();
        client.createTable(tableDesc);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.