You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2014/05/14 02:27:04 UTC

svn commit: r1594423 [2/17] - in /hbase/branches/0.89-fb: ./ bin/ src/main/java/org/apache/hadoop/hbase/rest/ src/main/java/org/apache/hadoop/hbase/rest/client/ src/main/java/org/apache/hadoop/hbase/rest/metrics/ src/main/java/org/apache/hadoop/hbase/r...

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceBase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceBase.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceBase.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceBase.java Wed May 14 00:26:57 2014
@@ -1,32 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-
-public class ResourceBase implements Constants {
-
-  RESTServlet servlet;
-
-  public ResourceBase() throws IOException {
-    servlet = RESTServlet.getInstance();
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceConfig.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceConfig.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceConfig.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResourceConfig.java Wed May 14 00:26:57 2014
@@ -1,29 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import com.sun.jersey.api.core.PackagesResourceConfig;
-
-public class ResourceConfig extends PackagesResourceConfig {
-  public ResourceConfig() {
-    super("org.apache.hadoop.hbase.rest");
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResultGenerator.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResultGenerator.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ResultGenerator.java Wed May 14 00:26:57 2014
@@ -1,48 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-import java.util.Iterator;
- 
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.filter.Filter;
-import org.apache.hadoop.hbase.rest.model.ScannerModel;
-
-public abstract class ResultGenerator implements Iterator<KeyValue> {
-
-  public static ResultGenerator fromRowSpec(final String table, 
-      final RowSpec rowspec, final Filter filter) throws IOException {
-    if (rowspec.isSingleRow()) {
-      return new RowResultGenerator(table, rowspec, filter);
-    } else {
-      return new ScannerResultGenerator(table, rowspec, filter);
-    }
-  }
-
-  public static Filter buildFilter(final String filter) throws Exception {
-    return ScannerModel.buildFilter(filter);
-  }
-
-  public abstract void putBack(KeyValue kv);
-
-  public abstract void close();
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RootResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RootResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RootResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RootResource.java Wed May 14 00:26:57 2014
@@ -1,106 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.rest.model.TableListModel;
-import org.apache.hadoop.hbase.rest.model.TableModel;
-
-@Path("/")
-public class RootResource extends ResourceBase {
-  private static final Log LOG = LogFactory.getLog(RootResource.class);
-
-  static CacheControl cacheControl;
-  static {
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  /**
-   * Constructor
-   * @throws IOException
-   */
-  public RootResource() throws IOException {
-    super();
-  }
-
-  private final TableListModel getTableList() throws IOException {
-    TableListModel tableList = new TableListModel();
-    HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-    HTableDescriptor[] list = admin.listTables();
-    for (HTableDescriptor htd: list) {
-      tableList.add(new TableModel(htd.getNameAsString()));
-    }
-    return tableList;
-  }
-
-  @GET
-  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      ResponseBuilder response = Response.ok(getTableList());
-      response.cacheControl(cacheControl);
-      return response.build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-                  Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-
-  @Path("status/cluster")
-  public StorageClusterStatusResource getClusterStatusResource()
-      throws IOException {
-    return new StorageClusterStatusResource();
-  }
-
-  @Path("version")
-  public VersionResource getVersionResource() throws IOException {
-    return new VersionResource();
-  }
-
-  @Path("{table}")
-  public TableResource getTableResource(
-      final @PathParam("table") String table) throws IOException {
-    return new TableResource(table);
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java Wed May 14 00:26:57 2014
@@ -1,330 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.rest.model.CellModel;
-import org.apache.hadoop.hbase.rest.model.CellSetModel;
-import org.apache.hadoop.hbase.rest.model.RowModel;
-import org.apache.hadoop.hbase.util.Bytes;
-
-public class RowResource extends ResourceBase {
-  private static final Log LOG = LogFactory.getLog(RowResource.class);
-
-  String tableName;
-  RowSpec rowspec;
-  CacheControl cacheControl;
-
-  /**
-   * Constructor
-   * @param table
-   * @param rowspec
-   * @param versions
-   * @throws IOException
-   */
-  public RowResource(String table, String rowspec, String versions)
-      throws IOException {
-    super();
-    this.tableName = table;
-    this.rowspec = new RowSpec(URLDecoder.decode(rowspec,
-      HConstants.UTF8_ENCODING));
-    if (versions != null) {
-      this.rowspec.setMaxVersions(Integer.valueOf(versions));
-    }
-    this.cacheControl = new CacheControl();
-    this.cacheControl.setMaxAge(servlet.getMaxAge(tableName));
-    this.cacheControl.setNoTransform(false);    
-  }
-
-  @GET
-  @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      ResultGenerator generator =
-        ResultGenerator.fromRowSpec(tableName, rowspec, null);
-      if (!generator.hasNext()) {
-        throw new WebApplicationException(Response.Status.NOT_FOUND);
-      }
-      int count = 0;
-      CellSetModel model = new CellSetModel();
-      KeyValue value = generator.next();
-      byte[] rowKey = value.getRow();
-      RowModel rowModel = new RowModel(rowKey);
-      do {
-        if (!Bytes.equals(value.getRow(), rowKey)) {
-          model.addRow(rowModel);
-          rowKey = value.getRow();
-          rowModel = new RowModel(rowKey);
-        }
-        rowModel.addCell(
-          new CellModel(value.getFamily(), value.getQualifier(), 
-              value.getTimestamp(), value.getValue()));
-        if (++count > rowspec.getMaxValues()) {
-          break;
-        }
-        value = generator.next();
-      } while (value != null);
-      model.addRow(rowModel);
-      ResponseBuilder response = Response.ok(model);
-      response.cacheControl(cacheControl);
-      return response.build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-                  Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-
-  @GET
-  @Produces(MIMETYPE_BINARY)
-  public Response getBinary(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath() + " as "+ MIMETYPE_BINARY);
-    }
-    servlet.getMetrics().incrementRequests(1);
-    // doesn't make sense to use a non specific coordinate as this can only
-    // return a single cell
-    if (!rowspec.hasColumns() || rowspec.getColumns().length > 1) {
-      throw new WebApplicationException(Response.Status.BAD_REQUEST);
-    }
-    try {
-      ResultGenerator generator =
-        ResultGenerator.fromRowSpec(tableName, rowspec, null);
-      if (!generator.hasNext()) {
-        throw new WebApplicationException(Response.Status.NOT_FOUND);
-      }
-      KeyValue value = generator.next();
-      ResponseBuilder response = Response.ok(value.getValue());
-      response.cacheControl(cacheControl);
-      response.header("X-Timestamp", value.getTimestamp());
-      return response.build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-                  Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-
-  Response update(final CellSetModel model, final boolean replace) {
-    servlet.getMetrics().incrementRequests(1);
-    HTablePool pool = servlet.getTablePool();
-    HTableInterface table = null;
-    try {
-      List<RowModel> rows = model.getRows();
-      table = pool.getTable(tableName);
-      ((HTable)table).setAutoFlush(false);
-      for (RowModel row: rows) {
-        byte[] key = row.getKey();
-        Put put = new Put(key);
-        for (CellModel cell: row.getCells()) {
-          byte [][] parts = KeyValue.parseColumn(cell.getColumn());
-          if (parts.length == 2 && parts[1].length > 0) {
-            put.add(parts[0], parts[1], cell.getTimestamp(), cell.getValue());
-          } else {
-            put.add(parts[0], null, cell.getTimestamp(), cell.getValue());
-          }
-        }
-        table.put(put);
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("PUT " + put.toString());
-        }
-      }
-      ((HTable)table).setAutoFlush(true);
-      table.flushCommits();
-      ResponseBuilder response = Response.ok();
-      return response.build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-                  Response.Status.SERVICE_UNAVAILABLE);
-    } finally {
-      if (table != null) {
-        pool.putTable(table);
-      }
-    }
-  }
-
-  // This currently supports only update of one row at a time.
-  Response updateBinary(final byte[] message, final HttpHeaders headers,
-      final boolean replace) {
-    servlet.getMetrics().incrementRequests(1);
-    HTablePool pool = servlet.getTablePool();
-    HTableInterface table = null;    
-    try {
-      byte[] row = rowspec.getRow();
-      byte[][] columns = rowspec.getColumns();
-      byte[] column = null;
-      if (columns != null) {
-        column = columns[0];
-      }
-      long timestamp = HConstants.LATEST_TIMESTAMP;
-      List<String> vals = headers.getRequestHeader("X-Row");
-      if (vals != null && !vals.isEmpty()) {
-        row = Bytes.toBytes(vals.get(0));
-      }
-      vals = headers.getRequestHeader("X-Column");
-      if (vals != null && !vals.isEmpty()) {
-        column = Bytes.toBytes(vals.get(0));
-      }
-      vals = headers.getRequestHeader("X-Timestamp");
-      if (vals != null && !vals.isEmpty()) {
-        timestamp = Long.valueOf(vals.get(0));
-      }
-      if (column == null) {
-        throw new WebApplicationException(Response.Status.BAD_REQUEST);
-      }
-      Put put = new Put(row);
-      byte parts[][] = KeyValue.parseColumn(column);
-      if (parts.length == 2 && parts[1].length > 0) {
-        put.add(parts[0], parts[1], timestamp, message);
-      } else {
-        put.add(parts[0], null, timestamp, message);
-      }
-      table = pool.getTable(tableName);
-      table.put(put);
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("PUT " + put.toString());
-      }
-      return Response.ok().build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-                  Response.Status.SERVICE_UNAVAILABLE);
-    } finally {
-      if (table != null) {
-        pool.putTable(table);
-      }
-    }
-  }
-
-  @PUT
-  @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response put(final CellSetModel model,
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("PUT " + uriInfo.getAbsolutePath());
-    }
-    return update(model, true);
-  }
-
-  @PUT
-  @Consumes(MIMETYPE_BINARY)
-  public Response putBinary(final byte[] message,
-      final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("PUT " + uriInfo.getAbsolutePath() + " as "+ MIMETYPE_BINARY);
-    }
-    return updateBinary(message, headers, true);
-  }
-
-  @POST
-  @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response post(final CellSetModel model,
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("POST " + uriInfo.getAbsolutePath());
-    }
-    return update(model, false);
-  }
-
-  @POST
-  @Consumes(MIMETYPE_BINARY)
-  public Response postBinary(final byte[] message,
-      final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("POST " + uriInfo.getAbsolutePath() + " as "+MIMETYPE_BINARY);
-    }
-    return updateBinary(message, headers, false);
-  }
-
-  @DELETE
-  public Response delete(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("DELETE " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    Delete delete = null;
-    if (rowspec.hasTimestamp())
-      delete = new Delete(rowspec.getRow(), rowspec.getTimestamp(), null);
-    else
-      delete = new Delete(rowspec.getRow());
-
-    for (byte[] column: rowspec.getColumns()) {
-      byte[][] split = KeyValue.parseColumn(column);
-      if (rowspec.hasTimestamp()) {
-        if (split.length == 2 && split[1].length != 0) {
-          delete.deleteColumns(split[0], split[1], rowspec.getTimestamp());
-        } else {
-          delete.deleteFamily(split[0], rowspec.getTimestamp());
-        }
-      } else {
-        if (split.length == 2 && split[1].length != 0) {
-          delete.deleteColumns(split[0], split[1]);
-        } else {
-          delete.deleteFamily(split[0]);
-        }
-      }
-    }
-    HTablePool pool = servlet.getTablePool();
-    HTableInterface table = null;
-    try {
-      table = pool.getTable(tableName);
-      table.delete(delete);
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("DELETE " + delete.toString());
-      }
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-                  Response.Status.SERVICE_UNAVAILABLE);
-    } finally {
-      if (table != null) {
-        pool.putTable(table);
-      }
-    }
-    return Response.ok().build();
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResultGenerator.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResultGenerator.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowResultGenerator.java Wed May 14 00:26:57 2014
@@ -1,111 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.filter.Filter;
-
-public class RowResultGenerator extends ResultGenerator {
-  private Iterator<KeyValue> valuesI;
-  private KeyValue cache;
-
-  public RowResultGenerator(final String tableName, final RowSpec rowspec,
-      final Filter filter) throws IllegalArgumentException, IOException {
-    HTablePool pool = RESTServlet.getInstance().getTablePool(); 
-    HTableInterface table = pool.getTable(tableName);
-    try {
-      Get get = new Get(rowspec.getRow());
-      if (rowspec.hasColumns()) {
-        for (byte[] col: rowspec.getColumns()) {
-          byte[][] split = KeyValue.parseColumn(col);
-          if (split.length == 2 && split[1].length != 0) {
-            get.addColumn(split[0], split[1]);
-          } else {
-            get.addFamily(split[0]);
-          }
-        }
-      } else {
-        // rowspec does not explicitly specify columns, return them all
-        for (HColumnDescriptor family: 
-            table.getTableDescriptor().getFamilies()) {
-          get.addFamily(family.getName());
-        }
-      }
-      get.setTimeRange(rowspec.getStartTime(), rowspec.getEndTime());
-      get.setMaxVersions(rowspec.getMaxVersions());
-      if (filter != null) {
-        get.setFilter(filter);
-      }
-      Result result = table.get(get);
-      if (result != null && !result.isEmpty()) {
-        valuesI = result.list().iterator();
-      }
-    } finally {
-      pool.putTable(table);
-    }
-  }
-
-  public void close() {
-  }
-
-  public boolean hasNext() {
-    if (cache != null) {
-      return true;
-    }
-    if (valuesI == null) {
-      return false;
-    }
-    return valuesI.hasNext();
-  }
-
-  public KeyValue next() {
-    if (cache != null) {
-      KeyValue kv = cache;
-      cache = null;
-      return kv;
-    }
-    if (valuesI == null) {
-      return null;
-    }
-    try {
-      return valuesI.next();
-    } catch (NoSuchElementException e) {
-      return null;
-    }
-  }
-
-  public void putBack(KeyValue kv) {
-    this.cache = kv;
-  }
-
-  public void remove() {
-    throw new UnsupportedOperationException("remove not supported");
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java Wed May 14 00:26:57 2014
@@ -1,380 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.util.Collection;
-import java.util.TreeSet;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.util.Bytes;
-
-/**
- * Parses a path based row/column/timestamp specification into its component
- * elements.
- * <p>
- *  
- */
-public class RowSpec {
-  public static final long DEFAULT_START_TIMESTAMP = 0;
-  public static final long DEFAULT_END_TIMESTAMP = Long.MAX_VALUE;
-  
-  private byte[] row = HConstants.EMPTY_START_ROW;
-  private byte[] endRow = null;
-  private TreeSet<byte[]> columns =
-    new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
-  private long startTime = DEFAULT_START_TIMESTAMP;
-  private long endTime = DEFAULT_END_TIMESTAMP;
-  private int maxVersions = HColumnDescriptor.DEFAULT_VERSIONS;
-  private int maxValues = Integer.MAX_VALUE;
-
-  public RowSpec(String path) throws IllegalArgumentException {
-    int i = 0;
-    while (path.charAt(i) == '/') {
-      i++;
-    }
-    i = parseRowKeys(path, i);
-    i = parseColumns(path, i);
-    i = parseTimestamp(path, i);
-    i = parseQueryParams(path, i);
-  }
-
-  private int parseRowKeys(final String path, int i)
-      throws IllegalArgumentException {
-    StringBuilder startRow = new StringBuilder();
-    StringBuilder endRow = null;
-    try {
-      char c;
-      boolean doEndRow = false;
-      while (i < path.length() && (c = path.charAt(i)) != '/') {
-        if (c == ',') {
-          doEndRow = true;
-          i++;
-          break;
-        }
-        startRow.append(c);
-        i++;
-      }
-      i++;
-      this.row = Bytes.toBytes(startRow.toString());
-      if (doEndRow) {
-        endRow = new StringBuilder();
-        while ((c = path.charAt(i)) != '/') {
-          endRow.append(c);
-          i++;
-        }
-        i++;
-      }
-    } catch (IndexOutOfBoundsException e) {
-      throw new IllegalArgumentException(e);
-    }
-    // HBase does not support wildcards on row keys so we will emulate a
-    // suffix glob by synthesizing appropriate start and end row keys for
-    // table scanning
-    if (startRow.charAt(startRow.length() - 1) == '*') {
-      if (endRow != null)
-        throw new IllegalArgumentException("invalid path: start row "+
-          "specified with wildcard");
-      this.row = Bytes.toBytes(startRow.substring(0, 
-                   startRow.lastIndexOf("*")));
-      this.endRow = new byte[this.row.length + 1];
-      System.arraycopy(this.row, 0, this.endRow, 0, this.row.length);
-      this.endRow[this.row.length] = (byte)255;
-    } else {
-      this.row = Bytes.toBytes(startRow.toString());
-      if (endRow != null) {
-        this.endRow = Bytes.toBytes(endRow.toString());
-      }
-    }
-    return i;
-  }
-
-  private int parseColumns(final String path, int i)
-      throws IllegalArgumentException {
-    if (i >= path.length()) {
-      return i;
-    }
-    try {
-      char c;
-      StringBuilder column = new StringBuilder();
-      boolean hasColon = false;
-      while (i < path.length() && (c = path.charAt(i)) != '/') {
-        if (c == ',') {
-          if (column.length() < 1) {
-            throw new IllegalArgumentException("invalid path");
-          }
-          if (!hasColon) {
-            column.append(':');
-          }
-          this.columns.add(Bytes.toBytes(column.toString()));
-          column = new StringBuilder();
-          hasColon = false;
-          i++;
-          continue;
-        }
-        if (c == ':') {
-          hasColon = true;
-        }
-        column.append(c);
-        i++;
-      }
-      i++;
-      // trailing list entry
-      if (column.length() > 1) {
-        if (!hasColon) {
-          column.append(':');
-        }
-        this.columns.add(Bytes.toBytes(column.toString()));
-      }
-    } catch (IndexOutOfBoundsException e) {
-      throw new IllegalArgumentException(e);
-    }
-    return i;
-  }
-
-  private int parseTimestamp(final String path, int i)
-      throws IllegalArgumentException {
-    if (i >= path.length()) {
-      return i;
-    }
-    long time0 = 0, time1 = 0;
-    try {
-      char c = 0;
-      StringBuilder stamp = new StringBuilder();
-      while (i < path.length()) {
-        c = path.charAt(i);
-        if (c == '/' || c == ',') {
-          break;
-        }
-        stamp.append(c);
-        i++;
-      }
-      try {
-        time0 = Long.valueOf(stamp.toString());
-      } catch (NumberFormatException e) {
-        throw new IllegalArgumentException(e);
-      }
-      if (c == ',') {
-        stamp = new StringBuilder();
-        i++;
-        while (i < path.length() && ((c = path.charAt(i)) != '/')) {
-          stamp.append(c);
-          i++;
-        }
-        try {
-          time1 = Long.valueOf(stamp.toString());
-        } catch (NumberFormatException e) {
-          throw new IllegalArgumentException(e);
-        }
-      }
-      if (c == '/') {
-        i++;
-      }
-    } catch (IndexOutOfBoundsException e) {
-      throw new IllegalArgumentException(e);
-    }
-    if (time1 != 0) {
-      startTime = time0;
-      endTime = time1;
-    } else {
-      endTime = time0;
-    }
-    return i;
-  }
-
-  private int parseQueryParams(final String path, int i) {
-    while (i < path.length()) {
-      char c = path.charAt(i);
-      if (c != '?' && c != '&') {
-        break;
-      }
-      if (++i > path.length()) {
-        break;
-      }
-      char what = path.charAt(i);
-      if (++i > path.length()) {
-        break;
-      }
-      c = path.charAt(i);
-      if (c != '=') {
-        throw new IllegalArgumentException("malformed query parameter");
-      }
-      if (++i > path.length()) {
-        break;
-      }
-      switch (what) {
-      case 'm': {
-        StringBuilder sb = new StringBuilder();
-        while (i <= path.length()) {
-          c = path.charAt(i);
-          if (c < '0' || c > '9') {
-            i--;
-            break;
-          }
-          sb.append(c);
-        }
-        maxVersions = Integer.valueOf(sb.toString());
-      } break;
-      case 'n': {
-        StringBuilder sb = new StringBuilder();
-        while (i <= path.length()) {
-          c = path.charAt(i);
-          if (c < '0' || c > '9') {
-            i--;
-            break;
-          }
-          sb.append(c);
-        }
-        maxValues = Integer.valueOf(sb.toString());
-      } break;
-      default:
-        throw new IllegalArgumentException("unknown parameter '" + c + "'");
-      }
-    }
-    return i;
-  }
-
-  public RowSpec(byte[] startRow, byte[] endRow, byte[][] columns,
-      long startTime, long endTime, int maxVersions) {
-    this.row = startRow;
-    this.endRow = endRow;
-    if (columns != null) {
-      for (byte[] col: columns) {
-        this.columns.add(col);
-      }
-    }
-    this.startTime = startTime;
-    this.endTime = endTime;
-    this.maxVersions = maxVersions;
-  }
-
-  public RowSpec(byte[] startRow, byte[] endRow, Collection<byte[]> columns,
-      long startTime, long endTime, int maxVersions) {
-    this.row = startRow;
-    this.endRow = endRow;
-    if (columns != null) {
-      this.columns.addAll(columns);
-    }
-    this.startTime = startTime;
-    this.endTime = endTime;
-    this.maxVersions = maxVersions;
-  }
-
-  public boolean isSingleRow() {
-    return endRow == null;
-  }
-
-  public int getMaxVersions() {
-    return maxVersions;
-  }
-
-  public void setMaxVersions(final int maxVersions) {
-    this.maxVersions = maxVersions;
-  }
-
-  public int getMaxValues() {
-    return maxValues;
-  }
-
-  public void setMaxValues(final int maxValues) {
-    this.maxValues = maxValues;
-  }
-
-  public boolean hasColumns() {
-    return !columns.isEmpty();
-  }
-
-  public byte[] getRow() {
-    return row;
-  }
-
-  public byte[] getStartRow() {
-    return row;
-  }
-
-  public boolean hasEndRow() {
-    return endRow != null;
-  }
-
-  public byte[] getEndRow() {
-    return endRow;
-  }
-
-  public void addColumn(final byte[] column) {
-    columns.add(column);
-  }
-
-  public byte[][] getColumns() {
-    return columns.toArray(new byte[columns.size()][]);
-  }
-
-  public boolean hasTimestamp() {
-    return (startTime == 0) && (endTime != Long.MAX_VALUE);
-  }
-
-  public long getTimestamp() {
-    return endTime;
-  }
-
-  public long getStartTime() {
-    return startTime;
-  }
-
-  public void setStartTime(final long startTime) {
-    this.startTime = startTime;
-  }
-
-  public long getEndTime() {
-    return endTime;
-  }
-
-  public void setEndTime(long endTime) {
-    this.endTime = endTime;
-  }
-
-  public String toString() {
-    StringBuilder result = new StringBuilder();
-    result.append("{startRow => '");
-    if (row != null) {
-      result.append(Bytes.toString(row));
-    }
-    result.append("', endRow => '");
-    if (endRow != null)  {
-      result.append(Bytes.toString(endRow));
-    }
-    result.append("', columns => [");
-    for (byte[] col: columns) {
-      result.append(" '");
-      result.append(Bytes.toString(col));
-      result.append("'");
-    }
-    result.append(" ], startTime => ");
-    result.append(Long.toString(startTime));
-    result.append(", endTime => ");
-    result.append(Long.toString(endTime));
-    result.append(", maxVersions => ");
-    result.append(Integer.toString(maxVersions));
-    result.append(", maxValues => ");
-    result.append(Integer.toString(maxValues));
-    result.append("}");
-    return result.toString();
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerInstanceResource.java Wed May 14 00:26:57 2014
@@ -1,165 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.rest.model.CellModel;
-import org.apache.hadoop.hbase.rest.model.CellSetModel;
-import org.apache.hadoop.hbase.rest.model.RowModel;
-import org.apache.hadoop.hbase.util.Base64;
-import org.apache.hadoop.hbase.util.Bytes;
-
-public class ScannerInstanceResource extends ResourceBase {
-  private static final Log LOG =
-    LogFactory.getLog(ScannerInstanceResource.class);
-
-  static CacheControl cacheControl;
-  static {
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  ResultGenerator generator;
-  String id;
-  int batch = 1;
-
-  public ScannerInstanceResource(String table, String id, 
-      ResultGenerator generator, int batch) throws IOException {
-    this.id = id;
-    this.generator = generator;
-    this.batch = batch;
-  }
-
-  @GET
-  @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo, 
-      @QueryParam("n") int maxRows, final @QueryParam("c") int maxValues) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    CellSetModel model = new CellSetModel();
-    RowModel rowModel = null;
-    byte[] rowKey = null;
-    int limit = batch;
-    if (maxValues > 0) {
-      limit = maxValues;
-    }
-    int count = limit;
-    do {
-      KeyValue value = null;
-      try {
-        value = generator.next();
-      } catch (IllegalStateException e) {
-        ScannerResource.delete(id);
-        throw new WebApplicationException(Response.Status.GONE);
-      }
-      if (value == null) {
-        LOG.info("generator exhausted");
-        // respond with 204 (No Content) if an empty cell set would be
-        // returned
-        if (count == limit) {
-          return Response.noContent().build();
-        }
-        break;
-      }
-      if (rowKey == null) {
-        rowKey = value.getRow();
-        rowModel = new RowModel(rowKey);
-      }
-      if (!Bytes.equals(value.getRow(), rowKey)) {
-        // if maxRows was given as a query param, stop if we would exceed the
-        // specified number of rows
-        if (maxRows > 0) { 
-          if (--maxRows == 0) {
-            generator.putBack(value);
-            break;
-          }
-        }
-        model.addRow(rowModel);
-        rowKey = value.getRow();
-        rowModel = new RowModel(rowKey);
-      }
-      rowModel.addCell(
-        new CellModel(value.getFamily(), value.getQualifier(), 
-          value.getTimestamp(), value.getValue()));
-    } while (--count > 0);
-    model.addRow(rowModel);
-    ResponseBuilder response = Response.ok(model);
-    response.cacheControl(cacheControl);
-    return response.build();
-  }
-
-  @GET
-  @Produces(MIMETYPE_BINARY)
-  public Response getBinary(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath() + " as " +
-        MIMETYPE_BINARY);
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      KeyValue value = generator.next();
-      if (value == null) {
-        LOG.info("generator exhausted");
-        return Response.noContent().build();
-      }
-      ResponseBuilder response = Response.ok(value.getValue());
-      response.cacheControl(cacheControl);
-      response.header("X-Row", Base64.encodeBytes(value.getRow()));      
-      response.header("X-Column", 
-        Base64.encodeBytes(
-          KeyValue.makeColumn(value.getFamily(), value.getQualifier())));
-      response.header("X-Timestamp", value.getTimestamp());
-      return response.build();
-    } catch (IllegalStateException e) {
-      ScannerResource.delete(id);
-      throw new WebApplicationException(Response.Status.GONE);
-    }
-  }
-
-  @DELETE
-  public Response delete(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("DELETE " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    ScannerResource.delete(id);
-    return Response.ok().build();
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java Wed May 14 00:26:57 2014
@@ -1,129 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.filter.Filter;
-import org.apache.hadoop.hbase.rest.model.ScannerModel;
-
-public class ScannerResource extends ResourceBase {
-
-  private static final Log LOG = LogFactory.getLog(ScannerResource.class);
-
-  static final Map<String,ScannerInstanceResource> scanners =
-   Collections.synchronizedMap(new HashMap<String,ScannerInstanceResource>());
-
-  String tableName;
-
-  /**
-   * Constructor
-   * @param table
-   * @throws IOException
-   */
-  public ScannerResource(String table) throws IOException {
-    super();
-    this.tableName = table;
-  }
-
-  static void delete(final String id) {
-    ScannerInstanceResource instance = scanners.remove(id);
-    if (instance != null) {
-      instance.generator.close();
-    }
-  }
-
-  Response update(final ScannerModel model, final boolean replace, 
-      final UriInfo uriInfo) {
-    servlet.getMetrics().incrementRequests(1);
-    byte[] endRow = model.hasEndRow() ? model.getEndRow() : null;
-    RowSpec spec = new RowSpec(model.getStartRow(), endRow,
-      model.getColumns(), model.getStartTime(), model.getEndTime(), 1);
-    try {
-      Filter filter = ScannerResultGenerator.buildFilterFromModel(model);
-      ScannerResultGenerator gen = 
-        new ScannerResultGenerator(tableName, spec, filter);
-      String id = gen.getID();
-      ScannerInstanceResource instance = 
-        new ScannerInstanceResource(tableName, id, gen, model.getBatch());
-      scanners.put(id, instance);
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("new scanner: " + id);
-      }
-      UriBuilder builder = uriInfo.getAbsolutePathBuilder();
-      URI uri = builder.path(id).build();
-      return Response.created(uri).build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-              Response.Status.SERVICE_UNAVAILABLE);
-    } catch (Exception e) {
-      throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
-    }
-  }
-
-  @PUT
-  @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response put(final ScannerModel model, 
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("PUT " + uriInfo.getAbsolutePath());
-    }
-    return update(model, true, uriInfo);
-  }
-
-  @POST
-  @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response post(final ScannerModel model,
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("POST " + uriInfo.getAbsolutePath());
-    }
-    return update(model, false, uriInfo);
-  }
-
-  @Path("{scanner: .+}")
-  public ScannerInstanceResource getScannerInstanceResource(
-      final @PathParam("scanner") String id) {
-    ScannerInstanceResource instance = scanners.get(id);
-    if (instance == null) {
-      throw new WebApplicationException(Response.Status.NOT_FOUND);
-    }
-    return instance;
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java Wed May 14 00:26:57 2014
@@ -1,178 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.UnknownScannerException;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.filter.Filter;
-import org.apache.hadoop.hbase.rest.model.ScannerModel;
-import org.apache.hadoop.util.StringUtils;
-
-public class ScannerResultGenerator extends ResultGenerator {
-
-  private static final Log LOG =
-    LogFactory.getLog(ScannerResultGenerator.class);
-
-  public static Filter buildFilterFromModel(final ScannerModel model) 
-      throws Exception {
-    String filter = model.getFilter();
-    if (filter == null || filter.length() == 0) {
-      return null;
-    }
-    return buildFilter(filter);
-  }
-
-  private String id;
-  private Iterator<KeyValue> rowI;
-  private KeyValue cache;
-  private ResultScanner scanner;
-  private Result cached;
-
-  public ScannerResultGenerator(final String tableName, final RowSpec rowspec,
-      final Filter filter) throws IllegalArgumentException, IOException {
-    HTablePool pool = RESTServlet.getInstance().getTablePool(); 
-    HTableInterface table = pool.getTable(tableName);
-    try {
-      Scan scan;
-      if (rowspec.hasEndRow()) {
-        scan = new Scan(rowspec.getStartRow(), rowspec.getEndRow());
-      } else {
-        scan = new Scan(rowspec.getStartRow());
-      }
-      if (rowspec.hasColumns()) {
-        byte[][] columns = rowspec.getColumns();
-        for (byte[] column: columns) {
-          byte[][] split = KeyValue.parseColumn(column);
-          if (split.length > 1 && (split[1] != null && split[1].length != 0)) {
-            scan.addColumn(split[0], split[1]);
-          } else {
-            scan.addFamily(split[0]);
-          }
-        }
-      } else {
-        for (HColumnDescriptor family: 
-            table.getTableDescriptor().getFamilies()) {
-          scan.addFamily(family.getName());
-        }
-      }
-      scan.setTimeRange(rowspec.getStartTime(), rowspec.getEndTime());          
-      scan.setMaxVersions(rowspec.getMaxVersions());
-      if (filter != null) {
-        scan.setFilter(filter);
-      }
-      // always disable block caching on the cluster when scanning
-      scan.setCacheBlocks(false);
-      scanner = table.getScanner(scan);
-      cached = null;
-      id = Long.toString(System.currentTimeMillis()) +
-             Integer.toHexString(scanner.hashCode());
-    } finally {
-      pool.putTable(table);
-    }
-  }
-
-  public String getID() {
-    return id;
-  }
-
-  public void close() {
-  }
-
-  public boolean hasNext() {
-    if (cache != null) {
-      return true;
-    }
-    if (rowI != null && rowI.hasNext()) {
-      return true;
-    }
-    if (cached != null) {
-      return true;
-    }
-    try {
-      Result result = scanner.next();
-      if (result != null && !result.isEmpty()) {
-        cached = result;
-      }
-    } catch (UnknownScannerException e) {
-      throw new IllegalArgumentException(e);
-    } catch (IOException e) {
-      LOG.error(StringUtils.stringifyException(e));
-    }
-    return cached != null;
-  }
-
-  public KeyValue next() {
-    if (cache != null) {
-      KeyValue kv = cache;
-      cache = null;
-      return kv;
-    }
-    boolean loop;
-    do {
-      loop = false;
-      if (rowI != null) {
-        if (rowI.hasNext()) {
-          return rowI.next();
-        } else {
-          rowI = null;
-        }
-      }
-      if (cached != null) {
-        rowI = cached.list().iterator();
-        loop = true;
-        cached = null;
-      } else {
-        Result result = null;
-        try {
-          result = scanner.next();
-        } catch (UnknownScannerException e) {
-          throw new IllegalArgumentException(e);
-        } catch (IOException e) {
-          LOG.error(StringUtils.stringifyException(e));
-        }
-        if (result != null && !result.isEmpty()) {
-          rowI = result.list().iterator();
-          loop = true;
-        }
-      }
-    } while (loop);
-    return null;
-  }
-
-  public void putBack(KeyValue kv) {
-    this.cache = kv;
-  }
-
-  public void remove() {
-    throw new UnsupportedOperationException("remove not supported");
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java Wed May 14 00:26:57 2014
@@ -1,235 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import javax.xml.namespace.QName;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.TableExistsException;
-import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.rest.model.ColumnSchemaModel;
-import org.apache.hadoop.hbase.rest.model.TableSchemaModel;
-import org.apache.hadoop.hbase.util.Bytes;
-
-public class SchemaResource extends ResourceBase {
-  private static final Log LOG = LogFactory.getLog(SchemaResource.class);
-
-  static CacheControl cacheControl;
-  static {
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  String tableName;
-
-  /**
-   * Constructor
-   * @param table
-   * @throws IOException
-   */
-  public SchemaResource(String table) throws IOException {
-    super();
-    this.tableName = table;
-  }
-
-  private HTableDescriptor getTableSchema() throws IOException,
-      TableNotFoundException {
-    HTablePool pool = servlet.getTablePool();
-    HTableInterface table = pool.getTable(tableName);
-    try {
-      return table.getTableDescriptor();
-    } finally {
-      pool.putTable(table);
-    }
-  }
-
-  @GET
-  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      ResponseBuilder response =
-        Response.ok(new TableSchemaModel(getTableSchema()));
-      response.cacheControl(cacheControl);
-      return response.build();
-    } catch (TableNotFoundException e) {
-      throw new WebApplicationException(Response.Status.NOT_FOUND);
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-                  Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-
-  private Response replace(final byte[] name, final TableSchemaModel model,
-      final UriInfo uriInfo, final HBaseAdmin admin) {
-    try {
-      HTableDescriptor htd = new HTableDescriptor(name);
-      for (Map.Entry<QName,Object> e: model.getAny().entrySet()) {
-        htd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
-      }
-      for (ColumnSchemaModel family: model.getColumns()) {
-        HColumnDescriptor hcd = new HColumnDescriptor(family.getName());
-        for (Map.Entry<QName,Object> e: family.getAny().entrySet()) {
-          hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
-        }
-        htd.addFamily(hcd);
-      }
-      if (admin.tableExists(name)) {
-        admin.disableTable(name);
-        admin.modifyTable(name, htd);
-        admin.enableTable(name);
-      } else try {
-        admin.createTable(htd);
-      } catch (TableExistsException e) {
-        // race, someone else created a table with the same name
-        throw new WebApplicationException(e, Response.Status.NOT_MODIFIED);
-      }
-      return Response.created(uriInfo.getAbsolutePath()).build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-            Response.Status.SERVICE_UNAVAILABLE);
-    }      
-  } 
-
-  private Response update(final byte[] name, final TableSchemaModel model,
-      final UriInfo uriInfo, final HBaseAdmin admin) {
-    try {
-      HTableDescriptor htd = admin.getTableDescriptor(name);
-      admin.disableTable(name);
-      try {
-        for (ColumnSchemaModel family: model.getColumns()) {
-          HColumnDescriptor hcd = new HColumnDescriptor(family.getName());
-          for (Map.Entry<QName,Object> e: family.getAny().entrySet()) {
-            hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
-          }
-          if (htd.hasFamily(hcd.getName())) {
-            admin.modifyColumn(name, hcd.getName(), hcd);
-          } else {
-            admin.addColumn(model.getName(), hcd);            
-          }
-        }
-      } catch (IOException e) {
-        throw new WebApplicationException(e, 
-            Response.Status.INTERNAL_SERVER_ERROR);
-      } finally {
-        admin.enableTable(tableName);
-      }
-      return Response.ok().build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e,
-          Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-
-  private Response update(final TableSchemaModel model, final boolean replace,
-      final UriInfo uriInfo) {
-    try {
-      servlet.invalidateMaxAge(tableName);
-      byte[] name = Bytes.toBytes(tableName);
-      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      if (replace || !admin.tableExists(name)) {
-        return replace(name, model, uriInfo, admin);
-      } else {
-        return update(name, model, uriInfo, admin);
-      }
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-            Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-
-  @PUT
-  @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response put(final TableSchemaModel model, 
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("PUT " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    return update(model, true, uriInfo);
-  }
-
-  @POST
-  @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response post(final TableSchemaModel model, 
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("PUT " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    return update(model, false, uriInfo);
-  }
-
-  @DELETE
-  public Response delete(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("DELETE " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      boolean success = false;
-      for (int i = 0; i < 10; i++) try {
-        admin.disableTable(tableName);
-        success = true;
-        break;
-      } catch (IOException e) {
-      }
-      if (!success) {
-        throw new IOException("could not disable table");
-      }
-      admin.deleteTable(tableName);
-      return Response.ok().build();
-    } catch (TableNotFoundException e) {
-      throw new WebApplicationException(Response.Status.NOT_FOUND);
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-            Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java Wed May 14 00:26:57 2014
@@ -1,100 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.ClusterStatus;
-import org.apache.hadoop.hbase.HServerInfo;
-import org.apache.hadoop.hbase.HServerLoad;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.rest.model.StorageClusterStatusModel;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.UriInfo;
-import java.io.IOException;
-
-public class StorageClusterStatusResource extends ResourceBase {
-  private static final Log LOG =
-    LogFactory.getLog(StorageClusterStatusResource.class);
-
-  static CacheControl cacheControl;
-  static {
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  /**
-   * Constructor
-   * @throws IOException
-   */
-  public StorageClusterStatusResource() throws IOException {
-    super();
-  }
-
-  @GET
-  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      ClusterStatus status = admin.getClusterStatus();
-      StorageClusterStatusModel model = new StorageClusterStatusModel();
-      model.setRegions(status.getRegionsCount());
-      model.setRequests(status.getRequestsCount());
-      model.setAverageLoad(status.getAverageLoad());
-      for (HServerInfo info: status.getServerInfo()) {
-        HServerLoad load = info.getLoad();
-        StorageClusterStatusModel.Node node = 
-          model.addLiveNode(
-            info.getServerAddress().getHostname() + ":" + 
-            Integer.toString(info.getServerAddress().getPort()),
-            info.getStartCode(), load.getUsedHeapMB(),
-            load.getMaxHeapMB());
-        node.setRequests(load.getNumberOfRequests());
-        for (HServerLoad.RegionLoad region: load.getRegionsLoad()) {
-          node.addRegion(region.getName(), region.getStores(),
-            region.getStorefiles(), region.getStorefileSizeMB(),
-            region.getMemstoreSizeMB(), region.getStorefileIndexSizeMB());
-        }
-      }
-      for (String name: status.getDeadServerNames()) {
-        model.addDeadNode(name);
-      }
-      ResponseBuilder response = Response.ok(model);
-      response.cacheControl(cacheControl);
-      return response.build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-                  Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterVersionResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterVersionResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterVersionResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterVersionResource.java Wed May 14 00:26:57 2014
@@ -1,78 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.rest.model.StorageClusterVersionModel;
-
-public class StorageClusterVersionResource extends ResourceBase {
-  private static final Log LOG =
-    LogFactory.getLog(StorageClusterVersionResource.class);
-
-  static CacheControl cacheControl;
-  static {
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  /**
-   * Constructor
-   * @throws IOException
-   */
-  public StorageClusterVersionResource() throws IOException {
-    super();
-  }
-
-  @GET
-  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
-  public Response get(final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    try {
-      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      StorageClusterVersionModel model = new StorageClusterVersionModel();
-      model.setVersion(admin.getClusterStatus().getHBaseVersion());
-      ResponseBuilder response = Response.ok(model);
-      response.cacheControl(cacheControl);
-      return response.build();
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-                  Response.Status.SERVICE_UNAVAILABLE);
-    }
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java Wed May 14 00:26:57 2014
@@ -1,69 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-
-public class TableResource extends ResourceBase {
-
-  String table;
-
-  /**
-   * Constructor
-   * @param table
-   * @throws IOException
-   */
-  public TableResource(String table) throws IOException {
-    super();
-    this.table = table;
-  }
-
-  @Path("exists")
-  public ExistsResource getExistsResource() throws IOException {
-    return new ExistsResource(table);
-  }
-
-  @Path("regions")
-  public RegionsResource getRegionsResource() throws IOException {
-    return new RegionsResource(table);
-  }
-
-  @Path("scanner")
-  public ScannerResource getScannerResource() throws IOException {
-    return new ScannerResource(table);
-  }
-
-  @Path("schema")
-  public SchemaResource getSchemaResource() throws IOException {
-    return new SchemaResource(table);
-  }
-
-  @Path("{rowspec: .+}")
-  public RowResource getRowResource(
-      final @PathParam("rowspec") String rowspec,
-      final @QueryParam("v") String versions) throws IOException {
-    return new RowResource(table, rowspec, versions);
-  }
-}

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/VersionResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/VersionResource.java?rev=1594423&r1=1594422&r2=1594423&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/VersionResource.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/rest/VersionResource.java Wed May 14 00:26:57 2014
@@ -1,101 +0,0 @@
-/*
- * Copyright 2010 The Apache Software Foundation
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.hbase.rest;
-
-import java.io.IOException;
-
-import javax.servlet.ServletContext;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.rest.model.VersionModel;
-
-/**
- * Implements REST software version reporting
- * <p>
- * <tt>/version/rest</tt>
- * <p>
- * <tt>/version</tt> (alias for <tt>/version/rest</tt>)
- */
-public class VersionResource extends ResourceBase {
-
-  private static final Log LOG = LogFactory.getLog(VersionResource.class);
-
-  static CacheControl cacheControl;
-  static {
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  /**
-   * Constructor
-   * @throws IOException
-   */
-  public VersionResource() throws IOException {
-    super();
-  }
-
-  /**
-   * Build a response for a version request.
-   * @param context servlet context
-   * @param uriInfo (JAX-RS context variable) request URL
-   * @return a response for a version request 
-   */
-  @GET
-  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context ServletContext context, 
-      final @Context UriInfo uriInfo) {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    ResponseBuilder response = Response.ok(new VersionModel(context));
-    response.cacheControl(cacheControl);
-    return response.build();
-  }
-
-  /**
-   * Dispatch to StorageClusterVersionResource
-   */
-  @Path("cluster")
-  public StorageClusterVersionResource getClusterVersionResource() 
-      throws IOException {
-    return new StorageClusterVersionResource();
-  }
-
-  /**
-   * Dispatch <tt>/version/rest</tt> to self.
-   */
-  @Path("rest")
-  public VersionResource getVersionResource() {
-    return this;
-  }
-}