mirror of https://github.com/apache/lucene.git
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:
parent
2e2d3dac91
commit
2a13b648fa
|
@ -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,22 +900,25 @@ public final class ZkController {
|
|||
}
|
||||
CoreState coreState = new CoreState(coreName,
|
||||
cloudDesc.getCollectionName(), props, numShards);
|
||||
coreStates.put(shardZkNodeName, coreState);
|
||||
final String nodePath = "/node_states/" + getNodeName();
|
||||
|
||||
try {
|
||||
zkClient.setData(nodePath, ZkStateReader.toJSON(coreStates.values()),
|
||||
true);
|
||||
synchronized (coreStates) {
|
||||
coreStates.put(shardZkNodeName, coreState);
|
||||
try {
|
||||
zkClient.setData(nodePath, ZkStateReader.toJSON(coreStates.values()),
|
||||
true);
|
||||
|
||||
} catch (KeeperException e) {
|
||||
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"could not publish node state", e);
|
||||
} catch (InterruptedException e) {
|
||||
// Restore the interrupted status
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"could not publish node state", e);
|
||||
} catch (KeeperException e) {
|
||||
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"could not publish node state", e);
|
||||
} catch (InterruptedException e) {
|
||||
// Restore the interrupted status
|
||||
Thread.currentThread().interrupt();
|
||||
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||
"could not publish node state", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String doGetShardIdProcess(String coreName, CloudDescriptor descriptor)
|
||||
|
|
Loading…
Reference in New Issue