Search in sources :

Example 6 with ZkConfigManager

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

the class HdfsCollectionsAPIDistributedZkTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    System.setProperty("solr.hdfs.blockcache.blocksperbank", "512");
    System.setProperty("tests.hdfs.numdatanodes", "1");
    dfsCluster = HdfsTestUtil.setupClass(createTempDir().toFile().getAbsolutePath());
    ZkConfigManager configManager = new ZkConfigManager(zkClient());
    configManager.uploadConfigDir(configset("cloud-hdfs"), "conf");
    configManager.uploadConfigDir(configset("cloud-hdfs"), "conf2");
    System.setProperty("solr.hdfs.home", HdfsTestUtil.getDataDir(dfsCluster, "data"));
}
Also used : ZkConfigManager(org.apache.solr.common.cloud.ZkConfigManager) BeforeClass(org.junit.BeforeClass)

Example 7 with ZkConfigManager

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

the class TestConfigSetsAPIZkFailure method testCreateZkFailure.

@Test
public void testCreateZkFailure() throws Exception {
    final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
    final SolrClient solrClient = getHttpSolrClient(baseUrl);
    final Map<String, String> oldProps = ImmutableMap.of("immutable", "true");
    setupBaseConfigSet(BASE_CONFIGSET_NAME, oldProps);
    SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null);
    try {
        ZkConfigManager configManager = new ZkConfigManager(zkClient);
        assertFalse(configManager.configExists(CONFIGSET_NAME));
        Create create = new Create();
        create.setBaseConfigSetName(BASE_CONFIGSET_NAME).setConfigSetName(CONFIGSET_NAME);
        try {
            ConfigSetAdminResponse response = create.process(solrClient);
            Assert.fail("Expected solr exception");
        } catch (RemoteSolrException se) {
            // partial creation should have been cleaned up
            assertFalse(configManager.configExists(CONFIGSET_NAME));
            assertEquals(SolrException.ErrorCode.SERVER_ERROR.code, se.code());
        }
    } finally {
        zkClient.close();
    }
    solrClient.close();
}
Also used : RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException) SolrClient(org.apache.solr.client.solrj.SolrClient) ZkConfigManager(org.apache.solr.common.cloud.ZkConfigManager) Create(org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create) ConfigSetAdminResponse(org.apache.solr.client.solrj.response.ConfigSetAdminResponse) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) Test(org.junit.Test)

Example 8 with ZkConfigManager

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

the class MiniSolrCloudCluster method uploadConfigSet.

/**
   * Upload a config set
   * @param configDir a path to the config set to upload
   * @param configName the name to give the configset
   */
public void uploadConfigSet(Path configDir, String configName) throws IOException, KeeperException, InterruptedException {
    try (SolrZkClient zkClient = new SolrZkClient(zkServer.getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null)) {
        ZkConfigManager manager = new ZkConfigManager(zkClient);
        manager.uploadConfigDir(configDir, configName);
    }
}
Also used : ZkConfigManager(org.apache.solr.common.cloud.ZkConfigManager) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient)

Example 9 with ZkConfigManager

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

the class TestConfigSetsAPI method verifyCreate.

private void verifyCreate(String baseConfigSetName, String configSetName, Map<String, String> oldProps, Map<String, String> newProps) throws Exception {
    final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
    final SolrClient solrClient = getHttpSolrClient(baseUrl);
    setupBaseConfigSet(baseConfigSetName, oldProps);
    SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null);
    try {
        ZkConfigManager configManager = new ZkConfigManager(zkClient);
        assertFalse(configManager.configExists(configSetName));
        Create create = new Create();
        create.setBaseConfigSetName(baseConfigSetName).setConfigSetName(configSetName);
        if (newProps != null) {
            Properties p = new Properties();
            p.putAll(newProps);
            create.setNewConfigSetProperties(p);
        }
        ConfigSetAdminResponse response = create.process(solrClient);
        assertNotNull(response.getResponse());
        assertTrue(configManager.configExists(configSetName));
        verifyProperties(configSetName, oldProps, newProps, zkClient);
    } finally {
        zkClient.close();
    }
    solrClient.close();
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) SolrClient(org.apache.solr.client.solrj.SolrClient) ZkConfigManager(org.apache.solr.common.cloud.ZkConfigManager) Create(org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create) ConfigSetAdminResponse(org.apache.solr.client.solrj.response.ConfigSetAdminResponse) ConfigSetProperties(org.apache.solr.core.ConfigSetProperties) Properties(java.util.Properties) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient)

Example 10 with ZkConfigManager

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

the class TestConfigSetsAPI method uploadConfigSet.

private void uploadConfigSet(String configSetName, String suffix, String username, String password) throws Exception {
    // Read zipped sample config
    ByteBuffer sampleZippedConfig = TestDynamicLoading.getFileContent(createTempZipFile("solr/configsets/upload/" + configSetName), false);
    SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, 45000, null);
    try {
        ZkConfigManager configManager = new ZkConfigManager(zkClient);
        assertFalse(configManager.configExists(configSetName + suffix));
        Map map = postDataAndGetResponse(solrCluster.getSolrClient(), solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/admin/configs?action=UPLOAD&wt=json&name=" + configSetName + suffix, sampleZippedConfig, username, password);
        assertNotNull(map);
        long statusCode = (long) getObjectByPath(map, false, Arrays.asList("responseHeader", "status"));
        assertEquals(0l, statusCode);
        assertTrue("managed-schema file should have been uploaded", zkClient.exists("/configs/" + configSetName + suffix + "/managed-schema", true));
        assertTrue("managed-schema file contents on zookeeper are not exactly same as that of the file uploaded in config", Arrays.equals(zkClient.getData("/configs/" + configSetName + suffix + "/managed-schema", null, null, true), readFile("solr/configsets/upload/" + configSetName + "/managed-schema")));
        assertTrue("solrconfig.xml file should have been uploaded", zkClient.exists("/configs/" + configSetName + suffix + "/solrconfig.xml", true));
        byte[] data = zkClient.getData("/configs/" + configSetName + suffix, null, null, true);
        //assertEquals("{\"trusted\": false}", new String(data, StandardCharsets.UTF_8));
        assertTrue("solrconfig.xml file contents on zookeeper are not exactly same as that of the file uploaded in config", Arrays.equals(zkClient.getData("/configs/" + configSetName + suffix + "/solrconfig.xml", null, null, true), readFile("solr/configsets/upload/" + configSetName + "/solrconfig.xml")));
    } finally {
        zkClient.close();
    }
}
Also used : ZkConfigManager(org.apache.solr.common.cloud.ZkConfigManager) ByteBuffer(java.nio.ByteBuffer) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ZkConfigManager (org.apache.solr.common.cloud.ZkConfigManager)13 SolrZkClient (org.apache.solr.common.cloud.SolrZkClient)6 SolrException (org.apache.solr.common.SolrException)4 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 SolrClient (org.apache.solr.client.solrj.SolrClient)3 ConfigSetAdminResponse (org.apache.solr.client.solrj.response.ConfigSetAdminResponse)3 Test (org.junit.Test)3 Map (java.util.Map)2 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)2 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)2 Create (org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create)2 NamedList (org.apache.solr.common.util.NamedList)2 KeeperException (org.apache.zookeeper.KeeperException)2 BeforeClass (org.junit.BeforeClass)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ByteBuffer (java.nio.ByteBuffer)1