Search in sources :

Example 6 with CoreAdminHandler

use of org.apache.solr.handler.admin.CoreAdminHandler in project lucene-solr by apache.

the class TestLazyCores method unloadViaAdmin.

private void unloadViaAdmin(CoreContainer cc, String name) throws Exception {
    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody(req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.UNLOAD.toString(), CoreAdminParams.CORE, name), resp);
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler)

Example 7 with CoreAdminHandler

use of org.apache.solr.handler.admin.CoreAdminHandler in project lucene-solr by apache.

the class TestLazyCores method createViaAdmin.

private void createViaAdmin(CoreContainer cc, String name, boolean isTransient, boolean loadOnStartup) throws Exception {
    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody(req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.CREATE.toString(), CoreAdminParams.NAME, name, CoreAdminParams.TRANSIENT, Boolean.toString(isTransient), CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)), resp);
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler)

Example 8 with CoreAdminHandler

use of org.apache.solr.handler.admin.CoreAdminHandler in project lucene-solr by apache.

the class TestLazyCores method testCreateSame.

@Test
public void testCreateSame() throws Exception {
    final CoreContainer cc = init();
    try {
        // First, try all 4 combinations of load on startup and transient
        final CoreAdminHandler admin = new CoreAdminHandler(cc);
        SolrCore lc2 = cc.getCore("collection2");
        SolrCore lc4 = cc.getCore("collection4");
        SolrCore lc5 = cc.getCore("collection5");
        SolrCore lc6 = cc.getCore("collection6");
        copyMinConf(new File(solrHomeDirectory, "t2"));
        copyMinConf(new File(solrHomeDirectory, "t4"));
        copyMinConf(new File(solrHomeDirectory, "t5"));
        copyMinConf(new File(solrHomeDirectory, "t6"));
        // Should also fail with the same name
        tryCreateFail(admin, "collection2", "t12", "Core with name", "collection2", "already exists");
        tryCreateFail(admin, "collection4", "t14", "Core with name", "collection4", "already exists");
        tryCreateFail(admin, "collection5", "t15", "Core with name", "collection5", "already exists");
        tryCreateFail(admin, "collection6", "t16", "Core with name", "collection6", "already exists");
        lc2.close();
        lc4.close();
        lc5.close();
        lc6.close();
    } finally {
        cc.shutdown();
    }
}
Also used : CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler) File(java.io.File) Test(org.junit.Test)

Example 9 with CoreAdminHandler

use of org.apache.solr.handler.admin.CoreAdminHandler in project lucene-solr by apache.

the class TestManagedSchema method assertSchemaResource.

private void assertSchemaResource(String collection, String expectedSchemaResource) throws Exception {
    final CoreContainer cores = h.getCoreContainer();
    final CoreAdminHandler admin = new CoreAdminHandler(cores);
    SolrQueryRequest request = req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
    SolrQueryResponse response = new SolrQueryResponse();
    admin.handleRequestBody(request, response);
    assertNull("Exception on create", response.getException());
    NamedList responseValues = response.getValues();
    NamedList status = (NamedList) responseValues.get("status");
    NamedList collectionStatus = (NamedList) status.get(collection);
    String collectionSchema = (String) collectionStatus.get(CoreAdminParams.SCHEMA);
    assertEquals("Schema resource name differs from expected name", expectedSchemaResource, collectionSchema);
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) CoreContainer(org.apache.solr.core.CoreContainer) NamedList(org.apache.solr.common.util.NamedList) CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler)

Example 10 with CoreAdminHandler

use of org.apache.solr.handler.admin.CoreAdminHandler in project lucene-solr by apache.

the class TestManagedSchema method testDefaultSchemaFactory.

public void testDefaultSchemaFactory() throws Exception {
    deleteCore();
    initCore("solrconfig-managed-schema-test.xml", "schema-minimal.xml", tmpSolrHome.getPath());
    final CoreContainer cores = h.getCoreContainer();
    final CoreAdminHandler admin = new CoreAdminHandler(cores);
    SolrQueryRequest request = req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
    SolrQueryResponse response = new SolrQueryResponse();
    admin.handleRequestBody(request, response);
    assertNull("Exception on create", response.getException());
    assertSchemaResource(collection, "managed-schema");
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) CoreContainer(org.apache.solr.core.CoreContainer) CoreAdminHandler(org.apache.solr.handler.admin.CoreAdminHandler)

Aggregations

CoreAdminHandler (org.apache.solr.handler.admin.CoreAdminHandler)20 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)15 IOException (java.io.IOException)3 SolrException (org.apache.solr.common.SolrException)3 CollectionsHandler (org.apache.solr.handler.admin.CollectionsHandler)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 CoreContainer (org.apache.solr.core.CoreContainer)2 InfoHandler (org.apache.solr.handler.admin.InfoHandler)2 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)2 UpdateShardHandler (org.apache.solr.update.UpdateShardHandler)2 DefaultSolrThreadFactory (org.apache.solr.util.DefaultSolrThreadFactory)2 CharacterCodingException (java.nio.charset.CharacterCodingException)1 Path (java.nio.file.Path)1 Collections.singletonList (java.util.Collections.singletonList)1