Commit b164384c authored by Yong Liu's avatar Yong Liu

Refs #3019, add latestTimeStamp when creating CUBE ETAG.

parent e95a7653
...@@ -42,7 +42,7 @@ public class CubeEntityTagFilter extends OperationEntityTagFilter { ...@@ -42,7 +42,7 @@ public class CubeEntityTagFilter extends OperationEntityTagFilter {
data.add(measure); data.add(measure);
} }
} }
data.add(TimedCacheCleanerFilter.getLatestTimeStamp());
return data; return data;
} }
......
...@@ -29,7 +29,7 @@ public class TimedCacheCleanerFilter implements Filter { ...@@ -29,7 +29,7 @@ public class TimedCacheCleanerFilter implements Filter {
Date currentTime = new Date(); Date currentTime = new Date();
if (currentTime.getTime() - latestTimeStamp > this.EXPIRATION_TIMEOUT) { if (currentTime.getTime() - latestTimeStamp > this.EXPIRATION_TIMEOUT) {
this.latestTimeStamp = currentTime.getTime(); setLatestTimeStamp(currentTime.getTime());
//If cache is old, clear //If cache is old, clear
NesstarDBFactory.getInstance().clear(); NesstarDBFactory.getInstance().clear();
} }
...@@ -37,6 +37,14 @@ public class TimedCacheCleanerFilter implements Filter { ...@@ -37,6 +37,14 @@ public class TimedCacheCleanerFilter implements Filter {
chain.doFilter(request, response); chain.doFilter(request, response);
} }
public static void setLatestTimeStamp(long latestTimeStamp) {
TimedCacheCleanerFilter.latestTimeStamp = latestTimeStamp;
}
public static long getLatestTimeStamp() {
return latestTimeStamp;
}
public void init(FilterConfig arg0) throws ServletException { } public void init(FilterConfig arg0) throws ServletException { }
public void destroy() { } public void destroy() { }
......
...@@ -102,7 +102,7 @@ public final class CubeResource extends AbstractResource { ...@@ -102,7 +102,7 @@ public final class CubeResource extends AbstractResource {
} }
}, serverHandler); }, serverHandler);
} }
private boolean isInvalidRequest(CubeRequest cubeRequest) { private boolean isInvalidRequest(CubeRequest cubeRequest) {
return cubeRequest.getDimensions() == null || cubeRequest.getDimensions().isEmpty(); return cubeRequest.getDimensions() == null || cubeRequest.getDimensions().isEmpty();
} }
...@@ -156,6 +156,9 @@ public final class CubeResource extends AbstractResource { ...@@ -156,6 +156,9 @@ public final class CubeResource extends AbstractResource {
} else { } else {
for (String id : cubeRequest.getMeasures()) { for (String id : cubeRequest.getMeasures()) {
Measure measure = getMeasure(id, classVariables); Measure measure = getMeasure(id, classVariables);
if (measure == null) {
continue;
}
sliceBuilder.addMeasure(measure); sliceBuilder.addMeasure(measure);
classVariables.getSlicemeasures().add(measure); classVariables.getSlicemeasures().add(measure);
} }
......
...@@ -24,7 +24,7 @@ public class CubeEntityTagFilterTest extends EntityTagFilterTest{ ...@@ -24,7 +24,7 @@ public class CubeEntityTagFilterTest extends EntityTagFilterTest{
public void testFilteringOnCube() throws Exception { public void testFilteringOnCube() throws Exception {
when(request.getRequestURL()).thenReturn(new StringBuffer("http://example.com/cube/cube1234")); when(request.getRequestURL()).thenReturn(new StringBuffer("http://example.com/cube/cube1234"));
when(request.getRequestURI()).thenReturn("/cube/cube1234"); when(request.getRequestURI()).thenReturn("/cube/cube1234");
when(request.getHeader("If-None-Match")).thenReturn("e82900cb24a5c9109973951fd8f9d95"); when(request.getHeader("If-None-Match")).thenReturn("80c3eeab70149ec9fdec22ce0c8fd7f8");
EntityTagFilter filter = new CubeEntityTagFilter(serverHandler); EntityTagFilter filter = new CubeEntityTagFilter(serverHandler);
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
...@@ -38,7 +38,7 @@ public class CubeEntityTagFilterTest extends EntityTagFilterTest{ ...@@ -38,7 +38,7 @@ public class CubeEntityTagFilterTest extends EntityTagFilterTest{
new StringBuffer("http://example.com/cube/cube1234?q={\"dimensions\":[{\"id\":\"dimensionID1\",\"members\":[\"memberID1\",\"memberID2\"]}],\"measures\":[\"measureID1\",\"measureID2\"]}")); new StringBuffer("http://example.com/cube/cube1234?q={\"dimensions\":[{\"id\":\"dimensionID1\",\"members\":[\"memberID1\",\"memberID2\"]}],\"measures\":[\"measureID1\",\"measureID2\"]}"));
when(request.getRequestURI()).thenReturn("/cube/cube1234"); when(request.getRequestURI()).thenReturn("/cube/cube1234");
when(request.getParameter("q")).thenReturn("{\"dimensions\":[{\"id\":\"dimensionID1\",\"members\":[\"memberID1\",\"memberID2\"]}],\"measures\":[\"measureID1\",\"measureID2\"]}"); when(request.getParameter("q")).thenReturn("{\"dimensions\":[{\"id\":\"dimensionID1\",\"members\":[\"memberID1\",\"memberID2\"]}],\"measures\":[\"measureID1\",\"measureID2\"]}");
when(request.getHeader("If-None-Match")).thenReturn("176481d3e6729a980c760cce59c8b1e6"); when(request.getHeader("If-None-Match")).thenReturn("8f7cf31c8d3cd8cc6903c795e7c0d696");
EntityTagFilter filter = new CubeEntityTagFilter(serverHandler); EntityTagFilter filter = new CubeEntityTagFilter(serverHandler);
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment