org.apache.solr.common.cloud
Class CloudState

java.lang.Object
  extended by org.apache.solr.common.cloud.CloudState
All Implemented Interfaces:
JSONWriter.Writable

public class CloudState
extends Object
implements JSONWriter.Writable

Immutable state of the cloud. Normally you can get the state by using ZkStateReader.getCloudState().


Constructor Summary
CloudState(Set<String> liveNodes, Map<String,Map<String,Slice>> collectionStates)
           
 
Method Summary
 Set<String> getCollections()
          Get collection names.
 Map<String,Map<String,Slice>> getCollectionStates()
           
 ZkNodeProps getLeader(String collection, String shard)
          Get properties of a shard leader for specific collection.
 Set<String> getLiveNodes()
          Get names of the currently live nodes.
 org.apache.solr.common.cloud.CloudState.RangeInfo getRanges(String collection)
           
 String getShard(int hash, String collection)
          Get shard id for hash.
 String getShardId(String coreNodeName)
          Get shardId for core.
 ZkNodeProps getShardProps(String collection, String coreNodeName)
          Get shard properties or null if shard is not found.
 Slice getSlice(String collection, String slice)
          Get the index Slice for collection.
 Map<String,Slice> getSlices(String collection)
          Get all slices for collection.
 boolean liveNodesContain(String name)
          Check if node is alive.
static CloudState load(byte[] bytes, Set<String> liveNodes)
          Create CloudState from json string that is typically stored in zookeeper.
static CloudState load(SolrZkClient zkClient, Set<String> liveNodes)
          Create CloudState by reading the current state from zookeeper.
 String toString()
           
 void write(JSONWriter jsonWriter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CloudState

public CloudState(Set<String> liveNodes,
                  Map<String,Map<String,Slice>> collectionStates)
Method Detail

getLeader

public ZkNodeProps getLeader(String collection,
                             String shard)
Get properties of a shard leader for specific collection.


getShardProps

public ZkNodeProps getShardProps(String collection,
                                 String coreNodeName)
Get shard properties or null if shard is not found.


getSlice

public Slice getSlice(String collection,
                      String slice)
Get the index Slice for collection.


getSlices

public Map<String,Slice> getSlices(String collection)
Get all slices for collection.


getCollections

public Set<String> getCollections()
Get collection names.


getCollectionStates

public Map<String,Map<String,Slice>> getCollectionStates()

getLiveNodes

public Set<String> getLiveNodes()
Get names of the currently live nodes.


getShardId

public String getShardId(String coreNodeName)
Get shardId for core.

Parameters:
coreNodeName - in the form of nodeName_coreName

liveNodesContain

public boolean liveNodesContain(String name)
Check if node is alive.


getRanges

public org.apache.solr.common.cloud.CloudState.RangeInfo getRanges(String collection)

getShard

public String getShard(int hash,
                       String collection)
Get shard id for hash. This is used when determining which Slice the document is to be submitted to.


toString

public String toString()
Overrides:
toString in class Object

load

public static CloudState load(SolrZkClient zkClient,
                              Set<String> liveNodes)
                       throws org.apache.zookeeper.KeeperException,
                              InterruptedException
Create CloudState by reading the current state from zookeeper.

Throws:
org.apache.zookeeper.KeeperException
InterruptedException

load

public static CloudState load(byte[] bytes,
                              Set<String> liveNodes)
                       throws org.apache.zookeeper.KeeperException,
                              InterruptedException
Create CloudState from json string that is typically stored in zookeeper.

Throws:
org.apache.zookeeper.KeeperException
InterruptedException

write

public void write(JSONWriter jsonWriter)
Specified by:
write in interface JSONWriter.Writable


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.