lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [40/50] [abbrv] lucene-solr:jira/solr-11320: SOLR-11285: Support simulations at scale in the autoscaling framework, part 1 (refactoring).
Date Tue, 17 Oct 2017 15:53:53 GMT
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8dd489ed/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
index e13a29a..720e7a6 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
@@ -25,15 +25,20 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import com.google.common.collect.ImmutableList;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrResponse;
+import org.apache.solr.client.solrj.cloud.DistributedQueueFactory;
 import org.apache.solr.client.solrj.cloud.autoscaling.Clause.Violation;
 import org.apache.solr.client.solrj.cloud.autoscaling.Policy.Suggester.Hint;
+import org.apache.solr.client.solrj.impl.ClusterStateProvider;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.ReplicaPosition;
@@ -110,7 +115,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
           if (!node_name.equals(node)) return;
           Map<String, List<ReplicaInfo>> shardVsReplicaStats = result.computeIfAbsent(collName,
k -> new HashMap<>());
           List<ReplicaInfo> replicaInfos = shardVsReplicaStats.computeIfAbsent(shard,
k -> new ArrayList<>());
-          replicaInfos.add(new ReplicaInfo(replicaName, collName, shard, Replica.Type.get((String)
r.get(ZkStateReader.REPLICA_TYPE)), new HashMap<>()));
+          replicaInfos.add(new ReplicaInfo(replicaName, collName, shard, r));
         });
       });
     });
@@ -268,7 +273,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "           'precision':100}]}";
 
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
-    Policy.Session session = policy.createSession(dataProviderWithData(dataproviderdata));
+    Policy.Session session = policy.createSession(cloudManagerWithData(dataproviderdata));
     SolrRequest op = session.getSuggester(MOVEREPLICA).hint(Hint.SRC_NODE, "127.0.0.1:65427_solr").getOperation();
     assertNotNull(op);
     assertEquals( "127.0.0.1:65434_solr",op.getParams().get("targetNode") );
@@ -290,7 +295,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "      'freedisk':884.7097854614258}," +
         "}";
 
-    ClusterDataProvider provider = getClusterDataProvider((Map<String, Map>) Utils.fromJSONString(nodeValues),
clusterState);
+    SolrCloudManager provider = getSolrCloudManager((Map<String, Map>) Utils.fromJSONString(nodeValues),
clusterState);
     Map policies = (Map) Utils.fromJSONString("{" +
         "  'cluster-preferences': [" +
         "    { 'maximize': 'freedisk', 'precision': 50}," +
@@ -407,7 +412,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
     assertEquals("r1", operation.getParams().get("replica"));
   }
 
-  private static ClusterDataProvider dataProviderWithData(String data){
+  private static SolrCloudManager cloudManagerWithData(String data) {
     final Map m = (Map) Utils.fromJSONString(data);
     Map replicaInfo = (Map) m.get("replicaInfo");
     replicaInfo.forEach((node, val) -> {
@@ -420,36 +425,39 @@ public class TestPolicy extends SolrTestCaseJ4 {
             Object o = l3.get(i);
             Map m3 = (Map) o;
             l3.set(i, new ReplicaInfo(m3.keySet().iterator().next().toString()
-                ,coll.toString(), shard.toString(), Replica.Type.get((String)m3.get("type")),
new HashMap<>()));
+                ,coll.toString(), shard.toString(), m3));
           }
         });
 
       });
 
     });
