hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r928031 [1/5] - in /hadoop/hbase/trunk: contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/ core/src/main/java/org/apache/hadoop/hbase/regionserver/...
Date Fri, 26 Mar 2010 19:33:28 GMT
Author: apurtell
Date: Fri Mar 26 19:33:27 2010
New Revision: 928031

URL: http://svn.apache.org/viewvc?rev=928031&view=rev
Log:
CRLF cleanup

Modified:
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/Main.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RegionsResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResourceConfig.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RootResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowSpec.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerResultGenerator.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/SchemaResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/TableResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/VersionResource.java
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/CellMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/CellSetMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/ColumnSchemaMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/ScannerMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/StorageClusterStatusMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/TableInfoMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/TableSchemaMessage.proto
    hadoop/hbase/trunk/contrib/stargate/src/main/resources/org/apache/hadoop/hbase/stargate/protobuf/VersionMessage.proto
    hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/DeleteCompare.java
    hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/DeleteTracker.java
    hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/GetDeleteTracker.java
    hadoop/hbase/trunk/core/src/main/resources/webapps/master/master.jsp
    hadoop/hbase/trunk/core/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
    hadoop/hbase/trunk/core/src/test/java/org/apache/hadoop/hbase/regionserver/TestDeleteCompare.java

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/Main.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/Main.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/Main.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/Main.java Fri Mar 26 19:33:27 2010
@@ -1,88 +1,88 @@
-/*
- * Copyright 2009 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.stargate;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import com.sun.jersey.spi.container.servlet.ServletContainer;
-
-/**
- * Main class for launching Stargate as a servlet hosted by an embedded Jetty
- * servlet container.
- * <p> 
- * The following options are supported:
- * <ul>
- * <li>-p: service port</li>
- * </ul>
- */
-public class Main implements Constants {
-
-  public static void main(String[] args) throws Exception {
-    // process command line
-
-    Options options = new Options();
-    options.addOption("p", "port", true, "service port");
-    options.addOption("m", "multiuser", false, "enable multiuser mode");
-    CommandLineParser parser = new PosixParser();
-    CommandLine cmd = parser.parse(options, args);
-    int port = 8080;
-    if (cmd.hasOption("p")) {
-      port = Integer.valueOf(cmd.getOptionValue("p"));
-    }
-
-    // set up the Jersey servlet container for Jetty
-
-    ServletHolder sh = new ServletHolder(ServletContainer.class);
-    sh.setInitParameter(
-      "com.sun.jersey.config.property.resourceConfigClass",
-      ResourceConfig.class.getCanonicalName());
-    sh.setInitParameter("com.sun.jersey.config.property.packages",
-      "jetty");
-
-    // set up Jetty and run the embedded server
-
-    Server server = new Server(port);
-    server.setSendServerVersion(false);
-    server.setSendDateHeader(false);
-    server.setStopAtShutdown(true);
-      // set up context
-    Context context = new Context(server, "/", Context.SESSIONS);
-    context.addServlet(sh, "/*");
-
-    // configure the Stargate singleton
-
-    RESTServlet servlet = RESTServlet.getInstance();
-    servlet.setMultiUser(cmd.hasOption("m"));
-    for (Connector conn: server.getConnectors()) {
-      servlet.addConnectorAddress(conn.getHost(), conn.getLocalPort());
-    }
-
-    server.start();
-    server.join();
-  }
-}
+/*
+ * Copyright 2009 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.stargate;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+/**
+ * Main class for launching Stargate as a servlet hosted by an embedded Jetty
+ * servlet container.
+ * <p> 
+ * The following options are supported:
+ * <ul>
+ * <li>-p: service port</li>
+ * </ul>
+ */
+public class Main implements Constants {
+
+  public static void main(String[] args) throws Exception {
+    // process command line
+
+    Options options = new Options();
+    options.addOption("p", "port", true, "service port");
+    options.addOption("m", "multiuser", false, "enable multiuser mode");
+    CommandLineParser parser = new PosixParser();
+    CommandLine cmd = parser.parse(options, args);
+    int port = 8080;
+    if (cmd.hasOption("p")) {
+      port = Integer.valueOf(cmd.getOptionValue("p"));
+    }
+
+    // set up the Jersey servlet container for Jetty
+
+    ServletHolder sh = new ServletHolder(ServletContainer.class);
+    sh.setInitParameter(
+      "com.sun.jersey.config.property.resourceConfigClass",
+      ResourceConfig.class.getCanonicalName());
+    sh.setInitParameter("com.sun.jersey.config.property.packages",
+      "jetty");
+
+    // set up Jetty and run the embedded server
+
+    Server server = new Server(port);
+    server.setSendServerVersion(false);
+    server.setSendDateHeader(false);
+    server.setStopAtShutdown(true);
+      // set up context
+    Context context = new Context(server, "/", Context.SESSIONS);
+    context.addServlet(sh, "/*");
+
+    // configure the Stargate singleton
+
+    RESTServlet servlet = RESTServlet.getInstance();
+    servlet.setMultiUser(cmd.hasOption("m"));
+    for (Connector conn: server.getConnectors()) {
+      servlet.addConnectorAddress(conn.getHost(), conn.getLocalPort());
+    }
+
+    server.start();
+    server.join();
+  }
+}

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RegionsResource.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RegionsResource.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RegionsResource.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RegionsResource.java Fri Mar 26 19:33:27 2010
@@ -1,110 +1,110 @@
-/*
- * 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.stargate;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Map;
-
-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.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
-import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.stargate.User;
-import org.apache.hadoop.hbase.stargate.model.TableInfoModel;
-import org.apache.hadoop.hbase.stargate.model.TableRegionModel;
-
-public class RegionsResource implements Constants {
-  private static final Log LOG = LogFactory.getLog(RegionsResource.class);
-
-  User user;
-  String table;
-  CacheControl cacheControl;
-  RESTServlet servlet;
-
-  public RegionsResource(User user, String table) throws IOException {
-    if (user != null) {
-      if (!user.isAdmin()) {
-        throw new WebApplicationException(Response.Status.FORBIDDEN);
-      }
-      this.user = user;
-    }
-    this.table = table;
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-    servlet = RESTServlet.getInstance();
-  }
-
-  private Map<HRegionInfo,HServerAddress> getTableRegions()
-      throws IOException {
-    HTablePool pool = servlet.getTablePool();
-    HTable table = (HTable) pool.getTable(this.table);
-    try {
-      return table.getRegionsInfo();
-    } 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 {
-      TableInfoModel model = new TableInfoModel(table);
-      Map<HRegionInfo,HServerAddress> regions = getTableRegions();
-      for (Map.Entry<HRegionInfo,HServerAddress> e: regions.entrySet()) {
-        HRegionInfo hri = e.getKey();
-        HServerAddress addr = e.getValue();
-        InetSocketAddress sa = addr.getInetSocketAddress();
-        model.add(
-          new TableRegionModel(table, hri.getRegionId(), hri.getStartKey(),
-                hri.getEndKey(),
-                sa.getHostName() + ":" + Integer.valueOf(sa.getPort())));
-      }
-      ResponseBuilder response = Response.ok(model);
-      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);
-    }
-  }
-
-}
+/*
+ * 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.stargate;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.Map;
+
+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.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.TableNotFoundException;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.HTablePool;
+import org.apache.hadoop.hbase.stargate.User;
+import org.apache.hadoop.hbase.stargate.model.TableInfoModel;
+import org.apache.hadoop.hbase.stargate.model.TableRegionModel;
+
+public class RegionsResource implements Constants {
+  private static final Log LOG = LogFactory.getLog(RegionsResource.class);
+
+  User user;
+  String table;
+  CacheControl cacheControl;
+  RESTServlet servlet;
+
+  public RegionsResource(User user, String table) throws IOException {
+    if (user != null) {
+      if (!user.isAdmin()) {
+        throw new WebApplicationException(Response.Status.FORBIDDEN);
+      }
+      this.user = user;
+    }
+    this.table = table;
+    cacheControl = new CacheControl();
+    cacheControl.setNoCache(true);
+    cacheControl.setNoTransform(false);
+    servlet = RESTServlet.getInstance();
+  }
+
+  private Map<HRegionInfo,HServerAddress> getTableRegions()
+      throws IOException {
+    HTablePool pool = servlet.getTablePool();
+    HTable table = (HTable) pool.getTable(this.table);
+    try {
+      return table.getRegionsInfo();
+    } 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 {
+      TableInfoModel model = new TableInfoModel(table);
+      Map<HRegionInfo,HServerAddress> regions = getTableRegions();
+      for (Map.Entry<HRegionInfo,HServerAddress> e: regions.entrySet()) {
+        HRegionInfo hri = e.getKey();
+        HServerAddress addr = e.getValue();
+        InetSocketAddress sa = addr.getInetSocketAddress();
+        model.add(
+          new TableRegionModel(table, hri.getRegionId(), hri.getStartKey(),
+                hri.getEndKey(),
+                sa.getHostName() + ":" + Integer.valueOf(sa.getPort())));
+      }
+      ResponseBuilder response = Response.ok(model);
+      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);
+    }
+  }
+
+}

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResourceConfig.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResourceConfig.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResourceConfig.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResourceConfig.java Fri Mar 26 19:33:27 2010
@@ -1,29 +1,29 @@
-/*
- * 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.stargate;
-
-import com.sun.jersey.api.core.PackagesResourceConfig;
-
-public class ResourceConfig extends PackagesResourceConfig {
-  public ResourceConfig() {
-    super("org.apache.hadoop.hbase.stargate");
-  }
-}
+/*
+ * 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.stargate;
+
+import com.sun.jersey.api.core.PackagesResourceConfig;
+
+public class ResourceConfig extends PackagesResourceConfig {
+  public ResourceConfig() {
+    super("org.apache.hadoop.hbase.stargate");
+  }
+}

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java Fri Mar 26 19:33:27 2010
@@ -1,51 +1,51 @@
-/*
- * 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.stargate;
-
-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.stargate.model.ScannerModel;
-
-import org.json.JSONObject;
-
-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(new JSONObject(filter));
-  }
-
-  public abstract void putBack(KeyValue kv);
-
-  public abstract void close();
-
-}
+/*
+ * 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.stargate;
+
+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.stargate.model.ScannerModel;
+
+import org.json.JSONObject;
+
+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(new JSONObject(filter));
+  }
+
+  public abstract void putBack(KeyValue kv);
+
+  public abstract void close();
+
+}

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RootResource.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RootResource.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RootResource.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RootResource.java Fri Mar 26 19:33:27 2010
@@ -1,191 +1,191 @@
-/*
- * 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.stargate;
-
-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.stargate.User;
-import org.apache.hadoop.hbase.stargate.model.TableListModel;
-import org.apache.hadoop.hbase.stargate.model.TableModel;
-
-@Path("/")
-public class RootResource implements Constants {
-  private static final Log LOG = LogFactory.getLog(RootResource.class);
-
-  RESTServlet servlet;
-  CacheControl cacheControl;
-
-  public RootResource() throws IOException {
-    servlet = RESTServlet.getInstance();
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  private final User auth(final String token) throws IOException {
-    User user = servlet.getAuthenticator().getUserForToken(token);
-    if (user == null || user.isDisabled()) {
-      throw new WebApplicationException(Response.Status.FORBIDDEN);
-    }
-    return user;
-  }
-
-  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;
-  }
-
-  private final TableListModel getTableListForUser(final User user) 
-      throws IOException {
-    TableListModel tableList;
-    if (user.isAdmin()) {
-      tableList = getTableList();
-    } else {
-      tableList = new TableListModel();
-      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      HTableDescriptor[] list = admin.listTables();
-      String prefix = user.getName() + ".";
-      for (HTableDescriptor htd: list) {
-        String name = htd.getNameAsString();
-        if (!name.startsWith(prefix)) {
-          continue;
-        }
-        tableList.add(new TableModel(name.substring(prefix.length())));
-      }
-    }
-    return tableList;
-  }
-
-  @GET
-  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) throws IOException {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    if (servlet.isMultiUser()) {
-      throw new WebApplicationException(Response.Status.BAD_REQUEST);
-    }
-    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 {
-    if (servlet.isMultiUser()) {
-      throw new WebApplicationException(Response.Status.BAD_REQUEST);
-    }
-    return new StorageClusterStatusResource();
-  }
-
-  @Path("version")
-  public VersionResource getVersionResource() throws IOException {
-    return new VersionResource();
-  }
-
-  @Path("{token: [0-9a-fA-F]{32} }") // 128 bit md5 sums
-  public Response getTableRootResource(
-      final @PathParam("token") String token) throws IOException {
-    if (servlet.isMultiUser()) {
-      User user = auth(token);
-      if (!servlet.userRequestLimit(user, 1)) {
-        throw new WebApplicationException(Response.status(509).build());
-      }
-      try {
-        ResponseBuilder response = Response.ok(getTableListForUser(user));
-        response.cacheControl(cacheControl);
-        return response.build();
-      } catch (IOException e) {
-        throw new WebApplicationException(e, 
-                    Response.Status.SERVICE_UNAVAILABLE);
-      }
-    }
-    throw new WebApplicationException(Response.Status.BAD_REQUEST);
-  }
-
-  @Path("{token: [0-9a-fA-F]{32} }/status/cluster") // 128 bit md5 sums
-  public StorageClusterStatusResource getClusterStatusResourceAuthorized(
-      final @PathParam("token") String token) throws IOException {
-    if (servlet.isMultiUser()) {
-      User user = auth(token);
-      if (user.isAdmin()) {
-        if (!servlet.userRequestLimit(user, 1)) {
-          throw new WebApplicationException(Response.status(509).build());
-        }
-        return new StorageClusterStatusResource();
-      }
-      throw new WebApplicationException(Response.Status.FORBIDDEN);
-    }
-    throw new WebApplicationException(Response.Status.BAD_REQUEST);
-  }
-
-  @Path("{token: [0-9a-fA-F]{32} }/{table}")
-  public TableResource getTableResource(
-      final @PathParam("token") String token, 
-      final @PathParam("table") String table) throws IOException {
-    if (servlet.isMultiUser()) {
-      User user = auth(token);
-      if (!servlet.userRequestLimit(user, 1)) {
-        throw new WebApplicationException(Response.status(509).build());
-      }
-      return new TableResource(user, table);
-    }
-    throw new WebApplicationException(Response.Status.BAD_REQUEST);
-  }
-
-  @Path("{table}")
-  public TableResource getTableResource(
-      final @PathParam("table") String table) throws IOException {
-    if (servlet.isMultiUser()) {
-      throw new WebApplicationException(Response.Status.BAD_REQUEST);
-    }
-    return new TableResource(null, table);
-  }
-
-}
+/*
+ * 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.stargate;
+
+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.stargate.User;
+import org.apache.hadoop.hbase.stargate.model.TableListModel;
+import org.apache.hadoop.hbase.stargate.model.TableModel;
+
+@Path("/")
+public class RootResource implements Constants {
+  private static final Log LOG = LogFactory.getLog(RootResource.class);
+
+  RESTServlet servlet;
+  CacheControl cacheControl;
+
+  public RootResource() throws IOException {
+    servlet = RESTServlet.getInstance();
+    cacheControl = new CacheControl();
+    cacheControl.setNoCache(true);
+    cacheControl.setNoTransform(false);
+  }
+
+  private final User auth(final String token) throws IOException {
+    User user = servlet.getAuthenticator().getUserForToken(token);
+    if (user == null || user.isDisabled()) {
+      throw new WebApplicationException(Response.Status.FORBIDDEN);
+    }
+    return user;
+  }
+
+  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;
+  }
+
+  private final TableListModel getTableListForUser(final User user) 
+      throws IOException {
+    TableListModel tableList;
+    if (user.isAdmin()) {
+      tableList = getTableList();
+    } else {
+      tableList = new TableListModel();
+      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
+      HTableDescriptor[] list = admin.listTables();
+      String prefix = user.getName() + ".";
+      for (HTableDescriptor htd: list) {
+        String name = htd.getNameAsString();
+        if (!name.startsWith(prefix)) {
+          continue;
+        }
+        tableList.add(new TableModel(name.substring(prefix.length())));
+      }
+    }
+    return tableList;
+  }
+
+  @GET
+  @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
+  public Response get(final @Context UriInfo uriInfo) throws IOException {
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("GET " + uriInfo.getAbsolutePath());
+    }
+    servlet.getMetrics().incrementRequests(1);
+    if (servlet.isMultiUser()) {
+      throw new WebApplicationException(Response.Status.BAD_REQUEST);
+    }
+    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 {
+    if (servlet.isMultiUser()) {
+      throw new WebApplicationException(Response.Status.BAD_REQUEST);
+    }
+    return new StorageClusterStatusResource();
+  }
+
+  @Path("version")
+  public VersionResource getVersionResource() throws IOException {
+    return new VersionResource();
+  }
+
+  @Path("{token: [0-9a-fA-F]{32} }") // 128 bit md5 sums
+  public Response getTableRootResource(
+      final @PathParam("token") String token) throws IOException {
+    if (servlet.isMultiUser()) {
+      User user = auth(token);
+      if (!servlet.userRequestLimit(user, 1)) {
+        throw new WebApplicationException(Response.status(509).build());
+      }
+      try {
+        ResponseBuilder response = Response.ok(getTableListForUser(user));
+        response.cacheControl(cacheControl);
+        return response.build();
+      } catch (IOException e) {
+        throw new WebApplicationException(e, 
+                    Response.Status.SERVICE_UNAVAILABLE);
+      }
+    }
+    throw new WebApplicationException(Response.Status.BAD_REQUEST);
+  }
+
+  @Path("{token: [0-9a-fA-F]{32} }/status/cluster") // 128 bit md5 sums
+  public StorageClusterStatusResource getClusterStatusResourceAuthorized(
+      final @PathParam("token") String token) throws IOException {
+    if (servlet.isMultiUser()) {
+      User user = auth(token);
+      if (user.isAdmin()) {
+        if (!servlet.userRequestLimit(user, 1)) {
+          throw new WebApplicationException(Response.status(509).build());
+        }
+        return new StorageClusterStatusResource();
+      }
+      throw new WebApplicationException(Response.Status.FORBIDDEN);
+    }
+    throw new WebApplicationException(Response.Status.BAD_REQUEST);
+  }
+
+  @Path("{token: [0-9a-fA-F]{32} }/{table}")
+  public TableResource getTableResource(
+      final @PathParam("token") String token, 
+      final @PathParam("table") String table) throws IOException {
+    if (servlet.isMultiUser()) {
+      User user = auth(token);
+      if (!servlet.userRequestLimit(user, 1)) {
+        throw new WebApplicationException(Response.status(509).build());
+      }
+      return new TableResource(user, table);
+    }
+    throw new WebApplicationException(Response.Status.BAD_REQUEST);
+  }
+
+  @Path("{table}")
+  public TableResource getTableResource(
+      final @PathParam("table") String table) throws IOException {
+    if (servlet.isMultiUser()) {
+      throw new WebApplicationException(Response.Status.BAD_REQUEST);
+    }
+    return new TableResource(null, table);
+  }
+
+}

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java Fri Mar 26 19:33:27 2010
@@ -1,112 +1,112 @@
-/*
- * 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.stargate;
-
-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");
-  }
-
-}
+/*
+ * 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.stargate;
+
+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: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowSpec.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowSpec.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowSpec.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/RowSpec.java Fri Mar 26 19:33:27 2010
@@ -1,317 +1,317 @@
-/*
- * 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.stargate;
-
-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;
-
-  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);
-  }
-
-  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;
-  }
-
-  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 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("}");
-    return result.toString();
-  }
-
-}
+/*
+ * 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.stargate;
+
+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;
+
+  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);
+  }
+
+  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;
+  }
+
+  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 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("}");
+    return result.toString();
+  }
+
+}

Modified: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java Fri Mar 26 19:33:27 2010
@@ -1,159 +1,159 @@
-/*
- * 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.stargate;
-
-import java.io.IOException;
-
-import javax.ws.rs.DELETE;
-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 org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.stargate.model.CellModel;
-import org.apache.hadoop.hbase.stargate.model.CellSetModel;
-import org.apache.hadoop.hbase.stargate.model.RowModel;
-import org.apache.hadoop.hbase.util.Bytes;
-
-import com.sun.jersey.core.util.Base64;
-
-public class ScannerInstanceResource implements Constants {
-  private static final Log LOG =
-    LogFactory.getLog(ScannerInstanceResource.class);
-
-  User user;
-  ResultGenerator generator;
-  String id;
-  int batch;
-  RESTServlet servlet;
-  CacheControl cacheControl;
-
-  public ScannerInstanceResource(User user, String table, String id, 
-      ResultGenerator generator, int batch) throws IOException {
-    this.user = user;
-    this.id = id;
-    this.generator = generator;
-    this.batch = batch;
-    servlet = RESTServlet.getInstance();
-    cacheControl = new CacheControl();
-    cacheControl.setNoCache(true);
-    cacheControl.setNoTransform(false);
-  }
-
-  @GET
-  @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) throws IOException {
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("GET " + uriInfo.getAbsolutePath());
-    }
-    servlet.getMetrics().incrementRequests(1);
-    CellSetModel model = new CellSetModel();
-    RowModel rowModel = null;
-    byte[] rowKey = null;
-    int count = batch;
-    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 == batch) {
-          return Response.noContent().build();
-        }
-        break;
-      }
-      if (rowKey == null) {
-        rowKey = value.getRow();
-        rowModel = new RowModel(rowKey);
-      }
-      if (!Bytes.equals(value.getRow(), rowKey)) {
-        // the user request limit is a transaction limit, so we need to
-        // account for scanner.next()
-        if (user != null && !servlet.userRequestLimit(user, 1)) {
-          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.encode(value.getRow()));      
-      response.header("X-Column", 
-        Base64.encode(
-          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();
-  }
-}
+/*
+ * 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.stargate;
+
+import java.io.IOException;
+
+import javax.ws.rs.DELETE;
+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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.stargate.model.CellModel;
+import org.apache.hadoop.hbase.stargate.model.CellSetModel;
+import org.apache.hadoop.hbase.stargate.model.RowModel;
+import org.apache.hadoop.hbase.util.Bytes;
+
+import com.sun.jersey.core.util.Base64;
+
+public class ScannerInstanceResource implements Constants {
+  private static final Log LOG =
+    LogFactory.getLog(ScannerInstanceResource.class);
+
+  User user;
+  ResultGenerator generator;
+  String id;
+  int batch;
+  RESTServlet servlet;
+  CacheControl cacheControl;
+
+  public ScannerInstanceResource(User user, String table, String id, 
+      ResultGenerator generator, int batch) throws IOException {
+    this.user = user;
+    this.id = id;
+    this.generator = generator;
+    this.batch = batch;
+    servlet = RESTServlet.getInstance();
+    cacheControl = new CacheControl();
+    cacheControl.setNoCache(true);
+    cacheControl.setNoTransform(false);
+  }
+
+  @GET
+  @Produces({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
+  public Response get(final @Context UriInfo uriInfo) throws IOException {
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("GET " + uriInfo.getAbsolutePath());
+    }
+    servlet.getMetrics().incrementRequests(1);
+    CellSetModel model = new CellSetModel();
+    RowModel rowModel = null;
+    byte[] rowKey = null;
+    int count = batch;
+    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 == batch) {
+          return Response.noContent().build();
+        }
+        break;
+      }
+      if (rowKey == null) {
+        rowKey = value.getRow();
+        rowModel = new RowModel(rowKey);
+      }
+      if (!Bytes.equals(value.getRow(), rowKey)) {
+        // the user request limit is a transaction limit, so we need to
+        // account for scanner.next()
+        if (user != null && !servlet.userRequestLimit(user, 1)) {
+          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.encode(value.getRow()));      
+      response.header("X-Column", 
+        Base64.encode(
+          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: hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerResource.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerResource.java?rev=928031&r1=928030&r2=928031&view=diff
==============================================================================
--- hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerResource.java (original)
+++ hadoop/hbase/trunk/contrib/stargate/src/main/java/org/apache/hadoop/hbase/stargate/ScannerResource.java Fri Mar 26 19:33:27 2010
@@ -1,143 +1,143 @@
-/*
- * 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.stargate;
-
-import java.io.IOException;
-import java.net.URI;
-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.stargate.User;
-import org.apache.hadoop.hbase.stargate.model.ScannerModel;
-
-public class ScannerResource implements Constants {
-
-  private static final Log LOG = LogFactory.getLog(ScannerResource.class);
-
-  static final Map<String,ScannerInstanceResource> scanners = 
-    new HashMap<String,ScannerInstanceResource>();
-
-  User user;
-  String tableName;
-  String actualTableName;
-  RESTServlet servlet;
-
-  public ScannerResource(User user, String table) throws IOException {
-    if (user != null) {
-      this.user = user;
-      this.actualTableName = 
-        !user.isAdmin() ? user.getName() + "." + table : table;
-    } else {
-      this.actualTableName = table;
-    }
-    this.tableName = table;
-    servlet = RESTServlet.getInstance();
-  }
-
-  static void delete(final String id) {
-    synchronized (scanners) {
-      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(actualTableName, spec, filter);
-      String id = gen.getID();
-      ScannerInstanceResource instance = 
-        new ScannerInstanceResource(user, actualTableName, id, gen, 
-          model.getBatch());
-      synchronized (scanners) {
-        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) {
-    synchronized (scanners) {
-      ScannerInstanceResource instance = scanners.get(id);
-      if (instance == null) {
-        throw new WebApplicationException(Response.Status.NOT_FOUND);
-      }
-      return instance;
-    }
-  }
-
-}
+/*
+ * 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.stargate;
+
+import java.io.IOException;
+import java.net.URI;
+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.stargate.User;
+import org.apache.hadoop.hbase.stargate.model.ScannerModel;
+
+public class ScannerResource implements Constants {
+
+  private static final Log LOG = LogFactory.getLog(ScannerResource.class);
+
+  static final Map<String,ScannerInstanceResource> scanners = 
+    new HashMap<String,ScannerInstanceResource>();
+
+  User user;
+  String tableName;
+  String actualTableName;
+  RESTServlet servlet;
+
+  public ScannerResource(User user, String table) throws IOException {
+    if (user != null) {
+      this.user = user;
+      this.actualTableName = 
+        !user.isAdmin() ? user.getName() + "." + table : table;
+    } else {
+      this.actualTableName = table;
+    }
+    this.tableName = table;
+    servlet = RESTServlet.getInstance();
+  }
+
+  static void delete(final String id) {
+    synchronized (scanners) {
+      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(actualTableName, spec, filter);
+      String id = gen.getID();
+      ScannerInstanceResource instance = 
+        new ScannerInstanceResource(user, actualTableName, id, gen, 
+          model.getBatch());
+      synchronized (scanners) {
+        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) {
+    synchronized (scanners) {
+      ScannerInstanceResource instance = scanners.get(id);
+      if (instance == null) {
+        throw new WebApplicationException(Response.Status.NOT_FOUND);
+      }
+      return instance;
+    }
+  }
+
+}



Mime
View raw message