MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / getTokenToReplicaMapper

Function getTokenToReplicaMapper

lib/metadata/schema-parser.js:995–1016  ·  view source on GitHub ↗
(strategy, strategyOptions)

Source from the content-addressed store, hash-verified

993}
994
995function getTokenToReplicaMapper(strategy, strategyOptions) {
996 if (/SimpleStrategy$/.test(strategy)) {
997 const rf = parseInt(strategyOptions['replication_factor'], 10);
998 if (rf > 1) {
999 return getTokenToReplicaSimpleMapper(rf);
1000 }
1001 }
1002 if (/NetworkTopologyStrategy$/.test(strategy)) {
1003 return getTokenToReplicaNetworkMapper(strategyOptions);
1004 }
1005 //default, wrap in an Array
1006 return (function noStrategy(tokenizer, ring, primaryReplicas) {
1007 const replicas = {};
1008 for (const key in primaryReplicas) {
1009 if (!primaryReplicas.hasOwnProperty(key)) {
1010 continue;
1011 }
1012 replicas[key] = [primaryReplicas[key]];
1013 }
1014 return replicas;
1015 });
1016}
1017
1018/**
1019 * @param {Number} replicationFactor

Callers 1

_createKeyspaceMethod · 0.85

Tested by

no test coverage detected