Package org.apache.solr.client.solrj.impl

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


    if (zkHost != null && zkHost.length() > 0) {
      if (collectionName == null || collectionName.length() == 0) {
        throw new MorphlineCompilationException("Parameter 'zkHost' requires that you also pass parameter 'collection'", config);
      }
      try {
        CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost);
        cloudSolrServer.setDefaultCollection(collectionName);
        cloudSolrServer.connect();
        return cloudSolrServer;
      } catch (MalformedURLException e) {
        throw new MorphlineRuntimeException(e);
      }
    } else {
View Full Code Here


    if (zkHost != null && zkHost.length() > 0) {
      if (collectionName == null || collectionName.length() == 0) {
        throw new MorphlineCompilationException("Parameter 'zkHost' requires that you also pass parameter 'collection'", config);
      }
      try {
        CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost);
        cloudSolrServer.setDefaultCollection(collectionName);
        cloudSolrServer.connect();
        return new SolrServerDocumentLoader(cloudSolrServer, batchSize);
      } catch (MalformedURLException e) {
        throw new MorphlineRuntimeException(e);
      }
    } else {
View Full Code Here

   
    this.maxDocumentLength = maxDocumentLength;
   
    try
    {
      CloudSolrServer cloudSolrServer = new CloudSolrServer(zookeeperHosts, new ModifiedLBHttpSolrServer(HttpClientUtil.createClient(null)));
      cloudSolrServer.setZkClientTimeout(zkClientTimeout);
      cloudSolrServer.setZkConnectTimeout(zkConnectTimeout);
      cloudSolrServer.setDefaultCollection(collection);
      // Set the solrj instance we want to use
      solrServer = cloudSolrServer;
    }
    catch (MalformedURLException e)
    {
View Full Code Here

    this.useUrlEncoding = useUrlEncoding;
    this.maxDocumentLength = maxDocumentLength;
   
    try
    {
      CloudSolrServer cloudSolrServer = new CloudSolrServer(zookeeperHosts, new ModifiedLBHttpSolrServer(HttpClientUtil.createClient(null)));
      cloudSolrServer.setZkClientTimeout(zkClientTimeout);
      cloudSolrServer.setZkConnectTimeout(zkConnectTimeout);
      cloudSolrServer.setDefaultCollection(collection);
      // Set the solrj instance we want to use
      solrServer = cloudSolrServer;
    }
    catch (MalformedURLException e)
    {
View Full Code Here

  private static SolrServer cloneCloudSolrServer(SolrServer solrServer, String core) {
    if (VersionUtil.isSolr3XAvailable() || solrServer == null) {
      return null;
    }

    CloudSolrServer cloudServer = (CloudSolrServer) solrServer;
    String zkHost = readField(solrServer, "zkHost");

    Constructor<? extends SolrServer> constructor = (Constructor<? extends SolrServer>) ClassUtils
        .getConstructorIfAvailable(solrServer.getClass(), String.class, LBHttpSolrServer.class);

    CloudSolrServer clone = (CloudSolrServer) BeanUtils.instantiateClass(constructor, zkHost,
        cloneLBHttpSolrServer(cloudServer.getLbServer(), core));

    if (org.springframework.util.StringUtils.hasText(core)) {
      clone.setDefaultCollection(core);
    }
    return clone;
  }
View Full Code Here

     
     
      try {
        LOG.info("Committing live merge...");
        if (options.zkHost != null) {
          CloudSolrServer server = new CloudSolrServer(options.zkHost);
          server.setDefaultCollection(options.collection);
          server.commit();
          server.shutdown();
        } else {
          for (List<String> urls : options.shardUrls) {
            for (String url : urls) {
              // TODO: we should do these concurrently
              HttpSolrServer server = new HttpSolrServer(url);
              server.commit();
              server.shutdown();
            }
          }
        }
        LOG.info("Done committing live merge");
      } catch (Exception e) {
View Full Code Here

    }

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

            // create specified collection if it doesn't exists
            try {
                createCollectionIfNeeded(cloudSolrServer);
            } catch (Throwable t) {
                if (log.isWarnEnabled()) {
                    log.warn("could not create the collection on {}", remoteSolrServerConfiguration.getSolrZkHost(), t);
                }
            }

            cloudSolrServer.setDefaultCollection(remoteSolrServerConfiguration.getSolrCollection());

            // SolrCloud may need some time to sync on collection creation (to spread it over the shards / replicas)
            int i = 0;
            while (i < 3) {
                try {
                    SolrPingResponse ping = cloudSolrServer.ping();
                    if (ping != null && 0 == ping.getStatus()) {
                        return cloudSolrServer;
                    } else {
                        throw new IOException("the found SolrCloud server is not alive");
                    }
View Full Code Here

    return this.solrServer;
  }

  private SolrServer createSolrServer() {
    if (StringUtils.hasText(this.properties.getZkHost())) {
      return new CloudSolrServer(this.properties.getZkHost());
    }
    return new HttpSolrServer(this.properties.getHost());
  }
View Full Code Here

        String solrCollection = "solr_" + System.nanoTime();
        req.setParam("name", solrCollection);
        req.setParam("numShards", "2");
        req.setParam("replicationFactor", "2");
        req.setParam("collection.configName", "myconf");
        CloudSolrServer cloudSolrServer = new CloudSolrServer(host);
        NamedList<Object> request = cloudSolrServer.request(req);
        return request != null && request.get("success") != null;
    }
View Full Code Here

    }

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

        // create specified collection if it doesn't exists
        try {
            createCollectionIfNeeded(cloudSolrServer);
        } catch (Throwable t) {
            if (log.isWarnEnabled()) {
                log.warn("could not create the collection on {}", remoteSolrServerConfiguration.getSolrZkHost(), t);
            }
        }

        cloudSolrServer.setDefaultCollection(remoteSolrServerConfiguration.getSolrCollection());

        // SolrCloud may need some time to sync on collection creation (to spread it over the shards / replicas)
        int i = 0;
        while (i < 3) {
            try {
                SolrPingResponse ping = cloudSolrServer.ping();
                if (ping != null && 0 == ping.getStatus()) {
                    return cloudSolrServer;
                } else {
                    throw new IOException("the found SolrCloud server is not alive");
                }
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.impl.CloudSolrServer

Copyright © 2018 www.massapicom. 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.