Permalink
Browse files

No need to repetedly pass MEMCACHE_SERVERS

  • Loading branch information...
1 parent 45afdfd commit d96dedef22a624234bbc9e51e4eb8a48e9ce4507 @fbrubacher committed Aug 8, 2012
@@ -20,7 +20,7 @@
public static void main(String[] args) throws Exception {
MemcachedClient memcache = new MemcachedClient(AddrUtil.getAddresses(MEMCACHED_SERVERS));
- OperationFuture promise = memcache.set("model", 0, "[0.1, 0.1]");
+ OperationFuture promise = memcache.set("model", 0, "[0.1, -0.1]");
promise.get();
Config topology_conf = new Config();
@@ -30,7 +30,7 @@ public static void main(String[] args) throws Exception {
else
topology_name = args[0];
- MLTopologyBuilder ml_topology_builder = new MLTopologyBuilder(topology_name);
+ MLTopologyBuilder ml_topology_builder = new MLTopologyBuilder(topology_name, MEMCACHED_SERVERS);
ml_topology_builder.setTrainingSpout(new ExampleTrainingSpout());
ml_topology_builder.setTrainingBolt(new LocalLearner(2, MEMCACHED_SERVERS));
@@ -10,9 +10,8 @@
public class MLTopologyBuilder {
- public static final String MEMCACHED_SERVERS = "127.0.0.1:11211";
-
String topology_prefix;
+ String memcached_servers;
BaseTrainingSpout training_spout;
Number training_spout_parallelism;
@@ -25,12 +24,13 @@
IRichBolt rich_evaluation_bolt;
Number evaluation_bolt_parallelism;
- public MLTopologyBuilder(String topologyPrefix) {
+ public MLTopologyBuilder(String topologyPrefix, String memcached_servers) {
+ this.memcached_servers = memcached_servers;
this.topology_prefix = topologyPrefix;
}
public TopologyBuilder prepareTopology(String drpcFunctionName, ILocalDRPC drpc) {
- return prepareTopology(drpcFunctionName, drpc, 1.0, 0.0, 0.5, MEMCACHED_SERVERS);
+ return prepareTopology(drpcFunctionName, drpc, 1.0, 0.0, 0.5);
}
public void setTrainingSpout(BaseTrainingSpout exampleTrainingSpout, Number parallelism) {
@@ -83,7 +83,7 @@ public void setEvaluationBolt(IRichBolt evaluation_bolt) {
}
public TopologyBuilder prepareTopology(String drpcFunctionName, ILocalDRPC drpc, double bias, double threshold,
- double learning_rate, String memcached_servers) {
+ double learning_rate) {
TopologyBuilder topology_builder = new TopologyBuilder();
// training
@@ -97,7 +97,7 @@ public TopologyBuilder prepareTopology(String drpcFunctionName, ILocalDRPC drpc,
topology_builder.setBolt(this.topology_prefix + "-training-bolt", this.rich_training_bolt,
this.training_bolt_parallelism).shuffleGrouping(this.topology_prefix + "-training-spout");
}
- topology_builder.setBolt("aggregator", new Aggregator(MEMCACHED_SERVERS)).globalGrouping(
+ topology_builder.setBolt("aggregator", new Aggregator(this.memcached_servers)).globalGrouping(
this.topology_prefix + "-training-bolt");
// evaluation

0 comments on commit d96dede

Please sign in to comment.