Skip to content

Commit

Permalink
Switching from Hashtable to ConcurrentHashMap. Fixing a bug with Json…
Browse files Browse the repository at this point in the history
…Keeper
  • Loading branch information
pabloem committed Jun 26, 2016
1 parent 05a8bc7 commit 2f3b949
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/org/vitrivr/cthulhu/keeper/JsonKeeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class JsonKeeper implements StatusKeeper {
private String outFile;
public JsonKeeper(Properties prop) {
this.prop = prop;
outFile = prop.getProperty("statusFile",".cthulhuStatus.json");
outFile = prop != null ? prop.getProperty("statusFile",".cthulhuStatus.json") : ".cthulhuStatus.json";
gson = new Gson();
}
public void saveStatus(CthulhuScheduler cs) {
try (FileWriter writer = new FileWriter(fileName)) {
try (FileWriter writer = new FileWriter(outFile)) {
gson.toJson(cs, writer);
} catch (IOException e) {
/* Ignoring */
Expand Down
4 changes: 2 additions & 2 deletions src/org/vitrivr/cthulhu/scheduler/CoordinatorScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import java.util.List;
import java.util.Map;
import java.util.Hashtable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.*;

import java.util.Properties;
Expand All @@ -25,7 +25,7 @@ public class CoordinatorScheduler extends CthulhuScheduler {
transient ScheduledFuture dispatchFuture;
public CoordinatorScheduler(Properties props) {
super(props);
wt = new Hashtable<String,Worker>();
wt = new ConcurrentHashMap<String,Worker>();

int dispatchDelay = 10;
if(props != null && props.getProperty("dispatchDelay") != null) {
Expand Down
9 changes: 5 additions & 4 deletions src/org/vitrivr/cthulhu/scheduler/CthulhuScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import org.apache.logging.log4j.Logger;

import java.util.List;
import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.*;

import java.util.Properties;
Expand All @@ -26,15 +27,15 @@ public abstract class CthulhuScheduler {
transient protected CthulhuRESTConnector conn;
transient protected JobQueue jq;
transient private JobFactory jf;
protected Hashtable<String,Worker> wt; // Worker table
protected Hashtable<String,Job> jt; // Job table
protected Map<String,Worker> wt; // Worker table
protected Map<String,Job> jt; // Job table
transient protected Logger lg;
protected Properties props;
public CthulhuScheduler(Properties props) {
sk = new JsonKeeper(props);
jq = new JobQueue();
jf = new JobFactory();
jt = new Hashtable<String,Job>();
jt = new ConcurrentHashMap<String,Job>();
conn = new CthulhuRESTConnector();
this.props = props;
lg = LogManager.getLogger("r.m.ms"); // master.masterscheduler
Expand Down

0 comments on commit 2f3b949

Please sign in to comment.