-    return new ClusterDataProvider(){
+    return new DelegatingCloudManager(null) {
       @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
-        return (Map<String, Object>) Utils.getObjectByPath(m,false, Arrays.asList("nodeValues",
node));
-      }
-
-      @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return (Map<String, Map<String, List<ReplicaInfo>>>) Utils.getObjectByPath(m,false,
Arrays.asList("replicaInfo", node));
+      public ClusterStateProvider getClusterStateProvider() {
+        return new DelegatingClusterStateProvider(null) {
+          @Override
+          public Set<String> getLiveNodes() {
+            return new HashSet<>((Collection<String>) m.get("liveNodes"));
+          }
+        };
       }
 
       @Override
-      public Collection<String> getNodes() {
-        return (Collection<String>) m.get("liveNodes");
-      }
+      public NodeStateProvider getNodeStateProvider() {
+        return new DelegatingNodeStateProvider(null) {
+          @Override
+          public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
+            return (Map<String, Object>) Utils.getObjectByPath(m,false, Arrays.asList("nodeValues",
node));
+          }
 
-      @Override
-      public String getPolicyNameByCollection(String coll) {
-        return null;
+          @Override
+          public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
+            return (Map<String, Map<String, List<ReplicaInfo>>>) Utils.getObjectByPath(m,false,
Arrays.asList("replicaInfo", node));
+          }
+        };
       }
     };
-
-
   }
 
   public void testPolicyWithReplicaType() {
@@ -472,7 +480,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "node4:{cores:8, freedisk: 375, heapUsage:16900, nodeRole:overseer, rack: rack1}"
+
         "}");
     Policy policy = new Policy(policies);
-    Policy.Suggester suggester = policy.createSession(getClusterDataProvider(nodeValues,
clusterState))
+    Policy.Suggester suggester = policy.createSession(getSolrCloudManager(nodeValues, clusterState))
         .getSuggester(ADDREPLICA)
         .hint(Hint.COLL_SHARD, new Pair("newColl", "shard1"))
         .hint(Hint.REPLICATYPE, Replica.Type.PULL);
@@ -612,7 +620,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "  'tlogReplicas':'0'}\n" +
         "}";
     Policy policy = new Policy(new HashMap<>());
-    Policy.Suggester suggester = policy.createSession(getClusterDataProvider(nodeValues,
clusterState))
+    Policy.Suggester suggester = policy.createSession(getSolrCloudManager(nodeValues, clusterState))
         .getSuggester(MOVEREPLICA)
         .hint(Hint.COLL, "collection1")
         .hint(Hint.COLL, "collection2")
@@ -668,7 +676,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "node4:{cores:8, freedisk: 375, heapUsage:16900, nodeRole:overseer, rack: rack1}"
+
         "}");
     Policy policy = new Policy(policies);
-    Policy.Suggester suggester = policy.createSession(getClusterDataProvider(nodeValues,
clusterState))
+    Policy.Suggester suggester = policy.createSession(getSolrCloudManager(nodeValues, clusterState))
         .getSuggester(ADDREPLICA)
         .hint(Hint.REPLICATYPE, Replica.Type.PULL)
         .hint(Hint.COLL_SHARD, new Pair<>("newColl", "shard1"))
@@ -796,7 +804,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
 
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(rules));
     Policy.Session session;
-    session = policy.createSession(getClusterDataProvider(nodeValues, clusterState));
+    session = policy.createSession(getSolrCloudManager(nodeValues, clusterState));
 
     List<Row> l = session.getSorted();
     assertEquals("node1", l.get(0).node);
@@ -823,7 +831,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "node5:{cores:0, freedisk: 895, heapUsage:17834}," +
         "node4:{cores:8, freedisk: 375, heapUsage:16900, nodeRole:overseer}" +
         "}");
-    session = policy.createSession(getClusterDataProvider(nodeValues, clusterState));
+    session = policy.createSession(getSolrCloudManager(nodeValues, clusterState));
     SolrRequest opReq = session.getSuggester(MOVEREPLICA)
         .hint(Hint.TARGET_NODE, "node5")
         .getOperation();
@@ -856,7 +864,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "      'freedisk':884.7097854614258}," +
         "}";
 
