You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/03/16 20:39:37 UTC
svn commit: r1578144 [32/37] - in /lucene/dev/branches/lucene5376_2: ./
dev-tools/ dev-tools/idea/.idea/libraries/
dev-tools/idea/solr/contrib/dataimporthandler/
dev-tools/idea/solr/contrib/map-reduce/ dev-tools/idea/solr/core/src/test/
dev-tools/scrip...
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/AssignTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/AssignTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/AssignTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/AssignTest.java Sun Mar 16 19:39:10 2014
@@ -58,11 +58,11 @@ public class AssignTest extends SolrTest
public void testAssignNode() throws Exception {
String cname = "collection1";
- Map<String,DocCollection> collectionStates = new HashMap<String,DocCollection>();
+ Map<String,DocCollection> collectionStates = new HashMap<>();
- Map<String,Slice> slices = new HashMap<String,Slice>();
+ Map<String,Slice> slices = new HashMap<>();
- Map<String,Replica> replicas = new HashMap<String,Replica>();
+ Map<String,Replica> replicas = new HashMap<>();
ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, "state",
ZkStateReader.STATE_PROP, "ACTIVE",
@@ -85,7 +85,7 @@ public class AssignTest extends SolrTest
collectionStates.put(cname, docCollection);
- Set<String> liveNodes = new HashSet<String>();
+ Set<String> liveNodes = new HashSet<>();
ClusterState state = new ClusterState(-1,liveNodes, collectionStates,ClusterStateTest.getMockZkStateReader(collectionStates.keySet()));
String nodeName = Assign.assignNode("collection1", state);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Sun Mar 16 19:39:10 2014
@@ -51,6 +51,7 @@ import org.apache.solr.client.solrj.requ
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocument;
@@ -99,7 +100,7 @@ public class BasicDistributedZkTest exte
String missingField="ignore_exception__missing_but_valid_field_t";
String invalidField="ignore_exception__invalid_field_not_in_schema";
- private Map<String,List<SolrServer>> otherCollectionClients = new HashMap<String,List<SolrServer>>();
+ private Map<String,List<SolrServer>> otherCollectionClients = new HashMap<>();
private String oneInstanceCollection = "oneInstanceCollection";
private String oneInstanceCollection2 = "oneInstanceCollection2";
@@ -131,8 +132,8 @@ public class BasicDistributedZkTest exte
sliceCount = 2;
shardCount = 4;
- completionService = new ExecutorCompletionService<Object>(executor);
- pending = new HashSet<Future<Object>>();
+ completionService = new ExecutorCompletionService<>(executor);
+ pending = new HashSet<>();
}
@@ -418,12 +419,12 @@ public class BasicDistributedZkTest exte
private void testShardParamVariations() throws Exception {
SolrQuery query = new SolrQuery("*:*");
- Map<String,Long> shardCounts = new HashMap<String,Long>();
+ Map<String,Long> shardCounts = new HashMap<>();
for (String shard : shardToJetty.keySet()) {
// every client should give the same numDocs for this shard
// shffle the clients in a diff order for each shard
- List<SolrServer> solrclients = new ArrayList<SolrServer>(this.clients);
+ List<SolrServer> solrclients = new ArrayList<>(this.clients);
Collections.shuffle(solrclients, random());
for (SolrServer client : solrclients) {
query.set("shards", shard);
@@ -437,11 +438,11 @@ public class BasicDistributedZkTest exte
shardCounts.get(shard).longValue(), numDocs);
List<CloudJettyRunner> replicaJetties
- = new ArrayList<CloudJettyRunner>(shardToJetty.get(shard));
+ = new ArrayList<>(shardToJetty.get(shard));
Collections.shuffle(replicaJetties, random());
// each replica should also give the same numDocs
- ArrayList<String> replicaAlts = new ArrayList<String>(replicaJetties.size() * 2);
+ ArrayList<String> replicaAlts = new ArrayList<>(replicaJetties.size() * 2);
for (CloudJettyRunner replicaJetty : shardToJetty.get(shard)) {
String replica = replicaJetty.url;
query.set("shards", replica);
@@ -474,7 +475,7 @@ public class BasicDistributedZkTest exte
// sums of multiple shards should add up regardless of how we
// query those shards or which client we use
long randomShardCountsExpected = 0;
- ArrayList<String> randomShards = new ArrayList<String>(shardCounts.size());
+ ArrayList<String> randomShards = new ArrayList<>(shardCounts.size());
for (Map.Entry<String,Long> shardData : shardCounts.entrySet()) {
if (random().nextBoolean() || randomShards.size() < 2) {
String shard = shardData.getKey();
@@ -484,7 +485,7 @@ public class BasicDistributedZkTest exte
randomShards.add(shard);
} else {
// use some set explicit replicas
- ArrayList<String> replicas = new ArrayList<String>(7);
+ ArrayList<String> replicas = new ArrayList<>(7);
for (CloudJettyRunner replicaJetty : shardToJetty.get(shard)) {
if (0 == random().nextInt(3) || 0 == replicas.size()) {
replicas.add(replicaJetty.url);
@@ -593,8 +594,9 @@ public class BasicDistributedZkTest exte
return url2;
}
- protected void createCollection(Map<String,List<Integer>> collectionInfos,
- String collectionName, int numShards, int numReplicas, int maxShardsPerNode, SolrServer client, String createNodeSetStr) throws SolrServerException, IOException {
+ protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos,
+ String collectionName, int numShards, int numReplicas, int maxShardsPerNode, SolrServer client, String createNodeSetStr) throws SolrServerException, IOException {
+ // TODO: Use CollectionAdminRequest for this test
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.CREATE.toString());
@@ -604,7 +606,7 @@ public class BasicDistributedZkTest exte
if (createNodeSetStr != null) params.set(OverseerCollectionProcessor.CREATE_NODE_SET, createNodeSetStr);
int clientIndex = clients.size() > 1 ? random().nextInt(2) : 0;
- List<Integer> list = new ArrayList<Integer>();
+ List<Integer> list = new ArrayList<>();
list.add(numShards);
list.add(numReplicas);
if (collectionInfos != null) {
@@ -613,7 +615,8 @@ public class BasicDistributedZkTest exte
params.set("name", collectionName);
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
-
+
+ CollectionAdminResponse res = new CollectionAdminResponse();
if (client == null) {
final String baseUrl = ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().substring(
0,
@@ -621,11 +624,12 @@ public class BasicDistributedZkTest exte
- DEFAULT_COLLECTION.length() - 1);
SolrServer aClient = createNewSolrServer("", baseUrl);
- aClient.request(request);
+ res.setResponse(aClient.request(request));
aClient.shutdown();
} else {
- client.request(request);
+ res.setResponse(client.request(request));
}
+ return res;
}
protected ZkCoreNodeProps getLeaderUrlFromZk(String collection, String slice) {
@@ -709,7 +713,7 @@ public class BasicDistributedZkTest exte
sd = sdoc("id", 1000, "foo_i",5);
clients.get(0).add(sd);
- List<Integer> expected = new ArrayList<Integer>();
+ List<Integer> expected = new ArrayList<>();
int val = 0;
for (SolrServer client : clients) {
val += 10;
@@ -764,7 +768,7 @@ public class BasicDistributedZkTest exte
private void testANewCollectionInOneInstanceWithManualShardAssignement() throws Exception {
log.info("### STARTING testANewCollectionInOneInstanceWithManualShardAssignement");
System.clearProperty("numShards");
- List<SolrServer> collectionClients = new ArrayList<SolrServer>();
+ List<SolrServer> collectionClients = new ArrayList<>();
SolrServer client = clients.get(0);
final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
0,
@@ -896,7 +900,7 @@ public class BasicDistributedZkTest exte
private void testANewCollectionInOneInstance() throws Exception {
log.info("### STARTING testANewCollectionInOneInstance");
- List<SolrServer> collectionClients = new ArrayList<SolrServer>();
+ List<SolrServer> collectionClients = new ArrayList<>();
SolrServer client = clients.get(0);
final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
0,
@@ -1085,7 +1089,7 @@ public class BasicDistributedZkTest exte
}
private void createNewCollection(final String collection) throws InterruptedException {
- final List<SolrServer> collectionClients = new ArrayList<SolrServer>();
+ final List<SolrServer> collectionClients = new ArrayList<>();
otherCollectionClients.put(collection, collectionClients);
int unique = 0;
for (final SolrServer client : clients) {
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java Sun Mar 16 19:39:10 2014
@@ -47,6 +47,8 @@ import com.carrotsearch.randomizedtestin
@Slow
@ThreadLeakLingering(linger = 60000)
public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase {
+ private static final int FAIL_TOLERANCE = 20;
+
public static Logger log = LoggerFactory.getLogger(ChaosMonkeyNothingIsSafeTest.class);
private static final Integer RUN_LENGTH = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.runlength", "-1"));
@@ -125,11 +127,11 @@ public class ChaosMonkeyNothingIsSafeTes
// as it's not supported for recovery
del("*:*");
- List<StopableThread> threads = new ArrayList<StopableThread>();
+ List<StopableThread> threads = new ArrayList<>();
int threadCount = 1;
int i = 0;
for (i = 0; i < threadCount; i++) {
- StopableIndexingThread indexThread = new StopableIndexingThread(Integer.toString(i), true);
+ StopableIndexingThread indexThread = new StopableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
threads.add(indexThread);
indexThread.start();
}
@@ -207,7 +209,7 @@ public class ChaosMonkeyNothingIsSafeTes
// we expect full throttle fails, but cloud client should not easily fail
for (StopableThread indexThread : threads) {
if (indexThread instanceof StopableIndexingThread && !(indexThread instanceof FullThrottleStopableIndexingThread)) {
- assertFalse("There were too many update fails - we expect it can happen, but shouldn't easily", ((StopableIndexingThread) indexThread).getFailCount() > 10);
+ assertFalse("There were too many update fails - we expect it can happen, but shouldn't easily", ((StopableIndexingThread) indexThread).getFailCount() > FAIL_TOLERANCE);
}
}
@@ -245,7 +247,7 @@ public class ChaosMonkeyNothingIsSafeTes
} finally {
client.shutdown();
}
- List<Integer> numShardsNumReplicas = new ArrayList<Integer>(2);
+ List<Integer> numShardsNumReplicas = new ArrayList<>(2);
numShardsNumReplicas.add(1);
numShardsNumReplicas.add(1);
checkForCollection("testcollection",numShardsNumReplicas, null);
@@ -268,7 +270,7 @@ public class ChaosMonkeyNothingIsSafeTes
public FullThrottleStopableIndexingThread(List<SolrServer> clients,
String id, boolean doDeletes) {
- super(id, doDeletes);
+ super(controlClient, cloudClient, id, doDeletes);
setName("FullThrottleStopableIndexingThread");
setDaemon(true);
this.clients = clients;
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java Sun Mar 16 19:39:10 2014
@@ -105,10 +105,10 @@ public class ChaosMonkeySafeLeaderTest e
del("*:*");
- List<StopableIndexingThread> threads = new ArrayList<StopableIndexingThread>();
+ List<StopableIndexingThread> threads = new ArrayList<>();
int threadCount = 2;
for (int i = 0; i < threadCount; i++) {
- StopableIndexingThread indexThread = new StopableIndexingThread(Integer.toString(i), true);
+ StopableIndexingThread indexThread = new StopableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
threads.add(indexThread);
indexThread.start();
}
@@ -169,7 +169,7 @@ public class ChaosMonkeySafeLeaderTest e
} finally {
client.shutdown();
}
- List<Integer> numShardsNumReplicas = new ArrayList<Integer>(2);
+ List<Integer> numShardsNumReplicas = new ArrayList<>(2);
numShardsNumReplicas.add(1);
numShardsNumReplicas.add(1);
checkForCollection("testcollection",numShardsNumReplicas, null);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java Sun Mar 16 19:39:10 2014
@@ -41,14 +41,14 @@ import static org.easymock.EasyMock.expe
public class ClusterStateTest extends SolrTestCaseJ4 {
@Test
public void testStoreAndRead() throws Exception {
- Map<String,DocCollection> collectionStates = new HashMap<String,DocCollection>();
- Set<String> liveNodes = new HashSet<String>();
+ Map<String,DocCollection> collectionStates = new HashMap<>();
+ Set<String> liveNodes = new HashSet<>();
liveNodes.add("node1");
liveNodes.add("node2");
- Map<String,Slice> slices = new HashMap<String,Slice>();
- Map<String,Replica> sliceToProps = new HashMap<String,Replica>();
- Map<String,Object> props = new HashMap<String,Object>();
+ Map<String,Slice> slices = new HashMap<>();
+ Map<String,Replica> sliceToProps = new HashMap<>();
+ Map<String,Object> props = new HashMap<>();
props.put("prop1", "value");
props.put("prop2", "value2");
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java Sun Mar 16 19:39:10 2014
@@ -152,7 +152,7 @@ public class ClusterStateUpdateTest exte
System.setProperty("solrcloud.update.delay", "1");
- Map<String,Object> props2 = new HashMap<String,Object>();
+ Map<String,Object> props2 = new HashMap<>();
props2.put("configName", "conf1");
ZkNodeProps zkProps2 = new ZkNodeProps(props2);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Sun Mar 16 19:39:10 2014
@@ -77,12 +77,9 @@ import org.apache.solr.common.cloud.Solr
import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
-import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.common.util.StrUtils;
@@ -176,8 +173,8 @@ public class CollectionsAPIDistributedZk
sliceCount = 2;
shardCount = 4;
- completionService = new ExecutorCompletionService<Object>(executor);
- pending = new HashSet<Future<Object>>();
+ completionService = new ExecutorCompletionService<>(executor);
+ pending = new HashSet<>();
checkCreatedVsState = false;
}
@@ -206,14 +203,14 @@ public class CollectionsAPIDistributedZk
testCollectionsAPI();
testCollectionsAPIAddRemoveStress();
testErrorHandling();
+ testNoCollectionSpecified();
deletePartiallyCreatedCollection();
deleteCollectionRemovesStaleZkCollectionsNode();
clusterPropTest();
-
addReplicaTest();
-
// last
deleteCollectionWithDownNodes();
+
if (DEBUG) {
super.printLayout();
}
@@ -226,7 +223,7 @@ public class CollectionsAPIDistributedZk
String collectionName = "out_of_sync_collection";
- List<Integer> numShardsNumReplicaList = new ArrayList<Integer>();
+ List<Integer> numShardsNumReplicaList = new ArrayList<>();
numShardsNumReplicaList.add(2);
numShardsNumReplicaList.add(1);
@@ -581,6 +578,40 @@ public class CollectionsAPIDistributedZk
String val2 = failure.getVal(0).toString();
assertTrue(val1.contains("SolrException") || val2.contains("SolrException"));
}
+
+ private void testNoCollectionSpecified() throws Exception {
+
+ cloudClient.getZkStateReader().updateClusterState(true);
+ assertFalse(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection"));
+ assertFalse(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection2"));
+
+ // try and create a SolrCore with no collection name
+ Create createCmd = new Create();
+ createCmd.setCoreName("corewithnocollection");
+ createCmd.setCollection("");
+ String dataDir = SolrTestCaseJ4.dataDir.getAbsolutePath() + File.separator
+ + System.currentTimeMillis() + "corewithnocollection" + "_1v";
+ createCmd.setDataDir(dataDir);
+ createCmd.setNumShards(1);
+ if (secondConfigSet) {
+ createCmd.setCollectionConfigName("conf1");
+ }
+
+ createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(1)))
+ .request(createCmd);
+
+ // try and create a SolrCore with no collection name
+ createCmd.setCollection(null);
+ createCmd.setCoreName("corewithnocollection2");
+
+ createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(1)))
+ .request(createCmd);
+
+ // in both cases, the collection should have default to the core name
+ cloudClient.getZkStateReader().updateClusterState(true);
+ assertTrue(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection"));
+ assertTrue(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection2"));
+ }
private void testNodesUsedByCreate() throws Exception {
// we can use this client because we just want base url
@@ -603,12 +634,12 @@ public class CollectionsAPIDistributedZk
request.setPath("/admin/collections");
createNewSolrServer("", baseUrl).request(request);
- List<Integer> numShardsNumReplicaList = new ArrayList<Integer>();
+ List<Integer> numShardsNumReplicaList = new ArrayList<>();
numShardsNumReplicaList.add(2);
numShardsNumReplicaList.add(2);
checkForCollection("nodes_used_collection", numShardsNumReplicaList , null);
- List<String> createNodeList = new ArrayList<String>();
+ List<String> createNodeList = new ArrayList<>();
Set<String> liveNodes = cloudClient.getZkStateReader().getClusterState()
.getLiveNodes();
@@ -634,7 +665,7 @@ public class CollectionsAPIDistributedZk
boolean disableLegacy = random().nextBoolean();
CloudSolrServer client1 = null;
- if(disableLegacy) {
+ if (disableLegacy) {
log.info("legacyCloud=false");
client1 = createCloudClient(null);
setClusterProp(client1, ZkStateReader.LEGACY_CLOUD, "false");
@@ -646,7 +677,7 @@ public class CollectionsAPIDistributedZk
// env make this pretty fragile
// create new collections rapid fire
- Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ Map<String,List<Integer>> collectionInfos = new HashMap<>();
int cnt = random().nextInt(TEST_NIGHTLY ? 6 : 3) + 1;
for (int i = 0; i < cnt; i++) {
@@ -756,7 +787,7 @@ public class CollectionsAPIDistributedZk
checkInstanceDirs(jettys.get(0));
- List<String> collectionNameList = new ArrayList<String>();
+ List<String> collectionNameList = new ArrayList<>();
collectionNameList.addAll(collectionInfos.keySet());
String collectionName = collectionNameList.get(random().nextInt(collectionNameList.size()));
@@ -786,7 +817,7 @@ public class CollectionsAPIDistributedZk
// lets try a collection reload
// get core open times
- Map<String,Long> urlToTimeBefore = new HashMap<String,Long>();
+ Map<String,Long> urlToTimeBefore = new HashMap<>();
collectStartTimes(collectionName, urlToTimeBefore);
assertTrue(urlToTimeBefore.size() > 0);
ModifiableSolrParams params = new ModifiableSolrParams();
@@ -852,7 +883,7 @@ public class CollectionsAPIDistributedZk
request.setPath("/admin/collections");
createNewSolrServer("", baseUrl).request(request);
- List<Integer> list = new ArrayList<Integer> (2);
+ List<Integer> list = new ArrayList<>(2);
list.add(1);
list.add(2);
checkForCollection(collectionName, list, null);
@@ -873,7 +904,7 @@ public class CollectionsAPIDistributedZk
int numShards = (numLiveNodes/2) + 1;
int replicationFactor = 2;
int maxShardsPerNode = 1;
- collectionInfos = new HashMap<String,List<Integer>>();
+ collectionInfos = new HashMap<>();
CloudSolrServer client = createCloudClient("awholynewcollection_" + cnt);
try {
exp = false;
@@ -891,7 +922,7 @@ public class CollectionsAPIDistributedZk
// Test createNodeSet
numLiveNodes = getCommonCloudSolrServer().getZkStateReader().getClusterState().getLiveNodes().size();
- List<String> createNodeList = new ArrayList<String>();
+ List<String> createNodeList = new ArrayList<>();
int numOfCreateNodes = numLiveNodes/2;
assertFalse("createNodeSet test is pointless with only " + numLiveNodes + " nodes running", numOfCreateNodes == 0);
int i = 0;
@@ -906,10 +937,11 @@ public class CollectionsAPIDistributedZk
maxShardsPerNode = 2;
numShards = createNodeList.size() * maxShardsPerNode;
replicationFactor = 1;
- collectionInfos = new HashMap<String,List<Integer>>();
+ collectionInfos = new HashMap<>();
client = createCloudClient("awholynewcollection_" + (cnt+1));
try {
- createCollection(collectionInfos, "awholynewcollection_" + (cnt+1), numShards, replicationFactor, maxShardsPerNode, client, StrUtils.join(createNodeList, ','), "conf1");
+ CollectionAdminResponse res = createCollection(collectionInfos, "awholynewcollection_" + (cnt+1), numShards, replicationFactor, maxShardsPerNode, client, StrUtils.join(createNodeList, ','), "conf1");
+ assertTrue(res.isSuccess());
} finally {
client.shutdown();
}
@@ -934,7 +966,7 @@ public class CollectionsAPIDistributedZk
public void run() {
// create new collections rapid fire
- Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ Map<String,List<Integer>> collectionInfos = new HashMap<>();
int cnt = random().nextInt(TEST_NIGHTLY ? 13 : 3) + 1;
for (int i = 0; i < cnt; i++) {
@@ -981,7 +1013,7 @@ public class CollectionsAPIDistributedZk
}
}
}
- List<Thread> threads = new ArrayList<Thread>();
+ List<Thread> threads = new ArrayList<>();
int numThreads = TEST_NIGHTLY ? 6 : 2;
for (int i = 0; i < numThreads; i++) {
CollectionThread thread = new CollectionThread("collection" + i);
@@ -1023,7 +1055,7 @@ public class CollectionsAPIDistributedZk
boolean allTimesAreCorrect = false;
while (System.currentTimeMillis() < timeoutAt) {
- Map<String,Long> urlToTimeAfter = new HashMap<String,Long>();
+ Map<String,Long> urlToTimeAfter = new HashMap<>();
collectStartTimes(collectionName, urlToTimeAfter);
boolean retry = false;
@@ -1151,13 +1183,13 @@ public class CollectionsAPIDistributedZk
}
private void checkNoTwoShardsUseTheSameIndexDir() throws Exception {
- Map<String, Set<String>> indexDirToShardNamesMap = new HashMap<String, Set<String>>();
+ Map<String, Set<String>> indexDirToShardNamesMap = new HashMap<>();
- List<MBeanServer> servers = new LinkedList<MBeanServer>();
+ List<MBeanServer> servers = new LinkedList<>();
servers.add(ManagementFactory.getPlatformMBeanServer());
servers.addAll(MBeanServerFactory.findMBeanServer(null));
for (final MBeanServer server : servers) {
- Set<ObjectName> mbeans = new HashSet<ObjectName>();
+ Set<ObjectName> mbeans = new HashSet<>();
mbeans.addAll(server.queryNames(null, null));
for (final ObjectName mbean : mbeans) {
Object value;
@@ -1203,7 +1235,7 @@ public class CollectionsAPIDistributedZk
try {
createCollection(collectionName, client,2,2);
String newReplicaName = Assign.assignNode(collectionName , client.getZkStateReader().getClusterState() );
- ArrayList<String> nodeList = new ArrayList<String>(client.getZkStateReader().getClusterState().getLiveNodes());
+ ArrayList<String> nodeList = new ArrayList<>(client.getZkStateReader().getClusterState().getLiveNodes());
Collections.shuffle(nodeList);
Map m = makeMap(
"action", CollectionAction.ADDREPLICA.toString(),
@@ -1280,7 +1312,7 @@ public class CollectionsAPIDistributedZk
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
NUM_SLICES, numShards);
- Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ Map<String,List<Integer>> collectionInfos = new HashMap<>();
createCollection(collectionInfos, COLL_NAME, props, client,"conf1");
waitForRecoveriesToFinish(COLL_NAME, false);
}
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java Sun Mar 16 19:39:10 2014
@@ -99,8 +99,8 @@ public class CustomCollectionTest extend
sliceCount = 2;
shardCount = 4;
- completionService = new ExecutorCompletionService<Object>(executor);
- pending = new HashSet<Future<Object>>();
+ completionService = new ExecutorCompletionService<>(executor);
+ pending = new HashSet<>();
checkCreatedVsState = false;
}
@@ -142,7 +142,7 @@ public class CustomCollectionTest extend
// env make this pretty fragile
// create new collections rapid fire
- Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ Map<String,List<Integer>> collectionInfos = new HashMap<>();
int replicationFactor = TestUtil.nextInt(random(), 0, 3) + 2;
int cnt = random().nextInt(6) + 1;
@@ -214,7 +214,7 @@ public class CustomCollectionTest extend
assertNull("A shard of a Collection configured with implicit router must have null range",
coll.getSlice("a").getRange());
- List<String> collectionNameList = new ArrayList<String>();
+ List<String> collectionNameList = new ArrayList<>();
collectionNameList.addAll(collectionInfos.keySet());
log.info("Collections created : "+collectionNameList );
@@ -360,7 +360,7 @@ public class CustomCollectionTest extend
int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
- HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
CloudSolrServer client = null;
String shard_fld = "shard_s";
try {
@@ -419,7 +419,7 @@ public class CustomCollectionTest extend
private void testCreateShardRepFactor() throws Exception {
String collectionName = "testCreateShardRepFactor";
- HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
CloudSolrServer client = null;
try {
client = createCloudClient(null);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java Sun Mar 16 19:39:10 2014
@@ -148,7 +148,7 @@ public class DeleteReplicaTest extends A
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
NUM_SLICES, numShards);
- Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ Map<String,List<Integer>> collectionInfos = new HashMap<>();
createCollection(collectionInfos, COLL_NAME, props, client);
}
}
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DeleteShardTest.java Sun Mar 16 19:39:10 2014
@@ -145,7 +145,7 @@ public class DeleteShardTest extends Abs
protected void setSliceAsInactive(String slice) throws SolrServerException, IOException,
KeeperException, InterruptedException {
DistributedQueue inQueue = Overseer.getInQueue(cloudClient.getZkStateReader().getZkClient());
- Map<String, Object> propMap = new HashMap<String, Object>();
+ Map<String, Object> propMap = new HashMap<>();
propMap.put(Overseer.QUEUE_OPERATION, "updateshardstate");
propMap.put(slice, Slice.INACTIVE);
propMap.put(ZkStateReader.COLLECTION_PROP, "collection1");
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java Sun Mar 16 19:39:10 2014
@@ -523,7 +523,7 @@ public class DistribCursorPagingTest ext
// start with a smallish number of documents, and test that we can do a full walk using a
// sort on *every* field in the schema...
- List<SolrInputDocument> initialDocs = new ArrayList<SolrInputDocument>();
+ List<SolrInputDocument> initialDocs = new ArrayList<>();
for (int i = 1; i <= numInitialDocs; i++) {
SolrInputDocument doc = CursorPagingTest.buildRandomDocument(i);
initialDocs.add(doc);
@@ -606,7 +606,7 @@ public class DistribCursorPagingTest ext
req.setShowSchema(true);
NamedList<Object> rsp = controlClient.request(req);
NamedList<Object> fields = (NamedList) ((NamedList)rsp.get("schema")).get("fields");
- ArrayList<String> names = new ArrayList<String>(fields.size());
+ ArrayList<String> names = new ArrayList<>(fields.size());
for (Map.Entry<String,Object> item : fields) {
names.add(item.getKey());
}
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java Sun Mar 16 19:39:10 2014
@@ -387,7 +387,7 @@ public class FullSolrCloudDistribCmdsTes
}
}
};
- List<Thread> threads = new ArrayList<Thread>();
+ List<Thread> threads = new ArrayList<>();
int nthreads = random().nextInt(TEST_NIGHTLY ? 4 : 2) + 1;
for (int i = 0; i < nthreads; i++) {
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java Sun Mar 16 19:39:10 2014
@@ -57,9 +57,9 @@ public class LeaderElectionIntegrationTe
protected String zkDir;
- private Map<Integer,CoreContainer> containerMap = new HashMap<Integer,CoreContainer>();
+ private Map<Integer,CoreContainer> containerMap = new HashMap<>();
- private Map<String,Set<Integer>> shardPorts = new HashMap<String,Set<Integer>>();
+ private Map<String,Set<Integer>> shardPorts = new HashMap<>();
private SolrZkClient zkClient;
@@ -142,7 +142,7 @@ public class LeaderElectionIntegrationTe
System.setProperty("solr.solr.home", TEST_HOME());
Set<Integer> ports = shardPorts.get(shard);
if (ports == null) {
- ports = new HashSet<Integer>();
+ ports = new HashSet<>();
shardPorts.put(shard, ports);
}
ports.add(port);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java Sun Mar 16 19:39:10 2014
@@ -228,7 +228,7 @@ public class LeaderElectionTest extends
@Test
public void testElection() throws Exception {
- List<ClientThread> threads = new ArrayList<ClientThread>();
+ List<ClientThread> threads = new ArrayList<>();
for (int i = 0; i < 15; i++) {
ClientThread thread = new ClientThread(i);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java Sun Mar 16 19:39:10 2014
@@ -114,7 +114,7 @@ public class MigrateRouteKeyTest extends
return ruleRemoved;
}
- private void invokeMigrateApi(String sourceCollection, String splitKey, String targetCollection) throws SolrServerException, IOException {
+ protected void invokeMigrateApi(String sourceCollection, String splitKey, String targetCollection) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.MIGRATE.toString());
params.set("collection", sourceCollection);
@@ -125,7 +125,7 @@ public class MigrateRouteKeyTest extends
invoke(params);
}
- private void invoke(ModifiableSolrParams params) throws SolrServerException, IOException {
+ protected void invoke(ModifiableSolrParams params) throws SolrServerException, IOException {
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
@@ -141,7 +141,7 @@ public class MigrateRouteKeyTest extends
}
private void createCollection(String targetCollection) throws Exception {
- HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
CloudSolrServer client = null;
try {
client = createCloudClient(null);
@@ -161,7 +161,7 @@ public class MigrateRouteKeyTest extends
waitForRecoveriesToFinish(targetCollection, false);
}
- private void multipleShardMigrateTest() throws Exception {
+ protected void multipleShardMigrateTest() throws Exception {
del("*:*");
commit();
assertTrue(cloudClient.query(new SolrQuery("*:*")).getResults().getNumFound() == 0);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java Sun Mar 16 19:39:10 2014
@@ -71,6 +71,9 @@ public class OverseerCollectionProcessor
private static final String CONFIG_NAME = "myconfig";
private static DistributedQueue workQueueMock;
+ private static DistributedMap runningMapMock;
+ private static DistributedMap completedMapMock;
+ private static DistributedMap failureMapMock;
private static ShardHandler shardHandlerMock;
private static ZkStateReader zkStateReaderMock;
private static ClusterState clusterStateMock;
@@ -81,7 +84,7 @@ public class OverseerCollectionProcessor
private OverseerCollectionProcessorToBeTested underTest;
private Thread thread;
- private Queue<QueueEvent> queue = new BlockingArrayQueue<QueueEvent>();
+ private Queue<QueueEvent> queue = new BlockingArrayQueue<>();
private class OverseerCollectionProcessorToBeTested extends
OverseerCollectionProcessor {
@@ -90,8 +93,10 @@ public class OverseerCollectionProcessor
public OverseerCollectionProcessorToBeTested(ZkStateReader zkStateReader,
String myId, ShardHandler shardHandler, String adminPath,
- DistributedQueue workQueue) {
- super(zkStateReader, myId, shardHandler, adminPath, workQueue);
+ DistributedQueue workQueue, DistributedMap runningMap,
+ DistributedMap completedMap,
+ DistributedMap failureMap) {
+ super(zkStateReader, myId, shardHandler, adminPath, workQueue, runningMap, completedMap, failureMap);
}
@Override
@@ -111,6 +116,9 @@ public class OverseerCollectionProcessor
@BeforeClass
public static void setUpOnce() throws Exception {
workQueueMock = createMock(DistributedQueue.class);
+ runningMapMock = createMock(DistributedMap.class);
+ completedMapMock = createMock(DistributedMap.class);
+ failureMapMock = createMock(DistributedMap.class);
shardHandlerMock = createMock(ShardHandler.class);
zkStateReaderMock = createMock(ZkStateReader.class);
clusterStateMock = createMock(ClusterState.class);
@@ -120,6 +128,9 @@ public class OverseerCollectionProcessor
@AfterClass
public static void tearDownOnce() {
workQueueMock = null;
+ runningMapMock = null;
+ completedMapMock = null;
+ failureMapMock = null;
shardHandlerMock = null;
zkStateReaderMock = null;
clusterStateMock = null;
@@ -131,13 +142,16 @@ public class OverseerCollectionProcessor
super.setUp();
queue.clear();
reset(workQueueMock);
- reset(workQueueMock);
+ reset(runningMapMock);
+ reset(completedMapMock);
+ reset(failureMapMock);
reset(shardHandlerMock);
reset(zkStateReaderMock);
reset(clusterStateMock);
reset(solrZkClientMock);
underTest = new OverseerCollectionProcessorToBeTested(zkStateReaderMock,
- "1234", shardHandlerMock, ADMIN_PATH, workQueueMock);
+ "1234", shardHandlerMock, ADMIN_PATH, workQueueMock, runningMapMock,
+ completedMapMock, failureMapMock);
zkMap.clear();
collectionsSet.clear();
}
@@ -202,7 +216,7 @@ public class OverseerCollectionProcessor
return collectionsSet;
}
}).anyTimes();
- final Set<String> liveNodes = new HashSet<String>();
+ final Set<String> liveNodes = new HashSet<>();
for (int i = 0; i < liveNodesCount; i++) {
final String address = "localhost:" + (8963 + i) + "_solr";
liveNodes.add(address);
@@ -316,14 +330,14 @@ public class OverseerCollectionProcessor
}
private class SubmitCapture {
- public Capture<ShardRequest> shardRequestCapture = new Capture<ShardRequest>();
- public Capture<String> nodeUrlsWithoutProtocolPartCapture = new Capture<String>();
- public Capture<ModifiableSolrParams> params = new Capture<ModifiableSolrParams>();
+ public Capture<ShardRequest> shardRequestCapture = new Capture<>();
+ public Capture<String> nodeUrlsWithoutProtocolPartCapture = new Capture<>();
+ public Capture<ModifiableSolrParams> params = new Capture<>();
}
protected List<SubmitCapture> mockShardHandlerForCreateJob(
Integer numberOfSlices, Integer numberOfReplica) {
- List<SubmitCapture> submitCaptures = new ArrayList<SubmitCapture>();
+ List<SubmitCapture> submitCaptures = new ArrayList<>();
for (int i = 0; i < (numberOfSlices * numberOfReplica); i++) {
SubmitCapture submitCapture = new SubmitCapture();
shardHandlerMock.submit(capture(submitCapture.shardRequestCapture),
@@ -370,9 +384,9 @@ public class OverseerCollectionProcessor
protected void verifySubmitCaptures(List<SubmitCapture> submitCaptures,
Integer numberOfSlices, Integer numberOfReplica, Collection<String> createNodes) {
- List<String> coreNames = new ArrayList<String>();
- Map<String,Map<String,Integer>> sliceToNodeUrlsWithoutProtocolPartToNumberOfShardsRunningMapMap = new HashMap<String,Map<String,Integer>>();
- List<String> nodeUrlWithoutProtocolPartForLiveNodes = new ArrayList<String>(
+ List<String> coreNames = new ArrayList<>();
+ Map<String,Map<String,Integer>> sliceToNodeUrlsWithoutProtocolPartToNumberOfShardsRunningMapMap = new HashMap<>();
+ List<String> nodeUrlWithoutProtocolPartForLiveNodes = new ArrayList<>(
createNodes.size());
for (String nodeName : createNodes) {
String nodeUrlWithoutProtocolPart = nodeName.replaceAll("_", "/");
@@ -510,7 +524,7 @@ public class OverseerCollectionProcessor
assertTrue("Wrong usage of testTemplage. createNodeListOption has to be " + CreateNodeListOptions.SEND + " when numberOfNodes and numberOfNodesToCreateOn are unequal", ((createNodeListOption == CreateNodeListOptions.SEND) || (numberOfNodes.intValue() == numberOfNodesToCreateOn.intValue())));
Set<String> liveNodes = commonMocks(numberOfNodes);
- List<String> createNodeList = new ArrayList<String>();
+ List<String> createNodeList = new ArrayList<>();
int i = 0;
for (String node : liveNodes) {
if (i++ < numberOfNodesToCreateOn) {
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerRolesTest.java Sun Mar 16 19:39:10 2014
@@ -216,7 +216,7 @@ public class OverseerRolesTest extends
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
NUM_SLICES, numShards);
- Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+ Map<String,List<Integer>> collectionInfos = new HashMap<>();
createCollection(collectionInfos, COLL_NAME, props, client);
}
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Sun Mar 16 19:39:10 2014
@@ -61,21 +61,21 @@ public class OverseerTest extends SolrTe
static final int TIMEOUT = 10000;
private static final boolean DEBUG = false;
- private List<Overseer> overseers = new ArrayList<Overseer>();
- private List<ZkStateReader> readers = new ArrayList<ZkStateReader>();
+ private List<Overseer> overseers = new ArrayList<>();
+ private List<ZkStateReader> readers = new ArrayList<>();
+
+ private String collection = "collection1";
public static class MockZKController{
private final SolrZkClient zkClient;
private final ZkStateReader zkStateReader;
private final String nodeName;
- private final String collection;
private final LeaderElector elector;
private final Map<String, ElectionContext> electionContext = Collections.synchronizedMap(new HashMap<String, ElectionContext>());
- public MockZKController(String zkAddress, String nodeName, String collection) throws InterruptedException, TimeoutException, IOException, KeeperException {
+ public MockZKController(String zkAddress, String nodeName) throws InterruptedException, TimeoutException, IOException, KeeperException {
this.nodeName = nodeName;
- this.collection = collection;
zkClient = new SolrZkClient(zkAddress, TIMEOUT);
zkStateReader = new ZkStateReader(zkClient);
zkStateReader.createClusterStateWatchersAndUpdate();
@@ -105,7 +105,7 @@ public class OverseerTest extends SolrTe
zkClient.close();
}
- public String publishState(String coreName, String coreNodeName, String stateName, int numShards)
+ public String publishState(String collection, String coreName, String coreNodeName, String stateName, int numShards)
throws KeeperException, InterruptedException, IOException {
if (stateName == null) {
ElectionContext ec = electionContext.remove(coreName);
@@ -134,41 +134,40 @@ public class OverseerTest extends SolrTe
q.offer(ZkStateReader.toJSON(m));
}
- for (int i = 0; i < 120; i++) {
- String shardId = getShardId("http://" + nodeName + "/solr/", coreName);
- if (shardId != null) {
- try {
- zkClient.makePath("/collections/" + collection + "/leader_elect/"
- + shardId + "/election", true);
- } catch (NodeExistsException nee) {}
- ZkNodeProps props = new ZkNodeProps(ZkStateReader.BASE_URL_PROP,
- "http://" + nodeName + "/solr/", ZkStateReader.NODE_NAME_PROP,
- nodeName, ZkStateReader.CORE_NAME_PROP, coreName,
- ZkStateReader.SHARD_ID_PROP, shardId,
- ZkStateReader.COLLECTION_PROP, collection,
- ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName);
- ShardLeaderElectionContextBase ctx = new ShardLeaderElectionContextBase(
- elector, shardId, collection, nodeName + "_" + coreName, props,
- zkStateReader);
- elector.setup(ctx);
- elector.joinElection(ctx, false);
- return shardId;
+ if (collection.length() > 0) {
+ for (int i = 0; i < 120; i++) {
+ String shardId = getShardId(collection, coreNodeName);
+ if (shardId != null) {
+ try {
+ zkClient.makePath("/collections/" + collection + "/leader_elect/"
+ + shardId + "/election", true);
+ } catch (NodeExistsException nee) {}
+ ZkNodeProps props = new ZkNodeProps(ZkStateReader.BASE_URL_PROP,
+ "http://" + nodeName + "/solr/", ZkStateReader.NODE_NAME_PROP,
+ nodeName, ZkStateReader.CORE_NAME_PROP, coreName,
+ ZkStateReader.SHARD_ID_PROP, shardId,
+ ZkStateReader.COLLECTION_PROP, collection,
+ ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName);
+ ShardLeaderElectionContextBase ctx = new ShardLeaderElectionContextBase(
+ elector, shardId, collection, nodeName + "_" + coreName, props,
+ zkStateReader);
+ elector.setup(ctx);
+ elector.joinElection(ctx, false);
+ return shardId;
+ }
+ Thread.sleep(500);
}
- Thread.sleep(500);
}
return null;
}
- private String getShardId(final String baseUrl, final String coreName) {
- Map<String,Slice> slices = zkStateReader.getClusterState().getSlicesMap(
- collection);
+ private String getShardId(String collection, String coreNodeName) {
+ Map<String,Slice> slices = zkStateReader.getClusterState().getSlicesMap(collection);
if (slices != null) {
for (Slice slice : slices.values()) {
for (Replica replica : slice.getReplicas()) {
- // TODO: for really large clusters, we could 'index' on this
- String rbaseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP);
- String rcore = replica.getStr(ZkStateReader.CORE_NAME_PROP);
- if (baseUrl.equals(rbaseUrl) && coreName.equals(rcore)) {
+ String cnn = replica.getName();
+ if (coreNodeName.equals(cnn)) {
return slice.getName();
}
}
@@ -226,17 +225,17 @@ public class OverseerTest extends SolrTe
ZkStateReader reader = new ZkStateReader(zkClient);
reader.createClusterStateWatchersAndUpdate();
- zkController = new MockZKController(server.getZkAddress(), "127.0.0.1", "collection1");
+ zkController = new MockZKController(server.getZkAddress(), "127.0.0.1");
final int numShards=6;
for (int i = 0; i < numShards; i++) {
- assertNotNull("shard got no id?", zkController.publishState("core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
+ assertNotNull("shard got no id?", zkController.publishState(collection, "core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
}
-
- assertEquals(2, reader.getClusterState().getSlice("collection1", "shard1").getReplicasMap().size());
- assertEquals(2, reader.getClusterState().getSlice("collection1", "shard2").getReplicasMap().size());
- assertEquals(2, reader.getClusterState().getSlice("collection1", "shard3").getReplicasMap().size());
+ Map<String,Replica> rmap = reader.getClusterState().getSlice("collection1", "shard1").getReplicasMap();
+ assertEquals(rmap.toString(), 2, rmap.size());
+ assertEquals(rmap.toString(), 2, reader.getClusterState().getSlice("collection1", "shard2").getReplicasMap().size());
+ assertEquals(rmap.toString(), 2, reader.getClusterState().getSlice("collection1", "shard3").getReplicasMap().size());
//make sure leaders are in cloud state
assertNotNull(reader.getLeaderUrl("collection1", "shard1", 15000));
@@ -259,6 +258,81 @@ public class OverseerTest extends SolrTe
}
@Test
+ public void testBadQueueItem() throws Exception {
+ String zkDir = dataDir.getAbsolutePath() + File.separator
+ + "zookeeper/server1/data";
+
+ ZkTestServer server = new ZkTestServer(zkDir);
+
+ MockZKController zkController = null;
+ SolrZkClient zkClient = null;
+ SolrZkClient overseerClient = null;
+
+ try {
+ server.run();
+ AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
+ AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
+
+ zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
+ zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+
+ overseerClient = electNewOverseer(server.getZkAddress());
+
+ ZkStateReader reader = new ZkStateReader(zkClient);
+ reader.createClusterStateWatchersAndUpdate();
+
+ zkController = new MockZKController(server.getZkAddress(), "127.0.0.1");
+
+ final int numShards=3;
+
+ for (int i = 0; i < numShards; i++) {
+ assertNotNull("shard got no id?", zkController.publishState(collection, "core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
+ }
+
+ assertEquals(1, reader.getClusterState().getSlice(collection, "shard1").getReplicasMap().size());
+ assertEquals(1, reader.getClusterState().getSlice(collection, "shard2").getReplicasMap().size());
+ assertEquals(1, reader.getClusterState().getSlice(collection, "shard3").getReplicasMap().size());
+
+ //make sure leaders are in cloud state
+ assertNotNull(reader.getLeaderUrl(collection, "shard1", 15000));
+ assertNotNull(reader.getLeaderUrl(collection, "shard2", 15000));
+ assertNotNull(reader.getLeaderUrl(collection, "shard3", 15000));
+
+ // publish a bad queue item
+ String emptyCollectionName = "";
+ zkController.publishState(emptyCollectionName, "core0", "node0", ZkStateReader.ACTIVE, 1);
+ zkController.publishState(emptyCollectionName, "core0", "node0", null, 1);
+
+ // make sure the Overseer is still processing items
+ for (int i = 0; i < numShards; i++) {
+ assertNotNull("shard got no id?", zkController.publishState("collection2", "core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
+ }
+
+ assertEquals(1, reader.getClusterState().getSlice("collection2", "shard1").getReplicasMap().size());
+ assertEquals(1, reader.getClusterState().getSlice("collection2", "shard2").getReplicasMap().size());
+ assertEquals(1, reader.getClusterState().getSlice("collection2", "shard3").getReplicasMap().size());
+
+ //make sure leaders are in cloud state
+ assertNotNull(reader.getLeaderUrl("collection2", "shard1", 15000));
+ assertNotNull(reader.getLeaderUrl("collection2", "shard2", 15000));
+ assertNotNull(reader.getLeaderUrl("collection2", "shard3", 15000));
+
+ } finally {
+ if (DEBUG) {
+ if (zkController != null) {
+ zkClient.printLayoutToStdOut();
+ }
+ }
+ close(zkClient);
+ if (zkController != null) {
+ zkController.close();
+ }
+ close(overseerClient);
+ server.shutdown();
+ }
+ }
+
+ @Test
public void testShardAssignmentBigger() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
@@ -289,7 +363,7 @@ public class OverseerTest extends SolrTe
reader.createClusterStateWatchersAndUpdate();
for (int i = 0; i < nodeCount; i++) {
- controllers[i] = new MockZKController(server.getZkAddress(), "node" + i, "collection1");
+ controllers[i] = new MockZKController(server.getZkAddress(), "node" + i);
}
for (int i = 0; i < nodeCount; i++) {
nodeExecutors[i] = Executors.newFixedThreadPool(1, new DefaultSolrThreadFactory("testShardAssignment"));
@@ -306,7 +380,7 @@ public class OverseerTest extends SolrTe
final String coreName = "core" + slot;
try {
- ids[slot]=controllers[slot % nodeCount].publishState(coreName, "node" + slot, ZkStateReader.ACTIVE, sliceCount);
+ ids[slot]=controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, ZkStateReader.ACTIVE, sliceCount);
} catch (Throwable e) {
e.printStackTrace();
fail("register threw exception:" + e.getClass());
@@ -346,7 +420,7 @@ public class OverseerTest extends SolrTe
// make sure all cores have been returned an id
int assignedCount = 0;
- for (int i = 0; i < 120; i++) {
+ for (int i = 0; i < 240; i++) {
assignedCount = 0;
for (int j = 0; j < coreCount; j++) {
if (ids[j] != null) {
@@ -361,7 +435,7 @@ public class OverseerTest extends SolrTe
assertEquals("Unable to verify all cores have been returned an id",
coreCount, assignedCount);
- final HashMap<String, AtomicInteger> counters = new HashMap<String,AtomicInteger>();
+ final HashMap<String, AtomicInteger> counters = new HashMap<>();
for (int i = 1; i < sliceCount+1; i++) {
counters.put("shard" + i, new AtomicInteger());
}
@@ -532,72 +606,72 @@ public class OverseerTest extends SolrTe
+ "zookeeper/server1/data";
ZkTestServer server = new ZkTestServer(zkDir);
- SolrZkClient controllerClient = null;
+
SolrZkClient overseerClient = null;
ZkStateReader reader = null;
MockZKController mockController = null;
+ SolrZkClient zkClient = null;
try {
server.run();
- controllerClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
+
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
- controllerClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
- reader = new ZkStateReader(controllerClient);
+ zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
+
+ zkClient.makePath(ZkStateReader.LIVE_NODES_ZKNODE, true);
+
+ reader = new ZkStateReader(zkClient);
reader.createClusterStateWatchersAndUpdate();
- mockController = new MockZKController(server.getZkAddress(), "node1",
- "collection1");
+ mockController = new MockZKController(server.getZkAddress(), "node1");
overseerClient = electNewOverseer(server.getZkAddress());
Thread.sleep(1000);
- mockController.publishState("core1", "core_node1",
+ mockController.publishState(collection, "core1", "core_node1",
ZkStateReader.RECOVERING, 1);
- waitForCollections(reader, "collection1");
+ waitForCollections(reader, collection);
verifyStatus(reader, ZkStateReader.RECOVERING);
- int version = getClusterStateVersion(controllerClient);
+ int version = getClusterStateVersion(zkClient);
- mockController.publishState("core1", "core_node1", ZkStateReader.ACTIVE,
+ mockController.publishState(collection, "core1", "core_node1", ZkStateReader.ACTIVE,
1);
- while (version == getClusterStateVersion(controllerClient))
- ;
+ while (version == getClusterStateVersion(zkClient));
verifyStatus(reader, ZkStateReader.ACTIVE);
- version = getClusterStateVersion(controllerClient);
+ version = getClusterStateVersion(zkClient);
overseerClient.close();
Thread.sleep(1000); // wait for overseer to get killed
- mockController.publishState("core1", "core_node1",
+ mockController.publishState(collection, "core1", "core_node1",
ZkStateReader.RECOVERING, 1);
- version = getClusterStateVersion(controllerClient);
+ version = getClusterStateVersion(zkClient);
overseerClient = electNewOverseer(server.getZkAddress());
- while (version == getClusterStateVersion(controllerClient));
+ while (version == getClusterStateVersion(zkClient));
verifyStatus(reader, ZkStateReader.RECOVERING);
assertEquals("Live nodes count does not match", 1, reader
.getClusterState().getLiveNodes().size());
assertEquals("Shard count does not match", 1, reader.getClusterState()
- .getSlice("collection1", "shard1").getReplicasMap().size());
- version = getClusterStateVersion(controllerClient);
- mockController.publishState("core1", "core_node1", null, 1);
- while (version == getClusterStateVersion(controllerClient));
+ .getSlice(collection, "shard1").getReplicasMap().size());
+ version = getClusterStateVersion(zkClient);
+ mockController.publishState(collection, "core1", "core_node1", null, 1);
+ while (version == getClusterStateVersion(zkClient));
Thread.sleep(500);
assertFalse("collection1 should be gone after publishing the null state",
- reader.getClusterState().getCollections().contains("collection1"));
+ reader.getClusterState().getCollections().contains(collection));
} finally {
-
close(mockController);
-
close(overseerClient);
- close(controllerClient);
+ close(zkClient);
close(reader);
server.shutdown();
}
@@ -675,17 +749,17 @@ public class OverseerTest extends SolrTe
for (int i = 0; i < atLeast(4); i++) {
killCounter.incrementAndGet(); //for each round allow 1 kill
- mockController = new MockZKController(server.getZkAddress(), "node1", "collection1");
- mockController.publishState("core1", "node1", "state1",1);
+ mockController = new MockZKController(server.getZkAddress(), "node1");
+ mockController.publishState(collection, "core1", "node1", "state1",1);
if(mockController2!=null) {
mockController2.close();
mockController2 = null;
}
- mockController.publishState("core1", "node1","state2",1);
- mockController2 = new MockZKController(server.getZkAddress(), "node2", "collection1");
- mockController.publishState("core1", "node1", "state1",1);
+ mockController.publishState(collection, "core1", "node1","state2",1);
+ mockController2 = new MockZKController(server.getZkAddress(), "node2");
+ mockController.publishState(collection, "core1", "node1", "state1",1);
verifyShardLeader(reader, "collection1", "shard1", "core1");
- mockController2.publishState("core4", "node2", "state2" ,1);
+ mockController2.publishState(collection, "core4", "node2", "state2" ,1);
mockController.close();
mockController = null;
verifyShardLeader(reader, "collection1", "shard1", "core4");
@@ -728,11 +802,11 @@ public class OverseerTest extends SolrTe
reader = new ZkStateReader(controllerClient);
reader.createClusterStateWatchersAndUpdate();
- mockController = new MockZKController(server.getZkAddress(), "node1", "collection1");
+ mockController = new MockZKController(server.getZkAddress(), "node1");
overseerClient = electNewOverseer(server.getZkAddress());
- mockController.publishState("core1", "core_node1", ZkStateReader.RECOVERING, 1);
+ mockController.publishState(collection, "core1", "core_node1", ZkStateReader.RECOVERING, 1);
waitForCollections(reader, "collection1");
@@ -742,8 +816,8 @@ public class OverseerTest extends SolrTe
int version = getClusterStateVersion(controllerClient);
- mockController = new MockZKController(server.getZkAddress(), "node1", "collection1");
- mockController.publishState("core1", "core_node1", ZkStateReader.RECOVERING, 1);
+ mockController = new MockZKController(server.getZkAddress(), "node1");
+ mockController.publishState(collection, "core1", "core_node1", ZkStateReader.RECOVERING, 1);
while (version == getClusterStateVersion(controllerClient));
@@ -793,11 +867,11 @@ public class OverseerTest extends SolrTe
reader = new ZkStateReader(controllerClient);
reader.createClusterStateWatchersAndUpdate();
- mockController = new MockZKController(server.getZkAddress(), "node1", "collection1");
+ mockController = new MockZKController(server.getZkAddress(), "node1");
overseerClient = electNewOverseer(server.getZkAddress());
- mockController.publishState("core1", "node1", ZkStateReader.RECOVERING, 12);
+ mockController.publishState(collection, "core1", "node1", ZkStateReader.RECOVERING, 12);
waitForCollections(reader, "collection1");
@@ -914,6 +988,7 @@ public class OverseerTest extends SolrTe
LeaderElector overseerElector = new LeaderElector(zkClient);
if (overseers.size() > 0) {
overseers.get(overseers.size() -1).close();
+ overseers.get(overseers.size() -1).getZkStateReader().getZkClient().close();
}
Overseer overseer = new Overseer(
new HttpShardHandlerFactory().getShardHandler(), "/admin/cores", reader);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RecoveryZkTest.java Sun Mar 16 19:39:10 2014
@@ -66,10 +66,10 @@ public class RecoveryZkTest extends Abst
int maxDoc = maxDocList[random().nextInt(maxDocList.length - 1)];
- indexThread = new StopableIndexingThread("1", true, maxDoc);
+ indexThread = new StopableIndexingThread(controlClient, cloudClient, "1", true, maxDoc);
indexThread.start();
- indexThread2 = new StopableIndexingThread("2", true, maxDoc);
+ indexThread2 = new StopableIndexingThread(controlClient, cloudClient, "2", true, maxDoc);
indexThread2.start();
@@ -100,7 +100,7 @@ public class RecoveryZkTest extends Abst
Thread.sleep(1000);
- waitForThingsToLevelOut(45);
+ waitForThingsToLevelOut(90);
Thread.sleep(2000);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/RemoteQueryErrorTest.java Sun Mar 16 19:39:10 2014
@@ -49,7 +49,7 @@ public class RemoteQueryErrorTest extend
createCollection("collection2", 2, 1, 10);
- List<Integer> numShardsNumReplicaList = new ArrayList<Integer>(2);
+ List<Integer> numShardsNumReplicaList = new ArrayList<>(2);
numShardsNumReplicaList.add(2);
numShardsNumReplicaList.add(1);
checkForCollection("collection2", numShardsNumReplicaList, null);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java Sun Mar 16 19:39:10 2014
@@ -339,31 +339,8 @@ public class ShardRoutingTest extends Ab
// todo - target diff servers and use cloud clients as well as non-cloud clients
}
- // TODO: refactor some of this stuff up into a base class for use by other tests
- void doQuery(String expectedDocs, String... queryParams) throws Exception {
- Set<String> expectedIds = new HashSet<String>( StrUtils.splitSmart(expectedDocs, ",", true) );
-
- QueryResponse rsp = cloudClient.query(params(queryParams));
- Set<String> obtainedIds = new HashSet<String>();
- for (SolrDocument doc : rsp.getResults()) {
- obtainedIds.add((String) doc.get("id"));
- }
-
- assertEquals(expectedIds, obtainedIds);
- }
-
void doRTG(String ids) throws Exception {
- cloudClient.query(params("qt","/get", "ids",ids));
-
- Set<String> expectedIds = new HashSet<String>( StrUtils.splitSmart(ids, ",", true) );
-
- QueryResponse rsp = cloudClient.query(params("qt","/get", "ids",ids));
- Set<String> obtainedIds = new HashSet<String>();
- for (SolrDocument doc : rsp.getResults()) {
- obtainedIds.add((String) doc.get("id"));
- }
-
- assertEquals(expectedIds, obtainedIds);
+ doQuery(ids, "qt", "/get", "ids", ids);
}
// TODO: refactor some of this stuff into the SolrJ client... it should be easier to use
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java Sun Mar 16 19:39:10 2014
@@ -78,8 +78,6 @@ public class ShardSplitTest extends Basi
@Override
@After
public void tearDown() throws Exception {
- super.tearDown();
-
if (VERBOSE || printLayoutOnTearDown) {
super.printLayout();
}
@@ -93,15 +91,6 @@ public class ShardSplitTest extends Basi
controlClientCloud.shutdown();
}
super.tearDown();
-
- System.clearProperty("zkHost");
- System.clearProperty("numShards");
- System.clearProperty("solr.xml.persist");
-
- // insurance
- DirectUpdateHandler2.commitOnClose = true;
-
-
}
@Override
@@ -126,7 +115,7 @@ public class ShardSplitTest extends Basi
Slice shard1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);
DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
- List<DocRouter.Range> subRanges = new ArrayList<DocRouter.Range>();
+ List<DocRouter.Range> subRanges = new ArrayList<>();
List<DocRouter.Range> ranges = router.partitionRange(4, shard1Range);
// test with only one range
@@ -169,7 +158,7 @@ public class ShardSplitTest extends Basi
final DocRouter router = clusterState.getCollection(AbstractDistribZkTestBase.DEFAULT_COLLECTION).getRouter();
Slice shard1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);
DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
- List<DocRouter.Range> subRanges = new ArrayList<DocRouter.Range>();
+ List<DocRouter.Range> subRanges = new ArrayList<>();
if (usually()) {
List<DocRouter.Range> ranges = router.partitionRange(4, shard1Range);
// 75% of range goes to shard1_0 and the rest to shard1_1
@@ -196,7 +185,7 @@ public class ShardSplitTest extends Basi
int max = atLeast(random, 401);
int sleep = atLeast(random, 25);
log.info("SHARDSPLITTEST: Going to add " + max + " number of docs at 1 doc per " + sleep + "ms");
- Set<String> deleted = new HashSet<String>();
+ Set<String> deleted = new HashSet<>();
for (int id = 101; id < max; id++) {
try {
indexAndUpdateCount(router, ranges, docCounts, String.valueOf(id), id);
@@ -257,7 +246,7 @@ public class ShardSplitTest extends Basi
int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
- HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
CloudSolrServer client = null;
String shard_fld = "shard_s";
try {
@@ -335,7 +324,7 @@ public class ShardSplitTest extends Basi
int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
- HashMap<String, List<Integer>> collectionInfos = new HashMap<String, List<Integer>>();
+ HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
CloudSolrServer client = null;
try {
client = createCloudClient(null);
@@ -577,9 +566,9 @@ public class ShardSplitTest extends Basi
log.info("Actual docCount for shard1_0 = {}", shard10Count);
log.info("Actual docCount for shard1_1 = {}", shard11Count);
- Map<String, String> idVsVersion = new HashMap<String, String>();
- Map<String, SolrDocument> shard10Docs = new HashMap<String, SolrDocument>();
- Map<String, SolrDocument> shard11Docs = new HashMap<String, SolrDocument>();
+ Map<String, String> idVsVersion = new HashMap<>();
+ Map<String, SolrDocument> shard10Docs = new HashMap<>();
+ Map<String, SolrDocument> shard11Docs = new HashMap<>();
for (int i = 0; i < response.getResults().size(); i++) {
SolrDocument document = response.getResults().get(i);
idVsVersion.put(document.getFieldValue("id").toString(), document.getFieldValue("_version_").toString());
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateTest.java Sun Mar 16 19:39:10 2014
@@ -34,13 +34,13 @@ import java.util.Set;
public class SliceStateTest extends SolrTestCaseJ4 {
@Test
public void testDefaultSliceState() throws Exception {
- Map<String, DocCollection> collectionStates = new HashMap<String, DocCollection>();
- Set<String> liveNodes = new HashSet<String>();
+ Map<String, DocCollection> collectionStates = new HashMap<>();
+ Set<String> liveNodes = new HashSet<>();
liveNodes.add("node1");
- Map<String, Slice> slices = new HashMap<String, Slice>();
- Map<String, Replica> sliceToProps = new HashMap<String, Replica>();
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Slice> slices = new HashMap<>();
+ Map<String, Replica> sliceToProps = new HashMap<>();
+ Map<String, Object> props = new HashMap<>();
Replica replica = new Replica("node1", props);
sliceToProps.put("node1", replica);
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SliceStateUpdateTest.java Sun Mar 16 19:39:10 2014
@@ -86,7 +86,7 @@ public class SliceStateUpdateTest extend
.getZkAddress(), "solrconfig.xml", "schema.xml");
log.info("####SETUP_START " + getTestName());
- Map<String, Object> props2 = new HashMap<String, Object>();
+ Map<String, Object> props2 = new HashMap<>();
props2.put("configName", "conf1");
ZkNodeProps zkProps2 = new ZkNodeProps(props2);
@@ -147,7 +147,7 @@ public class SliceStateUpdateTest extend
// new LinkedHashMap<String, DocCollection>(clusterState.getCollectionStates());
Map<String, Slice> slicesMap = clusterState.getSlicesMap("collection1");
- Map<String, Object> props = new HashMap<String, Object>(1);
+ Map<String, Object> props = new HashMap<>(1);
Slice slice = slicesMap.get("shard1");
Map<String, Object> prop = slice.getProperties();
prop.put("state", "inactive");
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java Sun Mar 16 19:39:10 2014
@@ -96,7 +96,7 @@ public class SyncSliceTest extends Abstr
waitForThingsToLevelOut(30);
del("*:*");
- List<CloudJettyRunner> skipServers = new ArrayList<CloudJettyRunner>();
+ List<CloudJettyRunner> skipServers = new ArrayList<>();
int docId = 0;
indexDoc(skipServers, id, docId++, i1, 50, tlong, 50, t1,
"to come to the aid of their country.");
@@ -156,7 +156,7 @@ public class SyncSliceTest extends Abstr
"to come to the aid of their country.");
- Set<CloudJettyRunner> jetties = new HashSet<CloudJettyRunner>();
+ Set<CloudJettyRunner> jetties = new HashSet<>();
jetties.addAll(shardToJetty.get("shard1"));
jetties.remove(leaderJetty);
assertEquals(shardCount - 1, jetties.size());
@@ -217,7 +217,7 @@ public class SyncSliceTest extends Abstr
"Test Setup Failure: shard1 should have just been set up to be inconsistent - but it's still consistent. Leader:"
+ leaderJetty.url + " Dead Guy:" + deadJetty.url + "skip list:" + skipServers, shardFailMessage);
- jetties = new HashSet<CloudJettyRunner>();
+ jetties = new HashSet<>();
jetties.addAll(shardToJetty.get("shard1"));
jetties.remove(leaderJetty);
assertEquals(shardCount - 1, jetties.size());
@@ -292,8 +292,8 @@ public class SyncSliceTest extends Abstr
}
private List<CloudJettyRunner> getRandomOtherJetty(CloudJettyRunner leader, CloudJettyRunner down) {
- List<CloudJettyRunner> skipServers = new ArrayList<CloudJettyRunner>();
- List<CloudJettyRunner> candidates = new ArrayList<CloudJettyRunner>();
+ List<CloudJettyRunner> skipServers = new ArrayList<>();
+ List<CloudJettyRunner> candidates = new ArrayList<>();
candidates.addAll(shardToJetty.get("shard1"));
if (leader != null) {
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java Sun Mar 16 19:39:10 2014
@@ -103,6 +103,8 @@ public class TestDistribDocBasedVersion
doTestDocVersions();
doTestHardFail();
+ commit(); // work arround SOLR-5628
+
testFinished = true;
} finally {
if (!testFinished) {
@@ -288,7 +290,7 @@ public class TestDistribDocBasedVersion
void doQuery(String expectedDocs, String... queryParams) throws Exception {
List<String> strs = StrUtils.splitSmart(expectedDocs, ",", true);
- Map<String, Object> expectedIds = new HashMap<String,Object>();
+ Map<String, Object> expectedIds = new HashMap<>();
for (int i=0; i<strs.size(); i+=2) {
String id = strs.get(i);
String vS = strs.get(i+1);
@@ -297,7 +299,7 @@ public class TestDistribDocBasedVersion
}
QueryResponse rsp = cloudClient.query(params(queryParams));
- Map<String, Object> obtainedIds = new HashMap<String,Object>();
+ Map<String, Object> obtainedIds = new HashMap<>();
for (SolrDocument doc : rsp.getResults()) {
obtainedIds.put((String) doc.get("id"), doc.get(vfield));
}
@@ -307,7 +309,7 @@ public class TestDistribDocBasedVersion
void doRTG(String ids, String versions) throws Exception {
- Map<String, Object> expectedIds = new HashMap<String,Object>();
+ Map<String, Object> expectedIds = new HashMap<>();
List<String> strs = StrUtils.splitSmart(ids, ",", true);
List<String> verS = StrUtils.splitSmart(versions, ",", true);
for (int i=0; i<strs.size(); i++) {
@@ -317,7 +319,7 @@ public class TestDistribDocBasedVersion
ss.query(params("qt","/get", "ids",ids));
QueryResponse rsp = cloudClient.query(params("qt","/get", "ids",ids));
- Map<String, Object> obtainedIds = new HashMap<String,Object>();
+ Map<String, Object> obtainedIds = new HashMap<>();
for (SolrDocument doc : rsp.getResults()) {
obtainedIds.put((String) doc.get("id"), doc.get(vfield));
}
@@ -328,10 +330,10 @@ public class TestDistribDocBasedVersion
void doRTG(String ids) throws Exception {
ss.query(params("qt","/get", "ids",ids));
- Set<String> expectedIds = new HashSet<String>( StrUtils.splitSmart(ids, ",", true) );
+ Set<String> expectedIds = new HashSet<>( StrUtils.splitSmart(ids, ",", true) );
QueryResponse rsp = cloudClient.query(params("qt","/get", "ids",ids));
- Set<String> obtainedIds = new HashSet<String>();
+ Set<String> obtainedIds = new HashSet<>();
for (SolrDocument doc : rsp.getResults()) {
obtainedIds.add((String) doc.get("id"));
}
Modified: lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java (original)
+++ lucene/dev/branches/lucene5376_2/solr/core/src/test/org/apache/solr/cloud/TestHashPartitioner.java Sun Mar 16 19:39:10 2014
@@ -146,8 +146,8 @@ public class TestHashPartitioner extends
List<String> expectedShardStr = StrUtils.splitSmart(expectedShards, ",", true);
- HashSet<String> expectedSet = new HashSet<String>(expectedShardStr);
- HashSet<String> obtainedSet = new HashSet<String>();
+ HashSet<String> expectedSet = new HashSet<>(expectedShardStr);
+ HashSet<String> obtainedSet = new HashSet<>();
for (Slice slice : slices) {
obtainedSet.add(slice.getName());
}
@@ -222,7 +222,7 @@ public class TestHashPartitioner extends
DocCollection createCollection(int nSlices, DocRouter router) {
List<Range> ranges = router.partitionRange(nSlices, router.fullRange());
- Map<String,Slice> slices = new HashMap<String,Slice>();
+ Map<String,Slice> slices = new HashMap<>();
for (int i=0; i<ranges.size(); i++) {
Range range = ranges.get(i);
Slice slice = new Slice("shard"+(i+1), null, map("range",range));