diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/IProtobufWrapper.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ProtobufMessageHandler.java similarity index 89% rename from src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/IProtobufWrapper.java rename to src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ProtobufMessageHandler.java index 049f253acfd..1c84655e3ef 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/IProtobufWrapper.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ProtobufMessageHandler.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package org.apache.hadoop.hbase.stargate.model; +package org.apache.hadoop.hbase.stargate; import java.io.IOException; @@ -27,7 +27,7 @@ import java.io.IOException; * and unmarshalling. Hooks up to the ProtobufMessageBodyConsumer and * ProtobufMessageBodyProducer adapters. */ -public abstract interface IProtobufWrapper { +public abstract interface ProtobufMessageHandler { /** * @return the protobuf represention of the model */ @@ -39,6 +39,6 @@ public abstract interface IProtobufWrapper { * @return reference to self for convenience * @throws IOException */ - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException; } diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellModel.java index d498ece8359..501fa3cd27e 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellModel.java @@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlValue; import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.CellMessage.Cell; import com.google.protobuf.ByteString; @@ -37,10 +38,24 @@ import com.google.protobuf.ByteString; * Representation of a cell. A cell is a single value associated a column and * optional qualifier, and either the timestamp when it was stored or the user- * provided timestamp if one was explicitly supplied. + * + *
+ * <complexType name="Cell"> + * <sequence> + * <element name="value" maxOccurs="1" minOccurs="1"> + * <simpleType> + * <restriction base="base64Binary"/> + * </simpleType> + * </element> + * </sequence> + * <attribute name="column" type="base64Binary" /> + * <attribute name="timestamp" type="int" /> + * </complexType> + **/ @XmlRootElement(name="Cell") @XmlType(propOrder={"column","timestamp"}) -public class CellModel implements IProtobufWrapper, Serializable { +public class CellModel implements ProtobufMessageHandler, Serializable { private static final long serialVersionUID = 1L; private long timestamp; @@ -138,7 +153,7 @@ public class CellModel implements IProtobufWrapper, Serializable { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { Cell.Builder builder = Cell.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellSetModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellSetModel.java index ed55f31b032..aa87f8e7f65 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellSetModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/CellSetModel.java @@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlElement; import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.CellMessage.Cell; import org.apache.hadoop.hbase.stargate.protobuf.generated.CellSetMessage.CellSet; @@ -37,9 +38,38 @@ import com.google.protobuf.ByteString; /** * Representation of a grouping of cells. May contain cells from more than * one row. Encapsulates RowModel and CellModel models. + * + *
+ * <complexType name="CellSet"> + * <sequence> + * <element name="row" type="tns:Row" maxOccurs="unbounded" + * minOccurs="1"></element> + * </sequence> + * </complexType> + * + * <complexType name="Row"> + * <sequence> + * <element name="key" type="base64Binary"></element> + * <element name="cell" type="tns:Cell" + * maxOccurs="unbounded" minOccurs="1"></element> + * </sequence> + * </complexType> + * + * <complexType name="Cell"> + * <sequence> + * <element name="value" maxOccurs="1" minOccurs="1"> + * <simpleType> + * <restriction base="base64Binary"/> + * </simpleType> + * </element> + * </sequence> + * <attribute name="column" type="base64Binary" /> + * <attribute name="timestamp" type="int" /> + * </complexType> + **/ @XmlRootElement(name="CellSet") -public class CellSetModel implements Serializable, IProtobufWrapper { +public class CellSetModel implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; @@ -97,7 +127,7 @@ public class CellSetModel implements Serializable, IProtobufWrapper { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { CellSet.Builder builder = CellSet.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ColumnSchemaModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ColumnSchemaModel.java index 4db4908435b..76842d5a0f3 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ColumnSchemaModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ColumnSchemaModel.java @@ -35,6 +35,13 @@ import org.apache.hadoop.hbase.HConstants; /** * Representation of a column family schema. + * + *
+ * <complexType name="ColumnSchema"> + * <attribute name="name" type="string"></attribute> + * <anyAttribute></anyAttribute> + * </complexType> + **/ @XmlRootElement(name="ColumnSchema") @XmlType(propOrder = {"name"}) diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ModelSchema.xsd b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ModelSchema.xsd new file mode 100755 index 00000000000..9ba45d2a987 --- /dev/null +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ModelSchema.xsd @@ -0,0 +1,133 @@ + +
+ * <complexType name="Row"> + * <sequence> + * <element name="key" type="base64Binary"></element> + * <element name="cell" type="tns:Cell" + * maxOccurs="unbounded" minOccurs="1"></element> + * </sequence> + * </complexType> + **/ @XmlRootElement(name="Row") -public class RowModel implements IProtobufWrapper, Serializable { +public class RowModel implements ProtobufMessageHandler, Serializable { private static final long serialVersionUID = 1L; private byte[] key; @@ -121,7 +133,7 @@ public class RowModel implements IProtobufWrapper, Serializable { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { // there is no standalone row protobuf message throw new UnsupportedOperationException( diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ScannerModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ScannerModel.java index f53a3555262..58e53d70dc8 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ScannerModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/ScannerModel.java @@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.ScannerMessage.Scanner; import org.apache.hadoop.hbase.util.Bytes; @@ -36,9 +37,20 @@ import com.google.protobuf.ByteString; /** * A representation of Scanner parameters. + * + *
+ * <complexType name="Scanner"> + * <attribute name="startRow" type="base64Binary"></attribute> + * <attribute name="endRow" type="base64Binary"></attribute> + * <attribute name="columns" type="base64Binary"></attribute> + * <attribute name="batch" type="int"></attribute> + * <attribute name="startTime" type="int"></attribute> + * <attribute name="endTime" type="int"></attribute> + * </complexType> + **/ @XmlRootElement(name="Scanner") -public class ScannerModel implements IProtobufWrapper, Serializable { +public class ScannerModel implements ProtobufMessageHandler, Serializable { private static final long serialVersionUID = 1L; private byte[] startRow = HConstants.EMPTY_START_ROW; @@ -223,7 +235,7 @@ public class ScannerModel implements IProtobufWrapper, Serializable { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { Scanner.Builder builder = Scanner.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterStatusModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterStatusModel.java index b6409be8c9b..924c22586c8 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterStatusModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterStatusModel.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.StorageClusterStatusMessage.StorageClusterStatus; import org.apache.hadoop.hbase.util.Bytes; @@ -46,10 +47,40 @@ import com.google.protobuf.ByteString; *
+ * <complexType name="StorageClusterStatus"> + * <sequence> + * <element name="liveNode" type="tns:Node" + * maxOccurs="unbounded" minOccurs="0"> + * </element> + * <element name="deadNode" type="string" maxOccurs="unbounded" + * minOccurs="0"> + * </element> + * </sequence> + * <attribute name="regions" type="int"></attribute> + * <attribute name="requests" type="int"></attribute> + * <attribute name="averageLoad" type="float"></attribute> + * </complexType> + * + * <complexType name="Node"> + * <sequence> + * <element name="region" type="tns:Region" + * maxOccurs="unbounded" minOccurs="0"></element> + * </sequence> + * <attribute name="name" type="string"></attribute> + * <attribute name="startCode" type="int"></attribute> + * <attribute name="requests" type="int"></attribute> + * </complexType> + * + * <complexType name="Region"> + * <attribute name="name" type="base64Binary"></attribute> + * </complexType> + **/ @XmlRootElement(name="ClusterStatus") public class StorageClusterStatusModel - implements Serializable, IProtobufWrapper { + implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; /** @@ -382,7 +413,7 @@ public class StorageClusterStatusModel } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { StorageClusterStatus.Builder builder = StorageClusterStatus.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterVersionModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterVersionModel.java index 5083ec38b7e..fb5b2205fbd 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterVersionModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/StorageClusterVersionModel.java @@ -26,7 +26,13 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; /** - * Simple representation of the version of the storage cluster (HBase) + * Simple representation of the version of the storage cluster + * + *
+ * <complexType name="StorageClusterVersion"> + * <attribute name="version" type="string"></attribute> + * </complexType> + **/ @XmlRootElement(name="ClusterVersion") public class StorageClusterVersionModel implements Serializable { diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableInfoModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableInfoModel.java index 5d7a880d46e..d36b1f7de8f 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableInfoModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableInfoModel.java @@ -30,16 +30,27 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.TableInfoMessage.TableInfo; import com.google.protobuf.ByteString; /** * Representation of a list of table regions. + * + *
+ * <complexType name="TableInfo"> + * <sequence> + * <element name="region" type="tns:TableRegion" + * maxOccurs="unbounded" minOccurs="1"></element> + * </sequence> + * <attribute name="name" type="string"></attribute> + * </complexType> + **/ @XmlRootElement(name="TableInfo") @XmlType(propOrder = {"name","regions"}) -public class TableInfoModel implements Serializable, IProtobufWrapper { +public class TableInfoModel implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; private String name; @@ -134,7 +145,7 @@ public class TableInfoModel implements Serializable, IProtobufWrapper { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { TableInfo.Builder builder = TableInfo.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableListModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableListModel.java index 86b3f4dec8b..e7c28b434cf 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableListModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableListModel.java @@ -28,13 +28,14 @@ import java.util.List; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.TableListMessage.TableList; /** * Simple representation of a list of table names. */ @XmlRootElement(name="TableList") -public class TableListModel implements Serializable, IProtobufWrapper { +public class TableListModel implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; @@ -99,7 +100,7 @@ public class TableListModel implements Serializable, IProtobufWrapper { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { TableList.Builder builder = TableList.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableModel.java index 90bfd0c9eaf..6142ce0098c 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableModel.java @@ -27,6 +27,14 @@ import javax.xml.bind.annotation.XmlRootElement; /** * Simple representation of a table name. + * + *
+ * <complexType name="Table"> + * <sequence> + * <element name="name" type="string"></element> + * </sequence> + * </complexType> + **/ @XmlRootElement(name="table") public class TableModel implements Serializable { diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableRegionModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableRegionModel.java index 1d16ec95ec6..7658b4e3e3d 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableRegionModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableRegionModel.java @@ -31,6 +31,16 @@ import org.apache.hadoop.hbase.util.Bytes; /** * Representation of a region of a table and its current location on the * storage cluster. + * + *
+ * <complexType name="TableRegion"> + * <attribute name="name" type="string"></attribute> + * <attribute name="id" type="int"></attribute> + * <attribute name="startKey" type="base64Binary"></attribute> + * <attribute name="endKey" type="base64Binary"></attribute> + * <attribute name="location" type="string"></attribute> + * </complexType> + **/ @XmlRootElement(name="Region") @XmlType(propOrder = {"name","id","startKey","endKey","location"}) diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableSchemaModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableSchemaModel.java index 8f0dccb39d3..d2e07b195ef 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableSchemaModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/TableSchemaModel.java @@ -38,15 +38,27 @@ import javax.xml.namespace.QName; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.protobuf.generated.ColumnSchemaMessage.ColumnSchema; import org.apache.hadoop.hbase.stargate.protobuf.generated.TableSchemaMessage.TableSchema; /** * A representation of HBase table descriptors. + * + *
+ * <complexType name="TableSchema"> + * <sequence> + * <element name="column" type="tns:ColumnSchema" + * maxOccurs="unbounded" minOccurs="1"></element> + * </sequence> + * <attribute name="name" type="string"></attribute> + * <anyAttribute></anyAttribute> + * </complexType> + **/ @XmlRootElement(name="TableSchema") @XmlType(propOrder = {"name","columns"}) -public class TableSchemaModel implements Serializable, IProtobufWrapper { +public class TableSchemaModel implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; private static final QName IS_META = new QName(HTableDescriptor.IS_META); private static final QName IS_ROOT = new QName(HTableDescriptor.IS_ROOT); @@ -264,7 +276,7 @@ public class TableSchemaModel implements Serializable, IProtobufWrapper { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { TableSchema.Builder builder = TableSchema.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/VersionModel.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/VersionModel.java index 8138fb72b15..e0d20b30f18 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/VersionModel.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/model/VersionModel.java @@ -27,6 +27,7 @@ import javax.servlet.ServletContext; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler; import org.apache.hadoop.hbase.stargate.RESTServlet; import org.apache.hadoop.hbase.stargate.protobuf.generated.VersionMessage.Version; @@ -44,7 +45,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer; * */ @XmlRootElement(name="Version") -public class VersionModel implements Serializable, IProtobufWrapper { +public class VersionModel implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; @@ -183,7 +184,7 @@ public class VersionModel implements Serializable, IProtobufWrapper { } @Override - public IProtobufWrapper getObjectFromMessage(byte[] message) + public ProtobufMessageHandler getObjectFromMessage(byte[] message) throws IOException { Version.Builder builder = Version.newBuilder(); builder.mergeFrom(message); diff --git a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/provider/JAXBContextResolver.java b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/provider/JAXBContextResolver.java index 51037ad6f21..711b18523d7 100644 --- a/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/provider/JAXBContextResolver.java +++ b/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/provider/JAXBContextResolver.java @@ -83,7 +83,6 @@ public class JAXBContextResolver implements ContextResolver