HBASE-6990 pretty print TTL (Esteban Gutierrez)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1595396 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Hsieh 2014-05-17 00:32:26 +00:00
parent 63292dd6c2
commit 675e004cf1
2 changed files with 24 additions and 3 deletions

View File

@ -39,6 +39,8 @@ import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ColumnFamilySchema
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.PrettyPrinter;
import org.apache.hadoop.hbase.util.PrettyPrinter.Unit;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
@ -929,6 +931,7 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append('{');
s.append(HConstants.NAME);
s.append(" => '");
@ -973,7 +976,7 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
s.append(", ");
s.append(key);
s.append(" => ");
s.append('\'').append(value).append('\'');
s.append('\'').append(PrettyPrinter.format(value, getUnit(key))).append('\'');
}
}
@ -995,7 +998,7 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
printComma = true;
s.append('\'').append(key).append('\'');
s.append(" => ");
s.append('\'').append(value).append('\'');
s.append('\'').append(PrettyPrinter.format(value, getUnit(key))).append('\'');
}
s.append('}');
}
@ -1010,13 +1013,24 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
printCommaForConfiguration = true;
s.append('\'').append(e.getKey()).append('\'');
s.append(" => ");
s.append('\'').append(e.getValue()).append('\'');
s.append('\'').append(PrettyPrinter.format(e.getValue(), getUnit(e.getKey()))).append('\'');
}
s.append("}");
}
return s;
}
public static Unit getUnit(String key) {
Unit unit;
/* TTL for now, we can add more as we neeed */
if (key.equals(HColumnDescriptor.TTL)) {
unit = Unit.TIME_INTERVAL;
} else {
unit = Unit.NONE;
}
return unit;
}
public static Map<String, String> getDefaultValues() {
return Collections.unmodifiableMap(DEFAULT_VALUES);
}

View File

@ -507,6 +507,13 @@ public final class HConstants {
*/
public static final int WEEK_IN_SECONDS = 7 * 24 * 3600;
/**
* Seconds in a day, hour and minute
*/
public static final int DAY_IN_SECONDS = 24 * 60 * 60;
public static final int HOUR_IN_SECONDS = 60 * 60;
public static final int MINUTE_IN_SECONDS = 60;
//TODO: although the following are referenced widely to format strings for
// the shell. They really aren't a part of the public API. It would be
// nice if we could put them somewhere where they did not need to be