-    ClusterDataProvider provider = getClusterDataProvider((Map<String, Map>) Utils.fromJSONString(nodeValues),
clusterState);
+    SolrCloudManager provider = getSolrCloudManager((Map<String, Map>) Utils.fromJSONString(nodeValues),
clusterState);
     Map policies = (Map) Utils.fromJSONString("{" +
         "  'cluster-preferences': [" +
         "    { 'maximize': 'freedisk', 'precision': 50}," +
@@ -924,8 +932,8 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "node4:{cores:8, freedisk: 375, heapUsage:16900, nodeRole:overseer, rack: rack1}"
+
         "}");
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoscaleJson));
-    ClusterDataProvider clusterDataProvider = getClusterDataProvider(nodeValues, clusterState);
-    Policy.Session session = policy.createSession(clusterDataProvider);
+    SolrCloudManager cloudManager = getSolrCloudManager(nodeValues, clusterState);
+    Policy.Session session = policy.createSession(cloudManager);
     for (int i = 0; i < 3; i++) {
       Policy.Suggester suggester = session.getSuggester(ADDREPLICA);
       SolrRequest op = suggester
@@ -956,29 +964,8 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "}");
 
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoscaleJson));
-    ClusterDataProvider clusterDataProvider = getClusterDataProvider(nodeValues, clusterState);
-    ClusterDataProvider cdp = new ClusterDataProvider() {
-      @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
-        return clusterDataProvider.getNodeValues(node, tags);
-      }
-
-      @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return clusterDataProvider.getReplicaInfo(node, keys);
-      }
-
-      @Override
-      public Collection<String> getNodes() {
-        return clusterDataProvider.getNodes();
-      }
-
-      @Override
-      public String getPolicyNameByCollection(String coll) {
-        return null;
-      }
-    };
-    Policy.Session session = policy.createSession(cdp);
+    SolrCloudManager cloudManager = getSolrCloudManager(nodeValues, clusterState);
+    Policy.Session session = policy.createSession(cloudManager);
     Policy.Suggester suggester = session.getSuggester(ADDREPLICA);
     SolrRequest op = suggester
         .hint(Hint.COLL_SHARD, new Pair<>("newColl", "shard1"))
@@ -1019,8 +1006,8 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "      {'core_node2':{}}]}}}");
     Map m = (Map) Utils.getObjectByPath(replicaInfoMap, false, "127.0.0.1:60089_solr/compute_plan_action_test");
     m.put("shard1", Arrays.asList(
-        new ReplicaInfo("core_node1", "compute_plan_action_test", "shard1", Replica.Type.NRT,
Collections.emptyMap()),
-        new ReplicaInfo("core_node2", "compute_plan_action_test", "shard1", Replica.Type.NRT,
Collections.emptyMap())
+        new ReplicaInfo("core_node1", "compute_plan_action_test", "shard1", Collections.singletonMap(ZkStateReader.REPLICA_TYPE,
Replica.Type.NRT)),
+        new ReplicaInfo("core_node2", "compute_plan_action_test", "shard1", Collections.singletonMap(ZkStateReader.REPLICA_TYPE,
Replica.Type.NRT))
     ));
 
     Map<String, Map<String, Object>> tagsMap = (Map) Utils.fromJSONString("{"
+
@@ -1032,28 +1019,33 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "            'freedisk':918005641216}}}");
 
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoscaleJson));
-    Policy.Session session = policy.createSession(new ClusterDataProvider() {
+    Policy.Session session = policy.createSession(new DelegatingCloudManager(null) {
       @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
-        return tagsMap.get(node);
-      }
+      public ClusterStateProvider getClusterStateProvider() {
+        return new DelegatingClusterStateProvider(null) {
+          @Override
+          public Set<String> getLiveNodes() {
+            return replicaInfoMap.keySet();
+          }
 
-      @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return (Map<String, Map<String, List<ReplicaInfo>>>) replicaInfoMap.get(node);
+        };
       }
 
       @Override
-      public Collection<String> getNodes() {
-        return replicaInfoMap.keySet();
-      }
+      public NodeStateProvider getNodeStateProvider() {
+        return new DelegatingNodeStateProvider(null) {
+          @Override
+          public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
+            return tagsMap.get(node);
+          }
 
-      @Override
-      public String getPolicyNameByCollection(String coll) {
-        return null;
+          @Override
+          public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
+            return (Map<String, Map<String, List<ReplicaInfo>>>) replicaInfoMap.get(node);
+          }
+        };
       }
     });
