調査対象: Cassandra-2.0.1
SimpleStrategy
レプリカを格納するノードを、データセンターおよびラックを意識せずに決める。
複数のデータセンターがある場合でもデータセンターをまたがってレプリカを持つとは限らない。
同一データセンターに複数のラックがある場合でも、ラックをまたがってレプリカを持つとは限らない。
/**
* This class returns the nodes responsible for a given key but does not respect rack awareness.
* Basically returns the RF nodes that lie right next to each other on the ring.
*
* このクラスは、与えられた key の担当ノードを、rack の配置を意識せずに返します。
* 基本的には、リング上に存在する次の RF (Replication Factor..?) ノードを返します。
*/
OldNetworkTopologyStrategy
複数のデータセンターがある場合は、レプリカのひとつを他のデータセンターのノードに格納する。
複数のラックがある場合は、他のレプリカを異なるラックのノードに格納する。
単一データセンターおよび単一ラックの場合は、SimpleStrategy と同じ挙動をする。
/**
* This Replication Strategy returns the nodes responsible for a given key but respects rack awareness.
* It places one replica in a different data center from the first (if there is any such data center),
* the third replica in a different rack in the first datacenter,
* and any remaining replicas on the first unused nodes on the ring.
*
* このレプリケーション・ストラテジーは、与えられた key の担当ノードを、rack の配置を意識して返します。
* もし複数のデータセンターがある場合は、レプリカのひとつを異なるデータセンターに格納しようと試みます。
* 残りのレプリカは、同じデータセンターの異なるラックに格納しようと試みます。
* それでも、設定されたレプリカ数を満たしていない場合は、SimpleStrategy と同様のロジック (データセンターおよびラックを意識しない) でレプリカを格納します。
*/
NetworkTopologyStrategy
各データセンター毎に設定されたレプリカ数を満たすように格納する。
データセンター内に複数のラックがある場合は、ラックをまたがって格納する。
データセンター内に複数のラックがない場合は、同じラックの異なるノードに格納する。
/**
* This Replication Strategy takes a property file that gives the intended replication factor in each datacenter.
* The sum total of the datacenter replication factor values should be equal to the keyspace replication factor.
* <p/>
* So for example, if the keyspace replication factor is 6, the
* datacenter replication factors could be 3, 2, and 1 - so 3 replicas in
* one datacenter, 2 in another, and 1 in another - totalling 6.
* <p/>
* This class also caches the Endpoints and invalidates the cache if there is a change in the number of tokens.
*
* このレプリケーション・ストラテジーは、各データセンターごとに replication factor を設定します。
* データセンターの replication factor 値の合計は、keyspace の replication factory と一致するべきです。
*
* 例えば、この keyspace の replication factor が 6 の場合、データセンターのレプリケーションファクターは 3 と 2 と 1 になります。
* 言い換えれば、3 つのレプリカが 1 つのデータセンターに格納され、2 つのレプリカが他のデータセンターに格納され、1 つのレプリカが他のデータセンターに格納されるので、合計のレプリカ数は 6 になります。
*
* このクラスは endpoint をキャッシュし、さらに token 数に変更が生じた場合にはキャッシュを無効にします。
*/