Search in sources :

Example 1 with ConfigSetAdminResponse

use of org.apache.solr.client.solrj.response.ConfigSetAdminResponse 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 2 with ConfigSetAdminResponse

use of org.apache.solr.client.solrj.response.ConfigSetAdminResponse 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 3 with ConfigSetAdminResponse

use of org.apache.solr.client.solrj.response.ConfigSetAdminResponse in project lucene-solr by apache.

the class TestConfigSetsAPI method testDelete.

@Test
public void testDelete() throws Exception {
    final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
    final SolrClient solrClient = getHttpSolrClient(baseUrl);
    final String configSet = "configSet";
    solrCluster.uploadConfigSet(configset("configset-2"), configSet);
    SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null);
    try {
        ZkConfigManager configManager = new ZkConfigManager(zkClient);
        assertTrue(configManager.configExists(configSet));
        Delete delete = new Delete();
        delete.setConfigSetName(configSet);
        ConfigSetAdminResponse response = delete.process(solrClient);
        assertNotNull(response.getResponse());
        assertFalse(configManager.configExists(configSet));
    } finally {
        zkClient.close();
    }
    solrClient.close();
}
Also used : Delete(org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Delete) 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) ConfigSetAdminResponse(org.apache.solr.client.solrj.response.ConfigSetAdminResponse) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) BasicAuthIntegrationTest(org.apache.solr.security.BasicAuthIntegrationTest) Test(org.junit.Test)

Aggregations

SolrClient (org.apache.solr.client.solrj.SolrClient)3 ConfigSetAdminResponse (org.apache.solr.client.solrj.response.ConfigSetAdminResponse)3 SolrZkClient (org.apache.solr.common.cloud.SolrZkClient)3 ZkConfigManager (org.apache.solr.common.cloud.ZkConfigManager)3 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 Test (org.junit.Test)2 Properties (java.util.Properties)1 RemoteSolrException (org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException)1 Delete (org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Delete)1 ConfigSetProperties (org.apache.solr.core.ConfigSetProperties)1 BasicAuthIntegrationTest (org.apache.solr.security.BasicAuthIntegrationTest)1