Skip to content

Commit

Permalink
MONDRIAN: Modifies all tests to ensure they use the PropertySaver obj…
Browse files Browse the repository at this point in the history
…ect rather than modifying the properties directly. This was causing a lot of problems when we try to reproduce test failures accross different environments. Also removes the use of property triggers, because the Eigenbase library has a bug where calling property.remove() wouldn't cause the trigger to be called.

Also adds the set() override in DelegatingTupleList so that list ordering can be properly delegated.

[git-p4: depot-paths = "//open/mondrian/": change = 14646]
  • Loading branch information
lucboudreau committed Oct 3, 2011
1 parent fed5f3f commit 4d27778
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 42 deletions.
12 changes: 12 additions & 0 deletions src/main/mondrian/calc/impl/DelegatingTupleList.java
Expand Up @@ -74,6 +74,10 @@ public Member get(int index) {
public int size() {
return list.size();
}

public Member set(int index, Member element) {
return list.get(column).set(index, element);
};
};
}

Expand Down Expand Up @@ -112,9 +116,17 @@ public Member get(int column) {
public int size() {
return destIndices.length;
}

public Member set(int column, Member element) {
return list.get(index).set(index, element);
};
};
}

public List<Member> set(int index, List<Member> element) {
return list.set(index, element);
};

public int size() {
return list.size();
}
Expand Down
52 changes: 10 additions & 42 deletions src/main/mondrian/rolap/RolapStar.java
Expand Up @@ -23,8 +23,6 @@
import mondrian.spi.Dialect;
import mondrian.util.Bug;
import org.apache.log4j.Logger;
import org.eigenbase.util.property.Property;
import org.eigenbase.util.property.TriggerBase;

import javax.sql.DataSource;
import java.io.PrintWriter;
Expand All @@ -47,40 +45,6 @@
public class RolapStar {
private static final Logger LOGGER = Logger.getLogger(RolapStar.class);

/**
* Controls the aggregate data cache for all RolapStars.
* An administrator or tester might selectively enable or
* disable in memory caching to allow direct measurement of database
* performance.
*/
private static boolean disableCaching =
MondrianProperties.instance().DisableCaching.get();

static {
// Trigger is used to lookup and change the value of the
// variable that controls aggregate data caching
// Using a trigger means we don't have to look up the property eveytime.
MondrianProperties.instance().DisableCaching.addTrigger(
new TriggerBase(true) {
public void execute(Property property, String value) {
disableCaching = property.booleanValue();
// must flush all caches
if (disableCaching) {
// REVIEW: could replace following code with call to
// CacheControl.flush(CellRegion)
for (RolapSchema schema1
: RolapSchema.getRolapSchemas())
{
for (RolapStar star : schema1.getStars()) {
star.clearCachedAggregations(true);
}
}
}
}
}
);
}

private final RolapSchema schema;

// not final for test purposes
Expand Down Expand Up @@ -505,6 +469,10 @@ boolean isCacheAggregations() {
return this.cacheAggregations;
}

boolean isCacheDisabled() {
return MondrianProperties.instance().DisableCaching.get();
}

/**
* Clears the aggregate cache. This only does something if aggregate caching
* is disabled (see {@link #setCacheAggregations(boolean)}).
Expand All @@ -513,7 +481,7 @@ boolean isCacheAggregations() {
* settings. If false, clears only cache from the current thread
*/
void clearCachedAggregations(boolean forced) {
if (forced || !cacheAggregations || RolapStar.disableCaching) {
if (forced || !cacheAggregations || isCacheDisabled()) {
if (LOGGER.isDebugEnabled()) {
StringBuilder buf = new StringBuilder(100);
buf.append("RolapStar.clearCachedAggregations: schema=");
Expand Down Expand Up @@ -555,7 +523,7 @@ public Aggregation lookupOrCreateAggregation(

// Let the change listener get the opportunity to register the
// first time the aggregation is used
if ((this.cacheAggregations) && (!RolapStar.disableCaching)) {
if ((this.cacheAggregations) && (!isCacheDisabled())) {
if (changeListener != null) {
Util.discard(
changeListener.isAggregationChanged(aggregation));
Expand All @@ -580,7 +548,7 @@ public Aggregation lookupAggregation(AggregationKey aggregationKey) {
return aggregation;
}

if (cacheAggregations && !RolapStar.disableCaching) {
if (cacheAggregations && !isCacheDisabled()) {
// Look in global cache
synchronized (sharedAggregations) {
aggregation = sharedAggregations.get(aggregationKey);
Expand Down Expand Up @@ -612,7 +580,7 @@ public void checkAggregateModifications() {
clearAggregationRequests();

if (changeListener != null) {
if (cacheAggregations && !RolapStar.disableCaching) {
if (cacheAggregations && !isCacheDisabled()) {
synchronized (sharedAggregations) {
for (Map.Entry<AggregationKey, Aggregation> e
: sharedAggregations.entrySet())
Expand Down Expand Up @@ -648,7 +616,7 @@ public void pushAggregateModificationsToGlobalCache() {
// Need synchronized access to both aggregationRequests as to
// aggregations, synchronize this instead
synchronized (this) {
if (cacheAggregations && !RolapStar.disableCaching) {
if (cacheAggregations && !isCacheDisabled()) {
// Push pending modifications other thread could not push
// to global cache, because it was in use
Iterator<Map.Entry<AggregationKey, Aggregation>>
Expand Down Expand Up @@ -702,7 +670,7 @@ private void pushAggregateModification(
Aggregation localAggregation,
Map<AggregationKey, Aggregation> destAggregations)
{
if (cacheAggregations && !RolapStar.disableCaching) {
if (cacheAggregations && !isCacheDisabled()) {
synchronized (destAggregations) {
boolean found = false;
Iterator<Map.Entry<AggregationKey, Aggregation>>
Expand Down

0 comments on commit 4d27778

Please sign in to comment.