use of co.cask.cdap.data2.dataset2.lib.table.hbase.MetricHBaseTableUtil.Version in project cdap by caskdata.
the class MetricsDataMigrator method migrateMetricsTables.
public void migrateMetricsTables(HBaseTableUtil hBaseTableUtil, boolean keepOldData) throws DataMigrationException {
Version cdapVersion = findMetricsTableVersion(new MetricHBaseTableUtil(hBaseTableUtil));
if (cdapVersion == Version.VERSION_2_6_OR_LOWER) {
migrateMetricsTableFromVersion26(cdapVersion);
} else if (cdapVersion == Version.VERSION_2_7) {
migrateMetricsTableFromVersion27(cdapVersion);
} else {
System.out.println("Unsupported version" + cdapVersion);
return;
}
if (!keepOldData) {
System.out.println("Performing cleanup of old metrics tables");
cleanUpOldTables(cdapVersion);
}
}
use of co.cask.cdap.data2.dataset2.lib.table.hbase.MetricHBaseTableUtil.Version in project cdap by caskdata.
the class HBaseTable method undo.
@Override
protected void undo(NavigableMap<byte[], NavigableMap<byte[], Update>> persisted) throws Exception {
if (persisted.isEmpty()) {
return;
}
// NOTE: we use Delete with the write pointer as the specific version to delete.
List<Delete> deletes = Lists.newArrayList();
for (Map.Entry<byte[], NavigableMap<byte[], Update>> row : persisted.entrySet()) {
DeleteBuilder delete = tableUtil.buildDelete(row.getKey());
delete.setAttribute(TX_MAX_LIFETIME_MILLIS_KEY, txMaxLifetimeMillis);
for (Map.Entry<byte[], Update> column : row.getValue().entrySet()) {
// we want support tx and non-tx modes
if (tx != null) {
delete.setAttribute(TxConstants.TX_ROLLBACK_ATTRIBUTE_KEY, new byte[0]);
// TODO: hijacking timestamp... bad
delete.deleteColumn(columnFamily, column.getKey(), tx.getWritePointer());
} else {
delete.deleteColumns(columnFamily, column.getKey());
}
}
deletes.add(delete.build());
}
if (!deletes.isEmpty()) {
hbaseDelete(deletes);
}
}
use of co.cask.cdap.data2.dataset2.lib.table.hbase.MetricHBaseTableUtil.Version in project cdap by caskdata.
the class InMemoryTableService method merge.
private static void merge(ConcurrentNavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, Update>>> table, byte[] row, Map<byte[], Update> changes, long version) {
// get the correct row from the table, create it if it doesn't exist
NavigableMap<byte[], NavigableMap<Long, Update>> rowMap = table.get(row);
if (rowMap == null) {
rowMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
table.put(row, rowMap);
}
// now merge the changes into the row, one by one
for (Map.Entry<byte[], Update> keyVal : changes.entrySet()) {
// create the column in the row if it does not exist
NavigableMap<Long, Update> colMap = rowMap.get(keyVal.getKey());
if (colMap == null) {
colMap = Maps.newTreeMap();
rowMap.put(keyVal.getKey(), colMap);
}
// put into the column with given version
Update merged = Updates.mergeUpdates(colMap.get(version), keyVal.getValue());
colMap.put(version, merged);
}
}
use of co.cask.cdap.data2.dataset2.lib.table.hbase.MetricHBaseTableUtil.Version in project cdap by caskdata.
the class MdsKey method getMetadataKey.
static String getMetadataKey(String type, byte[] rowKey) {
MDSKey.Splitter keySplitter = new MDSKey(rowKey).split();
// The rowkey is
// [rowPrefix][targetType][targetId][key] for value rows and
// [rowPrefix][targetType][targetId][key][index] for value index rows
// so skip the first few strings.
// Skip rowType
keySplitter.skipBytes();
// Skip targetType
keySplitter.skipString();
// Skip targetId
if (type.equals(EntityIdKeyHelper.TYPE_MAP.get(ProgramId.class))) {
keySplitter.skipString();
keySplitter.skipString();
keySplitter.skipString();
keySplitter.skipString();
} else if (type.equals(EntityIdKeyHelper.TYPE_MAP.get(ApplicationId.class))) {
keySplitter.skipString();
keySplitter.skipString();
} else if (type.equals(EntityIdKeyHelper.TYPE_MAP.get(DatasetId.class))) {
keySplitter.skipString();
keySplitter.skipString();
} else if (type.equals(EntityIdKeyHelper.TYPE_MAP.get(StreamId.class))) {
keySplitter.skipString();
keySplitter.skipString();
} else if (type.equals(EntityIdKeyHelper.TYPE_MAP.get(StreamViewId.class))) {
// skip namespace, stream, view
keySplitter.skipString();
keySplitter.skipString();
keySplitter.skipString();
} else if (type.equals(EntityIdKeyHelper.TYPE_MAP.get(ArtifactId.class))) {
// skip namespace, name, version
keySplitter.skipString();
keySplitter.skipString();
keySplitter.skipString();
} else {
throw new IllegalArgumentException("Illegal Type " + type + " of metadata source.");
}
return keySplitter.getString();
}
Aggregations