Examples of HCatClient


Examples of org.apache.hcatalog.api.HCatClient

        client.createTable(tableDesc);
    }

    public static void createTable(String metaStoreUrl, String databaseName, String tableName,
                                   List<String> partitionKeys) 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"));

        List<HCatFieldSchema> partitionSchema = new ArrayList<HCatFieldSchema>();
        for (String partitionKey : partitionKeys) {
            partitionSchema.add(new HCatFieldSchema(partitionKey, HCatFieldSchema.Type.STRING, ""));
        }

        HCatCreateTableDesc tableDesc = HCatCreateTableDesc
                .create(databaseName, tableName, cols)
                .ifNotExists(true)
                .comments("falcon integration test")
                .partCols(new ArrayList<HCatFieldSchema>(partitionSchema))
                .build();
        client.createTable(tableDesc);
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

                .partCols(new ArrayList<HCatFieldSchema>(partitionSchema))
                .isTableExternal(true)
                .location(externalLocation)
                .build();

        HCatClient client = HiveCatalogService.get(metaStoreUrl);
        client.createTable(tableDesc);
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

        execHiveDDL(ddl.toString());
    }

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

Examples of org.apache.hcatalog.api.HCatClient

        String changes = lateDataHandler.detectChanges(lateDataPath, computedMetrics, new Configuration());
        Assert.assertEquals("foo", changes);
    }

    private void reinstatePartition() throws Exception {
        final HCatClient client = HiveCatalogService.get(metastoreUrl);

        Map<String, String> partitionSpec = new HashMap<String, String>();
        partitionSpec.put("ds", PARTITION_VALUE);

        client.dropPartitions(DATABASE_NAME, TABLE_NAME, partitionSpec, true);

        Thread.sleep(1000); // sleep so the next add is delayed a bit

        HCatAddPartitionDesc reinstatedPartition = HCatAddPartitionDesc.create(
                DATABASE_NAME, TABLE_NAME, null, partitionSpec).build();
        client.addPartition(reinstatedPartition);

        CatalogPartition reInstatedPartition = CatalogServiceFactory.getCatalogService().getPartition(
                metastoreUrl, DATABASE_NAME, TABLE_NAME, partitionSpec);
        Assert.assertNotNull(reInstatedPartition);
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

        String changes = lateDataHandler.detectChanges(lateDataPath, computedMetrics, new Configuration());
        Assert.assertEquals("foo", changes);
    }

    private void reinstatePartition() throws Exception {
        final HCatClient client = HiveCatalogService.get(metastoreUrl);

        Map<String, String> partitionSpec = new HashMap<String, String>();
        partitionSpec.put("ds", PARTITION_VALUE);

        client.dropPartitions(DATABASE_NAME, TABLE_NAME, partitionSpec, true);

        Thread.sleep(1000); // sleep so the next add is delayed a bit

        HCatAddPartitionDesc reinstatedPartition = HCatAddPartitionDesc.create(
                DATABASE_NAME, TABLE_NAME, null, partitionSpec).build();
        client.addPartition(reinstatedPartition);

        CatalogPartition reInstatedPartition = CatalogServiceFactory.getCatalogService().getPartition(
                metastoreUrl, DATABASE_NAME, TABLE_NAME, partitionSpec);
        Assert.assertNotNull(reInstatedPartition);
    }
View Full Code Here

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

                    hcatConf.set(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL.varname, "true");
                }

                LOG.info("Creating and caching HCatalog client object for " + catalogUrl);
                UserGroupInformation currentUser = UserGroupInformation.getLoginUser();
                HCatClient hcatClient = currentUser.doAs(new PrivilegedExceptionAction<HCatClient>() {
                    public HCatClient run() throws Exception {
                        return HCatClient.create(hcatConf);
                    }
                });
                CACHE.putIfAbsent(catalogUrl, hcatClient);
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

    public boolean isAlive(final String catalogUrl,
                           final String metaStorePrincipal) throws FalconException {
        LOG.info("Checking if the service is alive for: " + catalogUrl);

        try {
            HCatClient client = getProxiedClient(catalogUrl, metaStorePrincipal);
            HCatDatabase database = client.getDatabase("default");
            return database != null;
        } catch (HCatException e) {
            throw new FalconException("Exception checking if the service is alive:" + e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.apache.hcatalog.api.HCatClient

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

        try {
            HCatClient client = getProxiedClient(catalogUrl, metaStorePrincipal);
            HCatTable table = client.getTable(database, tableName);
            return table != null;
        } catch (HCatException e) {
            throw new FalconException("Exception checking if the table exists:" + e.getMessage(), 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("Checking if the table is external:" + tableName);

        try {
            HCatClient client = get(catalogUrl);
            HCatTable table = client.getTable(database, tableName);
            return !table.getTabletype().equals("MANAGED_TABLE");
        } catch (HCatException e) {
            throw new FalconException("Exception checking if the table is external:" + e.getMessage(), e);
        }
    }
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.