-
     Policy.Suggester suggester = session.getSuggester(MOVEREPLICA)
         .hint(Hint.TARGET_NODE, "127.0.0.1:60099_solr");
     SolrRequest op = suggester.getOperation();
@@ -1089,27 +1081,39 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "node4:{cores:8, freedisk: 375, heapUsage:16900, nodeRole:overseer, sysprop.rack:
rack1}" +
         "}");
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(rules));
-    ClusterDataProvider clusterDataProvider = getClusterDataProvider(nodeValues, clusterState);
-    ClusterDataProvider cdp = new ClusterDataProvider() {
+    SolrCloudManager cloudManager = getSolrCloudManager(nodeValues, clusterState);
+    SolrCloudManager cdp = new DelegatingCloudManager(null) {
       @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
-        return clusterDataProvider.getNodeValues(node, tags);
-      }
+      public NodeStateProvider getNodeStateProvider() {
+        return new DelegatingNodeStateProvider(null) {
+          @Override
+          public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
+            return cloudManager.getNodeStateProvider().getNodeValues(node, tags);
+          }
 
-      @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return clusterDataProvider.getReplicaInfo(node, keys);
+          @Override
+          public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
+            return cloudManager.getNodeStateProvider().getReplicaInfo(node, keys);
+          }
+        };
       }
 
       @Override
-      public Collection<String> getNodes() {
-        return clusterDataProvider.getNodes();
-      }
+      public ClusterStateProvider getClusterStateProvider() {
+        return new DelegatingClusterStateProvider(null) {
+          @Override
+          public Set<String> getLiveNodes() {
+            return cloudManager.getClusterStateProvider().getLiveNodes();
+          }
 
-      @Override
-      public String getPolicyNameByCollection(String coll) {
-        return "p1";
+          @Override
+          public String getPolicyNameByCollection(String coll) {
+            return "p1";
+          }
+        };
       }
+
+
     };
     Policy.Session session = policy.createSession(cdp);
 
@@ -1120,32 +1124,58 @@ public class TestPolicy extends SolrTestCaseJ4 {
     assertEquals("node2", op.getNode());
   }
 
