summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimAbstractMachine.java41
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimMachineContext.java5
2 files changed, 28 insertions, 18 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimAbstractMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimAbstractMachine.java
index d90a7d6f..d968d884 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimAbstractMachine.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimAbstractMachine.java
@@ -135,6 +135,28 @@ public abstract class SimAbstractMachine implements SimMachine {
}
@Override
+ public void reset() {
+ final FlowGraph graph = getMemory().getInput().getGraph();
+
+ for (SimProcessingUnit cpu : getCpus()) {
+ final Inlet inlet = cpu.getInput();
+ graph.disconnect(inlet);
+ }
+
+ graph.disconnect(getMemory().getInput());
+
+ for (SimNetworkInterface ifx : getNetworkInterfaces()) {
+ ((NetworkAdapter) ifx).disconnect();
+ }
+
+ for (SimStorageInterface storage : getStorageInterfaces()) {
+ StorageDevice impl = (StorageDevice) storage;
+ graph.disconnect(impl.getRead());
+ graph.disconnect(impl.getWrite());
+ }
+ }
+
+ @Override
public final void shutdown() {
if (isClosed) {
return;
@@ -180,24 +202,7 @@ public abstract class SimAbstractMachine implements SimMachine {
* Run the stop procedures for the resources associated with the machine.
*/
protected void doCancel() {
- final FlowGraph graph = getMemory().getInput().getGraph();
-
- for (SimProcessingUnit cpu : getCpus()) {
- final Inlet inlet = cpu.getInput();
- graph.disconnect(inlet);
- }
-
- graph.disconnect(getMemory().getInput());
-
- for (SimNetworkInterface ifx : getNetworkInterfaces()) {
- ((NetworkAdapter) ifx).disconnect();
- }
-
- for (SimStorageInterface storage : getStorageInterfaces()) {
- StorageDevice impl = (StorageDevice) storage;
- graph.disconnect(impl.getRead());
- graph.disconnect(impl.getWrite());
- }
+ reset();
}
@Override
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimMachineContext.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimMachineContext.java
index f6a3bd38..5d08e2b7 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimMachineContext.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/SimMachineContext.java
@@ -68,6 +68,11 @@ public interface SimMachineContext {
List<? extends SimStorageInterface> getStorageInterfaces();
/**
+ * Reset all resources of the machine.
+ */
+ void reset();
+
+ /**
* Shutdown the workload.
*/
void shutdown();