(strategy, strategyOptions)
| 993 | } |
| 994 | |
| 995 | function 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 |
no test coverage detected