Add try-with-resources to CloudManager in tests (#1315)

This commit is contained in:
Tomas Fernandez Lobbe 2020-03-04 13:32:44 -08:00 committed by GitHub
parent dd9b9f2f7f
commit 2cabeb924d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 52 deletions

View File

@ -42,7 +42,6 @@ import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.CommonTestInjection;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.common.util.TimeSource;
import org.apache.solr.handler.component.TrackingShardHandlerFactory;
@ -85,7 +84,7 @@ public class RoutingToNodesWithPropertiesTest extends SolrCloudTestCase {
" 'sysprop.zone':'#EACH'}]}";
SolrRequest req = CloudTestUtils.AutoScalingRequest.create(SolrRequest.METHOD.POST, commands);
NamedList<Object> response = cluster.getSolrClient().request(req);
cluster.getSolrClient().request(req);
CollectionAdminRequest.createCollection(COLLECTION, 2, 2)
.process(cluster.getSolrClient());
@ -107,8 +106,8 @@ public class RoutingToNodesWithPropertiesTest extends SolrCloudTestCase {
}
// check inject props
SolrCloudManager cloudManager = new SolrClientCloudManager(new ZkDistributedQueueFactory(cluster.getZkClient()),
cluster.getSolrClient());
try (SolrCloudManager cloudManager = new SolrClientCloudManager(new ZkDistributedQueueFactory(cluster.getZkClient()),
cluster.getSolrClient())) {
for (String zone1Node: zone1Nodes) {
NodeStateProvider nodeStateProvider = cloudManager.getNodeStateProvider();
Map<String, Object> map = nodeStateProvider.getNodeValues(zone1Node, Collections.singletonList(PROP_NAME));
@ -138,6 +137,7 @@ public class RoutingToNodesWithPropertiesTest extends SolrCloudTestCase {
new UpdateRequest()
.commit(cluster.getSolrClient(), COLLECTION);
}
}
@After
public void after() {

View File

@ -71,8 +71,7 @@ public class MetricTriggerTest extends SolrCloudTestCase {
final List<TriggerEvent> events = new ArrayList<>();
SolrZkClient zkClient = cluster.getSolrClient().getZkStateReader().getZkClient();
SolrResourceLoader loader = cluster.getJettySolrRunner(0).getCoreContainer().getResourceLoader();
SolrCloudManager cloudManager = new SolrClientCloudManager(new ZkDistributedQueueFactory(zkClient), cluster.getSolrClient());
try (SolrCloudManager cloudManager = new SolrClientCloudManager(new ZkDistributedQueueFactory(zkClient), cluster.getSolrClient())) {
try (MetricTrigger metricTrigger = new MetricTrigger("metricTrigger")) {
metricTrigger.configure(loader, cloudManager, props);
metricTrigger.setProcessor(noFirstRunProcessor);
@ -98,6 +97,7 @@ public class MetricTriggerTest extends SolrCloudTestCase {
assertEquals(1, events.size());
}
}
}
private Map<String, Object> createTriggerProps(long waitForSeconds, String metric, Double below, Double above, String collection, String shard, String node) {
Map<String, Object> props = new HashMap<>();