Created
June 27, 2014 23:41
-
-
Save ssk2/b51a786c064ce145b77d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package mesosphere.marathon.tasks | |
import javax.inject.Inject | |
import mesosphere.marathon.MarathonConf | |
import mesosphere.marathon.Protos.MarathonTask | |
import mesosphere.util.Stats | |
import org.apache.log4j.Logger | |
import org.apache.mesos.state.State | |
class TaskTrackerKeysTest @Inject() (state: State, stats: Stats, config: MarathonConf) { | |
private[this] val log = Logger.getLogger(getClass.getName) | |
def createAndWriteTasks(tasks: Int) { | |
for (id <- Range(1, tasks)) { | |
val marathonTask = MarathonTask.newBuilder() | |
.setId(id.toString) | |
.build | |
val oldVar = state.fetch("testvar:" + id.toString).get() | |
// val bytes = new ByteArrayOutputStream() | |
val newVar = oldVar.mutate(marathonTask.toByteArray) | |
state.store(newVar) | |
log.info(s"Wrote state variable for ${id}") | |
} | |
} | |
def expungeTasks(tasks: Int) { | |
for (id <- Range(1, tasks)) { | |
val currentVar = state.fetch("testvar:" + id.toString).get() | |
state.expunge(currentVar) | |
} | |
} | |
def timeRead(tasks: Int) { | |
state.names() | |
for (id <- Range(1, tasks)) { | |
stats.time(s"TaskTrackerKeysTest.read.{$tasks}") { | |
val currentVar = state.fetch("testvar:" + id.toString).get() | |
} | |
} | |
} | |
def testTasks(tasks: Int) { | |
log.info(s"Testing with ${tasks} tasks") | |
createAndWriteTasks(tasks) | |
timeRead(tasks) | |
expungeTasks(tasks) | |
} | |
testTasks(1) | |
testTasks(10) | |
testTasks(100) | |
testTasks(1000) | |
testTasks(10000) | |
} |
Author
ssk2
commented
Jun 27, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment