Search in sources :

Example 56 with JettySolrRunner

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

the class TestSolrCloudWithDelegationTokens method startup.

@BeforeClass
public static void startup() throws Exception {
    System.setProperty("authenticationPlugin", HttpParamDelegationTokenPlugin.class.getName());
    System.setProperty(KerberosPlugin.DELEGATION_TOKEN_ENABLED, "true");
    System.setProperty("solr.kerberos.cookie.domain", "127.0.0.1");
    miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig("/solr"));
    JettySolrRunner runnerPrimary = miniCluster.getJettySolrRunners().get(0);
    solrClientPrimary = new HttpSolrClient.Builder(runnerPrimary.getBaseUrl().toString()).build();
    JettySolrRunner runnerSecondary = miniCluster.getJettySolrRunners().get(1);
    solrClientSecondary = new HttpSolrClient.Builder(runnerSecondary.getBaseUrl().toString()).build();
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) HttpParamDelegationTokenPlugin(org.apache.solr.security.HttpParamDelegationTokenPlugin) BeforeClass(org.junit.BeforeClass)

Example 57 with JettySolrRunner

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

the class TestPullReplicaErrorHandling method testPullReplicaDisconnectsFromZooKeeper.

public void testPullReplicaDisconnectsFromZooKeeper() throws Exception {
    int numShards = 1;
    CollectionAdminRequest.createCollection(collectionName, "conf", numShards, 1, 0, 1).setMaxShardsPerNode(1).process(cluster.getSolrClient());
    addDocs(10);
    DocCollection docCollection = assertNumberOfReplicas(numShards, 0, numShards, false, true);
    Slice s = docCollection.getSlices().iterator().next();
    try (HttpSolrClient pullReplicaClient = getHttpSolrClient(s.getReplicas(EnumSet.of(Replica.Type.PULL)).get(0).getCoreUrl())) {
        assertNumDocs(10, pullReplicaClient);
    }
    addDocs(20);
    JettySolrRunner jetty = getJettyForReplica(s.getReplicas(EnumSet.of(Replica.Type.PULL)).get(0));
    cluster.expireZkSession(jetty);
    addDocs(30);
    waitForState("Expecting node to be disconnected", collectionName, activeReplicaCount(1, 0, 0));
    addDocs(40);
    waitForState("Expecting node to be disconnected", collectionName, activeReplicaCount(1, 0, 1));
    try (HttpSolrClient pullReplicaClient = getHttpSolrClient(s.getReplicas(EnumSet.of(Replica.Type.PULL)).get(0).getCoreUrl())) {
        assertNumDocs(40, pullReplicaClient);
    }
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) Slice(org.apache.solr.common.cloud.Slice) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) DocCollection(org.apache.solr.common.cloud.DocCollection)

Example 58 with JettySolrRunner

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

the class TestCloudManagedSchemaConcurrent method verifyWaitForSchemaUpdateToPropagate.

private void verifyWaitForSchemaUpdateToPropagate() throws Exception {
    String testCollectionName = "collection1";
    ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
    Replica shard1Leader = clusterState.getLeader(testCollectionName, "shard1");
    final String coreUrl = (new ZkCoreNodeProps(shard1Leader)).getCoreUrl();
    assertNotNull(coreUrl);
    RestTestHarness harness = new RestTestHarness(() -> coreUrl.endsWith("/") ? coreUrl.substring(0, coreUrl.length() - 1) : coreUrl);
    try {
        addFieldTypePut(harness, "fooInt", 15);
    } finally {
        harness.close();
    }
    // go into ZK to get the version of the managed schema after the update
    SolrZkClient zkClient = cloudClient.getZkStateReader().getZkClient();
    Stat stat = new Stat();
    String znodePath = "/configs/conf1/managed-schema";
    byte[] managedSchemaBytes = zkClient.getData(znodePath, null, stat, false);
    int schemaZkVersion = stat.getVersion();
    // now loop over all replicas and verify each has the same schema version
    Replica randomReplicaNotLeader = null;
    for (Slice slice : clusterState.getActiveSlices(testCollectionName)) {
        for (Replica replica : slice.getReplicas()) {
            validateZkVersion(replica, schemaZkVersion, 0, false);
            // save a random replica to test zk watcher behavior
            if (randomReplicaNotLeader == null && !replica.getName().equals(shard1Leader.getName()))
                randomReplicaNotLeader = replica;
        }
    }
    assertNotNull(randomReplicaNotLeader);
    // now update the data and then verify the znode watcher fires correctly
    // before an after a zk session expiration (see SOLR-6249)
    zkClient.setData(znodePath, managedSchemaBytes, schemaZkVersion, false);
    stat = new Stat();
    managedSchemaBytes = zkClient.getData(znodePath, null, stat, false);
    int updatedSchemaZkVersion = stat.getVersion();
    assertTrue(updatedSchemaZkVersion > schemaZkVersion);
    validateZkVersion(randomReplicaNotLeader, updatedSchemaZkVersion, 2, true);
    // ok - looks like the watcher fired correctly on the replica
    // now, expire that replica's zk session and then verify the watcher fires again (after reconnect)
    JettySolrRunner randomReplicaJetty = getJettyOnPort(getReplicaPort(randomReplicaNotLeader));
    assertNotNull(randomReplicaJetty);
    chaosMonkey.expireSession(randomReplicaJetty);
    // update the data again to cause watchers to fire
    zkClient.setData(znodePath, managedSchemaBytes, updatedSchemaZkVersion, false);
    stat = new Stat();
    managedSchemaBytes = zkClient.getData(znodePath, null, stat, false);
    updatedSchemaZkVersion = stat.getVersion();
    // give up to 10 secs for the replica to recover after zk session loss and see the update
    validateZkVersion(randomReplicaNotLeader, updatedSchemaZkVersion, 10, true);
}
Also used : ClusterState(org.apache.solr.common.cloud.ClusterState) Stat(org.apache.zookeeper.data.Stat) ZkCoreNodeProps(org.apache.solr.common.cloud.ZkCoreNodeProps) RestTestHarness(org.apache.solr.util.RestTestHarness) Slice(org.apache.solr.common.cloud.Slice) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) Replica(org.apache.solr.common.cloud.Replica) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient)

Example 59 with JettySolrRunner

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

the class MiniSolrCloudCluster method stopJettySolrRunner.

/**
   * Stop a Solr instance
   * @param index the index of node in collection returned by {@link #getJettySolrRunners()}
   * @return the shut down node
   */
public JettySolrRunner stopJettySolrRunner(int index) throws Exception {
    JettySolrRunner jetty = jettys.get(index);
    jetty.stop();
    jettys.remove(index);
    return jetty;
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner)

Example 60 with JettySolrRunner

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

the class MiniSolrCloudCluster method checkForExceptions.

private Exception checkForExceptions(String message, Collection<Future<JettySolrRunner>> futures) throws InterruptedException {
    Exception parsed = new Exception(message);
    boolean ok = true;
    for (Future<JettySolrRunner> future : futures) {
        try {
            future.get();
        } catch (ExecutionException e) {
            parsed.addSuppressed(e.getCause());
            ok = false;
        } catch (InterruptedException e) {
            Thread.interrupted();
            throw e;
        }
    }
    return ok ? null : parsed;
}
Also used : JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) ExecutionException(java.util.concurrent.ExecutionException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

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