Search in sources :

Example 1 with SolrServer

use of org.platformlayer.service.solr.model.SolrServer in project platformlayer by platformlayer.

the class ITSolrService method testCreateAndDeleteItem.

@Test
public void testCreateAndDeleteItem() throws Exception {
    String id = random.randomAlphanumericString(8);
    SolrCluster solr = new SolrCluster();
    solr.dnsName = id + ".test.platformlayer.org";
    solr = putItem(id, solr);
    solr = waitForHealthy(solr);
    InetSocketAddress socketAddress = getUniqueEndpoint(solr);
    Assert.assertFalse(isPortOpen(socketAddress));
    openFirewall(solr, SolrConstants.API_PORT);
    Assert.assertTrue(isPortOpen(socketAddress));
    // TODO: Make endpoint http://<ip>:<port>/<path>...
    String url = "http://" + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort() + "/solr";
    testSolr(url);
    String customFieldKey = "customfield1";
    SolrSchemaField field = new SolrSchemaField();
    field.name = customFieldKey;
    field.type = "text_general";
    field.getTags().add(Tag.buildParentTag(solr.getKey()));
    // TODO: Our scoping of keys is problematic now...
    // If two clusters both have the same key "customfield1", they can't have the same ID
    field = putItem(id + "-" + customFieldKey, field);
    waitForHealthy(field);
    // Currently, we need to do a manual configure operation...
    // TODO: trigger this automatically
    SolrServer server = getItem(id + "-0", SolrServer.class);
    JobData configureJob = getContext().doConfigure(server);
    waitForJobComplete(configureJob, TimeSpan.FIVE_MINUTES);
    testSolrCustomField(url, customFieldKey);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) JobData(org.platformlayer.jobs.model.JobData) SolrServer(org.platformlayer.service.solr.model.SolrServer) CommonsHttpSolrServer(org.apache.solr.client.solrj.impl.CommonsHttpSolrServer) SolrCluster(org.platformlayer.service.solr.model.SolrCluster) SolrSchemaField(org.platformlayer.service.solr.model.SolrSchemaField) Test(org.testng.annotations.Test) PlatformLayerApiTest(org.platformlayer.tests.PlatformLayerApiTest)

Example 2 with SolrServer

use of org.platformlayer.service.solr.model.SolrServer in project platformlayer by platformlayer.

the class SolrServerController method addChildren.

@Override
protected void addChildren() throws OpsException {
    SolrServer model = OpsContext.get().getInstance(SolrServer.class);
    int port = SolrConstants.API_PORT;
    InstanceBuilder vm;
    {
        vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
        vm.publicPorts.add(port);
        vm.hostPolicy.allowRunInContainer = true;
        // TODO: This needs to be configurable...
        vm.minimumMemoryMb = 2048;
        addChild(vm);
    }
    {
        SolrInstall install = injected(SolrInstall.class);
        vm.addChild(install);
    }
    {
        SolrInstance service = injected(SolrInstance.class);
        vm.addChild(service);
    }
    {
        PublicEndpoint endpoint = injected(PublicEndpoint.class);
        // endpoint.network = null;
        endpoint.publicPort = port;
        endpoint.backendPort = port;
        endpoint.dnsName = model.dnsName;
        endpoint.tagItem = model.getKey();
        endpoint.parentItem = model.getKey();
        vm.addChild(endpoint);
    }
}
Also used : PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) SolrServer(org.platformlayer.service.solr.model.SolrServer) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 3 with SolrServer

use of org.platformlayer.service.solr.model.SolrServer in project platformlayer by platformlayer.

the class SolrClusterController method getMachines.

@Override
public List<Machine> getMachines(boolean required) throws OpsException {
    Filter parentFilter = TagFilter.byTag(Tag.buildParentTag(model.getKey()));
    List<Machine> machines = Lists.newArrayList();
    for (SolrServer server : platformLayer.listItems(SolrServer.class, parentFilter)) {
        Machine machine = instances.getMachine(server, required);
        if (machine != null) {
            machines.add(machine);
        }
    }
    return machines;
}
Also used : TagFilter(org.platformlayer.TagFilter) Filter(org.platformlayer.Filter) SolrServer(org.platformlayer.service.solr.model.SolrServer) Machine(org.platformlayer.ops.Machine)

Example 4 with SolrServer

use of org.platformlayer.service.solr.model.SolrServer in project platformlayer by platformlayer.

the class SolrTemplateData method getCluster.

public SolrCluster getCluster() throws OpsException {
    if (cluster == null) {
        cluster = OpsContext.get().getInstance(SolrCluster.class);
        if (cluster == null) {
            SolrServer server = getServer();
            PlatformLayerKey parent = Tag.PARENT.findUnique(server);
            if (parent != null) {
                cluster = platformLayer.getItem(parent, SolrCluster.class);
            }
        }
    }
    return cluster;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) SolrServer(org.platformlayer.service.solr.model.SolrServer) SolrCluster(org.platformlayer.service.solr.model.SolrCluster)

Aggregations

SolrServer (org.platformlayer.service.solr.model.SolrServer)4 SolrCluster (org.platformlayer.service.solr.model.SolrCluster)2 InetSocketAddress (java.net.InetSocketAddress)1 CommonsHttpSolrServer (org.apache.solr.client.solrj.impl.CommonsHttpSolrServer)1 Filter (org.platformlayer.Filter)1 TagFilter (org.platformlayer.TagFilter)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 JobData (org.platformlayer.jobs.model.JobData)1 Machine (org.platformlayer.ops.Machine)1 InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)1 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)1 SolrSchemaField (org.platformlayer.service.solr.model.SolrSchemaField)1 PlatformLayerApiTest (org.platformlayer.tests.PlatformLayerApiTest)1 Test (org.testng.annotations.Test)1