Class MiniSolrCloudCluster.Builder

java.lang.Object
org.apache.solr.cloud.MiniSolrCloudCluster.Builder
Enclosing class:
MiniSolrCloudCluster

public static class MiniSolrCloudCluster.Builder extends Object
Builder class for a MiniSolrCloudCluster
  • Constructor Details

    • Builder

      public Builder(int nodeCount, Path baseDir)
      Create a builder
      Parameters:
      nodeCount - the number of nodes in the cluster
      baseDir - a base directory for the cluster
  • Method Details

    • withJettyConfig

      Use a JettyConfig.Builder to configure the cluster's jetty servers
    • withSolrXml

      public MiniSolrCloudCluster.Builder withSolrXml(String solrXml)
      Use the provided string as solr.xml content
    • withSolrXml

      public MiniSolrCloudCluster.Builder withSolrXml(Path solrXml)
      Read solr.xml from the provided path
    • withSecurityJson

      public MiniSolrCloudCluster.Builder withSecurityJson(Path securityJson)
      Configure the specified security.json for the MiniSolrCloudCluster
      Parameters:
      securityJson - The path specifying the security.json file
      Returns:
      the instance of MiniSolrCloudCluster.Builder
    • withSecurityJson

      public MiniSolrCloudCluster.Builder withSecurityJson(String securityJson)
      Configure the specified security.json for the MiniSolrCloudCluster
      Parameters:
      securityJson - The string specifying the security.json configuration
      Returns:
      the instance of MiniSolrCloudCluster.Builder
    • addConfig

      public MiniSolrCloudCluster.Builder addConfig(String configName, Path configPath)
      Upload a collection config before tests start
      Parameters:
      configName - the config name
      configPath - the path to the config files
    • useOtherCollectionConfigSetExecution

      public MiniSolrCloudCluster.Builder useOtherCollectionConfigSetExecution()
      This method makes the MiniSolrCloudCluster use the "other" Collection API execution strategy than it normally would. When some test classes call this method (and some don't) we make sure that a run of multiple tests with a single seed will exercise both code lines (distributed and Overseer based Collection API) so regressions can be spotted faster.

      The real need is for a few tests covering reasonable use cases to call this method. If you're adding a new test, you don't have to call it (but it's ok if you do).

    • withDistributedClusterStateUpdates

      public MiniSolrCloudCluster.Builder withDistributedClusterStateUpdates(boolean distributedCollectionConfigSetApi, boolean distributedClusterStateUpdates)
      Force the cluster Collection and config state API execution as well as the cluster state update strategy to be either Overseer based or distributed. This method can be useful when debugging tests failing in only one of the two modes to have all local runs exhibit the issue, as well obviously for tests that are not compatible with one of the two modes.

      If this method is not called, the strategy being used will be random if the configuration passed to the cluster (solr.xml equivalent) contains a placeholder similar to:

      
       <solrcloud>
         ....
         <str name="distributedClusterStateUpdates">${solr.distributedClusterStateUpdates:false}</str>
         <str name="distributedCollectionConfigSetExecution">${solr.distributedCollectionConfigSetExecution:false}</str>
         ....
       </solrcloud>
       
      For an example of a configuration supporting this setting, see MiniSolrCloudCluster.DEFAULT_CLOUD_SOLR_XML. When a test sets a different solr.xml config (using withSolrXml(java.lang.String)), if the config does not contain the placeholder, the strategy will be defined by the values assigned to useDistributedClusterStateUpdates and useDistributedCollectionConfigSetExecution in CloudConfig.CloudConfigBuilder.
      Parameters:
      distributedCollectionConfigSetApi - When true, Collection and Config Set API commands are executed in a distributed way by nodes. When false, they are executed by Overseer.
      distributedClusterStateUpdates - When true, cluster state updates are handled in a distributed way by nodes. When false, cluster state updates are handled by Overseer.

      If distributedCollectionConfigSetApi is true then this parameter must be true.

    • withProperty

      public MiniSolrCloudCluster.Builder withProperty(String propertyName, String propertyValue)
      Set a cluster property
      Parameters:
      propertyName - the property name
      propertyValue - the property value
    • withMetrics

      public MiniSolrCloudCluster.Builder withMetrics(boolean trackJettyMetrics)
    • formatZkServer

      public MiniSolrCloudCluster.Builder formatZkServer(boolean formatZkServer)
    • configure

      public MiniSolrCloudCluster configure() throws Exception
      Configure and run the MiniSolrCloudCluster
      Throws:
      Exception - if an error occurs on startup
    • build

      public MiniSolrCloudCluster build() throws Exception
      Configure, run and return the MiniSolrCloudCluster
      Throws:
      Exception - if an error occurs on startup
    • withDefaultClusterProperty

      public MiniSolrCloudCluster.Builder withDefaultClusterProperty(String key, String value)
    • withTraceIdGenerationDisabled

      public MiniSolrCloudCluster.Builder withTraceIdGenerationDisabled()
      Disables the default/built-in simple trace ID generation/propagation.

      Tracers are registered as global singletons and if for example a test needs to use a MockTracer or a "real" Tracer, it needs to call this method so that the test setup doesn't accidentally reset the Tracer it wants to use.