Search in sources :

Example 91 with JettySolrRunner

use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.

the class GraphExpressionTest method testGraphHandler.

@Test
public void testGraphHandler() throws Exception {
    new UpdateRequest().add(id, "0", "from_s", "bill", "to_s", "jim", "message_t", "Hello jim").add(id, "1", "from_s", "bill", "to_s", "sam", "message_t", "Hello sam").add(id, "2", "from_s", "bill", "to_s", "max", "message_t", "Hello max").add(id, "3", "from_s", "max", "to_s", "kip", "message_t", "Hello kip").add(id, "4", "from_s", "sam", "to_s", "steve", "message_t", "Hello steve").add(id, "5", "from_s", "jim", "to_s", "ann", "message_t", "Hello steve").commit(cluster.getSolrClient(), COLLECTION);
    commit();
    List<JettySolrRunner> runners = cluster.getJettySolrRunners();
    JettySolrRunner runner = runners.get(0);
    String url = runner.getBaseUrl().toString();
    HttpSolrClient client = getHttpSolrClient(url);
    ModifiableSolrParams params = new ModifiableSolrParams();
    String expr = "sort(by=\"node asc\", gatherNodes(collection1, " + "walk=\"bill->from_s\"," + "trackTraversal=\"true\"," + "gather=\"to_s\"))";
    params.add("expr", expr);
    QueryRequest query = new QueryRequest(params);
    query.setPath("/collection1/graph");
    query.setResponseParser(new InputStreamResponseParser("xml"));
    query.setMethod(SolrRequest.METHOD.POST);
    NamedList<Object> genericResponse = client.request(query);
    InputStream stream = (InputStream) genericResponse.get("stream");
    InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
    String xml = readString(reader);
    //Validate the nodes
    String error = h.validateXPath(xml, "//graph/node[1][@id ='jim']", "//graph/node[2][@id ='max']", "//graph/node[3][@id ='sam']");
    if (error != null) {
        throw new Exception(error);
    }
    //Validate the edges
    error = h.validateXPath(xml, "//graph/edge[1][@source ='bill']", "//graph/edge[1][@target ='jim']", "//graph/edge[2][@source ='bill']", "//graph/edge[2][@target ='max']", "//graph/edge[3][@source ='bill']", "//graph/edge[3][@target ='sam']");
    if (error != null) {
        throw new Exception(error);
    }
    client.close();
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) InputStreamReader(java.io.InputStreamReader) UpdateRequest(org.apache.solr.client.solrj.request.UpdateRequest) InputStreamResponseParser(org.apache.solr.client.solrj.impl.InputStreamResponseParser) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) InputStream(java.io.InputStream) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) IOException(java.io.IOException) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) Test(org.junit.Test)

Example 92 with JettySolrRunner

use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.

the class SearchHandlerTest method testZkConnected.

@Test
public void testZkConnected() throws Exception {
    MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(5, createTempDir(), buildJettyConfig("/solr"));
    final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient();
    try {
        assertNotNull(miniCluster.getZkServer());
        List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners();
        assertEquals(5, jettys.size());
        for (JettySolrRunner jetty : jettys) {
            assertTrue(jetty.isRunning());
        }
        // create collection
        String collectionName = "testSolrCloudCollection";
        String configName = "solrCloudCollectionConfig";
        miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1/conf"), configName);
        CollectionAdminRequest.createCollection(collectionName, configName, 2, 2).process(miniCluster.getSolrClient());
        QueryRequest req = new QueryRequest();
        QueryResponse rsp = req.process(cloudSolrClient, collectionName);
        assertTrue(rsp.getResponseHeader().getBooleanArg("zkConnected"));
    } finally {
        miniCluster.shutdown();
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) MiniSolrCloudCluster(org.apache.solr.cloud.MiniSolrCloudCluster) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) Test(org.junit.Test)

Example 93 with JettySolrRunner

use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.

the class TestDelegationWithHadoopAuth method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    assumeFalse("Hadoop does not work on Windows", Constants.WINDOWS);
    // nodes
    configureCluster(NUM_SERVERS).withSecurityJson(TEST_PATH().resolve("security").resolve("hadoop_simple_auth_with_delegation.json")).configure();
    JettySolrRunner runnerPrimary = cluster.getJettySolrRunners().get(0);
    primarySolrClient = new HttpSolrClient.Builder(runnerPrimary.getBaseUrl().toString()).build();
    JettySolrRunner runnerSecondary = cluster.getJettySolrRunners().get(1);
    secondarySolrClient = new HttpSolrClient.Builder(runnerSecondary.getBaseUrl().toString()).build();
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) BeforeClass(org.junit.BeforeClass)

Example 94 with JettySolrRunner

use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.

the class BasicAuthStandaloneTest method createJetty.

private JettySolrRunner createJetty(SolrInstance instance) throws Exception {
    Properties nodeProperties = new Properties();
    nodeProperties.setProperty("solr.data.dir", instance.getDataDir().toString());
    JettySolrRunner jetty = new JettySolrRunner(instance.getHomeDir().toString(), nodeProperties, buildJettyConfig("/solr"));
    jetty.start();
    return jetty;
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) Properties(java.util.Properties)

Example 95 with JettySolrRunner

use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.

the class BaseDistributedSearchTestCase method createJetty.

public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride, String schemaOverride, boolean explicitCoreNodeName) throws Exception {
    Properties props = new Properties();
    if (solrConfigOverride != null)
        props.setProperty("solrconfig", solrConfigOverride);
    if (schemaOverride != null)
        props.setProperty("schema", schemaOverride);
    if (shardList != null)
        props.setProperty("shards", shardList);
    if (dataDir != null) {
        props.setProperty("solr.data.dir", dataDir);
    }
    if (explicitCoreNodeName) {
        props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
    }
    props.setProperty("coreRootDirectory", solrHome.toPath().resolve("cores").toAbsolutePath().toString());
    JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, JettyConfig.builder().stopAtShutdown(true).setContext(context).withFilters(getExtraRequestFilters()).withServlets(getExtraServlets()).withSSLConfig(sslConfig).build());
    jetty.start();
    return jetty;
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) Properties(java.util.Properties)

Aggregations

JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)137 Test (org.junit.Test)52 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)29 Replica (org.apache.solr.common.cloud.Replica)28 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)25 SolrInputDocument (org.apache.solr.common.SolrInputDocument)20 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)20 File (java.io.File)19 SolrQuery (org.apache.solr.client.solrj.SolrQuery)19 DocCollection (org.apache.solr.common.cloud.DocCollection)18 Slice (org.apache.solr.common.cloud.Slice)18 IOException (java.io.IOException)15 ArrayList (java.util.ArrayList)15 Properties (java.util.Properties)15 SolrClient (org.apache.solr.client.solrj.SolrClient)15 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)15 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)15 CoreContainer (org.apache.solr.core.CoreContainer)14 BeforeClass (org.junit.BeforeClass)14 ClusterState (org.apache.solr.common.cloud.ClusterState)13