Skip to content

Commit

Permalink
Moved cassandra schema to schema/cassandra (cadence-workflow#1115)
Browse files Browse the repository at this point in the history
Preparation for multiple databases implementations.
  • Loading branch information
mfateev authored Sep 15, 2018
1 parent 1a22c01 commit 42df0fc
Show file tree
Hide file tree
Showing 51 changed files with 26 additions and 26 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ clean:
install-schema: bins
./cadence-cassandra-tool --ep 127.0.0.1 create -k cadence --rf 1
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence setup-schema -v 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence/versioned
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cassandra/cadence/versioned
./cadence-cassandra-tool --ep 127.0.0.1 create -k cadence_visibility --rf 1
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility setup-schema -v 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/visibility/versioned
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/cassandra/visibility/versioned

start: bins
./cadence-server start
Expand All @@ -173,17 +173,17 @@ install-schema-cdc: bins
@echo Setting up cadence_active key space
./cadence-cassandra-tool --ep 127.0.0.1 create -k cadence_active --rf 1
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_active setup-schema -v 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_active update-schema -d ./schema/cadence/versioned
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_active update-schema -d ./schema/cassandra/cadence/versioned
./cadence-cassandra-tool --ep 127.0.0.1 create -k cadence_visibility_active --rf 1
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility_active setup-schema -v 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility_active update-schema -d ./schema/visibility/versioned
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility_active update-schema -d ./schema/cassandra/visibility/versioned
@echo Setting up cadence_standby key space
./cadence-cassandra-tool --ep 127.0.0.1 create -k cadence_standby --rf 1
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_standby setup-schema -v 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_standby update-schema -d ./schema/cadence/versioned
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_standby update-schema -d ./schema/cassandra/cadence/versioned
./cadence-cassandra-tool --ep 127.0.0.1 create -k cadence_visibility_standby --rf 1
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility_standby setup-schema -v 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility_standby update-schema -d ./schema/visibility/versioned
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility_standby update-schema -d ./schema/cassandra/visibility/versioned

start-cdc-active: bins
./cadence-server --zone active start
Expand Down
8 changes: 4 additions & 4 deletions common/persistence/cassandra/cassandraPersistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -2587,7 +2587,7 @@ func (d *cassandraPersistence) createTransferTasks(batch *gocql.Batch, transferT
var taskList string
var scheduleID int64
targetWorkflowID := p.TransferTaskTransferTargetWorkflowID
targetRunID := p.TransferTaskTypeTransferTargetRunID
targetRunID := p.TransferTaskTransferTargetRunID
targetChildWorkflowOnly := false

switch task.GetType() {
Expand All @@ -2606,7 +2606,7 @@ func (d *cassandraPersistence) createTransferTasks(batch *gocql.Batch, transferT
targetWorkflowID = task.(*p.CancelExecutionTask).TargetWorkflowID
targetRunID = task.(*p.CancelExecutionTask).TargetRunID
if targetRunID == "" {
targetRunID = p.TransferTaskTypeTransferTargetRunID
targetRunID = p.TransferTaskTransferTargetRunID
}
targetChildWorkflowOnly = task.(*p.CancelExecutionTask).TargetChildWorkflowOnly
scheduleID = task.(*p.CancelExecutionTask).InitiatedID
Expand All @@ -2616,7 +2616,7 @@ func (d *cassandraPersistence) createTransferTasks(batch *gocql.Batch, transferT
targetWorkflowID = task.(*p.SignalExecutionTask).TargetWorkflowID
targetRunID = task.(*p.SignalExecutionTask).TargetRunID
if targetRunID == "" {
targetRunID = p.TransferTaskTypeTransferTargetRunID
targetRunID = p.TransferTaskTransferTargetRunID
}
targetChildWorkflowOnly = task.(*p.SignalExecutionTask).TargetChildWorkflowOnly
scheduleID = task.(*p.SignalExecutionTask).InitiatedID
Expand Down Expand Up @@ -3385,7 +3385,7 @@ func createTransferTaskInfo(result map[string]interface{}) *p.TransferTaskInfo {
info.TargetWorkflowID = v.(string)
case "target_run_id":
info.TargetRunID = v.(gocql.UUID).String()
if info.TargetRunID == p.TransferTaskTypeTransferTargetRunID {
if info.TargetRunID == p.TransferTaskTransferTargetRunID {
info.TargetRunID = ""
}
case "target_child_workflow_only":
Expand Down
4 changes: 2 additions & 2 deletions common/persistence/cassandra/cassandraPersistenceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
testUser = ""
testPassword = ""
testDatacenter = ""
testSchemaDir = "schema/"
testSchemaDir = "schema/cassandra/"
)

// TestCluster allows executing cassandra operations in testing.
Expand Down Expand Up @@ -80,7 +80,7 @@ func InitTestSuiteWithMetadata(tb *persistencetests.TestBase, options *persisten
panic("nil metadata")
}
if options.SchemaDir == "" {
options.SchemaDir = "schema"
options.SchemaDir = testSchemaDir
}
log := bark.NewLoggerFromLogrus(log.New())
tb.PersistenceTestCluster = &TestCluster{}
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/dataInterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const (
TransferTaskTransferTargetWorkflowID = "20000000-0000-f000-f000-000000000001"
// TransferTaskTransferTargetRunID is the the dummy run ID for transfer tasks of types
// that do not have a target workflow
TransferTaskTypeTransferTargetRunID = "30000000-0000-f000-f000-000000000002"
TransferTaskTransferTargetRunID = "30000000-0000-f000-f000-000000000002"
)

type (
Expand Down
4 changes: 2 additions & 2 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
# THE SOFTWARE.

setup_schema() {
SCHEMA_DIR=$CADENCE_HOME/schema/cadence/versioned
SCHEMA_DIR=$CADENCE_HOME/schema/cassandra/cadence/versioned
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS create -k $KEYSPACE --rf $RF
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $KEYSPACE setup-schema -v 0.0
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $KEYSPACE update-schema -d $SCHEMA_DIR
VISIBILITY_SCHEMA_DIR=$CADENCE_HOME/schema/visibility/versioned
VISIBILITY_SCHEMA_DIR=$CADENCE_HOME/schema/cassandra/visibility/versioned
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS create -k $VISIBILITY_KEYSPACE --rf $RF
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $VISIBILITY_KEYSPACE setup-schema -v 0.0
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $VISIBILITY_KEYSPACE update-schema -d $VISIBILITY_SCHEMA_DIR
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions tools/cassandra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ See https://www.ecyrd.com/cassandracalculator for an easy way to determine how m
## Setting up schema on a new cluster manually
```
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence setup-schema -v 0.0 -- this sets up just the schema version tables with initial version of 0.0
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence/versioned -- upgrades your schema to the latest version
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cassandra/cadence/versioned -- upgrades your schema to the latest version
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility setup-schema -v 0.0 -- this sets up just the schema version tables with initial version of 0.0 for visibility
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/visibility/versioned -- upgrades your schema to the latest version for visibility
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/cassandra/visibility/versioned -- upgrades your schema to the latest version for visibility
```

## Updating schema on an existing cluster
You can only upgrade to a new version after the initial setup done above.

```
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence/versioned -v x.x -y -- executes a dryrun of upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cadence/versioned -v x.x -- actually executes the upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cassandra/cadence/versioned -v x.x -y -- executes a dryrun of upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence update-schema -d ./schema/cassandra/cadence/versioned -v x.x -- actually executes the upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/visibility/versioned -v x.x -y -- executes a dryrun of upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/visibility/versioned -v x.x -- actually executes the upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/cassandra/visibility/versioned -v x.x -y -- executes a dryrun of upgrade to version x.x
./cadence-cassandra-tool -ep 127.0.0.1 -k cadence_visibility update-schema -d ./schema/cassandra/visibility/versioned -v x.x -- actually executes the upgrade to version x.x
```

2 changes: 1 addition & 1 deletion tools/cassandra/updateTask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (s *UpdateSchemaTestSuite) TestDryrun() {
s.Nil(err)
defer client.Close()

dir := "../../schema/cadence/versioned"
dir := "../../schema/cassandra/cadence/versioned"
RunTool([]string{"./tool", "-k", s.keyspace, "-q", "setup-schema", "-v", "0.0"})
RunTool([]string{"./tool", "-k", s.keyspace, "-q", "update-schema", "-d", dir})

Expand Down
4 changes: 2 additions & 2 deletions tools/cassandra/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ func getExpectedVersion(dir string) (string, error) {
// rollback, the code version (expected version) would fall lower than the actual version in
// cassandra.
func VerifyCompatibleVersion(cfg config.Cassandra, rootPath string) error {
schemaPath := path.Join(rootPath, "schema/cadence/versioned")
schemaPath := path.Join(rootPath, "schema/cassandra/cadence/versioned")
if err := checkCompatibleVersion(cfg, cfg.Keyspace, schemaPath); err != nil {
return err
}
schemaPath = path.Join(rootPath, "schema/visibility/versioned")
schemaPath = path.Join(rootPath, "schema/cassandra/visibility/versioned")
return checkCompatibleVersion(cfg, cfg.VisibilityKeyspace, schemaPath)
}

Expand Down
4 changes: 2 additions & 2 deletions tools/cassandra/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ func (s *VersionTestSuite) TestVerifyCompatibleVersion() {
_, filename, _, ok := runtime.Caller(0)
s.True(ok)
root := path.Dir(path.Dir(path.Dir(filename)))
cqlFile := path.Join(root, "schema/cadence/schema.cql")
visCqlFile := path.Join(root, "schema/visibility/schema.cql")
cqlFile := path.Join(root, "schema/cassandra/cadence/schema.cql")
visCqlFile := path.Join(root, "schema/cassandra/visibility/schema.cql")

defer s.createKeyspace(keyspace)()
defer s.createKeyspace(visKeyspace)()
Expand Down

0 comments on commit 42df0fc

Please sign in to comment.