use of co.cask.cdap.data2.datafabric.DefaultDatasetNamespace in project cdap by caskdata.
the class MetricsDataMigrator method findMetricsTableVersion.
@Nullable
private Version findMetricsTableVersion(MetricHBaseTableUtil metricHBaseTableUtil) {
// Figure out what is the latest working version of CDAP
// 1) if latest is 2.8.x - nothing to do, if "pre-2.8", proceed to next step.
// 2) find a most recent metrics table: start by looking for 2.7, then 2.6
// 3) if we find 2.7 - we will migrate data from 2.7 table, if not - migrate data from 2.6 metrics table
// todo - use UpgradeTool to figure out if version is 2.8.x, return if it is 2.8.x
String tableName27 = cConf.get(Constants.Metrics.METRICS_TABLE_PREFIX, UpgradeMetricsConstants.DEFAULT_METRICS_TABLE_PREFIX) + ".agg";
// versions older than 2.7, has two metrics table, identified by system and user prefix
String tableName26 = "system." + tableName27;
DefaultDatasetNamespace defaultDatasetNamespace = new DefaultDatasetNamespace(cConf);
String metricsEntityTable26 = defaultDatasetNamespace.namespace(NamespaceId.SYSTEM, tableName26);
String metricsEntityTable27 = defaultDatasetNamespace.namespace(NamespaceId.SYSTEM, tableName27);
Version version = null;
try (HBaseAdmin hAdmin = new HBaseAdmin(hConf)) {
for (HTableDescriptor desc : hAdmin.listTables()) {
if (desc.getNameAsString().equals(metricsEntityTable27)) {
System.out.println("Matched HBase Table Name For Migration " + desc.getNameAsString());
version = metricHBaseTableUtil.getVersion(desc);
version = verifyVersion(Version.VERSION_2_7, version);
if (version == null) {
return null;
}
break;
}
if (desc.getNameAsString().equals(metricsEntityTable26)) {
System.out.println("Matched HBase Table Name For Migration " + desc.getNameAsString());
version = metricHBaseTableUtil.getVersion(desc);
version = verifyVersion(Version.VERSION_2_6_OR_LOWER, version);
if (version == null) {
return null;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return version;
}
use of co.cask.cdap.data2.datafabric.DefaultDatasetNamespace in project cdap by caskdata.
the class MetricsDataMigrator method addTableNamesToDelete.
private void addTableNamesToDelete(Set<String> tablesToDelete, CConfiguration cConf, String scope, List<Integer> resolutions) {
DefaultDatasetNamespace defaultDatasetNamespace = new DefaultDatasetNamespace(cConf);
tablesToDelete.add(addNamespace(defaultDatasetNamespace, scope, entityTableName));
// add aggregates table
tablesToDelete.add(addNamespace(defaultDatasetNamespace, scope, metricsTableName));
// add timeseries tables
for (int resolution : resolutions) {
tablesToDelete.add(addNamespace(defaultDatasetNamespace, scope, metricsTableNamePrefix + ".ts." + resolution));
}
}
Aggregations