You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2016/02/27 08:06:26 UTC
[1/2] lucene-solr git commit: SOLR-8697: Fix precommit failure
Repository: lucene-solr
Updated Branches:
refs/heads/master e590ed67c -> 06053fc01
SOLR-8697: Fix precommit failure
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c2bc9382
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c2bc9382
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c2bc9382
Branch: refs/heads/master
Commit: c2bc93822d73b66c74ed998ea6c57a3cce05af44
Parents: e590ed6
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Sat Feb 27 12:19:50 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Sat Feb 27 12:19:50 2016 +0530
----------------------------------------------------------------------
solr/core/src/test/org/apache/solr/cloud/OverseerTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c2bc9382/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
index ea82cbf..2ff7320 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
@@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -125,7 +126,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
try {
ec.cancelElection();
} catch (Exception e) {
- log.warn(String.format("Error cancelling election for %s", ec.id), e);
+ log.warn(String.format(Locale.ROOT, "Error cancelling election for %s", ec.id), e);
}
}
deleteNode(ZkStateReader.LIVE_NODES_ZKNODE + "/" + nodeName);
[2/2] lucene-solr git commit: SOLR-8752: Add a test for
SizeLimitedDistributedMap and improve javadocs
Posted by sh...@apache.org.
SOLR-8752: Add a test for SizeLimitedDistributedMap and improve javadocs
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/06053fc0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/06053fc0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/06053fc0
Branch: refs/heads/master
Commit: 06053fc01cf149553d2cb18535f692fab5699420
Parents: c2bc938
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Sat Feb 27 12:35:58 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Sat Feb 27 12:35:58 2016 +0530
----------------------------------------------------------------------
.../solr/cloud/SizeLimitedDistributedMap.java | 5 +-
.../cloud/TestSizeLimitedDistributedMap.java | 58 ++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/06053fc0/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java b/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
index 3326dca..82ab141 100644
--- a/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
+++ b/solr/core/src/java/org/apache/solr/cloud/SizeLimitedDistributedMap.java
@@ -27,7 +27,10 @@ import org.apache.zookeeper.data.Stat;
/**
* A size limited distributed map maintained in zk.
- * Oldest znodes (as per modification time) are evicted as newer ones come in.
+ * Oldest znodes (as per modification time) are evicted as newer ones come in.
+ *
+ * When the map hits the specified maximum size, the oldest <code>maxSize / 10</code> items
+ * are evicted on the next {@link #put(String, byte[])} invocation.
*/
public class SizeLimitedDistributedMap extends DistributedMap {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/06053fc0/solr/core/src/test/org/apache/solr/cloud/TestSizeLimitedDistributedMap.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestSizeLimitedDistributedMap.java b/solr/core/src/test/org/apache/solr/cloud/TestSizeLimitedDistributedMap.java
new file mode 100644
index 0000000..2131f48
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/cloud/TestSizeLimitedDistributedMap.java
@@ -0,0 +1,58 @@
+package org.apache.solr.cloud;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.cloud.SolrZkClient;
+
+public class TestSizeLimitedDistributedMap extends SolrTestCaseJ4 {
+
+ public void testCleanup() throws Exception {
+ String zkDir = createTempDir("TestSizeLimitedDistributedMap").toFile().getAbsolutePath();
+
+ ZkTestServer server = new ZkTestServer(zkDir);
+ try {
+ server.run();
+
+ AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
+ AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
+
+ try (SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), 10000)) {
+ DistributedMap map = Overseer.getCompletedMap(zkClient);
+ assertTrue(map instanceof SizeLimitedDistributedMap);
+ for (int i = 0; i < Overseer.NUM_RESPONSES_TO_STORE; i++) {
+ map.put("xyz_" + i, new byte[0]);
+ }
+
+ assertEquals("Number of items do not match", Overseer.NUM_RESPONSES_TO_STORE, map.size());
+ // add another to trigger cleanup
+ map.put("xyz_10000", new byte[0]);
+ assertEquals("Distributed queue was not cleaned up",
+ Overseer.NUM_RESPONSES_TO_STORE - (Overseer.NUM_RESPONSES_TO_STORE / 10) + 1, map.size());
+ for (int i = Overseer.NUM_RESPONSES_TO_STORE; i >= Overseer.NUM_RESPONSES_TO_STORE / 10; i--) {
+ assertTrue(map.contains("xyz_" + i));
+ }
+ for (int i = Overseer.NUM_RESPONSES_TO_STORE / 10 - 1; i >= 0; i--) {
+ assertFalse(map.contains("xyz_" + i));
+ }
+ }
+ } finally {
+ server.shutdown();
+ }
+ }
+}