Skip to content

Commit

Permalink
Rewrote the FlowEngine (#256)
Browse files Browse the repository at this point in the history
* Removed unused components. Updated tests.

Improved checkpointing model

Improved model, started with SimPowerSource

implemented FailureModels and Checkpointing

First working version

midway commit

first update

All simulation are now run with a single CPU and single MemoryUnit. multi CPUs are combined into one. This is for performance and explainability.

* fixed merge conflicts

* Updated M3SA paths.

* Fixed small typo
  • Loading branch information
DanteNiewenhuis authored Oct 25, 2024
1 parent 27f5b7d commit 5a365db
Show file tree
Hide file tree
Showing 339 changed files with 4,587 additions and 41,563 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package org.opendc.compute.api

/**
* Flavors define the compute and memory capacity of [Task] instance. To put it simply, a flavor is an available
* Flavors define the compute and memory capacity of [ServiceTask] instance. To put it simply, a flavor is an available
* hardware configuration for a task. It defines the size of a virtual task that can be launched.
*/
public interface Flavor : Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public interface Resource {
*/
public val name: String

/**
* The identifying labels attached to the resource.
*/
public val labels: Map<String, String>

/**
* The non-identifying metadata attached to the resource.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,42 @@ package org.opendc.compute.api
*/
public enum class TaskState {
/**
* Resources are being allocated for the instance. The instance is not running yet.
* A static task is created
*
*/
PROVISIONING,
CREATED,

/**
* A user shut down the instance.
* Resources are being allocated for the instance. The instance is not running yet.
*/
TERMINATED,
PROVISIONING,

/**
* The task instance is booting up or running.
*/
RUNNING,

/**
* The task is in an error state.
* The task is in a failed state.
*/
FAILED,

/**
* The task has been terminated due to too many failures
*
*/
TERMINATED,

/**
* The task has been completed successfully
*
*/
ERROR,
COMPLETED,

/**
* The task has been deleted and cannot be started later on.
* Task has been deleted
*
* @constructor Create empty Deleted
*/
DELETED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import java.time.Instant
public data class CarbonFragment(
var startTime: Long,
var endTime: Long,
var carbonIntensity: Double,
var carbonIntensity: Float,
) {
init {
require(endTime > startTime) {
Expand All @@ -67,7 +67,7 @@ public class CarbonTrace(reports: List<CarbonFragment>? = null) {
return index < numberOfReports
}

public fun getCarbonIntensity(timestamp: Instant): Double {
public fun getCarbonIntensity(timestamp: Instant): Float {
return getCarbonIntensity(timestamp.toEpochMilli())
}

Expand All @@ -79,9 +79,9 @@ public class CarbonTrace(reports: List<CarbonFragment>? = null) {
* @param timestamp
* @return The carbon intensity at the given timestamp in gCO2/kWh
*/
public fun getCarbonIntensity(timestamp: Long): Double {
public fun getCarbonIntensity(timestamp: Long): Float {
if (reports == null) {
return 0.0
return 0.0f
}

var currentFragment: CarbonFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class CarbonTraceLoader {
try {
while (reader.nextRow()) {
val startTime = reader.getInstant(startTimeCol)!!
val carbonIntensity = reader.getDouble(carbonIntensityCol)
val carbonIntensity = reader.getFloat(carbonIntensityCol)

builder.add(startTime, carbonIntensity)
}
Expand Down Expand Up @@ -106,7 +106,7 @@ public class CarbonTraceLoader {
*/
fun add(
startTime: Instant,
carbonIntensity: Double,
carbonIntensity: Float,
) {
fragments.add(
CarbonFragment(startTime.toEpochMilli(), Long.MAX_VALUE, carbonIntensity),
Expand Down
1 change: 0 additions & 1 deletion opendc-compute/opendc-compute-failure/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ dependencies {
implementation(projects.opendcCommon)
implementation(project(mapOf("path" to ":opendc-trace:opendc-trace-api")))
implementation(project(mapOf("path" to ":opendc-simulator:opendc-simulator-compute")))
implementation(project(mapOf("path" to ":opendc-compute:opendc-compute-service")))
implementation(project(mapOf("path" to ":opendc-compute:opendc-compute-simulator")))

api(libs.commons.math3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

package org.opendc.compute.failure.hostfault

import org.opendc.compute.service.ComputeService
import org.opendc.compute.simulator.SimHost
import org.opendc.compute.simulator.host.SimHost
import org.opendc.compute.simulator.service.ComputeService

/**
* Interface responsible for applying the fault to a host.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
package org.opendc.compute.failure.hostfault

import kotlinx.coroutines.delay
import org.opendc.compute.api.ComputeClient
import org.opendc.compute.service.ComputeService
import org.opendc.compute.simulator.SimHost
import org.opendc.simulator.compute.workload.SimWorkload
import org.opendc.compute.simulator.host.SimHost
import org.opendc.compute.simulator.service.ComputeService

/**
* A type of [HostFault] where the hosts are stopped and recover after a given amount of time.
Expand All @@ -38,18 +36,20 @@ public class StartStopHostFault(
victims: List<SimHost>,
faultDuration: Long,
) {
val client: ComputeClient = service.newClient()
val client: ComputeService.ComputeClient = service.newClient()

for (host in victims) {
val tasks = host.instances
val guests = host.getGuests()

val sortedTasks = tasks.sortedBy { it.name }
val snapshots = sortedTasks.map { (it.meta["workload"] as SimWorkload).getSnapshot() }
val snapshots = guests.map { it.virtualMachine!!.getActiveWorkload().getSnapshot() }
val tasks = guests.map { it.task }
host.fail()

for ((task, snapshot) in sortedTasks.zip(snapshots)) {
for ((task, snapshot) in tasks.zip(snapshots)) {
client.rescheduleTask(task, snapshot)
}

print("test")
}

delay(faultDuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import kotlinx.coroutines.launch
import org.opendc.compute.failure.hostfault.HostFault
import org.opendc.compute.failure.hostfault.StartStopHostFault
import org.opendc.compute.failure.victimselector.StochasticVictimSelector
import org.opendc.compute.service.ComputeService
import org.opendc.compute.simulator.SimHost
import org.opendc.compute.simulator.host.SimHost
import org.opendc.compute.simulator.service.ComputeService
import java.time.InstantSource
import java.util.random.RandomGenerator
import kotlin.coroutines.CoroutineContext
Expand Down
Loading

0 comments on commit 5a365db

Please sign in to comment.