javadoc and model improvements from Stargate github

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@791045 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2009-07-04 01:28:03 +00:00
parent 90366d50f8
commit 22aaa2c118
18 changed files with 323 additions and 35 deletions

View File

@ -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;
}

View File

@ -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.
*
* <pre>
* &lt;complexType name="Cell"&gt;
* &lt;sequence&gt;
* &lt;element name="value" maxOccurs="1" minOccurs="1"&gt;
* &lt;simpleType&gt;
* &lt;restriction base="base64Binary"/&gt;
* &lt;/simpleType&gt;
* &lt;/element&gt;
* &lt;/sequence&gt;
* &lt;attribute name="column" type="base64Binary" /&gt;
* &lt;attribute name="timestamp" type="int" /&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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);

View File

@ -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.
*
* <pre>
* &lt;complexType name="CellSet"&gt;
* &lt;sequence&gt;
* &lt;element name="row" type="tns:Row" maxOccurs="unbounded"
* minOccurs="1"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;/complexType&gt;
*
* &lt;complexType name="Row"&gt;
* &lt;sequence&gt;
* &lt;element name="key" type="base64Binary"&gt;&lt;/element&gt;
* &lt;element name="cell" type="tns:Cell"
* maxOccurs="unbounded" minOccurs="1"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;/complexType&gt;
*
* &lt;complexType name="Cell"&gt;
* &lt;sequence&gt;
* &lt;element name="value" maxOccurs="1" minOccurs="1"&gt;
* &lt;simpleType&gt;
* &lt;restriction base="base64Binary"/&gt;
* &lt;/simpleType&gt;
* &lt;/element&gt;
* &lt;/sequence&gt;
* &lt;attribute name="column" type="base64Binary" /&gt;
* &lt;attribute name="timestamp" type="int" /&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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);

View File

