From 0d8d2f48e4fa1e599dbb6f666d1814f12bb03f92 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Tue, 31 Jan 2012 15:58:18 +0000 Subject: [PATCH] allow for over closing SolrZkClient as we do with SolrCore git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1238680 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/solr/cloud/CloudStateUpdateTest.java | 5 ++--- .../org/apache/solr/common/cloud/SolrZkClient.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java b/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java index 9e876c43df6..7de69b87f42 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java @@ -243,9 +243,8 @@ public class CloudStateUpdateTest extends SolrTestCaseJ4 { } container1.shutdown(); container2.shutdown(); - if (!container3.isShutDown()) { - container3.shutdown(); - } + container3.shutdown(); + zkServer.shutdown(); super.tearDown(); System.clearProperty("zkClientTimeout"); diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java index f7746124bfb..314c571f81b 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java @@ -491,6 +491,15 @@ public class SolrZkClient { keeper.create(currentPath, bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, mode); } } catch (NodeExistsException e) { + + if (!failOnExists) { + // TODO: version ? for now, don't worry about race + setData(currentPath, data, -1, retryOnConnLoss); + // set new watch + exists(currentPath, watcher, retryOnConnLoss); + return; + } + // ignore unless it's the last node in the path if (i == paths.length - 1) { throw e; @@ -643,6 +652,7 @@ public class SolrZkClient { * @throws InterruptedException */ public void close() throws InterruptedException { + if (isClosed) return; // it's okay if we over close - same as solrcore isClosed = true; keeper.close(); numCloses.incrementAndGet();