Search in sources :

Example 1 with CoprocessorDescriptor

use of co.cask.cdap.spi.hbase.CoprocessorDescriptor in project cdap by caskdata.

the class HBase10CDH550TableDescriptorUtil method getHTableDescriptor.

public static HTableDescriptor getHTableDescriptor(TableDescriptor descriptor) {
    TableName tableName = TableName.valueOf(descriptor.getNamespace(), descriptor.getName());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    for (Map.Entry<String, ColumnFamilyDescriptor> family : descriptor.getFamilies().entrySet()) {
        htd.addFamily(getHColumnDesciptor(family.getValue()));
    }
    for (Map.Entry<String, CoprocessorDescriptor> coprocessor : descriptor.getCoprocessors().entrySet()) {
        CoprocessorDescriptor cpd = coprocessor.getValue();
        try {
            Path path = cpd.getPath() == null ? null : new Path(cpd.getPath());
            htd.addCoprocessor(cpd.getClassName(), path, cpd.getPriority(), cpd.getProperties());
        } catch (IOException e) {
            LOG.error("Error adding coprocessor.", e);
        }
    }
    for (Map.Entry<String, String> property : descriptor.getProperties().entrySet()) {
        htd.setValue(property.getKey(), property.getValue());
    }
    return htd;
}
Also used : Path(org.apache.hadoop.fs.Path) TableName(org.apache.hadoop.hbase.TableName) IOException(java.io.IOException) ColumnFamilyDescriptor(co.cask.cdap.spi.hbase.ColumnFamilyDescriptor) CoprocessorDescriptor(co.cask.cdap.spi.hbase.CoprocessorDescriptor) HashMap(java.util.HashMap) Map(java.util.Map) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 2 with CoprocessorDescriptor

use of co.cask.cdap.spi.hbase.CoprocessorDescriptor in project cdap by caskdata.

the class HBase96TableDescriptorUtil method getTableDescriptor.

public static TableDescriptor getTableDescriptor(HTableDescriptor descriptor) {
    Set<ColumnFamilyDescriptor> families = new HashSet<>();
    for (HColumnDescriptor family : descriptor.getColumnFamilies()) {
        families.add(getColumnFamilyDescriptor(family));
    }
    Set<CoprocessorDescriptor> coprocessors = new HashSet<>();
    coprocessors.addAll(CoprocessorUtil.getCoprocessors(descriptor).values());
    Map<String, String> properties = CoprocessorUtil.getNonCoprocessorProperties(descriptor);
    // TODO: should add configurations as well
    return new TableDescriptor(descriptor.getTableName().getNamespaceAsString(), descriptor.getTableName().getQualifierAsString(), families, coprocessors, properties);
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) ColumnFamilyDescriptor(co.cask.cdap.spi.hbase.ColumnFamilyDescriptor) CoprocessorDescriptor(co.cask.cdap.spi.hbase.CoprocessorDescriptor) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) TableDescriptor(co.cask.cdap.spi.hbase.TableDescriptor) HashSet(java.util.HashSet)

Example 3 with CoprocessorDescriptor

use of co.cask.cdap.spi.hbase.CoprocessorDescriptor in project cdap by caskdata.

the class HBase96TableDescriptorUtil method getHTableDescriptor.

public static HTableDescriptor getHTableDescriptor(TableDescriptor descriptor) {
    TableName tableName = TableName.valueOf(descriptor.getNamespace(), descriptor.getName());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    for (Map.Entry<String, ColumnFamilyDescriptor> family : descriptor.getFamilies().entrySet()) {
        htd.addFamily(getHColumnDesciptor(family.getValue()));
    }
    for (Map.Entry<String, CoprocessorDescriptor> coprocessor : descriptor.getCoprocessors().entrySet()) {
        CoprocessorDescriptor cpd = coprocessor.getValue();
        try {
            Path path = cpd.getPath() == null ? null : new Path(cpd.getPath());
            htd.addCoprocessor(cpd.getClassName(), path, cpd.getPriority(), cpd.getProperties());
        } catch (IOException e) {
            LOG.error("Error adding coprocessor.", e);
        }
    }
    for (Map.Entry<String, String> property : descriptor.getProperties().entrySet()) {
        htd.setValue(property.getKey(), property.getValue());
    }
    return htd;
}
Also used : Path(org.apache.hadoop.fs.Path) TableName(org.apache.hadoop.hbase.TableName) IOException(java.io.IOException) ColumnFamilyDescriptor(co.cask.cdap.spi.hbase.ColumnFamilyDescriptor) CoprocessorDescriptor(co.cask.cdap.spi.hbase.CoprocessorDescriptor) HashMap(java.util.HashMap) Map(java.util.Map) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 4 with CoprocessorDescriptor

