allow global aggregators to be specified in xml
explicitly setting the aggregator in the PregelixJob constructors would
override any values read in from the conf's resources.
Instead, this commit doesn't set the conf explicitly and instead
specifies an array of aggregator class names which will always be in
place when `getGlobalAggregatorClasses` is called.
diff --git a/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/job/PregelixJob.java b/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/job/PregelixJob.java
index 06e79de..e42f533 100644
--- a/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/job/PregelixJob.java
+++ b/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/job/PregelixJob.java
@@ -84,6 +84,8 @@
public static final String DYNAMIC_OPTIMIZATION = "pregelix.dynamicopt";
/** comma */
public static final String COMMA_STR = ",";
+ /** the names of the aggregator classes active for all vertex types */
+ public static final String[] DEFAULT_GLOBAL_AGGREGATOR_CLASSES = { GlobalCountAggregator.class.getName() };
/**
* Construct a Pregelix job from an existing configuration
@@ -93,7 +95,6 @@
*/
public PregelixJob(Configuration conf) throws IOException {
super(conf);
- this.addGlobalAggregatorClass(GlobalCountAggregator.class);
}
/**
@@ -105,7 +106,6 @@
*/
public PregelixJob(String jobName) throws IOException {
super(new Configuration(), jobName);
- this.addGlobalAggregatorClass(GlobalCountAggregator.class);
}
/**
@@ -119,7 +119,6 @@
*/
public PregelixJob(Configuration conf, String jobName) throws IOException {
super(conf, jobName);
- this.addGlobalAggregatorClass(GlobalCountAggregator.class);
}
/**
@@ -262,13 +261,13 @@
final public void setCheckpointingInterval(int ckpInterval) {
getConfiguration().setInt(CKP_INTERVAL, ckpInterval);
}
-
+
/**
* Indicate if dynamic optimization is enabled
*
* @param dynamicOpt
*/
- final public void setEnableDynamicOptimization(boolean dynamicOpt){
+ final public void setEnableDynamicOptimization(boolean dynamicOpt) {
getConfiguration().setBoolean(DYNAMIC_OPTIMIZATION, dynamicOpt);
}
diff --git a/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/util/BspUtils.java b/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/util/BspUtils.java
index f44942f..03b5f29 100644
--- a/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/util/BspUtils.java
+++ b/pregelix/pregelix-api/src/main/java/edu/uci/ics/pregelix/api/util/BspUtils.java
@@ -126,6 +126,9 @@
String[] classnames = aggStrs.split(PregelixJob.COMMA_STR);
try {
List<Class<? extends GlobalAggregator<I, V, E, M, P, F>>> classes = new ArrayList<Class<? extends GlobalAggregator<I, V, E, M, P, F>>>();
+ for (String defaultClass : PregelixJob.DEFAULT_GLOBAL_AGGREGATOR_CLASSES) {
+ classes.add((Class<? extends GlobalAggregator<I, V, E, M, P, F>>) conf.getClassByName(defaultClass));
+ }
for (int i = 0; i < classnames.length; i++) {
classes.add((Class<? extends GlobalAggregator<I, V, E, M, P, F>>) conf.getClassByName(classnames[i]));
}