title: Solrcloud Zookeper Setup : No registered leader was found after waiting for 4000ms , collection: c1 slice: shard2
body: <p>Am using solr 4.10.3, I start solr via embedded jetty server in java. Am trying to configure solrcloud with 2 shards(Leaders). I have an external zookeeper setup, I point to zookeeper instance while starting solr like this.</p>
  
  <pre><code>        System.setProperty("zkHost", "192.168.2.21:2111");
          System.setProperty("numShards", "2");
          System.setProperty("collection.configName", "configuration1");
          System.setProperty("bootstrap_confdir","/conf/zooconf");
  </code></pre>
  
  <p>I have two solr instances running, one in 8983 port &amp; other in 8984. The problem is, am not sure whether both solr nodes are recognized as leader. Since i start solr via java, i cannot view the status in solr admin UI.</p>
  
  <p>Following is my solr.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;solr&gt;
    &lt;solrcloud&gt;
      &lt;str name="host"&gt;192.168.2.21&lt;/str&gt;
      &lt;int name="hostPort"&gt;${hostPort:8984}&lt;/int&gt;
      &lt;str name="hostContext"&gt;${hostContext:solr}&lt;/str&gt;
      &lt;int name="zkClientTimeout"&gt;${solr.zkclienttimeout:30000}&lt;/int&gt;
      &lt;bool name="genericCoreNodeNames"&gt;${genericCoreNodeNames:true}&lt;/bool&gt;
    &lt;/solrcloud&gt;
  
    &lt;shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory"&gt;
      &lt;int name="socketTimeout"&gt;${socketTimeout:120000}&lt;/int&gt;
      &lt;int name="connTimeout"&gt;${connTimeout:15000}&lt;/int&gt;
    &lt;/shardHandlerFactory&gt;
  &lt;/solr&gt;
  </code></pre>
  
  <p>In main method i connect to one of the solr instances(8983) and create the core using the following code snippet.</p>
  
  <pre><code>    CloudSolrServer server = new CloudSolrServer("192.168.2.21:2111"); 
      server.setZkConnectTimeout(15*60*1000);
      server.setZkClientTimeout(15*60*1000);
      server.setParser(new BinaryResponseParser());
      server.setRequestWriter(new BinaryRequestWriter());     
      server.setDefaultCollection("C1");
  
      Create adminRequest = new Create();
      adminRequest.setAction(CoreAdminAction.CREATE);
      adminRequest.setCoreName("C1");
      adminRequest.setCollection("C1");
      adminRequest.setCollectionConfigName("configuration1");
      adminRequest.setDataDir("c:\\setup\somelocation");
      adminRequest.setInstanceDir("c:\\setup\somelocation\C1");
      adminRequest.process(solrServer);
  </code></pre>
  
  <p>When i execute this, C1 is created in only one solr instance(8983). (<strong>isn't the core supposed to be created in two solr instance's data directories.?</strong>). And while adding the document, Following exception is thrown.</p>
  
  <blockquote>
    <p>No registered leader was found after waiting for 4000ms , collection: c1 slice: shard2</p>
  </blockquote>
  
  <p>This is the clusterState while adding document :</p>
  
  <pre><code>live nodes:[192.168.2.21:8984_solr, 192.168.2.21:8983_solr] collections: {
     C1=DocCollection(C1)=   {
        "shards":{
           "shard1":{
              "range":"80000000-ffffffff",
              "state":"active",
              "replicas":{
                 "core_node1":{
                    "state":"active",
                    "core":"C1",
                    "node_name":"192.168.2.21:8983_solr",
                    "base_url":"http://192.168.2.21:8983/solr",
                    "leader":"true"
                 }
              }
           },
           "shard2":{
              "range":"0-7fffffff",
              "state":"active",
              "replicas":{
  
              }
           }
        },
        "maxShardsPerNode":"1",
        "router":{
           "name":"compositeId"
        },
        "replicationFactor":"1",
        "autoAddReplicas":"false",
        "autoCreated":"true"
     }
  }
  </code></pre>
  
  <p>And if i create the core in the other solr instance(8984) before adding the document, it works fine.. Documents are indexed and distributed between 2 shards. Is there anything wrong that i am doing? Please help me out.</p>
  
  <p>Thanks in advance..</p>