use of co.cask.cdap.spi.hbase.CoprocessorDescriptor in project cdap by caskdata.

the class HBase10CDHTableDescriptorUtil method getHTableDescriptor.

public static HTableDescriptor getHTableDescriptor(TableDescriptor descriptor) {
    TableName tableName = TableName.valueOf(descriptor.getNamespace(), descriptor.getName());
    HTableDescriptor htd = new HTableDescriptor(tableName);
    for (Map.Entry<String, ColumnFamilyDescriptor> family : descriptor.getFamilies().entrySet()) {
        htd.addFamily(getHColumnDesciptor(family.getValue()));
    }
    for (Map.Entry<String, CoprocessorDescriptor> coprocessor : descriptor.getCoprocessors().entrySet()) {
        CoprocessorDescriptor cpd = coprocessor.getValue();
        try {
            Path path = cpd.getPath() == null ? null : new Path(cpd.getPath());
            htd.addCoprocessor(cpd.getClassName(), path, cpd.getPriority(), cpd.getProperties());
        } catch (IOException e) {
            LOG.error("Error adding coprocessor.", e);
        }
    }
    for (Map.Entry<String, String> property : descriptor.getProperties().entrySet()) {
        htd.setValue(property.getKey(), property.getValue());
    }
    return htd;
}
Also used : Path(org.apache.hadoop.fs.Path) TableName(org.apache.hadoop.hbase.TableName) IOException(java.io.IOException) ColumnFamilyDescriptor(co.cask.cdap.spi.hbase.ColumnFamilyDescriptor) CoprocessorDescriptor(co.cask.cdap.spi.hbase.CoprocessorDescriptor) HashMap(java.util.HashMap) Map(java.util.Map) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 5 with CoprocessorDescriptor

use of co.cask.cdap.spi.hbase.CoprocessorDescriptor in project cdap by caskdata.

the class AbstractHBaseDataSetAdmin method addCoprocessor.

protected void addCoprocessor(HTableDescriptorBuilder tableDescriptor, Class<? extends Coprocessor> coprocessor, Integer priority) throws IOException {
    CoprocessorDescriptor descriptor = coprocessorManager.getCoprocessorDescriptor(coprocessor, priority);
    Path path = descriptor.getPath() == null ? null : new Path(descriptor.getPath());
    tableDescriptor.addCoprocessor(descriptor.getClassName(), path, descriptor.getPriority(), descriptor.getProperties());
}
Also used : Path(org.apache.hadoop.fs.Path) CoprocessorDescriptor(co.cask.cdap.spi.hbase.CoprocessorDescriptor)

Aggregations

CoprocessorDescriptor (co.cask.cdap.spi.hbase.CoprocessorDescriptor)18 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)15 ColumnFamilyDescriptor (co.cask.cdap.spi.hbase.ColumnFamilyDescriptor)14 Path (org.apache.hadoop.fs.Path)10 Map (java.util.Map)9 HashMap (java.util.HashMap)8 TableDescriptor (co.cask.cdap.spi.hbase.TableDescriptor)7 IOException (java.io.IOException)7 HashSet (java.util.HashSet)7 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)7 TableName (org.apache.hadoop.hbase.TableName)7 ProjectInfo (co.cask.cdap.common.utils.ProjectInfo)1 HTableDescriptorBuilder (co.cask.cdap.data2.util.hbase.HTableDescriptorBuilder)1 HBaseDDLExecutor (co.cask.cdap.spi.hbase.HBaseDDLExecutor)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Matcher (java.util.regex.Matcher)1 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)1 ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)1 Location (org.apache.twill.filesystem.Location)1