本文整理汇总了Java中mondrian.olap.CacheControl类的典型用法代码示例。如果您正苦于以下问题:Java CacheControl类的具体用法?Java CacheControl怎么用?Java CacheControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheControl类属于mondrian.olap包,在下文中一共展示了CacheControl类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearCache
import mondrian.olap.CacheControl; //导入依赖的package包/类
private void clearCache(RolapCube cube) {
// Clear the cache for the Sales cube, so the query runs as if
// for the first time. (TODO: Cleaner way to do this.)
final Cube salesCube =
getConnection().getSchema().lookupCube("Sales", true);
RolapHierarchy hierarchy =
(RolapHierarchy) salesCube.lookupHierarchy(
new Id.NameSegment("Store", Id.Quoting.UNQUOTED),
false);
SmartMemberReader memberReader =
(SmartMemberReader) hierarchy.getMemberReader();
MemberCacheHelper cacheHelper = memberReader.cacheHelper;
cacheHelper.mapLevelToMembers.cache.clear();
cacheHelper.mapMemberToChildren.cache.clear();
// Flush the cache, to ensure that the query gets executed.
cube.clearCachedAggregations(true);
CacheControl cacheControl = getConnection().getCacheControl(null);
final CacheControl.CellRegion measuresRegion =
cacheControl.createMeasuresRegion(cube);
cacheControl.flush(measuresRegion);
waitForFlush(cacheControl, measuresRegion, cube.getName());
}
示例2: waitForFlush
import mondrian.olap.CacheControl; //导入依赖的package包/类
private void waitForFlush(
final CacheControl cacheControl,
final CacheControl.CellRegion measuresRegion,
final String cubeName)
{
int i = 100;
while (true) {
try {
Thread.sleep(i);
} catch (InterruptedException e) {
fail(e.getMessage());
}
String cacheState = getCacheState(cacheControl, measuresRegion);
if (regionIsEmpty(cacheState, cubeName)) {
break;
}
i *= 2;
if (i > 6400) {
fail(
"Cache didn't flush in sufficient time\nCache Was: \n"
+ cacheState);
break;
}
}
}
示例3: getCacheState
import mondrian.olap.CacheControl; //导入依赖的package包/类
private String getCacheState(
final CacheControl cacheControl,
final CacheControl.CellRegion measuresRegion)
{
StringWriter out = new StringWriter();
cacheControl.printCacheState(new PrintWriter(out), measuresRegion);
return out.toString();
}
示例4: initializeFactCacheControl
import mondrian.olap.CacheControl; //导入依赖的package包/类
CacheControl initializeFactCacheControl(RolapConnection connection) {
try {
factCacheControl = connection.getCacheControl(new PrintWriter("factCacheControl.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return factCacheControl;
}
示例5: clearCache
import mondrian.olap.CacheControl; //导入依赖的package包/类
/**
* Clears aggregation cache
*
* @param cube
*/
public void clearCache(String cube) {
final TestContext testContext = getTestContext();
final CacheControl cacheControl =
testContext.getConnection().getCacheControl(null);
// Flush the entire cache.
final Connection connection = testContext.getConnection();
final Cube salesCube = connection.getSchema().lookupCube(cube, true);
final CacheControl.CellRegion measuresRegion =
cacheControl.createMeasuresRegion(salesCube);
cacheControl.flush(measuresRegion);
}
示例6: testSegmentCacheEvents
import mondrian.olap.CacheControl; //导入依赖的package包/类
public void testSegmentCacheEvents() throws Exception {
SegmentCache mockCache = new MockSegmentCache();
SegmentCacheWorker testWorker =
new SegmentCacheWorker(mockCache, null);
// Flush the cache before we start. Wait a second for the cache
// flush to propagate.
final CacheControl cc =
getTestContext().getConnection().getCacheControl(null);
Cube salesCube = getCube("Sales");
cc.flush(cc.createMeasuresRegion(salesCube));
Thread.sleep(1000);
MondrianServer.forConnection(getTestContext().getConnection())
.getAggregationManager().cacheMgr.segmentCacheWorkers
.add(testWorker);
final List<SegmentHeader> createdHeaders =
new ArrayList<SegmentHeader>();
final List<SegmentHeader> deletedHeaders =
new ArrayList<SegmentHeader>();
final SegmentCache.SegmentCacheListener listener =
new SegmentCache.SegmentCacheListener() {
public void handle(SegmentCacheEvent e) {
switch (e.getEventType()) {
case ENTRY_CREATED:
createdHeaders.add(e.getSource());
break;
case ENTRY_DELETED:
deletedHeaders.add(e.getSource());
break;
default:
throw new UnsupportedOperationException();
}
}
};
try {
// Register our custom listener.
((CompositeSegmentCache)MondrianServer
.forConnection(getTestContext().getConnection())
.getAggregationManager().cacheMgr.compositeCache)
.addListener(listener);
// Now execute a query and check the events
executeQuery(
"select {[Measures].[Unit Sales]} on columns from [Sales]");
// Wait for propagation.
Thread.sleep(2000);
assertEquals(2, createdHeaders.size());
assertEquals(0, deletedHeaders.size());
assertEquals("Sales", createdHeaders.get(0).cubeName);
assertEquals("FoodMart", createdHeaders.get(0).schemaName);
assertEquals("Unit Sales", createdHeaders.get(0).measureName);
createdHeaders.clear();
deletedHeaders.clear();
// Now flush the segment and check the events.
cc.flush(cc.createMeasuresRegion(salesCube));
// Wait for propagation.
Thread.sleep(2000);
assertEquals(0, createdHeaders.size());
assertEquals(2, deletedHeaders.size());
assertEquals("Sales", deletedHeaders.get(0).cubeName);
assertEquals("FoodMart", deletedHeaders.get(0).schemaName);
assertEquals("Unit Sales", deletedHeaders.get(0).measureName);
} finally {
((CompositeSegmentCache)MondrianServer
.forConnection(getTestContext().getConnection())
.getAggregationManager().cacheMgr.compositeCache)
.removeListener(listener);
MondrianServer.forConnection(getTestContext().getConnection())
.getAggregationManager().cacheMgr.segmentCacheWorkers
.remove(testWorker);
}
}
示例7: testNativeSetsCacheClearing
import mondrian.olap.CacheControl; //导入依赖的package包/类
/**
* tests if cache associated with Native Sets is flushed.
*
* @see <a href="http://jira.pentaho.com/browse/MONDRIAN-2366">Jira issue</a>
*/
public void testNativeSetsCacheClearing() {
final String mdx =
"select filter( gender.gender.members, measures.[Unit Sales] > 0) on 0 from sales ";
final String query = "select\n"
+ " `customer`.`gender` as `c0`\n"
+ "from\n"
+ " `customer` as `customer`,\n"
+ " `sales_fact_1997` as `sales_fact_1997`,\n"
+ " `time_by_day` as `time_by_day`\n"
+ "where\n"
+ " `sales_fact_1997`.`customer_id` = `customer`.`customer_id`\n"
+ "and\n"
+ " `sales_fact_1997`.`time_id` = `time_by_day`.`time_id`\n"
+ "and\n"
+ " `time_by_day`.`the_year` = 1997\n"
+ "group by\n"
+ " `customer`.`gender`\n"
+ "having\n"
+ " (sum(`sales_fact_1997`.`unit_sales`) > 0)\n"
+ "order by\n"
+ " ISNULL(`customer`.`gender`) ASC, `customer`.`gender` ASC";
propSaver.set(propSaver.properties.GenerateFormattedSql, true);
SqlPattern mysqlPattern =
new SqlPattern(
DatabaseProduct.MYSQL,
query,
null);
mondrian.olap.Result rest = executeQuery(mdx);
RolapCube cube = (RolapCube) rest.getQuery().getCube();
RolapConnection con = (RolapConnection) rest.getQuery().getConnection();
CacheControl cacheControl = con.getCacheControl(null);
for (RolapHierarchy hier : cube.getHierarchies()) {
if (hier.hasAll()) {
cacheControl.flush(
cacheControl.createMemberSet(hier.getAllMember(), true));
}
}
SqlPattern[] patterns = new SqlPattern[]{mysqlPattern};
if (propSaver.properties.EnableNativeFilter.get()) {
assertQuerySqlOrNot(
getTestContext(), mdx, patterns, false, false, false);
}
}
示例8: getCacheControl
import mondrian.olap.CacheControl; //导入依赖的package包/类
public CacheControl getCacheControl(RolapConnection connection, PrintWriter pw){
return server.getAggregationManager().getCacheControl(connection, pw);
}