HBASE-3121 [rest] Do not perform cache control when returning results

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1024055 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2010-10-18 22:56:36 +00:00
parent 5f7c8ca1b2
commit 2fe608efd3
4 changed files with 3 additions and 59 deletions

View File

@ -593,7 +593,7 @@ Release 0.21.0 - Unreleased
HBASE-3098 TestMetaReaderEditor is broken in TRUNK; hangs
HBASE-3110 TestReplicationSink failing in TRUNK up on Hudson
HBASE-3101 bin assembly doesn't include -tests or -source jars
HBASE-3121 [rest] Do not perform cache control when returning results
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -21,14 +21,9 @@
package org.apache.hadoop.hbase.rest;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.rest.metrics.RESTMetrics;
@ -39,8 +34,6 @@ public class RESTServlet implements Constants {
private static RESTServlet INSTANCE;
private final Configuration conf;
private final HTablePool pool;
private final Map<String,Integer> maxAgeMap =
Collections.synchronizedMap(new HashMap<String,Integer>());
private final RESTMetrics metrics = new RESTMetrics();
/**
@ -100,44 +93,4 @@ public class RESTServlet implements Constants {
RESTMetrics getMetrics() {
return metrics;
}
/**
* @param tableName the table name
* @return the maximum cache age suitable for use with this table, in
* seconds
* @throws IOException
*/
public int getMaxAge(String tableName) throws IOException {
Integer i = maxAgeMap.get(tableName);
if (i != null) {
return i.intValue();
}
HTableInterface table = pool.getTable(tableName);
try {
int maxAge = DEFAULT_MAX_AGE;
for (HColumnDescriptor family :
table.getTableDescriptor().getFamilies()) {
int ttl = family.getTimeToLive();
if (ttl < 0) {
continue;
}
if (ttl < maxAge) {
maxAge = ttl;
}
}
maxAgeMap.put(tableName, maxAge);
return maxAge;
} finally {
pool.putTable(table);
}
}
/**
* Signal that a previously calculated maximum cache age has been
* invalidated by a schema change.
* @param tableName the table name
*/
public void invalidateMaxAge(String tableName) {
maxAgeMap.remove(tableName);
}
}

View File

@ -30,7 +30,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
@ -56,7 +55,6 @@ public class RowResource extends ResourceBase {
String tableName;
RowSpec rowspec;
CacheControl cacheControl;
/**
* Constructor
@ -77,9 +75,6 @@ public class RowResource extends ResourceBase {
if (versions != null) {
this.rowspec.setMaxVersions(Integer.valueOf(versions));
}
this.cacheControl = new CacheControl();
this.cacheControl.setMaxAge(servlet.getMaxAge(tableName));
this.cacheControl.setNoTransform(false);
}
@GET
@ -115,9 +110,7 @@ public class RowResource extends ResourceBase {
value = generator.next();
} while (value != null);
model.addRow(rowModel);
ResponseBuilder response = Response.ok(model);
response.cacheControl(cacheControl);
return response.build();
return Response.ok(model).build();
} catch (IOException e) {
throw new WebApplicationException(e,
Response.Status.SERVICE_UNAVAILABLE);
@ -144,7 +137,6 @@ public class RowResource extends ResourceBase {
}
KeyValue value = generator.next();
ResponseBuilder response = Response.ok(value.getValue());
response.cacheControl(cacheControl);
response.header("X-Timestamp", value.getTimestamp());
return response.build();
} catch (IOException e) {

View File

@ -148,7 +148,7 @@ public class SchemaResource extends ResourceBase {
hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
}
if (htd.hasFamily(hcd.getName())) {
admin.modifyColumn(name, hcd.getName(), hcd);
admin.modifyColumn(name, hcd);
} else {
admin.addColumn(model.getName(), hcd);
}
@ -169,7 +169,6 @@ public class SchemaResource extends ResourceBase {
private Response update(final TableSchemaModel model, final boolean replace,
final UriInfo uriInfo) {
try {
servlet.invalidateMaxAge(tableName);
byte[] name = Bytes.toBytes(tableName);
HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
if (replace || !admin.tableExists(name)) {