Search in sources :

Example 1 with RemoteSolrException

use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.

the class TestCollectionAPI method testCollectionCreationShardNameValidation.

private void testCollectionCreationShardNameValidation() throws Exception {
    try (CloudSolrClient client = createCloudClient(null)) {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.CREATE.toString());
        params.set("name", "valid_collection_name");
        params.set("router.name", "implicit");
        params.set("numShards", "1");
        params.set("shards", "invalid@name#with$weird%characters");
        SolrRequest request = new QueryRequest(params);
        request.setPath("/admin/collections");
        try {
            client.request(request);
            fail();
        } catch (RemoteSolrException e) {
            final String errorMessage = e.getMessage();
            assertTrue(errorMessage.contains("Invalid shard"));
            assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
            assertTrue(errorMessage.contains("shard names must consist entirely of"));
        }
    }
}
Also used : RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException) QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 2 with RemoteSolrException

use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException 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 3 with RemoteSolrException

use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.

the class TestCollectionAPI method testCollectionCreationCollectionNameValidation.

private void testCollectionCreationCollectionNameValidation() throws Exception {
    try (CloudSolrClient client = createCloudClient(null)) {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.CREATE.toString());
        params.set("name", "invalid@name#with$weird%characters");
        SolrRequest request = new QueryRequest(params);
        request.setPath("/admin/collections");
        try {
            client.request(request);
            fail();
        } catch (RemoteSolrException e) {
            final String errorMessage = e.getMessage();
            assertTrue(errorMessage.contains("Invalid collection"));
            assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
            assertTrue(errorMessage.contains("collection names must consist entirely of"));
        }
    }
}
Also used : RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException) QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 4 with RemoteSolrException

use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.

the class TestCollectionAPI method testShardCreationNameValidation.

private void testShardCreationNameValidation() throws Exception {
    try (CloudSolrClient client = createCloudClient(null)) {
        client.connect();
        // Create a collection w/ implicit router
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.CREATE.toString());
        params.set("name", "valid_collection_name");
        params.set("shards", "a");
        params.set("router.name", "implicit");
        SolrRequest request = new QueryRequest(params);
        request.setPath("/admin/collections");
        client.request(request);
        params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.CREATESHARD.toString());
        params.set("collection", "valid_collection_name");
        params.set("shard", "invalid@name#with$weird%characters");
        request = new QueryRequest(params);
        request.setPath("/admin/collections");
        try {
            client.request(request);
            fail();
        } catch (RemoteSolrException e) {
            final String errorMessage = e.getMessage();
            assertTrue(errorMessage.contains("Invalid shard"));
            assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
            assertTrue(errorMessage.contains("shard names must consist entirely of"));
        }
    }
}
Also used : RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException) QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 5 with RemoteSolrException

use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.

the class TestCollectionAPI method testAliasCreationNameValidation.

private void testAliasCreationNameValidation() throws Exception {
    try (CloudSolrClient client = createCloudClient(null)) {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.CREATEALIAS.toString());
        params.set("name", "invalid@name#with$weird%characters");
        params.set("collections", COLLECTION_NAME);
        SolrRequest request = new QueryRequest(params);
        request.setPath("/admin/collections");
        try {
            client.request(request);
            fail();
        } catch (RemoteSolrException e) {
            final String errorMessage = e.getMessage();
            assertTrue(errorMessage.contains("Invalid alias"));
            assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
            assertTrue(errorMessage.contains("alias names must consist entirely of"));
        }
    }
}
Also used : RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException) QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Aggregations

RemoteSolrException (org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException)9 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)5 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)5 SolrRequest (org.apache.solr.client.solrj.SolrRequest)4 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)4 SolrQuery (org.apache.solr.client.solrj.SolrQuery)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 SolrServerException (org.apache.solr.client.solrj.SolrServerException)2 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)2 SolrDocument (org.apache.solr.common.SolrDocument)2 SolrDocumentList (org.apache.solr.common.SolrDocumentList)2 SolrZkClient (org.apache.solr.common.cloud.SolrZkClient)2 Test (org.junit.Test)2 DatasetFieldType (edu.harvard.iq.dataverse.DatasetFieldType)1 DataverseFacet (edu.harvard.iq.dataverse.DataverseFacet)1 Field (java.lang.reflect.Field)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1