@ -35,6 +35,13 @@ import org.apache.hadoop.hbase.HConstants;
/**
* Representation of a column family schema.
*
* <pre>
* &lt;complexType name="ColumnSchema"&gt;
* &lt;attribute name="name" type="string"&gt;&lt;/attribute&gt;
* &lt;anyAttribute&gt;&lt;/anyAttribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@XmlRootElement(name="ColumnSchema")
@XmlType(propOrder = {"name"})

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="ModelSchema" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="ModelSchema">
<element name="CellSet" type="tns:CellSet"></element>
<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"></restriction></simpleType></element>
</sequence>
<attribute name="column" type="base64Binary" />
<attribute name="timestamp" type="int" />
</complexType>
<element name="Version" type="tns:Version"></element>
<complexType name="Version">
<attribute name="Stargate" type="string"></attribute>
<attribute name="JVM" type="string"></attribute>
<attribute name="OS" type="string"></attribute>
<attribute name="Server" type="string"></attribute>
<attribute name="Jersey" type="string"></attribute>
</complexType>
<element name="TableList" type="tns:TableList"></element>
<complexType name="TableList">
<sequence>
<element name="table" type="tns:Table" maxOccurs="unbounded" minOccurs="1"></element>
</sequence>
</complexType>
<complexType name="Table">
<sequence>
<element name="name" type="string"></element>
</sequence>
</complexType>
<element name="TableInfo" type="tns:TableInfo"></element>
<complexType name="TableInfo">
<sequence>
<element name="region" type="tns:TableRegion" maxOccurs="unbounded" minOccurs="1"></element>
</sequence>
<attribute name="name" type="string"></attribute>
</complexType>
<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>
<element name="TableSchema" type="tns:TableSchema"></element>
<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>
<complexType name="ColumnSchema">
<attribute name="name" type="string"></attribute>
<anyAttribute></anyAttribute>
</complexType>
<element name="Scanner" type="tns:Scanner"></element>
<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>
<element name="StorageClusterVersion"
type="tns:StorageClusterVersion">
</element>
<complexType name="StorageClusterVersion">
<attribute name="version" type="string"></attribute>
</complexType>
<element name="StorageClusterStatus"
type="tns:StorageClusterStatus">
</element>
<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>
</schema>

View File

@ -29,13 +29,25 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler;
/**
* Representation of a row. A row is a related set of cells, grouped by common
* row key. RowModels do not appear in results by themselves. They are always
* encapsulated within CellSetModels.
*
* <pre>
* &lt;complexType name="Row"&gt;
* &lt;sequence&gt;
* &lt;element name="key" type="base64Binary"&gt;&lt;/element&gt;
* &lt;element name="cell" type="tns:Cell"
* maxOccurs="unbounded" minOccurs="1"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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(

View File

@ -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.
*
* <pre>
* &lt;complexType name="Scanner"&gt;
* &lt;attribute name="startRow" type="base64Binary"&gt;&lt;/attribute&gt;
* &lt;attribute name="endRow" type="base64Binary"&gt;&lt;/attribute&gt;
* &lt;attribute name="columns" type="base64Binary"&gt;&lt;/attribute&gt;
* &lt;attribute name="batch" type="int"&gt;&lt;/attribute&gt;
* &lt;attribute name="startTime" type="int"&gt;&lt;/attribute&gt;
* &lt;attribute name="endTime" type="int"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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);

View File

@ -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;
* <li>liveNodes: detailed status of the live region servers</li>
* <li>deadNodes: the names of region servers declared dead</li>
* </ul>
*
* <pre>
* &lt;complexType name="StorageClusterStatus"&gt;
* &lt;sequence&gt;
* &lt;element name="liveNode" type="tns:Node"
* maxOccurs="unbounded" minOccurs="0"&gt;
* &lt;/element&gt;
* &lt;element name="deadNode" type="string" maxOccurs="unbounded"
* minOccurs="0"&gt;
* &lt;/element&gt;
* &lt;/sequence&gt;
* &lt;attribute name="regions" type="int"&gt;&lt;/attribute&gt;
* &lt;attribute name="requests" type="int"&gt;&lt;/attribute&gt;
* &lt;attribute name="averageLoad" type="float"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
*
* &lt;complexType name="Node"&gt;
* &lt;sequence&gt;
* &lt;element name="region" type="tns:Region"
* maxOccurs="unbounded" minOccurs="0"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;attribute name="name" type="string"&gt;&lt;/attribute&gt;
* &lt;attribute name="startCode" type="int"&gt;&lt;/attribute&gt;
* &lt;attribute name="requests" type="int"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
*
* &lt;complexType name="Region"&gt;
* &lt;attribute name="name" type="base64Binary"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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);

View File

@ -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
*
* <pre>
* &lt;complexType name="StorageClusterVersion"&gt;
* &lt;attribute name="version" type="string"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@XmlRootElement(name="ClusterVersion")
public class StorageClusterVersionModel implements Serializable {

View File

@ -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.
*
* <pre>
* &lt;complexType name="TableInfo"&gt;
* &lt;sequence&gt;
* &lt;element name="region" type="tns:TableRegion"
* maxOccurs="unbounded" minOccurs="1"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;attribute name="name" type="string"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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);

View File

@ -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);

View File

@ -27,6 +27,14 @@ import javax.xml.bind.annotation.XmlRootElement;
/**
* Simple representation of a table name.
*
* <pre>
* &lt;complexType name="Table"&gt;
* &lt;sequence&gt;
* &lt;element name="name" type="string"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;/complexType&gt;
* </pre>
*/
@XmlRootElement(name="table")
public class TableModel implements Serializable {

View File

@ -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.
*
* <pre>
* &lt;complexType name="TableRegion"&gt;
* &lt;attribute name="name" type="string"&gt;&lt;/attribute&gt;
* &lt;attribute name="id" type="int"&gt;&lt;/attribute&gt;
* &lt;attribute name="startKey" type="base64Binary"&gt;&lt;/attribute&gt;
* &lt;attribute name="endKey" type="base64Binary"&gt;&lt;/attribute&gt;
* &lt;attribute name="location" type="string"&gt;&lt;/attribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@XmlRootElement(name="Region")
@XmlType(propOrder = {"name","id","startKey","endKey","location"})

View File

@ -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.
*
* <pre>
* &lt;complexType name="TableSchema"&gt;
* &lt;sequence&gt;
* &lt;element name="column" type="tns:ColumnSchema"
* maxOccurs="unbounded" minOccurs="1"&gt;&lt;/element&gt;
* &lt;/sequence&gt;
* &lt;attribute name="name" type="string"&gt;&lt;/attribute&gt;
* &lt;anyAttribute&gt;&lt;/anyAttribute&gt;
* &lt;/complexType&gt;
* </pre>
*/
@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);

