Skip to content

Commit

Permalink
HBASE-1064 HBase REST xml/json improvements
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@736503 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
saintstack committed Jan 22, 2009
1 parent e3665e1 commit 7fa5fe9
Show file tree
Hide file tree
Showing 55 changed files with 5,545 additions and 1,731 deletions.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ Release 0.20.0 - Unreleased
HBASE-1031 Add the Zookeeper jar
HBASE-1142 Cleanup thrift server; remove Text and profuse DEBUG messaging
(Tim Sell via Stack)
HBASE-1064 HBase REST xml/json improvements (Brian Beggs working of
initial Michael Gottesman work via Stack)

Release 0.19.0 - Unreleased
Release 0.19.0 - 01/21/2009
INCOMPATIBLE CHANGES
HBASE-885 TableMap and TableReduce should be interfaces
(Doğacan Güney via Stack)
Expand Down
34 changes: 34 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,42 @@ Foundation (http://www.apache.org/).

In addition, this product includes software developed by:


European Commission project OneLab (http://www.one-lab.org)


Facebook, Inc. (http://developers.facebook.com/thrift/ -- Page includes the Thrift Software License)


JUnit (http://www.junit.org/)


Michael Gottesman developed AgileJSON. Its source code is here:

http://github.com/gottesmm/agile-json-2.0/tree/master

It has this license at the head of the each source file:

* Permission is hereby granted, free of charge, to any person obtaining a
* copy
* of this software and associated documentation files (the "Software"), to
* deal
* in the Software without restriction, including without limitation the
* rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all
* copies or substantial portions of the Software.
*
* The Software shall be used for Good, not Evil.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
Binary file added lib/AgileJSON-2.0.jar
Binary file not shown.
23 changes: 22 additions & 1 deletion src/java/org/apache/hadoop/hbase/HColumnDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
import java.util.Map;

import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.rest.exception.HBaseRestException;
import org.apache.hadoop.hbase.rest.serializer.IRestSerializer;
import org.apache.hadoop.hbase.rest.serializer.ISerializable;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;

import agilejson.TOJSON;

/**
* An HColumnDescriptor contains information about a column family such as the
* number of versions, compression settings, etc.
Expand All @@ -40,7 +45,7 @@
* column and recreating it. If there is data stored in the column, it will be
* deleted when the column is deleted.
*/
public class HColumnDescriptor implements WritableComparable<HColumnDescriptor> {
public class HColumnDescriptor implements ISerializable, WritableComparable<HColumnDescriptor> {
// For future backward compatibility

// Version 3 was when column names become byte arrays and when we picked up
Expand Down Expand Up @@ -257,6 +262,7 @@ public HColumnDescriptor(final byte [] familyName, final int maxVersions,
/**
* @return Name of this column family with colon as required by client API
*/
@TOJSON(fieldName = "name", base64=true)
public byte [] getNameWithColon() {
return HStoreKey.addDelimiter(this.name);
}
Expand Down Expand Up @@ -315,6 +321,7 @@ public void setValue(String key, String value) {
}

/** @return compression type being used for the column family */
@TOJSON
public CompressionType getCompression() {
String value = getValue(COMPRESSION);
if (value != null) {
Expand All @@ -327,6 +334,7 @@ else if (value.equalsIgnoreCase("RECORD"))
}

/** @return maximum number of versions */
@TOJSON
public int getMaxVersions() {
String value = getValue(HConstants.VERSIONS);
if (value != null)
Expand All @@ -344,6 +352,7 @@ public void setMaxVersions(int maxVersions) {
/**
* @return Compression type setting.
*/
@TOJSON
public CompressionType getCompressionType() {
return getCompression();
}
Expand All @@ -364,6 +373,7 @@ public void setCompressionType(CompressionType type) {
/**
* @return True if we are to keep all in use HRegionServer cache.
*/
@TOJSON(prefixLength = 2)
public boolean isInMemory() {
String value = getValue(HConstants.IN_MEMORY);
if (value != null)
Expand All @@ -382,6 +392,7 @@ public void setInMemory(boolean inMemory) {
/**
* @return Maximum value length.
*/
@TOJSON
public synchronized int getMaxValueLength() {
if (this.maxValueLength == null) {
String value = getValue(LENGTH);
Expand All @@ -402,6 +413,7 @@ public void setMaxValueLength(int maxLength) {
/**
* @return Time-to-live of cell contents, in seconds.
*/
@TOJSON
public int getTimeToLive() {
String value = getValue(TTL);
return (value != null)? Integer.valueOf(value).intValue(): DEFAULT_TTL;
Expand All @@ -417,6 +429,7 @@ public void setTimeToLive(int timeToLive) {
/**
* @return True if MapFile blocks should be cached.
*/
@TOJSON(prefixLength = 2)
public boolean isBlockCacheEnabled() {
String value = getValue(BLOCKCACHE);
if (value != null)
Expand All @@ -434,6 +447,7 @@ public void setBlockCacheEnabled(boolean blockCacheEnabled) {
/**
* @return true if a bloom filter is enabled
*/
@TOJSON(prefixLength = 2)
public boolean isBloomfilter() {
String value = getValue(BLOOMFILTER);
if (value != null)
Expand Down Expand Up @@ -577,4 +591,11 @@ else if (result > 0)
}
return result;
}

/* (non-Javadoc)
* @see org.apache.hadoop.hbase.rest.xml.IOutputXML#toXML()
*/
public void restSerialize(IRestSerializer serializer) throws HBaseRestException {
serializer.serializeColumnDescriptor(this);
}
}
20 changes: 19 additions & 1 deletion src/java/org/apache/hadoop/hbase/HTableDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.client.tableindexed.IndexSpecification;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.rest.exception.HBaseRestException;
import org.apache.hadoop.hbase.rest.serializer.IRestSerializer;
import org.apache.hadoop.hbase.rest.serializer.ISerializable;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.WritableComparable;

import agilejson.TOJSON;

/**
* HTableDescriptor contains the name of an HTable, and its
* column families.
*/
public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
public class HTableDescriptor implements WritableComparable<HTableDescriptor>, ISerializable {

// Changes prior to version 3 were not recorded here.
// Version 3 adds metadata as a map where keys and values are byte[].
Expand Down Expand Up @@ -383,6 +388,7 @@ public void setReadOnly(final boolean readOnly) {
}

/** @return name of table */
@TOJSON
public byte [] getName() {
return name;
}
Expand Down Expand Up @@ -621,6 +627,11 @@ else if (result > 0)
public Collection<HColumnDescriptor> getFamilies() {
return Collections.unmodifiableCollection(this.families.values());
}

@TOJSON(fieldName = "columns")
public HColumnDescriptor[] getColumnFamilies() {
return getFamilies().toArray(new HColumnDescriptor[0]);
}

/**
* @param column
Expand Down Expand Up @@ -667,4 +678,11 @@ public static Path getTableDir(Path rootdir, final byte [] tableName) {
new HColumnDescriptor(HConstants.COLUMN_FAMILY_HISTORIAN,
HConstants.ALL_VERSIONS, HColumnDescriptor.CompressionType.NONE,
false, false, Integer.MAX_VALUE, HConstants.WEEK_IN_SECONDS, false)});

/* (non-Javadoc)
* @see org.apache.hadoop.hbase.rest.xml.IOutputXML#toXML()
*/
public void restSerialize(IRestSerializer serializer) throws HBaseRestException {
serializer.serializeTableDescriptor(this);
}
}
2 changes: 1 addition & 1 deletion src/java/org/apache/hadoop/hbase/RegionHistorian.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ public void offline() {
LOG.debug("Offlined");
}
}
}
}
Loading

0 comments on commit 7fa5fe9

Please sign in to comment.