Java Code Examples for org.apache.solr.core.CoreContainer#getMultiCoreHandler()

The following examples show how to use org.apache.solr.core.CoreContainer#getMultiCoreHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoresCreateViaPropertyIT.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void newCoreUsingAllDefaults() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Now create the new core with
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);

    TimeUnit.SECONDS.sleep(15); //Wait a little for background threads to catchup

    //Get a reference to the new core
    SolrCore defaultCore = getCore(coreContainer, "alfresco");
    SolrCore archiveCore = getCore(coreContainer, "archive");

    assertNotNull(defaultCore);
    assertNotNull(archiveCore);
}
 
Example 2
Source File: CoresCreateUpdateDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void newCoreUsingAllDefaults() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Now create the new core with
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);
    createSimpleCore(coreAdminHandler, null, null,null);

    //Get a reference to the new core
    SolrCore defaultCore = getCore(coreContainer, "alfresco");

    TimeUnit.SECONDS.sleep(3); //Wait a little for background threads to catchup
    assertNotNull(defaultCore);

    //Call custom actions
    SolrQueryResponse response = callHandler(coreAdminHandler, defaultCore, "SUMMARY");
    assertSummaryCorrect(response, defaultCore.getName());
}
 
Example 3
Source File: AdminHandlerDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void newCoreUsingAdminHandler() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Create the new core
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);

    SolrCore testingCore = createCoreUsingTemplate(coreContainer, coreAdminHandler, CORE_NAME, "rerank", 1, 1);
    Properties props = testingCore.getCoreDescriptor().getSubstitutableProperties();
    //The default sharding method is DB_ID
    assertEquals(DB_ID.toString(), props.get("shard.method"));

    //Call custom actions
    SolrQueryResponse response = callHandler(coreAdminHandler, testingCore, "check");
    assertNotNull(response);
    response = callHandler(coreAdminHandler, testingCore, "summary");
    assertSummaryCorrect(response, testingCore.getName());
    response = callHandler(coreAdminHandler, testingCore, "Report");
    assertNotNull(response);
    NamedList<Object> report = (NamedList<Object>) response.getValues().get("report");
    assertNotNull(report.get(CORE_NAME));

    //Create a core using ACL_ID sharding
    testingCore = createCoreUsingTemplate(coreContainer, coreAdminHandler, CORE_NAME+"aclId", "rerank", 1, 1,"property.shard.method",ACL_ID.toString());
    props = testingCore.getCoreDescriptor().getSubstitutableProperties();
    assertEquals(ACL_ID.toString(), props.get("shard.method"));
}
 
Example 4
Source File: SolrITInitializer.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void initSingleSolrServer(String testClassName, Properties solrcoreProperties) throws Throwable
{
    initSolrServers(0,testClassName,solrcoreProperties);
    
    JettySolrRunner jsr = jettyContainers.get(testClassName);
    CoreContainer coreContainer = jsr.getCoreContainer();
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);
    String[] extras = null;
    if ((solrcoreProperties != null) && !solrcoreProperties.isEmpty())
    {
        int i = 0;
        extras = new String[solrcoreProperties.size()*2];
        for (Map.Entry<Object, Object> prop:solrcoreProperties.entrySet())
        {
            extras[i++] = "property."+prop.getKey();
            extras[i++] = (String) prop.getValue();
        }

    }
    defaultCore = createCoreUsingTemplate(coreContainer, coreAdminHandler, "alfresco", "rerank", 1, 1, extras);
    assertNotNull(defaultCore);
    String url = buildUrl(jsr.getLocalPort()) + "/" + "alfresco";
    SolrClient standaloneClient = createNewSolrClient(url);
    assertNotNull(standaloneClient);
    solrCollectionNameToStandaloneClient.put("alfresco", standaloneClient);
}
 
Example 5
Source File: AbstractAlfrescoDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected static List<AlfrescoCoreAdminHandler> getAdminHandlers(Collection<JettySolrRunner> runners)
{
    List<AlfrescoCoreAdminHandler> coreAdminHandlers = new ArrayList<>();
    for (JettySolrRunner jettySolrRunner : runners)
    {
        CoreContainer coreContainer = jettySolrRunner.getCoreContainer();
        AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
        coreAdminHandlers.add(coreAdminHandler);
    }
    return coreAdminHandlers;
}
 
