Examples of CloudSolrServer


Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

      if (allowZeroDocs == false) {
        assertTrue("Solr should contain atleast one solr doc to run this test.", orginalSolrDocs.size() > 0);
      }

      setAuthenticationUser(solrUserName);
      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      try {
        cloudSolrServer.deleteByQuery(ALL_DOCS);
        cloudSolrServer.commit();
      } finally {
        cloudSolrServer.shutdown();
      }

      // Validate Solr doc count is zero
      SolrDocumentList solrRespDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      validateSolrDocCountAndContent(new SolrDocumentList(), solrRespDocs);
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

      if (allowZeroDocs == false) {
        assertTrue("Solr should contain atleast one solr doc to run this test.", orginalSolrDocs.size() > 0);
      }

      setAuthenticationUser(solrUserName);
      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      try {
        cloudSolrServer.deleteByQuery(ALL_DOCS);
        cloudSolrServer.commit();
        fail("The specified user: " + solrUserName + " shouldn't get deletedocs access!");
      } catch (Exception exception) {
        assertTrue("Expected " + SENTRY_ERROR_MSG + " in " + exception.toString(),
            exception.toString().contains(SENTRY_ERROR_MSG));
      } finally {
        cloudSolrServer.shutdown();
      }

      // Validate Solr doc count and content is same as original set.
      SolrDocumentList solrRespDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      validateSolrDocCountAndContent(orginalSolrDocs, solrRespDocs);
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

      if (runAsAdmin == true) {
        // Authenticate as user "admin"
        setAuthenticationUser(ADMIN_USER);
      }

      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      assertNotNull("Solr query shouldn't be null.", solrQueryStr);
      SolrDocumentList solrDocs = null;
      try {
        SolrQuery query = new SolrQuery(solrQueryStr);
        QueryResponse response = cloudSolrServer.query(query);
        solrDocs = response.getResults();
        return solrDocs;
      } finally {
        cloudSolrServer.shutdown();
      }
    } finally {
      setAuthenticationUser(originalUser);
    }
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

   * @param collectionName - Name of the collection
   * @return instance of CloudSolrServer
   * @throws MalformedURLException
   */
  protected CloudSolrServer getCloudSolrServer(String collectionName) throws MalformedURLException {
    CloudSolrServer cloudSolrServer = new CloudSolrServer(zkServer.getZkAddress(),
        random().nextBoolean());
    cloudSolrServer.setDefaultCollection(collectionName);
    cloudSolrServer.connect();
    return cloudSolrServer;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

    }

    private SolrServer initializeWithCloudSolrServer() throws IOException, SolrServerException {
        // try SolrCloud client
        CloudSolrServer cloudSolrServer = new CloudSolrServer(solrZkHost);
        cloudSolrServer.connect();
        cloudSolrServer.setDefaultCollection("collection1"); // workaround for first request when the needed collection may not exist

        // create specified collection if it doesn't exists
        createCollectionIfNeeded(cloudSolrServer);

        cloudSolrServer.setDefaultCollection(solrCollection);

        // SolrCloud may need some time to sync on collection creation (to spread it over the shards / replicas)
        int i = 0;
        while (i < 3) {
            try {
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

                                  SolrInputDocument solrInputDoc) throws Exception {
    String originalUser = getAuthenticatedUser();
    try {
      SolrDocumentList orginalSolrDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      setAuthenticationUser(solrUserName);
      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      try {
        cloudSolrServer.add(solrInputDoc);
        cloudSolrServer.commit();
      } finally {
        cloudSolrServer.shutdown();
      }

      orginalSolrDocs.add(ClientUtils.toSolrDocument(solrInputDoc));
      SolrDocumentList solrRespDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      // Validate Solr content to check whether the update command went through.
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

                                  SolrInputDocument solrInputDoc) throws Exception {
    String originalUser = getAuthenticatedUser();
    try {
      SolrDocumentList orginalSolrDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      setAuthenticationUser(solrUserName);
      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      try {
        cloudSolrServer.add(solrInputDoc);
        cloudSolrServer.commit();
        fail("The specified user: " + solrUserName + " shouldn't get update access!");
      } catch (Exception exception) {
        assertTrue("Expected " + SENTRY_ERROR_MSG + " in " + exception.toString(),
            exception.toString().contains(SENTRY_ERROR_MSG));
      } finally {
        cloudSolrServer.shutdown();
      }

      SolrDocumentList solrRespDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      // Validate Solr content to check whether the update command didn't go through.
      validateSolrDocCountAndContent(orginalSolrDocs, solrRespDocs);
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

      if (allowZeroDocs == false) {
        assertTrue("Solr should contain atleast one solr doc to run this test.", orginalSolrDocs.size() > 0);
      }

      setAuthenticationUser(solrUserName);
      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      try {
        cloudSolrServer.deleteByQuery(ALL_DOCS);
        cloudSolrServer.commit();
      } finally {
        cloudSolrServer.shutdown();
      }

      // Validate Solr doc count is zero
      SolrDocumentList solrRespDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      validateSolrDocCountAndContent(new SolrDocumentList(), solrRespDocs);
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

      if (allowZeroDocs == false) {
        assertTrue("Solr should contain atleast one solr doc to run this test.", orginalSolrDocs.size() > 0);
      }

      setAuthenticationUser(solrUserName);
      CloudSolrServer cloudSolrServer = getCloudSolrServer(collectionName);
      try {
        cloudSolrServer.deleteByQuery(ALL_DOCS);
        cloudSolrServer.commit();
        fail("The specified user: " + solrUserName + " shouldn't get deletedocs access!");
      } catch (Exception exception) {
        assertTrue("Expected " + SENTRY_ERROR_MSG + " in " + exception.toString(),
            exception.toString().contains(SENTRY_ERROR_MSG));
      } finally {
        cloudSolrServer.shutdown();
      }

      // Validate Solr doc count and content is same as original set.
      SolrDocumentList solrRespDocs = getSolrDocs(collectionName, ALL_DOCS, true);
      validateSolrDocCountAndContent(orginalSolrDocs, solrRespDocs);
View Full Code Here

Examples of org.apache.solr.client.solrj.impl.CloudSolrServer

                                             String collectionName) throws Exception {
    String originalUser = getAuthenticatedUser();
    try {
      setAuthenticationUser(solrUserName);
      QueryRequest request = populateCollectionAdminParams(adminOp, collectionName);
      CloudSolrServer solrServer = createNewCloudSolrServer();
      try {
        NamedList<Object> result = solrServer.request(request);
        if (adminOp.compareTo(CollectionAction.CREATE) == 0) {
          // Wait for collection creation to complete.
          waitForRecoveriesToFinish(collectionName, solrServer, false);
        }
      } finally {
        solrServer.shutdown();
      }
    } finally {
      setAuthenticationUser(originalUser);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.