-  private ClusterDataProvider getClusterDataProvider(final Map<String, Map> nodeValues,
String clusterState) {
-    return new ClusterDataProvider() {
+  private SolrCloudManager getSolrCloudManager(final Map<String, Map> nodeValues, String
clusterState) {
+    return new SolrCloudManager() {
       @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
-        Map<String, Object> result = new LinkedHashMap<>();
-        tags.stream().forEach(s -> result.put(s, nodeValues.get(node).get(s)));
-        return result;
+      public ClusterStateProvider getClusterStateProvider() {
+        return new DelegatingClusterStateProvider(null) {
+          @Override
+          public Set<String> getLiveNodes() {
+            return nodeValues.keySet();
+          }
+
+        };
       }
 
       @Override
-      public Collection<String> getNodes() {
-        return nodeValues.keySet();
+      public NodeStateProvider getNodeStateProvider() {
+        return new DelegatingNodeStateProvider(null) {
+          @Override
+          public Map<String, Object> getNodeValues(String node, Collection<String>
tags) {
+            Map<String, Object> result = new LinkedHashMap<>();
+            tags.stream().forEach(s -> result.put(s, nodeValues.get(node).get(s)));
+            return result;
+          }
+
+          @Override
+          public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
+            return getReplicaDetails(node, clusterState);
+          }
+        };
       }
 
       @Override
-      public String getPolicyNameByCollection(String coll) {
+      public DistribStateManager getDistribStateManager() {
         return null;
       }
 
       @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return getReplicaDetails(node, clusterState);
+      public DistributedQueueFactory getDistributedQueueFactory() {
+        return null;
       }
 
+      @Override
+      public SolrResponse request(SolrRequest req) throws IOException {
+        return null;
+      }
+
+      @Override
+      public byte[] httpRequest(String url, SolrRequest.METHOD method, Map<String, String>
headers, String payload, int timeout, boolean followRedirects) throws IOException {
+        return new byte[0];
+      }
     };
   }
+
   public void testEmptyClusterState(){
     String autoScaleJson =  " {'policies':{'c1':[{" +
         "        'replica':1," +
@@ -1158,27 +1188,32 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "    '127.0.0.1:50096_solr':{" +
         "      'cores':0," +
         "      'port':'50096'}}");
-    ClusterDataProvider dataProvider = new ClusterDataProvider() {
+    SolrCloudManager dataProvider = new DelegatingCloudManager(null) {
       @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
keys) {
-        Map<String, Object> result = new LinkedHashMap<>();
-        keys.stream().forEach(s -> result.put(s, nodeValues.get(node).get(s)));
-        return result;
-      }
-
-      @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return getReplicaDetails(node, clusterState);
+      public ClusterStateProvider getClusterStateProvider() {
+        return new DelegatingClusterStateProvider(null) {
+          @Override
+          public Set<String> getLiveNodes() {
+            return new HashSet<>(Arrays.asList( "127.0.0.1:50097_solr", "127.0.0.1:50096_solr"));
+          }
+        };
       }
 
       @Override
-      public String getPolicyNameByCollection(String coll) {
-        return null;
-      }
+      public NodeStateProvider getNodeStateProvider() {
+        return new DelegatingNodeStateProvider(null) {
+          @Override
+          public Map<String, Object> getNodeValues(String node, Collection<String>
keys) {
+            Map<String, Object> result = new LinkedHashMap<>();
+            keys.stream().forEach(s -> result.put(s, nodeValues.get(node).get(s)));
+            return result;
+          }
 
-      @Override
-      public Collection<String> getNodes() {
-        return Arrays.asList( "127.0.0.1:50097_solr", "127.0.0.1:50096_solr");
+          @Override
+          public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
+            return getReplicaDetails(node, clusterState);
+          }
+        };
       }
     };
     List<ReplicaPosition> locations = PolicyHelper.getReplicaLocations(
@@ -1215,32 +1250,37 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "node4:{cores:0, freedisk: 900, heap:16900, nodeRole:overseer, sysprop.rack:rack2}"
+
         "}");
 
-    ClusterDataProvider dataProvider = new ClusterDataProvider() {
+    SolrCloudManager cloudManager = new DelegatingCloudManager(null) {
       @Override
-      public Map<String, Object> getNodeValues(String node, Collection<String>
keys) {
-        Map<String, Object> result = new LinkedHashMap<>();
-        keys.stream().forEach(s -> result.put(s, nodeValues.get(node).get(s)));
-        return result;
-      }
-
-      @Override
-      public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
-        return getReplicaDetails(node, clusterState);
-      }
+      public NodeStateProvider getNodeStateProvider() {
+        return new DelegatingNodeStateProvider(null) {
+          @Override
+          public Map<String, Object> getNodeValues(String node, Collection<String>
keys) {
+            Map<String, Object> result = new LinkedHashMap<>();
+            keys.stream().forEach(s -> result.put(s, nodeValues.get(node).get(s)));
+            return result;
+          }
 
-      @Override
-      public String getPolicyNameByCollection(String coll) {
-        return null;
+          @Override
+          public Map<String, Map<String, List<ReplicaInfo>>> getReplicaInfo(String
node, Collection<String> keys) {
+            return getReplicaDetails(node, clusterState);
+          }
+        };
       }
 
       @Override
-      public Collection<String> getNodes() {
-        return Arrays.asList("node1", "node2", "node3", "node4");
+      public ClusterStateProvider getClusterStateProvider() {
+        return new DelegatingClusterStateProvider(null) {
+          @Override
+          public Set<String> getLiveNodes() {
+            return new HashSet<>(Arrays.asList("node1", "node2", "node3", "node4"));
+          }
+        };
       }
     };
     List<ReplicaPosition> locations = PolicyHelper.getReplicaLocations(
         "newColl", new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScaleJson)),
-        dataProvider, Collections.singletonMap("newColl", "policy1"), Arrays.asList("shard1",
"shard2"), 3,0,0, null);
+        cloudManager, Collections.singletonMap("newColl", "policy1"), Arrays.asList("shard1",
"shard2"), 3,0,0, null);
     assertTrue(locations.stream().allMatch(it -> ImmutableList.of("node2", "node1", "node3").contains(it.node))
);
   }
 
@@ -1267,7 +1307,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "    {      'nodeRole':'overseer','replica':0}]," +
         "  'cluster-preferences':[{'minimize':'cores'}]}";
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
-    Policy.Session session = policy.createSession(dataProviderWithData(dataproviderdata));
+    Policy.Session session = policy.createSession(cloudManagerWithData(dataproviderdata));
     Policy.Suggester suggester = session.getSuggester(MOVEREPLICA).hint(Hint.TARGET_NODE,
"10.0.0.6:7574_solr");
     SolrRequest op = suggester.getOperation();
     assertNotNull(op);
@@ -1304,7 +1344,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
         "       {replica:'<2', shard:'#EACH',node:'#ANY'}," +
         "       { nodeRole:overseer,replica:0}]}";
     Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
-    Policy.Session session = policy.createSession(dataProviderWithData(dataproviderdata));
+    Policy.Session session = policy.createSession(cloudManagerWithData(dataproviderdata));
     Policy.Suggester suggester = session.getSuggester(CollectionParams.CollectionAction.MOVEREPLICA)
         .hint(Hint.TARGET_NODE, "127.0.0.1:51147_solr");
     SolrRequest op = suggester.getOperation();

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8dd489ed/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
index 0a83138..a3dd436 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
@@ -17,8 +17,6 @@
 
 package org.apache.solr.client.solrj.impl;
 
-
-import java.io.IOException;
 import java.net.ConnectException;
 import java.net.SocketException;
 import java.util.Collections;
@@ -32,6 +30,7 @@ import java.util.function.Function;
 import com.google.common.collect.ImmutableSet;
 import org.apache.http.NoHttpResponseException;
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.cloud.autoscaling.DelegatingClusterStateProvider;
 import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.common.cloud.ClusterState;
 import org.apache.solr.common.cloud.DocCollection;
@@ -119,14 +118,14 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
 
   private ClusterStateProvider getStateProvider(Set<String> livenodes,
                                                                 Map<String, ClusterState.CollectionRef>
colls) {
-    return new ClusterStateProvider() {
+    return new DelegatingClusterStateProvider(null) {
       @Override
       public ClusterState.CollectionRef getState(String collection) {
         return colls.get(collection);
       }
 
       @Override
-      public Set<String> liveNodes() {
+      public Set<String> getLiveNodes() {
         return livenodes;
       }
 
@@ -141,20 +140,7 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
       }
 
       @Override
-      public void connect() { }
-
-      @Override
-      public void close() throws IOException {
-
-      }
-
-      @Override
-      public Object getClusterProperty(String propertyName) {
-        return null;
-      }
-
-      @Override
-      public Object getClusterProperty(String propertyName, String def) {
+      public <T> T getClusterProperty(String propertyName, T def) {
         return def;
       }
     };


Mime
View raw message