Example 6
Source File: TemplatesDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void newCoreUsinglshTemplate() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Now create the new core with
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);
    SolrCore rankCore = createCoreUsingTemplate(coreContainer, coreAdminHandler, "templateWithrerank", AlfrescoCoreAdminHandler.DEFAULT_TEMPLATE, 2, 1);

    //Call custom actions
    SolrQueryResponse response = callHandler(coreAdminHandler, rankCore, "SUMMARY");
    assertSummaryCorrect(response, rankCore.getName());
}
 
Example 7
Source File: CoresCreateUpdateDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void newCoreWithUpdateSharedProperties() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Now create the new core with
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler) coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);
    String coreName = "alfSharedCore";

    //First, we have no cores so we can update the shared properties, including disallowed
    updateShared(coreAdminHandler,"property.solr.host", "myhost", "property.my.property", "chocolate",
            "property.alfresco.identifier.property.0", "http://www.alfresco.org/model/content/1.0}userName");
    Properties props = AlfrescoSolrDataModel.getCommonConfig();
    assertEquals(props.getProperty("my.property"), "chocolate");
    assertEquals(props.getProperty("alfresco.identifier.property.0"), "http://www.alfresco.org/model/content/1.0}userName");

    createSimpleCore(coreAdminHandler, coreName, StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.toString(), null);
    //Get a reference to the new core
    SolrCore defaultCore = getCore(coreContainer, coreName);

    TimeUnit.SECONDS.sleep(3); //Wait a little for background threads to catchup
    assertNotNull(defaultCore);

    String solrHost = props.getProperty("solr.host");
    assertFalse(props.containsKey("new.property"));
    try
    {
        updateShared(coreAdminHandler,"property.solr.host", "superhost", "property.new.property", "catchup", "property.alfresco.identifier.property.0", "not_this_time");
        fail();
    } catch (SolrException se)
    {
        assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, se.code());
    }
    updateShared(coreAdminHandler,"property.solr.host", "superhost", "property.new.property", "catchup");
    props = AlfrescoSolrDataModel.getCommonConfig();
    assertEquals(props.getProperty("new.property"), "catchup");
    assertNotEquals(props.getProperty("solr.host"), solrHost);
}
 
Example 8
Source File: CoresCreateUpdateDistributedIT.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void newCoreUsingArchiveStore() throws Exception
{
    CoreContainer coreContainer = jettyContainers.get(testFolder).getCoreContainer();

    //Now create the new core with
    AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler)  coreContainer.getMultiCoreHandler();
    assertNotNull(coreAdminHandler);
    String coreName = "archive";

    createSimpleCore(coreAdminHandler, coreName, StoreRef.STORE_REF_ARCHIVE_SPACESSTORE.toString(),AlfrescoCoreAdminHandler.DEFAULT_TEMPLATE,
            "property.alfresco.maxTotalBagels", "99", "property.alfresco.maxTotalConnections", "3456");
    //Get a reference to the new core
    SolrCore defaultCore = getCore(coreContainer, coreName);

    TimeUnit.SECONDS.sleep(3); //Wait a little for background threads to catchup
    assertNotNull(defaultCore);

    //Call custom actions
    SolrQueryResponse response = callHandler(coreAdminHandler, defaultCore, "SUMMARY");
    assertSummaryCorrect(response, defaultCore.getName());

    assertEquals("3456", defaultCore.getCoreDescriptor().getCoreProperty("alfresco.maxTotalConnections","notset"));
    assertEquals("99", defaultCore.getCoreDescriptor().getCoreProperty("alfresco.maxTotalBagels", "notset"));

    //Test updating properties
    updateCore(coreAdminHandler,coreName, "property.alfresco.maxTotalBagels", "101",
            "property.alfresco.maxTotalConnections", "55",
            "property.solr.is.great", "true");
    defaultCore = getCore(coreContainer, coreName);
    assertEquals("55", defaultCore.getCoreDescriptor().getCoreProperty("alfresco.maxTotalConnections","notset"));
    assertEquals("101", defaultCore.getCoreDescriptor().getCoreProperty("alfresco.maxTotalBagels", "notset"));
    assertEquals("true", defaultCore.getCoreDescriptor().getCoreProperty("solr.is.great", "notset"));
}