diff --git a/tools/scalar-schema/src/scalar_schema/core.clj b/tools/scalar-schema/src/scalar_schema/core.clj index 62f6dce274..81ddc15b13 100644 --- a/tools/scalar-schema/src/scalar_schema/core.clj +++ b/tools/scalar-schema/src/scalar_schema/core.clj @@ -9,24 +9,25 @@ [nil "--dynamo" "Operate for DynamoDB"] [nil "--jdbc" "Operate for a JDBC database"] ["-h" "--host DB_HOST" "Address of Cassandra like IP or URI address of your Cosmos DB account"] - ["-P" "--port DB_PORT" "Port of Cassandra. This option is ignored when Cosmos DB and DynamoDB." + ["-P" "--port DB_PORT" "Port of Cassandra" :parse-fn #(Integer/parseInt %)] - ["-u" "--user USERNAME" "Username of the database. This option is ignored when Cosmos DB and DynamoDB."] - ["-p" "--password PASSWORD" "Password of Cassandra or Cosmos DB account or a JDBC database"] + ["-u" "--user USERNAME" "Username of Cassandra or a JDBC database"] + ["-p" "--password PASSWORD" "Password of a database"] ["-f" "--schema-file SCHEMA_JSON" "Schema file"] - ["-r" "--ru RESOURCE_UNIT" "Base RU for each table on Cosmos DB or DynamoDB. The RU of the coordinator for Scalar DB transaction is specified by this option. This option is ignored when Cassandra." + ["-r" "--ru RESOURCE_UNIT" "Base RU for each table on Cosmos DB or DynamoDB. The RU of the coordinator for Scalar DB transaction is specified by this option" :parse-fn #(Integer/parseInt %)] ["-R" "--replication-factor REPLICATION_FACTOR" - "The number of replicas. This options is ignored when Cosmos DB and DynamoDB." + "The number of replicas for Cassandra" :default 1 :parse-fn #(Integer/parseInt %)] ["-n" "--network-strategy NETWORK_STRATEGY" - "The network topology strategy. SimpleStrategy or NetworkTopologyStrategy. This option is ignored when Cosmos DB and DynamoDB."] + "The network topology strategy for Cassandra. SimpleStrategy or NetworkTopologyStrategy"] ["-D" "--delete-all" "All database will be deleted, if this is enabled."] [nil "--region REGION" "Region where the tool creates tables for DynamoDB"] [nil "--prefix NAMESPACE_PREFIX" "Namespace prefix. The prefix is added to all the namespaces."] ["-j" "--jdbc-url JDBC_URL" "JDBC URL for a JDBC database"] - [nil "--no-scaling" "Disable auto-scaling for Cosmos DB and DynamoDB. This option is ignored when Cassandra and JDBC databases"] - [nil "--no-backup" "Disable continuous backup for DynamoDB. This option is ignored when Cosmos DB and Cassandra and JDBC databases."] + [nil "--no-scaling" "Disable auto-scaling for Cosmos DB and DynamoDB"] + [nil "--no-backup" "Disable continuous backup for DynamoDB"] + [nil "--endpoint-override ENDPOINT_OVERRIDE" "Endpoint with which the DynamoDB SDK should communicate"] [nil "--help"]]) (defn -main [& args] diff --git a/tools/scalar-schema/src/scalar_schema/dynamo.clj b/tools/scalar-schema/src/scalar_schema/dynamo.clj index 3284605ea4..50b24767cf 100644 --- a/tools/scalar-schema/src/scalar_schema/dynamo.clj +++ b/tools/scalar-schema/src/scalar_schema/dynamo.clj @@ -39,10 +39,12 @@ "blob" ScalarAttributeType/B}) (defn- get-client - [user password region] + [user password region endpoint-override] (-> (DynamoDbClient/builder) (.credentialsProvider (dynamo/get-credentials-provider user password)) (.region (Region/of region)) + (#(if endpoint-override + (.endpointOverride % (java.net.URI/create endpoint-override)) %)) .build)) (defn- table-exists? @@ -207,9 +209,9 @@ (log/warn table "doesn't exist")))) (defn make-dynamo-operator - [{:keys [user password region no-scaling no-backup]}] - (let [client (get-client user password region) - scaling-client (scaling/get-scaling-client user password region)] + [{:keys [user password region no-scaling no-backup endpoint-override]}] + (let [client (get-client user password region endpoint-override) + scaling-client (scaling/get-scaling-client user password region endpoint-override)] (reify proto/IOperator (create-table [_ schema opts] (create-table client schema opts) @@ -219,7 +221,8 @@ (when-not no-backup (backup/enable-continuous-backup client schema))) (delete-table [_ schema _] - (scaling/disable-auto-scaling scaling-client schema) + (when-not no-scaling + (scaling/disable-auto-scaling scaling-client schema)) (delete-table client schema)) (close [_ _] (.close client) diff --git a/tools/scalar-schema/src/scalar_schema/dynamo/auto_scaling.clj b/tools/scalar-schema/src/scalar_schema/dynamo/auto_scaling.clj index d9bcb4e6a8..633d220c58 100644 --- a/tools/scalar-schema/src/scalar_schema/dynamo/auto_scaling.clj +++ b/tools/scalar-schema/src/scalar_schema/dynamo/auto_scaling.clj @@ -28,10 +28,12 @@ :index-write ScalableDimension/DYNAMODB_INDEX_WRITE_CAPACITY_UNITS}) (defn get-scaling-client - [user password region] + [user password region endpoint-override] (-> (ApplicationAutoScalingClient/builder) (.credentialsProvider (dynamo/get-credentials-provider user password)) (.region (Region/of region)) + (#(if endpoint-override + (.endpointOverride % (java.net.URI/create endpoint-override)) %)) .build)) (defn- get-resource-id