protected override void PreStart() { base.PreStart(); // Get a session to talk to Cassandra with CassandraSnapshotStoreSettings settings = _cassandraExtension.SnapshotStoreSettings; _session = _cassandraExtension.SessionManager.ResolveSession(settings.SessionKey); // Create the keyspace if necessary and always attempt to create the table if (settings.KeyspaceAutocreate) { _session.Execute(string.Format(SnapshotStoreStatements.CreateKeyspace, settings.Keyspace, settings.KeyspaceCreationOptions)); } var fullyQualifiedTableName = string.Format("{0}.{1}", settings.Keyspace, settings.Table); var createTable = string.IsNullOrWhiteSpace(settings.TableCreationProperties) ? string.Format(SnapshotStoreStatements.CreateTable, fullyQualifiedTableName, string.Empty, string.Empty) : string.Format(SnapshotStoreStatements.CreateTable, fullyQualifiedTableName, " AND ", settings.TableCreationProperties); _session.Execute(createTable); // Prepare some statements _writeSnapshot = _session.PrepareFormat(SnapshotStoreStatements.WriteSnapshot, fullyQualifiedTableName); _deleteSnapshot = _session.PrepareFormat(SnapshotStoreStatements.DeleteSnapshot, fullyQualifiedTableName); _selectSnapshot = _session.PrepareFormat(SnapshotStoreStatements.SelectSnapshot, fullyQualifiedTableName); _selectSnapshotMetadata = _session.PrepareFormat(SnapshotStoreStatements.SelectSnapshotMetadata, fullyQualifiedTableName); }
public CassandraExtension(ExtendedActorSystem system) { if (system == null) throw new ArgumentNullException("system"); // Initialize fallback configuration defaults system.Settings.InjectTopLevelFallback(CassandraPersistence.DefaultConfig()); // Get or add the session manager SessionManager = CassandraSession.Instance.Apply(system); // Read config var journalConfig = system.Settings.Config.GetConfig("cassandra-journal"); JournalSettings = new CassandraJournalSettings(journalConfig); var snapshotConfig = system.Settings.Config.GetConfig("cassandra-snapshot-store"); SnapshotStoreSettings = new CassandraSnapshotStoreSettings(snapshotConfig); }