View File

@ -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;
* </ul>
*/
@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);

View File

@ -83,7 +83,6 @@ public class JAXBContextResolver implements ContextResolver<JAXBContext> {
@Override
public JAXBContext getContext(Class<?> objectType) {
System.out.println("Executed getContext");
return (types.contains(objectType)) ? context : null;
}
}

View File

@ -36,31 +36,31 @@ import javax.ws.rs.ext.Provider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.stargate.Constants;
import org.apache.hadoop.hbase.stargate.model.IProtobufWrapper;
import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler;
/**
* Adapter for hooking up Jersey content processing dispatch to
* IProtobufWrapper interface capable handlers for decoding protobuf input.
* ProtobufMessageHandler interface capable handlers for decoding protobuf input.
*/
@Provider
@Consumes(Constants.MIMETYPE_PROTOBUF)
public class ProtobufMessageBodyConsumer
implements MessageBodyReader<IProtobufWrapper> {
implements MessageBodyReader<ProtobufMessageHandler> {
private static final Log LOG =
LogFactory.getLog(ProtobufMessageBodyConsumer.class);
@Override
public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return IProtobufWrapper.class.isAssignableFrom(type);
return ProtobufMessageHandler.class.isAssignableFrom(type);
}
@Override
public IProtobufWrapper readFrom(Class<IProtobufWrapper> type, Type genericType,
public ProtobufMessageHandler readFrom(Class<ProtobufMessageHandler> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream inputStream)
throws IOException, WebApplicationException {
IProtobufWrapper obj = null;
ProtobufMessageHandler obj = null;
try {
obj = type.newInstance();
ByteArrayOutputStream baos = new ByteArrayOutputStream();

View File

@ -36,10 +36,10 @@ import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import org.apache.hadoop.hbase.stargate.Constants;
import org.apache.hadoop.hbase.stargate.model.IProtobufWrapper;
import org.apache.hadoop.hbase.stargate.ProtobufMessageHandler;
/**
* An adapter between Jersey and IProtobufWrapper implementors. Hooks up
* An adapter between Jersey and ProtobufMessageHandler implementors. Hooks up
* protobuf output producing methods to the Jersey content handling framework.
* Jersey will first call getSize() to learn the number of bytes that will be
* sent, then writeTo to perform the actual I/O.
@ -47,18 +47,18 @@ import org.apache.hadoop.hbase.stargate.model.IProtobufWrapper;
@Provider
@Produces(Constants.MIMETYPE_PROTOBUF)
public class ProtobufMessageBodyProducer
implements MessageBodyWriter<IProtobufWrapper> {
implements MessageBodyWriter<ProtobufMessageHandler> {
private Map<Object, byte[]> buffer = new WeakHashMap<Object, byte[]>();
@Override
public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return IProtobufWrapper.class.isAssignableFrom(type);
return ProtobufMessageHandler.class.isAssignableFrom(type);
}
@Override
public long getSize(IProtobufWrapper m, Class<?> type, Type genericType,
public long getSize(ProtobufMessageHandler m, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
@ -71,7 +71,7 @@ public class ProtobufMessageBodyProducer
return bytes.length;
}
public void writeTo(IProtobufWrapper m, Class<?> type, Type genericType,
public void writeTo(ProtobufMessageHandler m, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {