fix a concurrency issue around writing hashmap to json

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1292064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-02-21 22:30:33 +00:00
parent 2e2d3dac91
commit 2a13b648fa
1 changed files with 18 additions and 15 deletions

View File

@ -85,7 +85,7 @@ public final class ZkController {
public final static String COLLECTION_PARAM_PREFIX="collection.";
public final static String CONFIGNAME_PROP="configName";
private final Map<String, CoreState> coreStates = Collections.synchronizedMap(new HashMap<String, CoreState>());
private final Map<String, CoreState> coreStates = new HashMap<String, CoreState>();
private SolrZkClient zkClient;
private ZkCmdExecutor cmdExecutor;
@ -900,9 +900,10 @@ public final class ZkController {
}
CoreState coreState = new CoreState(coreName,
cloudDesc.getCollectionName(), props, numShards);
coreStates.put(shardZkNodeName, coreState);
final String nodePath = "/node_states/" + getNodeName();
synchronized (coreStates) {
coreStates.put(shardZkNodeName, coreState);
try {
zkClient.setData(nodePath, ZkStateReader.toJSON(coreStates.values()),
true);
@ -918,6 +919,8 @@ public final class ZkController {
}
}
}
private String doGetShardIdProcess(String coreName, CloudDescriptor descriptor)
throws InterruptedException {
final String shardZkNodeName = getNodeName() + "_" + coreName;