Skip to content

Commit

Permalink
Documentation update (#261)
Browse files Browse the repository at this point in the history
* Updated a lot of documentation, added a new get-started tutorial.

* Applied Spotless

* Applied Spotless Java

* Added bitbrains workload to site
  • Loading branch information
DanteNiewenhuis authored Nov 5, 2024
1 parent f3e578a commit 0f835d5
Show file tree
Hide file tree
Showing 46 changed files with 752 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package org.opendc.compute.carbon

import org.opendc.simulator.compute.power.CarbonFragmentNew
import org.opendc.simulator.compute.power.CarbonFragment
import org.opendc.trace.Trace
import org.opendc.trace.conv.CARBON_INTENSITY_TIMESTAMP
import org.opendc.trace.conv.CARBON_INTENSITY_VALUE
Expand All @@ -41,14 +41,14 @@ public class CarbonTraceLoader {
/**
* The cache of workloads.
*/
private val cache = ConcurrentHashMap<String, SoftReference<List<CarbonFragmentNew>>>()
private val cache = ConcurrentHashMap<String, SoftReference<List<CarbonFragment>>>()

private val builder = CarbonFragmentNewBuilder()

/**
* Read the metadata into a workload.
*/
private fun parseCarbon(trace: Trace): List<CarbonFragmentNew> {
private fun parseCarbon(trace: Trace): List<CarbonFragment> {
val reader = checkNotNull(trace.getTable(TABLE_CARBON_INTENSITIES)).newReader()

val startTimeCol = reader.resolve(CARBON_INTENSITY_TIMESTAMP)
Expand Down Expand Up @@ -77,7 +77,7 @@ public class CarbonTraceLoader {
/**
* Load the trace with the specified [name] and [format].
*/
public fun get(pathToFile: File): List<CarbonFragmentNew> {
public fun get(pathToFile: File): List<CarbonFragment> {
val trace = Trace.open(pathToFile, "carbon")

return parseCarbon(trace)
Expand All @@ -97,7 +97,7 @@ public class CarbonTraceLoader {
/**
* The total load of the trace.
*/
public val fragments: MutableList<CarbonFragmentNew> = mutableListOf()
public val fragments: MutableList<CarbonFragment> = mutableListOf()

/**
* Add a fragment to the trace.
Expand All @@ -110,7 +110,11 @@ public class CarbonTraceLoader {
carbonIntensity: Double,
) {
fragments.add(
CarbonFragmentNew(startTime.toEpochMilli(), Long.MAX_VALUE, carbonIntensity),
CarbonFragment(
startTime.toEpochMilli(),
Long.MAX_VALUE,
carbonIntensity,
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

package org.opendc.compute.carbon

import org.opendc.simulator.compute.power.CarbonFragmentNew
import org.opendc.simulator.compute.power.CarbonFragment
import java.io.File
import javax.management.InvalidAttributeValueException

/**
* Construct a workload from a trace.
*/
public fun getCarbonFragments(pathToFile: String?): List<CarbonFragmentNew>? {
public fun getCarbonFragments(pathToFile: String?): List<CarbonFragment>? {
if (pathToFile == null) {
return null
}
Expand All @@ -42,7 +42,7 @@ public fun getCarbonFragments(pathToFile: String?): List<CarbonFragmentNew>? {
/**
* Construct a workload from a trace.
*/
public fun getCarbonFragments(file: File): List<CarbonFragmentNew> {
public fun getCarbonFragments(file: File): List<CarbonFragment> {
if (!file.exists()) {
throw InvalidAttributeValueException("The carbon trace cannot be found")
}
Expand Down
6 changes: 3 additions & 3 deletions opendc-experiments/opendc-experiments-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ dependencies {
val createScenarioApp by tasks.creating(CreateStartScripts::class) {
dependsOn(tasks.jar)

applicationName = "OpenDCScenarioRunner"
mainClass.set("org.opendc.experiments.base.runner.ScenarioCli")
applicationName = "OpenDCExperimentRunner"
mainClass.set("org.opendc.experiments.base.runner.ExperimentCli")
classpath = tasks.jar.get().outputs.files + configurations["runtimeClasspath"]
outputDir = project.buildDir.resolve("scripts")
}

// Create custom Scenario distribution
distributions {
main {
distributionBaseName.set("OpenDCScenarioRunner")
distributionBaseName.set("OpenDCExperimentRunner")

contents {
from("README.md")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario
package org.opendc.experiments.base.experiment

import org.opendc.experiments.base.scenario.specs.ExperimentSpec
import org.opendc.experiments.base.scenario.specs.ScenarioSpec
import org.opendc.experiments.base.experiment.specs.ExperimentSpec
import org.opendc.experiments.base.experiment.specs.ScenarioSpec
import java.io.File

private val experimentReader = ExperimentReader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario
package org.opendc.experiments.base.experiment

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
import org.opendc.compute.simulator.telemetry.parquet.ComputeExportConfig
import org.opendc.experiments.base.scenario.specs.ExperimentSpec
import org.opendc.experiments.base.experiment.specs.ExperimentSpec
import java.io.File
import java.io.InputStream
import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario
package org.opendc.experiments.base.experiment

import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.opendc.experiments.base.scenario.specs.ScenarioSpec
import org.opendc.experiments.base.experiment.specs.ScenarioSpec
import java.io.File

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario
package org.opendc.experiments.base.experiment

import org.opendc.compute.simulator.telemetry.parquet.ComputeExportConfig
import org.opendc.experiments.base.scenario.specs.AllocationPolicySpec
import org.opendc.experiments.base.scenario.specs.CheckpointModelSpec
import org.opendc.experiments.base.scenario.specs.ExportModelSpec
import org.opendc.experiments.base.scenario.specs.FailureModelSpec
import org.opendc.experiments.base.scenario.specs.ScenarioTopologySpec
import org.opendc.experiments.base.scenario.specs.WorkloadSpec
import org.opendc.experiments.base.experiment.specs.AllocationPolicySpec
import org.opendc.experiments.base.experiment.specs.CheckpointModelSpec
import org.opendc.experiments.base.experiment.specs.ExportModelSpec
import org.opendc.experiments.base.experiment.specs.FailureModelSpec
import org.opendc.experiments.base.experiment.specs.ScenarioTopologySpec
import org.opendc.experiments.base.experiment.specs.WorkloadSpec

/**
* A data class representing a scenario for a set of experiments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable
import org.opendc.compute.simulator.scheduler.ComputeSchedulerEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable
import org.opendc.common.logger.infoNewLine
Expand Down Expand Up @@ -50,14 +50,14 @@ public data class ExperimentSpec(
val outputFolder: String = "output",
val initialSeed: Int = 0,
val runs: Int = 1,
val exportModels: Set<ExportModelSpec> = setOf(ExportModelSpec()),
val computeExportConfig: ComputeExportConfig = ComputeExportConfig.ALL_COLUMNS,
val maxNumFailures: Set<Int> = setOf(10),
val topologies: Set<ScenarioTopologySpec>,
val workloads: Set<WorkloadSpec>,
val allocationPolicies: Set<AllocationPolicySpec> = setOf(AllocationPolicySpec()),
val exportModels: Set<ExportModelSpec> = setOf(ExportModelSpec()),
val failureModels: Set<FailureModelSpec?> = setOf(null),
val checkpointModels: Set<CheckpointModelSpec?> = setOf(null),
val computeExportConfig: ComputeExportConfig = ComputeExportConfig.ALL_COLUMNS,
val maxNumFailures: Set<Int> = setOf(10),
) {
init {
require(runs > 0) { "The number of runs should always be positive" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

/*
* Copyright (c) 2024 AtLarge Research
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable
import org.opendc.compute.simulator.telemetry.parquet.ComputeExportConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* SOFTWARE.
*/

package org.opendc.experiments.base.scenario.specs
package org.opendc.experiments.base.experiment.specs

import kotlinx.serialization.Serializable
import org.opendc.compute.workload.ComputeWorkload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import com.github.ajalt.clikt.parameters.options.defaultLazy
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.file
import com.github.ajalt.clikt.parameters.types.int
import org.opendc.experiments.base.scenario.getExperiment
import org.opendc.experiments.base.experiment.getExperiment
import java.io.File

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package org.opendc.experiments.base.runner

import org.opendc.experiments.base.scenario.Scenario
import org.opendc.experiments.base.experiment.Scenario
import java.util.concurrent.ForkJoinPool

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import org.opendc.compute.simulator.TaskWatcher
import org.opendc.compute.simulator.service.ComputeService
import org.opendc.compute.simulator.service.ServiceTask
import org.opendc.compute.workload.Task
import org.opendc.experiments.base.scenario.specs.FailureModelSpec
import org.opendc.experiments.base.scenario.specs.createFailureModel
import org.opendc.experiments.base.experiment.specs.FailureModelSpec
import org.opendc.experiments.base.experiment.specs.createFailureModel
import java.time.InstantSource
import java.util.Random
import kotlin.coroutines.coroutineContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import org.opendc.compute.simulator.service.ComputeService
import org.opendc.compute.simulator.telemetry.parquet.ParquetComputeMonitor
import org.opendc.compute.topology.clusterTopology
import org.opendc.compute.workload.ComputeWorkloadLoader
import org.opendc.experiments.base.scenario.Scenario
import org.opendc.experiments.base.scenario.specs.getWorkloadType
import org.opendc.experiments.base.experiment.Scenario
import org.opendc.experiments.base.experiment.specs.getWorkloadType
import org.opendc.simulator.kotlin.runSimulation
import java.io.File
import java.time.Duration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import org.opendc.compute.workload.ComputeWorkloadLoader
import org.opendc.compute.workload.Task
import org.opendc.compute.workload.sampleByLoad
import org.opendc.compute.workload.trace
import org.opendc.experiments.base.experiment.specs.TraceBasedFailureModelSpec
import org.opendc.experiments.base.runner.replay
import org.opendc.experiments.base.scenario.specs.TraceBasedFailureModelSpec
import org.opendc.simulator.kotlin.runSimulation
import java.io.File
import java.util.Random
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import com.github.ajalt.clikt.parameters.options.defaultLazy
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.file
import com.github.ajalt.clikt.parameters.types.int
import org.opendc.experiments.base.experiment.getExperiment
import org.opendc.experiments.base.runner.runExperiment
import org.opendc.experiments.base.scenario.getExperiment
import org.opendc.experiments.m3sa.m3saAnalyze
import org.opendc.experiments.m3sa.scenario.getOutputFolder
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

package org.opendc.experiments.m3sa.runner

import org.opendc.experiments.base.experiment.Scenario
import org.opendc.experiments.base.runner.runScenario
import org.opendc.experiments.base.runner.setupOutputFolderStructure
import org.opendc.experiments.base.scenario.Scenario
import java.util.concurrent.ForkJoinPool

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package org.opendc.experiments.m3sa.scenario

import org.opendc.experiments.base.scenario.ExperimentReader
import org.opendc.experiments.base.experiment.ExperimentReader
import java.io.File

private val experimentReader = ExperimentReader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@

package org.opendc.simulator.compute.power;

public class CarbonFragmentNew {
private long endTime;
/**
* An object holding the carbon intensity during a specific time frame.
* Used by {@link CarbonModel}.
*/
public class CarbonFragment {
private long startTime;
private long endTime;
private double carbonIntensity;

public CarbonFragmentNew(long startTime, long endTime, double carbonIntensity) {
public CarbonFragment(long startTime, long endTime, double carbonIntensity) {
this.setStartTime(startTime);
this.setEndTime(endTime);
this.setCarbonIntensity(carbonIntensity);
Expand Down
Loading

0 comments on commit 0f835d5

Please sign in to comment.