// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Jupiter.Implementation; public class ScyllaSettings : IValidatableObject { public string ConnectionString { get; set; } = "Contact Points=localhost,scylla;Default Keyspace=jupiter"; public int MaxSnapshotsPerNamespace { get; set; } = 10; /// /// Set to override the replication strategy used to create keyspace /// Note that this only applies when creating the keyspace /// To modify a existing keyspace see https://docs.datastax.com/en/dse/6.7/dse-admin/datastax_enterprise/operations/opsChangeKSStrategy.html /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Used by serialization")] public Dictionary? KeyspaceReplicationStrategy { get; set; } /// /// Set to override the replication strategy used to create the local keyspace /// Note that this only applies when creating the keyspace /// To modify a existing keyspace see https://docs.datastax.com/en/dse/6.7/dse-admin/datastax_enterprise/operations/opsChangeKSStrategy.html /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Used by serialization")] public Dictionary? LocalKeyspaceReplicationStrategy { get; set; } /// /// Used to configure the load balancing policy to stick to this specified datacenter /// [Required] public string LocalDatacenterName { get; set; } = null!; [Required] public string LocalKeyspaceSuffix { get; set; } = null!; /// /// Max number of connections opened, so the max amount of scylla nodes connected to. /// See https://docs.datastax.com/en/developer/nodejs-driver/4.6/features/connection-pooling/ /// public int MaxConnectionForLocalHost { get; set; } = 8; /// /// Fixed maximum amount of requests in flight for a connection before a new connection is used (thus max requests per node) /// public int MaxRequestsPerConnection { get; set; } = 4096; /// /// The time for a replication log event to live in the incremental state before being deleted, assumption is that the snapshot will have processed the event within this time /// public TimeSpan ReplicationLogTimeToLive { get; set; } = TimeSpan.FromDays(7); /// /// Whether a Cosmos DB Cassandra layer from Azure should be used. /// public bool UseAzureCosmosDB { get; set; } = false; /// /// Set to false to disable use of SSL, this is only used when connecting to a CosmosDB instance /// public bool UseSSL { get; set; } = true; /// /// Toggle to enable reading objects from the object_last_access_time_v2 table /// public bool ListObjectsFromLastAccessTable { get; set; } = true; /// /// Set to update the last access field in the object table, this is legacy and causes extra compaction work on the database /// public bool UpdateLegacyLastAccessField { get; set; } = false; /// /// Read timeout in milliseconds /// Set to -1 to get the default timeout, set to 0 to disable timeouts /// public int ReadTimeout { get; set; } = -1; // use the default timeout value by default /// /// Enable to scan database per shard, this requires setting more information about your cluster /// public bool UsePerShardScanning { get; set; } = false; /// /// Count of cores each nodes has, only used when UsePerShardScanning is set /// [Range(1, 128)] public uint CountOfCoresPerNode { get; set; } = 1; /// /// Count of nodes in the DC, only used when UsePerShardScanning is set /// [Range(1, 64)] public uint CountOfNodes { get; set; } = 1; /// /// Enable to migrate data from blob_index table to blob_index_v2 table /// public bool MigrateFromOldBlobIndex { get; set; } = false; /// /// Enable to use list namespaces from the old table, this can set for a period while migration from old to new table happens /// public bool ListObjectsFromOldNamespaceTable { get; set; } = false; /// /// Set to disable any modifications to cassandra schema from Unreal Cloud DDC /// public bool AvoidSchemaChanges { get; set; } = false; /// /// Runs the record fetching in parallel (up to CountOfNodes) - experimental change that only applies when UsePerShardScanning is active /// public bool AllowParallelRecordFetch { get; set; } = false; /// /// Can be used to disable the cleanup of unused namespaces and buckets /// public bool CleanupOldTrackedState { get; set; } = true; public IEnumerable Validate(ValidationContext validationContext) { List results = new List(); if (UsePerShardScanning) { Validator.TryValidateProperty(CountOfNodes, new ValidationContext(this, null, null) { MemberName = nameof(CountOfNodes) }, results); Validator.TryValidateProperty(CountOfCoresPerNode, new ValidationContext(this, null, null) { MemberName = nameof(CountOfCoresPerNode) }, results); } return results; } }