Search in sources :

Example 6 with CloudConfig

use of org.apache.solr.core.CloudConfig in project lucene-solr by apache.

the class ZkControllerTest method testReadConfigName.

@Test
public void testReadConfigName() throws Exception {
    String zkDir = createTempDir("zkData").toFile().getAbsolutePath();
    CoreContainer cc = null;
    ZkTestServer server = new ZkTestServer(zkDir);
    try {
        server.run();
        AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
        AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
        SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), TIMEOUT);
        String actualConfigName = "firstConfig";
        zkClient.makePath(ZkConfigManager.CONFIGS_ZKNODE + "/" + actualConfigName, true);
        Map<String, Object> props = new HashMap<>();
        props.put("configName", actualConfigName);
        ZkNodeProps zkProps = new ZkNodeProps(props);
        zkClient.makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + COLLECTION_NAME, Utils.toJSON(zkProps), CreateMode.PERSISTENT, true);
        zkClient.close();
        cc = getCoreContainer();
        CloudConfig cloudConfig = new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "solr").build();
        ZkController zkController = new ZkController(cc, server.getZkAddress(), TIMEOUT, cloudConfig, new CurrentCoreDescriptorProvider() {

            @Override
            public List<CoreDescriptor> getCurrentDescriptors() {
                // do nothing
                return null;
            }
        });
        try {
            String configName = zkController.getZkStateReader().readConfigName(COLLECTION_NAME);
            assertEquals(configName, actualConfigName);
        } finally {
            zkController.close();
        }
    } finally {
        if (cc != null) {
            cc.shutdown();
        }
        server.shutdown();
    }
}
Also used : HashMap(java.util.HashMap) CloudConfig(org.apache.solr.core.CloudConfig) CoreContainer(org.apache.solr.core.CoreContainer) List(java.util.List) Test(org.junit.Test)

Aggregations

CloudConfig (org.apache.solr.core.CloudConfig)6 CoreContainer (org.apache.solr.core.CoreContainer)4 HashMap (java.util.HashMap)3 List (java.util.List)2 CoreDescriptor (org.apache.solr.core.CoreDescriptor)2 Test (org.junit.Test)2 Path (java.nio.file.Path)1 ClusterState (org.apache.solr.common.cloud.ClusterState)1 Replica (org.apache.solr.common.cloud.Replica)1 Slice (org.apache.solr.common.cloud.Slice)1 SolrZkClient (org.apache.solr.common.cloud.SolrZkClient)1 ZkStateReader (org.apache.solr.common.cloud.ZkStateReader)1 StrUtils.formatString (org.apache.solr.common.util.StrUtils.formatString)1 MetricsConfig (org.apache.solr.core.MetricsConfig)1 NodeConfig (org.apache.solr.core.NodeConfig)1 PluginInfo (org.apache.solr.core.PluginInfo)1 SolrJmxReporter (org.apache.solr.metrics.reporters.SolrJmxReporter)1 UpdateShardHandlerConfig (org.apache.solr.update.UpdateShardHandlerConfig)1 KeeperException (org.apache.zookeeper.KeeperException)1