-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new schema test that creates and drops tables with a configurable
number of fields. Closes #36
- Loading branch information
1 parent
d992530
commit 8bcde4d
Showing
24 changed files
with
147 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...easycassstress/profiles/AllowFiltering.kt → ...asycassstress/workloads/AllowFiltering.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...asycassstress/profiles/BasicTimeSeries.kt → ...sycassstress/workloads/BasicTimeSeries.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/easycassstress/profiles/CountersWide.kt → .../easycassstress/workloads/CountersWide.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/kotlin/com/rustyrazorblade/easycassstress/workloads/CreateDrop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.rustyrazorblade.easycassstress.workloads | ||
|
||
import com.datastax.driver.core.ResultSet | ||
import com.datastax.driver.core.Session | ||
import com.rustyrazorblade.easycassstress.PartitionKey | ||
import com.rustyrazorblade.easycassstress.StressContext | ||
import com.rustyrazorblade.easycassstress.WorkloadParameter | ||
import org.apache.logging.log4j.kotlin.logger | ||
import java.util.concurrent.atomic.AtomicInteger | ||
import java.util.stream.IntStream | ||
import kotlin.collections.ArrayDeque | ||
|
||
/** | ||
* Creates and drops unique tables. | ||
* Most useful when paired with another workload, to determine if | ||
* impact of schema operations on running workloads. | ||
*/ | ||
class CreateDrop : IStressProfile { | ||
@WorkloadParameter("Number of fields in each table.") | ||
var fields = 1 | ||
|
||
@WorkloadParameter("Number of tables to keep active") | ||
var activeTables = 10 | ||
|
||
lateinit var currentTables : ArrayDeque<String> | ||
|
||
var tableCount = AtomicInteger(0) | ||
|
||
var logger = logger() | ||
|
||
override fun prepare(session: Session) { | ||
} | ||
|
||
override fun schema(): List<String> { | ||
return listOf() | ||
} | ||
|
||
override fun getDefaultReadRate() = 0.0 | ||
|
||
|
||
override fun getRunner(context: StressContext): IStressRunner { | ||
currentTables = ArrayDeque(activeTables * 2) | ||
|
||
return object : IStressRunner { | ||
override fun getNextMutation(partitionKey: PartitionKey): Operation { | ||
// consider removing this to be able to test concurrent schema modifications | ||
|
||
synchronized(this) { | ||
if (currentTables.size > activeTables) { | ||
val name = currentTables.removeFirst() | ||
val drop = "DROP TABLE IF EXISTS $name" | ||
return Operation.DDL(statement = drop) | ||
} else { | ||
var next = tableCount.addAndGet(1) | ||
var name = "create_drop_$next" | ||
// create `fields` fields in the table | ||
var fieldsStr = (0 until fields).map { "f${it} text" }.joinToString(", ") | ||
|
||
var create = """CREATE TABLE $name ( id text, $fieldsStr, primary key (id) )""" | ||
logger.debug(create) | ||
currentTables.addLast(name) | ||
|
||
return Operation.DDL(statement = create) | ||
} | ||
} | ||
} | ||
|
||
|
||
override fun getNextSelect(partitionKey: PartitionKey): Operation { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getNextDelete(partitionKey: PartitionKey): Operation { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...lade/easycassstress/profiles/DSESearch.kt → ...ade/easycassstress/workloads/DSESearch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...blade/easycassstress/profiles/KeyValue.kt → ...lade/easycassstress/workloads/KeyValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...razorblade/easycassstress/profiles/LWT.kt → ...azorblade/easycassstress/workloads/LWT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rblade/easycassstress/profiles/Locking.kt → ...blade/easycassstress/workloads/Locking.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...azorblade/easycassstress/profiles/Maps.kt → ...zorblade/easycassstress/workloads/Maps.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ycassstress/profiles/MaterializedViews.kt → ...cassstress/workloads/MaterializedViews.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sstress/profiles/RandomPartitionAccess.kt → ...stress/workloads/RandomPartitionAccess.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lade/easycassstress/profiles/RangeScan.kt → ...ade/easycassstress/workloads/RangeScan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...razorblade/easycassstress/profiles/SAI.kt → ...azorblade/easycassstress/workloads/SAI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.