hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r946057 - in /hbase/branches/0.20: ./ src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/auth/ src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/util/ ...
Date Wed, 19 May 2010 07:02:32 GMT
Author: apurtell
Date: Wed May 19 07:02:31 2010
New Revision: 946057

URL: http://svn.apache.org/viewvc?rev=946057&view=rev
Log:
HBASE-2567 [stargate] minimize differences between 0.20 branch and trunk

Added:
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResourceBase.java
Removed:
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/User.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/auth/
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/util/
    hbase/branches/0.20/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/auth/
    hbase/branches/0.20/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/util/
Modified:
    hbase/branches/0.20/CHANGES.txt
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Constants.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ExistsResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Main.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RESTServlet.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RegionsResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RootResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowSpec.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResultGenerator.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/SchemaResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterStatusResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterVersionResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/TableResource.java
    hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/VersionResource.java

Modified: hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/CHANGES.txt?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/CHANGES.txt (original)
+++ hbase/branches/0.20/CHANGES.txt Wed May 19 07:02:31 2010
@@ -12,6 +12,9 @@ Release 0.20.5 - Mon May 17 10:14:58 PDT
    HBASE-2428  NPE in ProcessRegionClose because meta is offline kills master
                and thus the cluster
 
+  IMPROVEMENTS
+   HBASE-2567  [stargate] minimize differences between 0.20 branch and trunk
+
 Release 0.20.4 - Mon May  3 16:16:02 PDT 2010
   INCOMPATIBLE CHANGES
    HBASE-2248  Provide new non-copy mechanism to assure atomic reads in get

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Constants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Constants.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Constants.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Constants.java Wed May 19 07:02:31 2010
@@ -21,20 +21,10 @@
 package org.apache.hadoop.hbase.stargate;
 
 /**
- * Common constants for org.apache.hadoop.hbase.stargate
+ * Common constants
  */
 public interface Constants {
-  public static final String VERSION_STRING = "0.0.2";
-
-  public static final String AUTHENTICATOR_KEY = "stargate.authenticator";
-  public static final String MULTIUSER_KEY = "stargate.multiuser";
-  public static final String STATUS_REPORT_PERIOD_KEY =
-    "stargate.status.period";
-
-  public static final String USERS_TABLE = "users";
-
-  public static final String INSTANCE_ZNODE_ROOT = "/stargate/instance";
-  public static final String USERS_ZNODE_ROOT = "/stargate/users";
+  public static final String VERSION_STRING = "1.0";
 
   public static final int DEFAULT_MAX_AGE = 60 * 60 * 4;  // 4 hours
 

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ExistsResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ExistsResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ExistsResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ExistsResource.java Wed May 19 07:02:31 2010
@@ -33,39 +33,34 @@ import javax.ws.rs.core.Response.Respons
 
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 
-public class ExistsResource implements Constants {
+public class ExistsResource extends ResourceBase {
 
-  User user;
-  String tableName;
-  String actualTableName;
-  CacheControl cacheControl;
-  RESTServlet servlet;
-
-  public ExistsResource(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 CacheControl cacheControl;
+  static {
     cacheControl = new CacheControl();
     cacheControl.setNoCache(true);
     cacheControl.setNoTransform(false);
   }
 
+  String tableName;
+
+  /**
+   * Constructor
+   * @param table
+   * @throws IOException
+   */
+  public ExistsResource(String table) throws IOException {
+    super();
+    this.tableName = table;
+  }
+
   @GET
   @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
     MIMETYPE_BINARY})
-  public Response get(final @Context UriInfo uriInfo) throws IOException {
-    if (!servlet.userRequestLimit(user, 1)) {
-      Response.status(509).build();
-    }
+  public Response get(final @Context UriInfo uriInfo) {
     try {
       HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      if (!admin.tableExists(actualTableName)) {
+      if (!admin.tableExists(tableName)) {
         throw new WebApplicationException(Response.Status.NOT_FOUND);
       }
     } catch (IOException e) {
@@ -75,5 +70,4 @@ public class ExistsResource implements C
     response.cacheControl(cacheControl);
     return response.build();
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Main.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Main.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Main.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/Main.java Wed May 19 07:02:31 2010
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 The Apache Software Foundation
+ * Copyright 2010 The Apache Software Foundation
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,12 +20,11 @@
 
 package org.apache.hadoop.hbase.stargate;
 
-import java.net.InetAddress;
-
 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.Server;
 import org.mortbay.jetty.servlet.Context;
 import org.mortbay.jetty.servlet.ServletHolder;
@@ -33,8 +32,7 @@ import org.mortbay.jetty.servlet.Servlet
 import com.sun.jersey.spi.container.servlet.ServletContainer;
 
 /**
- * Main class for launching Stargate as a servlet hosted by an embedded Jetty
- * servlet container.
+ * Main class for launching REST gateway as a servlet hosted by Jetty.
  * <p> 
  * The following options are supported:
  * <ul>
@@ -48,7 +46,6 @@ public class Main implements Constants {
 
     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;
@@ -65,19 +62,10 @@ public class Main implements Constants {
     sh.setInitParameter("com.sun.jersey.config.property.packages",
       "jetty");
 
-    // configure the Stargate singleton
+    // set up Jetty and run the embedded server
 
     RESTServlet servlet = RESTServlet.getInstance();
-    port = servlet.getConfiguration().getInt("stargate.port", port);
-    if (!servlet.isMultiUser()) {
-      servlet.setMultiUser(cmd.hasOption("m"));
-    }
-    servlet.addConnectorAddress(
-      servlet.getConfiguration().get("stargate.hostname",
-        InetAddress.getLocalHost().getCanonicalHostName()),
-      port);
-
-    // set up Jetty and run the embedded server
+    port = servlet.getConfiguration().getInt("hbase.rest.port", port);
 
     Server server = new Server(port);
     server.setSendServerVersion(false);

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RESTServlet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RESTServlet.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RESTServlet.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RESTServlet.java Wed May 19 07:02:31 2010
@@ -20,124 +20,30 @@
 
 package org.apache.hadoop.hbase.stargate;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.hbase.Chore;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.stargate.auth.Authenticator;
-import org.apache.hadoop.hbase.stargate.auth.HBCAuthenticator;
-import org.apache.hadoop.hbase.stargate.auth.HTableAuthenticator;
-import org.apache.hadoop.hbase.stargate.auth.JDBCAuthenticator;
-import org.apache.hadoop.hbase.stargate.auth.ZooKeeperAuthenticator;
 import org.apache.hadoop.hbase.stargate.metrics.StargateMetrics;
-import org.apache.hadoop.hbase.stargate.util.HTableTokenBucket;
-import org.apache.hadoop.hbase.stargate.util.SoftUserData;
-import org.apache.hadoop.hbase.stargate.util.UserData;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.util.Threads;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
-
-import org.apache.hadoop.util.StringUtils;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.Watcher.Event.EventType;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.data.Stat;
-
-import com.sun.jersey.api.json.JSONJAXBContext;
-import com.sun.jersey.api.json.JSONMarshaller;
-import com.sun.jersey.server.impl.container.servlet.ServletAdaptor;
 
 /**
  * Singleton class encapsulating global REST servlet state and functions.
  */
-public class RESTServlet extends ServletAdaptor 
-    implements Constants, Watcher {
-
-  private static final Log LOG = LogFactory.getLog(RESTServlet.class);
-  private static final long serialVersionUID = 1L;
+public class RESTServlet implements Constants {
 
   private static RESTServlet instance;
 
-  @XmlRootElement(name="status")
-  static class StatusModel {  
-    @XmlAttribute long requests;
-    @XmlElement List<String> connectors = new ArrayList<String>();
-    public void addConnector(String host, int port) {
-      connectors.add(host + ":" + Integer.toString(port));
-    }
-  }
-
-  class StatusReporter extends Chore {
-
-    final JSONJAXBContext context;
-    final JSONMarshaller marshaller;
-    
-    public StatusReporter(int period, AtomicBoolean stopping) 
-        throws IOException {
-      super(period, stopping);
-        try {
-          context = new JSONJAXBContext(StatusModel.class);
-          marshaller = context.createJSONMarshaller();
-        } catch (JAXBException e) {
-          throw new IOException(e);
-        }
-    }
-
-    @Override
-    protected void chore() {
-      if (wrapper != null) try {
-        StatusModel model = new StatusModel();
-        model.requests = (long)metrics.getRequests();
-        for (Pair<String,Integer> e: connectors) {
-          model.addConnector(e.getFirst(), e.getSecond());
-        }
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        marshaller.marshallToJSON(model, os);
-        ensureExists(znode, CreateMode.EPHEMERAL, os.toByteArray());
-      } catch (Exception e) {
-        LOG.error(StringUtils.stringifyException(e));
-      }
-    }
-  }
-
-  final String znode = INSTANCE_ZNODE_ROOT + "/" + System.currentTimeMillis();
-  transient final HBaseConfiguration conf;
-  transient final HTablePool pool;
-  transient volatile ZooKeeperWrapper wrapper;
-  transient Chore statusReporter;
-  transient Authenticator authenticator;
+  HBaseConfiguration conf;
+  HTablePool pool;
   AtomicBoolean stopping = new AtomicBoolean(false);
-  boolean multiuser;
   Map<String,Integer> maxAgeMap = 
     Collections.synchronizedMap(new HashMap<String,Integer>());
-  List<Pair<String,Integer>> connectors = 
-    Collections.synchronizedList(new ArrayList<Pair<String,Integer>>());
   StargateMetrics metrics = new StargateMetrics();
 
   /**
@@ -151,44 +57,6 @@ public class RESTServlet extends Servlet
     return instance;
   }
 
-  private boolean ensureExists(final String znode, final CreateMode mode,
-      final byte[] data) {
-    try {
-      ZooKeeper zk = wrapper.getZooKeeper();
-      Stat stat = zk.exists(znode, false);
-      if (stat != null) {
-        zk.setData(znode, data, -1);
-        return true;
-      }
-      zk.create(znode, data, Ids.OPEN_ACL_UNSAFE, mode);
-      LOG.info("Created ZNode " + znode);
-      return true;
-    } catch (KeeperException.NodeExistsException e) {
-      return true;      // ok, move on.
-    } catch (KeeperException.NoNodeException e) {
-      return ensureParentExists(znode, CreateMode.PERSISTENT, new byte[]{}) &&
-        ensureExists(znode, mode, data);
-    } catch (KeeperException e) {
-      LOG.warn(StringUtils.stringifyException(e));
-    } catch (InterruptedException e) {
-      LOG.warn(StringUtils.stringifyException(e));
-    }
-    return false;
-  }
-
-  private boolean ensureParentExists(final String znode, final CreateMode mode,
-      final byte[] data) {
-    int index = znode.lastIndexOf('/');
-    if (index <= 0) {   // Parent is root, which always exists.
-      return true;
-    }
-    return ensureExists(znode.substring(0, index), mode, data);
-  }
-
-  ZooKeeperWrapper initZooKeeperWrapper() throws IOException {
-    return new ZooKeeperWrapper(conf, this);
-  }
-
   /**
    * Constructor
    * @throws IOException
@@ -196,48 +64,12 @@ public class RESTServlet extends Servlet
   public RESTServlet() throws IOException {
     this.conf = new HBaseConfiguration();
     this.pool = new HTablePool(conf, 10);
-    this.wrapper = initZooKeeperWrapper();
-    this.statusReporter = new StatusReporter(
-      conf.getInt(STATUS_REPORT_PERIOD_KEY, 1000 * 30), stopping);
-    Threads.setDaemonThreadRunning(statusReporter, "Stargate.statusReporter");
-    this.multiuser = conf.getBoolean("stargate.multiuser", false);
-    if (this.multiuser) {
-      LOG.info("multiuser mode enabled");
-      getAuthenticator();
-    }
-  }
-
-  @Override
-  public void process(WatchedEvent event) {
-    LOG.debug(("ZooKeeper.Watcher event " + event.getType() + " with path " +
-      event.getPath()));
-    // handle disconnection (or manual delete to test disconnection scenario)
-    if (event.getState() == KeeperState.Expired || 
-        (event.getType().equals(EventType.NodeDeleted) && 
-            event.getPath().equals(znode))) {
-      wrapper.close();
-      wrapper = null;
-      while (!stopping.get()) try {
-        wrapper = initZooKeeperWrapper();
-        break;
-      } catch (IOException e) {
-        LOG.error(StringUtils.stringifyException(e));
-        try {
-          Thread.sleep(10 * 1000);
-        } catch (InterruptedException ex) {
-        }
-      }
-    }
   }
 
   HTablePool getTablePool() {
     return pool;
   }
 
-  ZooKeeperWrapper getZooKeeperWrapper() {
-    return wrapper;
-  }
-
   HBaseConfiguration getConfiguration() {
     return conf;
   }
@@ -246,10 +78,6 @@ public class RESTServlet extends Servlet
     return metrics;
   }
 
-  void addConnectorAddress(String host, int port) {
-    connectors.add(new Pair<String,Integer>(host, port));
-  }
-
   /**
    * @param tableName the table name
    * @return the maximum cache age suitable for use with this table, in
@@ -289,84 +117,4 @@ public class RESTServlet extends Servlet
   public void invalidateMaxAge(String tableName) {
     maxAgeMap.remove(tableName);
   }
-
-  /**
-   * @return true if the servlet should operate in multiuser mode
-   */
-  public boolean isMultiUser() {
-    return multiuser;
-  }
-
-  /**
-   * @param multiuser true if the servlet should operate in multiuser mode 
-   */
-  public void setMultiUser(boolean multiuser) {
-    this.multiuser = multiuser;
-  }
-
-  /**
-   * @return an authenticator
-   */
-  public Authenticator getAuthenticator() {
-    if (authenticator == null) {
-      String className = conf.get(AUTHENTICATOR_KEY,
-        HBCAuthenticator.class.getCanonicalName());
-      try {
-        Class<?> c = getClass().getClassLoader().loadClass(className);
-        if (className.endsWith(HBCAuthenticator.class.getName()) ||
-            className.endsWith(HTableAuthenticator.class.getName()) ||
-            className.endsWith(JDBCAuthenticator.class.getName())) {
-          Constructor<?> cons = c.getConstructor(HBaseConfiguration.class);
-          authenticator = (Authenticator)
-            cons.newInstance(new Object[] { conf });
-        } else if (className.endsWith(ZooKeeperAuthenticator.class.getName())) {
-          Constructor<?> cons = c.getConstructor(HBaseConfiguration.class,
-            ZooKeeperWrapper.class);
-          authenticator = (Authenticator)
-            cons.newInstance(new Object[] { conf, wrapper });
-        } else {
-          authenticator = (Authenticator)c.newInstance();
-        }
-      } catch (Exception e) {
-        LOG.error(StringUtils.stringifyException(e));
-      }
-      if (authenticator == null) {
-        authenticator = new HBCAuthenticator(conf);
-      }
-      LOG.info("using authenticator " + authenticator);
-    }
-    return authenticator;
-  }
-
-  /**
-   * @param authenticator
-   */
-  public void setAuthenticator(Authenticator authenticator) {
-    this.authenticator = authenticator;
-  }
-
-  /**
-   * Check if the user has exceeded their request token limit within the
-   * current interval
-   * @param user the user
-   * @param want the number of tokens desired
-   * @throws IOException
-   */
-  public boolean userRequestLimit(final User user, int want) 
-      throws IOException {
-    if (multiuser) {
-      UserData ud = SoftUserData.get(user);
-      HTableTokenBucket tb = (HTableTokenBucket) ud.get(UserData.TOKENBUCKET);
-      if (tb == null) {
-        tb = new HTableTokenBucket(conf, Bytes.toBytes(user.getToken()));
-        ud.put(UserData.TOKENBUCKET, tb);
-      }
-      if (tb.available() < want) {
-        return false;
-      }
-      tb.remove(want);
-    }
-    return true;
-  }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RegionsResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RegionsResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RegionsResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RegionsResource.java Wed May 19 07:02:31 2010
@@ -41,38 +41,30 @@ import org.apache.hadoop.hbase.HServerAd
 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 {
+public class RegionsResource extends ResourceBase {
   private static final Log LOG = LogFactory.getLog(RegionsResource.class);
 
-  User user;
-  String tableName;
-  String actualTableName;
-  CacheControl cacheControl;
-  RESTServlet servlet;
-
-  public RegionsResource(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;
+  static CacheControl cacheControl;
+  static {
     cacheControl = new CacheControl();
     cacheControl.setNoCache(true);
     cacheControl.setNoTransform(false);
-    servlet = RESTServlet.getInstance();
+  }
+
+  String tableName;
+
+  public RegionsResource(String table) throws IOException {
+    super();
+    this.tableName = table;
   }
 
   private Map<HRegionInfo,HServerAddress> getTableRegions()
       throws IOException {
     HTablePool pool = servlet.getTablePool();
-    HTable table = pool.getTable(actualTableName);
+    HTable table = pool.getTable(tableName);
     try {
       return table.getRegionsInfo();
     } finally {
@@ -82,32 +74,22 @@ public class RegionsResource implements 
 
   @GET
   @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) throws IOException {
+  public Response get(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("GET " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     try {
-      String name = user.isAdmin() ? actualTableName : tableName;
-      TableInfoModel model = new TableInfoModel(name);
+      TableInfoModel model = new TableInfoModel(tableName);
       Map<HRegionInfo,HServerAddress> regions = getTableRegions();
       for (Map.Entry<HRegionInfo,HServerAddress> e: regions.entrySet()) {
         HRegionInfo hri = e.getKey();
-        if (user.isAdmin()) {
-          HServerAddress addr = e.getValue();
-          InetSocketAddress sa = addr.getInetSocketAddress();
-          model.add(
-            new TableRegionModel(name, hri.getRegionId(), hri.getStartKey(),
-              hri.getEndKey(),
-              sa.getHostName() + ":" + Integer.valueOf(sa.getPort())));
-        } else {
-          model.add(
-            new TableRegionModel(name, hri.getRegionId(), hri.getStartKey(),
-              hri.getEndKey()));
-        }
+        HServerAddress addr = e.getValue();
+        InetSocketAddress sa = addr.getInetSocketAddress();
+        model.add(
+          new TableRegionModel(tableName, hri.getRegionId(),
+            hri.getStartKey(), hri.getEndKey(),
+            sa.getHostName() + ":" + Integer.valueOf(sa.getPort())));
       }
       ResponseBuilder response = Response.ok(model);
       response.cacheControl(cacheControl);
@@ -119,5 +101,4 @@ public class RegionsResource implements 
                   Response.Status.SERVICE_UNAVAILABLE);
     }
   }
-
 }

Added: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResourceBase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResourceBase.java?rev=946057&view=auto
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResourceBase.java (added)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResourceBase.java Wed May 19 07:02:31 2010
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+public class ResourceBase implements Constants {
+
+  RESTServlet servlet;
+
+  public ResourceBase() throws IOException {
+    servlet = RESTServlet.getInstance();
+  }
+}

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ResultGenerator.java Wed May 19 07:02:31 2010
@@ -45,5 +45,4 @@ public abstract class ResultGenerator im
   public abstract void putBack(KeyValue kv);
 
   public abstract void close();
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RootResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RootResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RootResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RootResource.java Wed May 19 07:02:31 2010
@@ -38,30 +38,26 @@ import org.apache.commons.logging.LogFac
 
 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 {
+public class RootResource extends ResourceBase {
   private static final Log LOG = LogFactory.getLog(RootResource.class);
 
-  RESTServlet servlet;
-  CacheControl cacheControl;
-
-  public RootResource() throws IOException {
-    servlet = RESTServlet.getInstance();
+  static CacheControl cacheControl;
+  static {
     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;
+  /**
+   * Constructor
+   * @throws IOException
+   */
+  public RootResource() throws IOException {
+    super();
   }
 
   private final TableListModel getTableList() throws IOException {
@@ -74,37 +70,13 @@ public class RootResource implements Con
     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 {
+  public Response get(final @Context UriInfo uriInfo) {
     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);
@@ -116,12 +88,9 @@ public class RootResource implements Con
   }
 
   @Path("status/cluster")
-  public StorageClusterStatusResource getClusterStatusResource() 
+  public StorageClusterStatusResource getClusterStatusResource()
       throws IOException {
-    if (servlet.isMultiUser()) {
-      throw new WebApplicationException(Response.Status.BAD_REQUEST);
-    }
-    return new StorageClusterStatusResource(User.DEFAULT_USER);
+    return new StorageClusterStatusResource();
   }
 
   @Path("version")
@@ -129,57 +98,9 @@ public class RootResource implements Con
     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)) {
-        return 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 != null && user.isAdmin()) {
-        return new StorageClusterStatusResource(user);
-      }
-      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);
-      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(User.DEFAULT_USER, table);
+    return new TableResource(table);
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java Wed May 19 07:02:31 2010
@@ -43,59 +43,52 @@ import org.apache.commons.logging.LogFac
 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.HTable;
 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.stargate.User;
 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;
 
-public class RowResource implements Constants {
+public class RowResource extends ResourceBase {
   private static final Log LOG = LogFactory.getLog(RowResource.class);
 
-  User user;
   String tableName;
-  String actualTableName;
   RowSpec rowspec;
   CacheControl cacheControl;
-  RESTServlet servlet;
 
-  public RowResource(User user, String table, String rowspec, String versions)
+  /**
+   * Constructor
+   * @param table
+   * @param rowspec
+   * @param versions
+   * @throws IOException
+   */
+  public RowResource(String table, String rowspec, String versions)
       throws IOException {
-    this.user = user;
-    if (user != null) {
-      this.actualTableName =
-        !user.isAdmin() ? user.getName() + "." + table : table;
-    } else {
-      this.actualTableName = table;
-    }
+    super();
     this.tableName = table;
     this.rowspec = new RowSpec(URLDecoder.decode(rowspec,
       HConstants.UTF8_ENCODING));
     if (versions != null) {
       this.rowspec.setMaxVersions(Integer.valueOf(versions));
     }
-    this.servlet = RESTServlet.getInstance();
-    cacheControl = new CacheControl();
-    cacheControl.setMaxAge(servlet.getMaxAge(actualTableName));
-    cacheControl.setNoTransform(false);
+    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) throws IOException {
+  public Response get(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("GET " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     try {
       ResultGenerator generator =
-        ResultGenerator.fromRowSpec(actualTableName, rowspec, null);
+        ResultGenerator.fromRowSpec(tableName, rowspec, null);
       if (!generator.hasNext()) {
         throw new WebApplicationException(Response.Status.NOT_FOUND);
       }
@@ -111,8 +104,8 @@ public class RowResource implements Cons
           rowModel = new RowModel(rowKey);
         }
         rowModel.addCell(
-          new CellModel(value.getColumn(), value.getTimestamp(),
-              value.getValue()));
+          new CellModel(value.getFamily(), value.getQualifier(), 
+              value.getTimestamp(), value.getValue()));
         if (++count > rowspec.getMaxValues()) {
           break;
         }
@@ -130,14 +123,10 @@ public class RowResource implements Cons
 
   @GET
   @Produces(MIMETYPE_BINARY)
-  public Response getBinary(final @Context UriInfo uriInfo) 
-      throws IOException {
+  public Response getBinary(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("GET " + uriInfo.getAbsolutePath() + " as "+ MIMETYPE_BINARY);
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     // doesn't make sense to use a non specific coordinate as this can only
     // return a single cell
@@ -146,7 +135,7 @@ public class RowResource implements Cons
     }
     try {
       ResultGenerator generator =
-        ResultGenerator.fromRowSpec(actualTableName, rowspec, null);
+        ResultGenerator.fromRowSpec(tableName, rowspec, null);
       if (!generator.hasNext()) {
         throw new WebApplicationException(Response.Status.NOT_FOUND);
       }
@@ -162,23 +151,23 @@ public class RowResource implements Cons
   }
 
   Response update(final CellSetModel model, final boolean replace) {
+    servlet.getMetrics().incrementRequests(1);
     HTablePool pool = servlet.getTablePool();
     HTable table = null;
     try {
       List<RowModel> rows = model.getRows();
-      // the user request limit is a transaction limit, so we need to
-      // account for updates by row
-      if (user != null && !servlet.userRequestLimit(user, rows.size())) {
-        throw new WebApplicationException(Response.status(509).build());
-      }
-      table = pool.getTable(actualTableName);
+      table = pool.getTable(tableName);
       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());
-          put.add(parts[0], parts[1], cell.getTimestamp(), cell.getValue());
+          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()) {
@@ -202,6 +191,7 @@ public class RowResource implements Cons
   // 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();
     HTable table = null;    
     try {
@@ -229,8 +219,12 @@ public class RowResource implements Cons
       }
       Put put = new Put(row);
       byte parts[][] = KeyValue.parseColumn(column);
-      put.add(parts[0], parts[1], timestamp, message);
-      table = pool.getTable(actualTableName);
+      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());
@@ -249,70 +243,48 @@ public class RowResource implements Cons
   @PUT
   @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
   public Response put(final CellSetModel model,
-      final @Context UriInfo uriInfo) throws IOException {
+      final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("PUT " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
-    servlet.getMetrics().incrementRequests(1);
     return update(model, true);
   }
 
   @PUT
   @Consumes(MIMETYPE_BINARY)
   public Response putBinary(final byte[] message,
-      final @Context UriInfo uriInfo, final @Context HttpHeaders headers)
-      throws IOException
-  {
+      final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("PUT " + uriInfo.getAbsolutePath() + " as "+ MIMETYPE_BINARY);
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
-    servlet.getMetrics().incrementRequests(1);
     return updateBinary(message, headers, true);
   }
 
   @POST
   @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
   public Response post(final CellSetModel model,
-      final @Context UriInfo uriInfo) throws IOException {
+      final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("POST " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
-    servlet.getMetrics().incrementRequests(1);
     return update(model, false);
   }
 
   @POST
   @Consumes(MIMETYPE_BINARY)
   public Response postBinary(final byte[] message,
-      final @Context UriInfo uriInfo, final @Context HttpHeaders headers) 
-      throws IOException {
+      final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("POST " + uriInfo.getAbsolutePath() + " as "+MIMETYPE_BINARY);
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
-    servlet.getMetrics().incrementRequests(1);
     return updateBinary(message, headers, false);
   }
 
   @DELETE
-  public Response delete(final @Context UriInfo uriInfo) throws IOException {
+  public Response delete(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("DELETE " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     Delete delete = null;
     if (rowspec.hasTimestamp())
@@ -339,7 +311,7 @@ public class RowResource implements Cons
     HTablePool pool = servlet.getTablePool();
     HTable table = null;
     try {
-      table = pool.getTable(actualTableName);
+      table = pool.getTable(tableName);
       table.delete(delete);
       if (LOG.isDebugEnabled()) {
         LOG.debug("DELETE " + delete.toString());
@@ -354,5 +326,4 @@ public class RowResource implements Cons
     }
     return Response.ok().build();
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResultGenerator.java Wed May 19 07:02:31 2010
@@ -43,7 +43,14 @@ public class RowResultGenerator extends 
     try {
       Get get = new Get(rowspec.getRow());
       if (rowspec.hasColumns()) {
-        get.addColumns(rowspec.getColumns());
+        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: 
@@ -101,5 +108,4 @@ public class RowResultGenerator extends 
   public void remove() {
     throw new UnsupportedOperationException("remove not supported");
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowSpec.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowSpec.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowSpec.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowSpec.java Wed May 19 07:02:31 2010
@@ -377,5 +377,4 @@ public class RowSpec {
     result.append("}");
     return result.toString();
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerInstanceResource.java Wed May 19 07:02:31 2010
@@ -40,38 +40,35 @@ 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.Base64;
 import org.apache.hadoop.hbase.util.Bytes;
 
-import com.sun.jersey.core.util.Base64;
-
-public class ScannerInstanceResource implements Constants {
+public class ScannerInstanceResource extends ResourceBase {
   private static final Log LOG =
     LogFactory.getLog(ScannerInstanceResource.class);
 
-  User user;
+  static CacheControl cacheControl;
+  static {
+    cacheControl = new CacheControl();
+    cacheControl.setNoCache(true);
+    cacheControl.setNoTransform(false);
+  }
+
   ResultGenerator generator;
   String id;
   int batch = 1;
-  RESTServlet servlet;
-  CacheControl cacheControl;
 
-  public ScannerInstanceResource(User user, String table, String id, 
+  public ScannerInstanceResource(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, 
-      @QueryParam("n") int maxRows, final @QueryParam("c") int maxValues)
-      throws IOException {
+      @QueryParam("n") int maxRows, final @QueryParam("c") int maxValues) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("GET " + uriInfo.getAbsolutePath());
     }
@@ -106,12 +103,6 @@ public class ScannerInstanceResource imp
         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;
-        }
         // if maxRows was given as a query param, stop if we would exceed the
         // specified number of rows
         if (maxRows > 0) { 
@@ -125,8 +116,8 @@ public class ScannerInstanceResource imp
         rowModel = new RowModel(rowKey);
       }
       rowModel.addCell(
-        new CellModel(value.getColumn(), value.getTimestamp(),
-              value.getValue()));
+        new CellModel(value.getFamily(), value.getQualifier(), 
+          value.getTimestamp(), value.getValue()));
     } while (--count > 0);
     model.addRow(rowModel);
     ResponseBuilder response = Response.ok(model);
@@ -150,8 +141,8 @@ public class ScannerInstanceResource imp
       }
       ResponseBuilder response = Response.ok(value.getValue());
       response.cacheControl(cacheControl);
-      response.header("X-Row", Base64.encode(value.getRow()));
-      response.header("X-Column", Base64.encode(value.getColumn()));
+      response.header("X-Row", Base64.encodeBytes(value.getRow()));
+      response.header("X-Column", Base64.encodeBytes(value.getColumn()));
       response.header("X-Timestamp", value.getTimestamp());
       return response.build();
     } catch (IllegalStateException e) {

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResource.java Wed May 19 07:02:31 2010
@@ -41,32 +41,25 @@ 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 {
+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>());
 
-  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;
-    }
+  /**
+   * Constructor
+   * @param table
+   * @throws IOException
+   */
+  public ScannerResource(String table) throws IOException {
+    super();
     this.tableName = table;
-    servlet = RESTServlet.getInstance();
   }
 
   static void delete(final String id) {
@@ -77,10 +70,7 @@ public class ScannerResource implements 
   }
 
   Response update(final ScannerModel model, final boolean replace, 
-      final UriInfo uriInfo) throws IOException {
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
+      final UriInfo uriInfo) {
     servlet.getMetrics().incrementRequests(1);
     byte[] endRow = model.hasEndRow() ? model.getEndRow() : null;
     RowSpec spec = new RowSpec(model.getStartRow(), endRow,
@@ -88,11 +78,10 @@ public class ScannerResource implements 
     try {
       Filter filter = ScannerResultGenerator.buildFilterFromModel(model);
       ScannerResultGenerator gen = 
-        new ScannerResultGenerator(actualTableName, spec, filter);
+        new ScannerResultGenerator(tableName, spec, filter);
       String id = gen.getID();
       ScannerInstanceResource instance = 
-        new ScannerInstanceResource(user, actualTableName, id, gen, 
-          model.getBatch());
+        new ScannerInstanceResource(tableName, id, gen, model.getBatch());
       scanners.put(id, instance);
       if (LOG.isDebugEnabled()) {
         LOG.debug("new scanner: " + id);
@@ -111,7 +100,7 @@ public class ScannerResource implements 
   @PUT
   @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
   public Response put(final ScannerModel model, 
-      final @Context UriInfo uriInfo) throws IOException {
+      final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("PUT " + uriInfo.getAbsolutePath());
     }
@@ -121,7 +110,7 @@ public class ScannerResource implements 
   @POST
   @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
   public Response post(final ScannerModel model,
-      final @Context UriInfo uriInfo) throws IOException {
+      final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("POST " + uriInfo.getAbsolutePath());
     }
@@ -137,5 +126,4 @@ public class ScannerResource implements 
     }
     return instance;
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResultGenerator.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResultGenerator.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ScannerResultGenerator.java Wed May 19 07:02:31 2010
@@ -175,5 +175,4 @@ public class ScannerResultGenerator exte
   public void remove() {
     throw new UnsupportedOperationException("remove not supported");
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/SchemaResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/SchemaResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/SchemaResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/SchemaResource.java Wed May 19 07:02:31 2010
@@ -48,39 +48,36 @@ import org.apache.hadoop.hbase.TableNotF
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 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.ColumnSchemaModel;
 import org.apache.hadoop.hbase.stargate.model.TableSchemaModel;
 import org.apache.hadoop.hbase.util.Bytes;
 
-public class SchemaResource implements Constants {
+public class SchemaResource extends ResourceBase {
   private static final Log LOG = LogFactory.getLog(SchemaResource.class);
 
-  User user;
-  String tableName;
-  String actualTableName;
-  CacheControl cacheControl;
-  RESTServlet servlet;
-
-  public SchemaResource(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 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();
-    HTable table = pool.getTable(actualTableName);
+    HTable table = pool.getTable(tableName);
     try {
       return table.getTableDescriptor();
     } finally {
@@ -90,13 +87,10 @@ public class SchemaResource implements C
 
   @GET
   @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
-  public Response get(final @Context UriInfo uriInfo) throws IOException {
+  public Response get(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("GET " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     try {
       ResponseBuilder response =
@@ -111,11 +105,10 @@ public class SchemaResource implements C
     }
   }
 
-  private Response replace(final byte[] tableName, 
-      final TableSchemaModel model, final UriInfo uriInfo,
-      final HBaseAdmin admin) {
+  private Response replace(final byte[] name, final TableSchemaModel model,
+      final UriInfo uriInfo, final HBaseAdmin admin) {
     try {
-      HTableDescriptor htd = new HTableDescriptor(tableName);
+      HTableDescriptor htd = new HTableDescriptor(name);
       for (Map.Entry<QName,Object> e: model.getAny().entrySet()) {
         htd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
       }
@@ -126,10 +119,10 @@ public class SchemaResource implements C
         }
         htd.addFamily(hcd);
       }
-      if (admin.tableExists(tableName)) {
-        admin.disableTable(tableName);
-        admin.modifyTable(tableName, htd);
-        admin.enableTable(tableName);
+      if (admin.tableExists(name)) {
+        admin.disableTable(name);
+        admin.modifyTable(name, htd);
+        admin.enableTable(name);
       } else try {
         admin.createTable(htd);
       } catch (TableExistsException e) {
@@ -143,11 +136,11 @@ public class SchemaResource implements C
     }      
   } 
 
-  private Response update(final byte[] tableName,final TableSchemaModel model,
+  private Response update(final byte[] name, final TableSchemaModel model,
       final UriInfo uriInfo, final HBaseAdmin admin) {
     try {
-      HTableDescriptor htd = admin.getTableDescriptor(tableName);
-      admin.disableTable(tableName);
+      HTableDescriptor htd = admin.getTableDescriptor(name);
+      admin.disableTable(name);
       try {
         for (ColumnSchemaModel family: model.getColumns()) {
           HColumnDescriptor hcd = new HColumnDescriptor(family.getName());
@@ -155,7 +148,7 @@ public class SchemaResource implements C
             hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
           }
           if (htd.hasFamily(hcd.getName())) {
-            admin.modifyColumn(tableName, hcd.getName(), hcd);
+            admin.modifyColumn(name, hcd.getName(), hcd);
           } else {
             admin.addColumn(model.getName(), hcd);            
           }
@@ -177,12 +170,12 @@ public class SchemaResource implements C
       final UriInfo uriInfo) {
     try {
       servlet.invalidateMaxAge(tableName);
-      byte[] tableName = Bytes.toBytes(actualTableName);
+      byte[] name = Bytes.toBytes(tableName);
       HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
-      if (replace || !admin.tableExists(tableName)) {
-        return replace(tableName, model, uriInfo, admin);
+      if (replace || !admin.tableExists(name)) {
+        return replace(name, model, uriInfo, admin);
       } else {
-        return update(tableName, model, uriInfo, admin);
+        return update(name, model, uriInfo, admin);
       }
     } catch (IOException e) {
       throw new WebApplicationException(e, 
@@ -193,13 +186,10 @@ public class SchemaResource implements C
   @PUT
   @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
   public Response put(final TableSchemaModel model, 
-      final @Context UriInfo uriInfo) throws IOException {
+      final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("PUT " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     return update(model, true, uriInfo);
   }
@@ -207,31 +197,25 @@ public class SchemaResource implements C
   @POST
   @Consumes({MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF})
   public Response post(final TableSchemaModel model, 
-      final @Context UriInfo uriInfo) throws IOException {
+      final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("PUT " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     return update(model, false, uriInfo);
   }
 
   @DELETE
-  public Response delete(final @Context UriInfo uriInfo) throws IOException {
+  public Response delete(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("DELETE " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      return Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     try {
       HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
       boolean success = false;
       for (int i = 0; i < 10; i++) try {
-        admin.disableTable(actualTableName);
+        admin.disableTable(tableName);
         success = true;
         break;
       } catch (IOException e) {
@@ -239,7 +223,7 @@ public class SchemaResource implements C
       if (!success) {
         throw new IOException("could not disable table");
       }
-      admin.deleteTable(actualTableName);
+      admin.deleteTable(tableName);
       return Response.ok().build();
     } catch (TableNotFoundException e) {
       throw new WebApplicationException(Response.Status.NOT_FOUND);
@@ -248,5 +232,4 @@ public class SchemaResource implements C
             Response.Status.SERVICE_UNAVAILABLE);
     }
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterStatusResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterStatusResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterStatusResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterStatusResource.java Wed May 19 07:02:31 2010
@@ -40,31 +40,31 @@ import org.apache.hadoop.hbase.HServerLo
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.stargate.model.StorageClusterStatusModel;
 
-public class StorageClusterStatusResource implements Constants {
+public class StorageClusterStatusResource extends ResourceBase {
   private static final Log LOG =
     LogFactory.getLog(StorageClusterStatusResource.class);
 
-  private User user;
-  private CacheControl cacheControl;
-  private RESTServlet servlet;
+  static CacheControl cacheControl;
+  static {
+    cacheControl = new CacheControl();
+    cacheControl.setNoCache(true);
+    cacheControl.setNoTransform(false);
+  }
 
-  public StorageClusterStatusResource(User user) throws IOException {
-    this.user = user;
-    this.servlet = RESTServlet.getInstance();
-    this.cacheControl = new CacheControl();
-    this.cacheControl.setNoCache(true);
-    this.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) throws IOException {
+  public Response get(final @Context UriInfo uriInfo) {
     if (LOG.isDebugEnabled()) {
       LOG.debug("GET " + uriInfo.getAbsolutePath());
     }
-    if (!servlet.userRequestLimit(user, 1)) {
-      Response.status(509).build();
-    }
     servlet.getMetrics().incrementRequests(1);
     try {
       HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterVersionResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterVersionResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterVersionResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/StorageClusterVersionResource.java Wed May 19 07:02:31 2010
@@ -33,24 +33,29 @@ import javax.ws.rs.core.Response.Respons
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.HBaseConfiguration;
+
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.stargate.model.StorageClusterVersionModel;
 
-public class StorageClusterVersionResource implements Constants {
+public class StorageClusterVersionResource extends ResourceBase {
   private static final Log LOG =
     LogFactory.getLog(StorageClusterVersionResource.class);
 
-  private CacheControl cacheControl;
-  private RESTServlet servlet;
-
-  public StorageClusterVersionResource() throws IOException {
-    servlet = RESTServlet.getInstance();
+  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) {
@@ -58,9 +63,8 @@ public class StorageClusterVersionResour
       LOG.debug("GET " + uriInfo.getAbsolutePath());
     }
     servlet.getMetrics().incrementRequests(1);
-    HBaseConfiguration conf = servlet.getConfiguration();
     try {
-      HBaseAdmin admin = new HBaseAdmin(conf);
+      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
       StorageClusterVersionModel model = new StorageClusterVersionModel();
       model.setVersion(admin.getClusterStatus().getHBaseVersion());
       ResponseBuilder response = Response.ok(model);

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/TableResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/TableResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/TableResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/TableResource.java Wed May 19 07:02:31 2010
@@ -25,51 +25,45 @@ import java.io.IOException;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
 
-import org.apache.hadoop.hbase.stargate.User;
+public class TableResource extends ResourceBase {
 
-public class TableResource implements Constants {
-
-  User user;
   String table;
 
-  public TableResource(User user, String table) {
-    this.user = user;
+  /**
+   * 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(user, table);
+    return new ExistsResource(table);
   }
 
   @Path("regions")
   public RegionsResource getRegionsResource() throws IOException {
-    return new RegionsResource(user, table);
+    return new RegionsResource(table);
   }
 
   @Path("scanner")
   public ScannerResource getScannerResource() throws IOException {
-    return new ScannerResource(user, table);
+    return new ScannerResource(table);
   }
 
   @Path("schema")
   public SchemaResource getSchemaResource() throws IOException {
-    return new SchemaResource(user, table);
+    return new SchemaResource(table);
   }
 
   @Path("{rowspec: .+}")
   public RowResource getRowResource(
       final @PathParam("rowspec") String rowspec,
-      final @QueryParam("v") String versions) {
-    try {
-      return new RowResource(user, table, rowspec, versions);
-    } catch (IOException e) {
-      throw new WebApplicationException(e, 
-                  Response.Status.INTERNAL_SERVER_ERROR);
-    }
+      final @QueryParam("v") String versions) throws IOException {
+    return new RowResource(table, rowspec, versions);
   }
-
 }

Modified: hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/VersionResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/VersionResource.java?rev=946057&r1=946056&r2=946057&view=diff
==============================================================================
--- hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/VersionResource.java (original)
+++ hbase/branches/0.20/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/VersionResource.java Wed May 19 07:02:31 2010
@@ -34,29 +34,32 @@ import javax.ws.rs.core.Response.Respons
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.hadoop.hbase.stargate.model.VersionModel;
 
 /**
- * Implements Stargate software version reporting via
- * <p>
- * <tt>/version/stargate</tt>
- * <p>
- * <tt>/version</tt> (alias for <tt>/version/stargate</tt>)
+ * Implements REST software version reporting
  */
-public class VersionResource implements Constants {
-  private static final Log LOG = LogFactory.getLog(VersionResource.class);
+public class VersionResource extends ResourceBase {
 
-  private CacheControl cacheControl;
-  private RESTServlet servlet;
+  private static final Log LOG = LogFactory.getLog(VersionResource.class);
 
-  public VersionResource() throws IOException {
-    servlet = RESTServlet.getInstance();
+  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
@@ -85,10 +88,18 @@ public class VersionResource implements 
   }
 
   /**
+   * Dispatch <tt>/version/rest</tt> to self.
+   */
+  @Path("rest")
+  public VersionResource getRESTVersionResource() {
+    return this;
+  }
+
+  /**
    * Dispatch <tt>/version/stargate</tt> to self.
    */
   @Path("stargate")
-  public VersionResource getVersionResource() {
+  public VersionResource getStargateVersionResource() {
     return this;
   }
 }



Mime
View raw message