use of org.apache.hadoop.hbase.NamespaceDescriptor in project atlas by apache.
the class HBaseBridge method importNameSpaceWithTable.
private void importNameSpaceWithTable(String namespaceToImport, String tableToImport) throws Exception {
importNameSpace(namespaceToImport);
List<HTableDescriptor> hTableDescriptors = new ArrayList<>();
if (StringUtils.isEmpty(tableToImport)) {
List<NamespaceDescriptor> matchingNameSpaceDescriptors = getMatchingNameSpaces(namespaceToImport);
if (CollectionUtils.isNotEmpty(matchingNameSpaceDescriptors)) {
hTableDescriptors = getTableDescriptors(matchingNameSpaceDescriptors);
}
} else {
tableToImport = namespaceToImport + ":" + tableToImport;
HTableDescriptor[] htds = hbaseAdmin.listTables(Pattern.compile(tableToImport));
hTableDescriptors.addAll(Arrays.asList(htds));
}
if (CollectionUtils.isNotEmpty(hTableDescriptors)) {
for (HTableDescriptor htd : hTableDescriptors) {
String tblName = htd.getTableName().getNameAsString();
importTable(tblName);
}
}
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project atlas by apache.
the class HBaseBridge method importNameSpaceAndTable.
private void importNameSpaceAndTable() throws Exception {
NamespaceDescriptor[] namespaceDescriptors = hbaseAdmin.listNamespaceDescriptors();
if (ArrayUtils.isNotEmpty(namespaceDescriptors)) {
for (NamespaceDescriptor namespaceDescriptor : namespaceDescriptors) {
String namespace = namespaceDescriptor.getName();
importNameSpace(namespace);
}
}
HTableDescriptor[] htds = hbaseAdmin.listTables();
if (ArrayUtils.isNotEmpty(htds)) {
for (HTableDescriptor htd : htds) {
String tableName = htd.getNameAsString();
importTable(tableName);
}
}
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project phoenix by apache.
the class ConnectionQueryServicesImpl method ensureNamespaceCreated.
void ensureNamespaceCreated(String schemaName) throws SQLException {
SQLException sqlE = null;
try (HBaseAdmin admin = getAdmin()) {
NamespaceDescriptor namespaceDescriptor = null;
try {
namespaceDescriptor = admin.getNamespaceDescriptor(schemaName);
} catch (org.apache.hadoop.hbase.NamespaceNotFoundException e) {
}
if (namespaceDescriptor == null) {
namespaceDescriptor = NamespaceDescriptor.create(schemaName).build();
admin.createNamespace(namespaceDescriptor);
}
return;
} catch (IOException e) {
sqlE = ServerUtil.parseServerException(e);
} finally {
if (sqlE != null) {
throw sqlE;
}
}
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project pinpoint by naver.
the class HBaseAdminTemplate method createNamespaceIfNotExists.
@Override
public boolean createNamespaceIfNotExists(String namespace) {
return execute(admin -> {
NamespaceDescriptor namespaceDescriptor = NamespaceDescriptor.create(namespace).build();
try {
admin.createNamespace(namespaceDescriptor);
} catch (NamespaceExistException e) {
// ignored
return false;
}
logger.info("{} namespace created.", namespace);
return true;
});
}
use of org.apache.hadoop.hbase.NamespaceDescriptor in project pinpoint by naver.
the class HBaseAdminTemplate method createNamespaceIfNotExists.
@Override
public boolean createNamespaceIfNotExists(String namespace, Map<String, String> configurations) {
return execute(admin -> {
NamespaceDescriptor namespaceDescriptor = NamespaceDescriptor.create(namespace).addConfiguration(configurations).build();
try {
admin.createNamespace(namespaceDescriptor);
} catch (NamespaceExistException e) {
// ignored
return false;
}
logger.info("{} namespace created.", namespace);
return true;
});
}
Aggregations