* Represents cluster and schema information. * The metadata class acts as a internal state of the driver.
| 72 | * The metadata class acts as a internal state of the driver. |
| 73 | */ |
| 74 | class Metadata { |
| 75 | |
| 76 | /** |
| 77 | * Creates a new instance of {@link Metadata}. |
| 78 | * @param {ClientOptions} options |
| 79 | * @param {ControlConnection} controlConnection Control connection used to retrieve information. |
| 80 | */ |
| 81 | constructor(options, controlConnection) { |
| 82 | if (!options) { |
| 83 | throw new errors.ArgumentError('Options are not defined'); |
| 84 | } |
| 85 | |
| 86 | Object.defineProperty(this, 'options', { value: options, enumerable: false, writable: false }); |
| 87 | Object.defineProperty(this, 'controlConnection', { value: controlConnection, enumerable: false, writable: false }); |
| 88 | this.keyspaces = {}; |
| 89 | this.initialized = false; |
| 90 | this._isDbaas = false; |
| 91 | this._schemaParser = schemaParserFactory.getByVersion(options, controlConnection, this.getUdt.bind(this)); |
| 92 | this.log = utils.log; |
| 93 | this._preparedQueries = new PreparedQueries(options.maxPrepared, (...args) => this.log(...args)); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Sets the cassandra version |
| 98 | * @internal |
| 99 | * @ignore |
| 100 | * @param {Array.<Number>} version |
| 101 | */ |
| 102 | setCassandraVersion(version) { |
| 103 | this._schemaParser = schemaParserFactory.getByVersion( |
| 104 | this.options, this.controlConnection, this.getUdt.bind(this), version, this._schemaParser); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Determines whether the cluster is provided as a service. |
| 109 | * @returns {boolean} true when the cluster is provided as a service (DataStax Astra), <code>false<code> when it's a |
| 110 | * different deployment (on-prem). |
| 111 | */ |
| 112 | isDbaas() { |
| 113 | return this._isDbaas; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Sets the product type as DBaaS. |
| 118 | * @internal |
| 119 | * @ignore |
| 120 | */ |
| 121 | setProductTypeAsDbaas() { |
| 122 | this._isDbaas = true; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @ignore |
| 127 | * @param {String} partitionerName |
| 128 | */ |
| 129 | setPartitioner(partitionerName) { |
| 130 | if (/RandomPartitioner$/.test(partitionerName)) { |
| 131 | return this.tokenizer = new t.RandomTokenizer(); |
nothing calls this directly
no outgoing calls
no test coverage detected