Search in sources :

Example 76 with SolrZkClient

use of org.apache.solr.common.cloud.SolrZkClient in project lucene-solr by apache.

the class TestDelegationWithHadoopAuth method testZNodePaths.

@Test
public void testZNodePaths() throws Exception {
    getDelegationToken(null, USER_1, primarySolrClient);
    SolrZkClient zkClient = new SolrZkClient(cluster.getZkServer().getZkAddress(), 1000);
    try {
        assertTrue(zkClient.exists("/security/zkdtsm", true));
        assertTrue(zkClient.exists("/security/token", true));
    } finally {
        zkClient.close();
    }
}
Also used : SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) Test(org.junit.Test)

Example 77 with SolrZkClient

use of org.apache.solr.common.cloud.SolrZkClient in project lucene-solr by apache.

the class SolrXmlInZkTest method setUpZkAndDiskXml.

private void setUpZkAndDiskXml(boolean toZk, boolean leaveOnLocal) throws Exception {
    Path tmpDir = createTempDir();
    Path solrHome = tmpDir.resolve("home");
    copyMinConf(new File(solrHome.toFile(), "myCollect"));
    if (leaveOnLocal) {
        FileUtils.copyFile(new File(SolrTestCaseJ4.TEST_HOME(), "solr-stress-new.xml"), new File(solrHome.toFile(), "solr.xml"));
    }
    ignoreException("No UpdateLog found - cannot sync");
    ignoreException("No UpdateLog found - cannot recover");
    System.setProperty("zkClientTimeout", "8000");
    zkDir = tmpDir.resolve("zookeeper" + System.nanoTime()).resolve("server1").resolve("data").toString();
    zkServer = new ZkTestServer(zkDir);
    zkServer.run();
    System.setProperty("zkHost", zkServer.getZkAddress());
    AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(), zkServer.getZkAddress(), "solrconfig.xml", "schema.xml");
    zkClient = new SolrZkClient(zkServer.getZkAddress(), AbstractZkTestCase.TIMEOUT);
    if (toZk) {
        zkClient.makePath("solr.xml", XML_FOR_ZK.getBytes(StandardCharsets.UTF_8), true);
    }
    zkClient.close();
    log.info("####SETUP_START " + getTestName());
    // set some system properties for use by tests
    Properties props = new Properties();
    props.setProperty("solr.test.sys.prop1", "propone");
    props.setProperty("solr.test.sys.prop2", "proptwo");
    cfg = SolrDispatchFilter.loadNodeConfig(solrHome, props);
    log.info("####SETUP_END " + getTestName());
}
Also used : Path(java.nio.file.Path) Properties(java.util.Properties) File(java.io.File) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient)

Example 78 with SolrZkClient

use of org.apache.solr.common.cloud.SolrZkClient in project lucene-solr by apache.

the class SolrCLIZkUtilsTest method setupCluster.

@BeforeClass
public static void setupCluster() throws Exception {
    configureCluster(1).addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf")).configure();
    zkAddr = cluster.getZkServer().getZkAddress();
    zkClient = new SolrZkClient(zkAddr, 30000);
}
Also used : SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) BeforeClass(org.junit.BeforeClass)

Example 79 with SolrZkClient

use of org.apache.solr.common.cloud.SolrZkClient in project lucene-solr by apache.

the class OverseerTest method electNewOverseer.

private SolrZkClient electNewOverseer(String address) throws InterruptedException, TimeoutException, IOException, KeeperException, ParserConfigurationException, SAXException {
    SolrZkClient zkClient = new SolrZkClient(address, TIMEOUT);
    ZkStateReader reader = new ZkStateReader(zkClient);
    readers.add(reader);
    LeaderElector overseerElector = new LeaderElector(zkClient);
    if (overseers.size() > 0) {
        overseers.get(overseers.size() - 1).close();
        overseers.get(overseers.size() - 1).getZkStateReader().getZkClient().close();
    }
    UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);
    updateShardHandlers.add(updateShardHandler);
    HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();
    httpShardHandlerFactorys.add(httpShardHandlerFactory);
    Overseer overseer = new Overseer(httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, null, new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "").build());
    overseers.add(overseer);
    ElectionContext ec = new OverseerElectionContext(zkClient, overseer, address.replaceAll("/", "_"));
    overseerElector.setup(ec);
    overseerElector.joinElection(ec, false);
    return zkClient;
}
Also used : ZkStateReader(org.apache.solr.common.cloud.ZkStateReader) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) UpdateShardHandler(org.apache.solr.update.UpdateShardHandler) HttpShardHandlerFactory(org.apache.solr.handler.component.HttpShardHandlerFactory)

Example 80 with SolrZkClient

use of org.apache.solr.common.cloud.SolrZkClient in project lucene-solr by apache.

the class SaslZkACLProviderTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    log.info("####SETUP_START " + getTestName());
    createTempDir();
    String zkDir = createTempDir() + File.separator + "zookeeper/server1/data";
    log.info("ZooKeeper dataDir:" + zkDir);
    zkServer = new SaslZkTestServer(zkDir, createTempDir() + File.separator + "miniKdc");
    zkServer.run();
    System.setProperty("zkHost", zkServer.getZkAddress());
    SolrZkClient zkClient = new SolrZkClientWithACLs(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT);
    try {
        zkClient.makePath("/solr", false, true);
    } finally {
        zkClient.close();
    }
    setupZNodes();
    log.info("####SETUP_END " + getTestName());
}
Also used : SolrZkClient(org.apache.solr.common.cloud.SolrZkClient)

Aggregations

SolrZkClient (org.apache.solr.common.cloud.SolrZkClient)130 Test (org.junit.Test)46 ZkStateReader (org.apache.solr.common.cloud.ZkStateReader)34 HashMap (java.util.HashMap)21 KeeperException (org.apache.zookeeper.KeeperException)18 SolrException (org.apache.solr.common.SolrException)15 ZkNodeProps (org.apache.solr.common.cloud.ZkNodeProps)14 IOException (java.io.IOException)13 ClusterState (org.apache.solr.common.cloud.ClusterState)13 DocCollection (org.apache.solr.common.cloud.DocCollection)12 Map (java.util.Map)11 Slice (org.apache.solr.common.cloud.Slice)11 Replica (org.apache.solr.common.cloud.Replica)10 ArrayList (java.util.ArrayList)9 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)8 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)8 Overseer (org.apache.solr.cloud.Overseer)8 ZkTestServer (org.apache.solr.cloud.ZkTestServer)8 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)7 NamedList (org.apache.solr.common.util.NamedList)7