Search in sources :

Example 56 with NamespaceId

use of co.cask.cdap.proto.id.NamespaceId in project cdap by caskdata.

the class GenerateClientUsageExample method metricsClient.

public void metricsClient() throws Exception {
    // Construct the client used to interact with CDAP
    MetricsClient metricsClient = new MetricsClient(clientConfig);
    // Fetch the total number of events that have been processed by a flowlet
    RuntimeMetrics metric = metricsClient.getFlowletMetrics(new NamespaceId("user").app("HelloWorld").flow("someFlow").flowlet("process.events.processed"));
}
Also used : MetricsClient(co.cask.cdap.client.MetricsClient) RuntimeMetrics(co.cask.cdap.api.metrics.RuntimeMetrics) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Example 57 with NamespaceId

use of co.cask.cdap.proto.id.NamespaceId in project cdap by caskdata.

the class AbstractHBaseTableUtilTest method drop.

private void drop(TableId tableId) throws IOException {
    HBaseTableUtil tableUtil = getTableUtil();
    TableId hTableId = tableUtil.createHTableId(new NamespaceId(tableId.getNamespace()), tableId.getTableName());
    tableUtil.dropTable(ddlExecutor, hTableId);
}
Also used : TableId(co.cask.cdap.data2.util.TableId) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Example 58 with NamespaceId

use of co.cask.cdap.proto.id.NamespaceId in project cdap by caskdata.

the class AbstractHBaseTableUtilTest method enable.

private void enable(String namespace, String tableName) throws IOException {
    HBaseTableUtil tableUtil = getTableUtil();
    TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName);
    TableName name = HTableNameConverter.toTableName(getPrefix(), hTableId);
    ddlExecutor.enableTableIfDisabled(name.getNamespaceAsString(), name.getQualifierAsString());
}
Also used : TableId(co.cask.cdap.data2.util.TableId) TableName(org.apache.hadoop.hbase.TableName) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Example 59 with NamespaceId

use of co.cask.cdap.proto.id.NamespaceId in project cdap by caskdata.

the class AbstractHBaseTableUtilTest method truncate.

private void truncate(String namespace, String tableName) throws IOException {
    HBaseTableUtil tableUtil = getTableUtil();
    TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName);
    tableUtil.truncateTable(ddlExecutor, hTableId);
}
Also used : TableId(co.cask.cdap.data2.util.TableId) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Example 60 with NamespaceId

use of co.cask.cdap.proto.id.NamespaceId in project cdap by caskdata.

the class AbstractHBaseTableUtilTest method writeSome.

private void writeSome(String namespace, String tableName) throws IOException {
    HBaseTableUtil tableUtil = getTableUtil();
    TableId hTableId = tableUtil.createHTableId(new NamespaceId(namespace), tableName);
    try (HTable table = tableUtil.createHTable(TEST_HBASE.getConfiguration(), hTableId)) {
        // writing at least couple megs to reflect in "megabyte"-based metrics
        for (int i = 0; i < 8; i++) {
            Put put = new Put(Bytes.toBytes("row" + i));
            put.add(Bytes.toBytes("d"), Bytes.toBytes("col" + i), new byte[1024 * 1024]);
            table.put(put);
        }
    }
}
Also used : TableId(co.cask.cdap.data2.util.TableId) NamespaceId(co.cask.cdap.proto.id.NamespaceId) HTable(org.apache.hadoop.hbase.client.HTable) Put(org.apache.hadoop.hbase.client.Put)

Aggregations

NamespaceId (co.cask.cdap.proto.id.NamespaceId)234 Test (org.junit.Test)99 Path (javax.ws.rs.Path)47 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)43 ApplicationId (co.cask.cdap.proto.id.ApplicationId)35 IOException (java.io.IOException)34 StreamId (co.cask.cdap.proto.id.StreamId)30 DatasetId (co.cask.cdap.proto.id.DatasetId)27 TableId (co.cask.cdap.data2.util.TableId)26 Id (co.cask.cdap.proto.Id)24 ProgramId (co.cask.cdap.proto.id.ProgramId)24 NotFoundException (co.cask.cdap.common.NotFoundException)22 ArtifactId (co.cask.cdap.proto.id.ArtifactId)21 BadRequestException (co.cask.cdap.common.BadRequestException)20 TopicId (co.cask.cdap.proto.id.TopicId)19 GET (javax.ws.rs.GET)18 Location (org.apache.twill.filesystem.Location)18 ArrayList (java.util.ArrayList)15 TopicMetadata (co.cask.cdap.messaging.TopicMetadata)13 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)12