Reworked the simulation package
authorChristos KK Loverdos <loverdos@gmail.com>
Thu, 8 Mar 2012 16:32:57 +0000 (18:32 +0200)
committerChristos KK Loverdos <loverdos@gmail.com>
Thu, 8 Mar 2012 16:33:02 +0000 (18:33 +0200)
14 files changed:
src/main/scala/gr/grnet/aquarium/logic/events/ResourceEvent.scala
src/main/scala/gr/grnet/aquarium/user/simulation/AquariumSim.scala
src/main/scala/gr/grnet/aquarium/user/simulation/ClientServiceSim.scala [deleted file]
src/main/scala/gr/grnet/aquarium/user/simulation/ClientSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/ResourceInstanceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/ResourceSim.scala
src/main/scala/gr/grnet/aquarium/user/simulation/StdBandwidthInstanceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/StdBandwidthResourceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/StdDiskspaceInstanceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/StdDiskspaceResourceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/StdVMTimeInstanceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/StdVMTimeResourceSim.scala [new file with mode: 0644]
src/main/scala/gr/grnet/aquarium/user/simulation/UserSim.scala
src/test/scala/gr/grnet/aquarium/user/UserStateComputationsTest.scala

index 85a5a47..6f0afbb 100644 (file)
@@ -269,6 +269,7 @@ case class ResourceEvent(
 
 object ResourceEvent {
   type Details = Map[String, String]
+  final val EmptyDetails: Details = Map()
 
   type ResourceType = String
   type ResourceIdType = String
index bb483a9..ed454da 100644 (file)
@@ -35,7 +35,9 @@
 
 package gr.grnet.aquarium.user.simulation
 
-import gr.grnet.aquarium.logic.accounting.dsl.{DSLResourcesMap, DSLComplexResource, DSLCostPolicy}
+import gr.grnet.aquarium.logic.accounting.dsl.DSLResourcesMap
+import gr.grnet.aquarium.store.ResourceEventStore
+import java.util.Date
 
 
 /**
@@ -44,6 +46,8 @@ import gr.grnet.aquarium.logic.accounting.dsl.{DSLResourcesMap, DSLComplexResour
  * @author Christos KK Loverdos <loverdos@gmail.com>
  */
 
-case class AquariumSim(resources: List[ResourceSim]) {
+case class AquariumSim(resources: List[ResourceSim], resourceEventStore: ResourceEventStore) {
   def resourcesMap = new DSLResourcesMap(resources.map(_.toDSLResource))
+  
+  def newUser(userId: String, userCreationDate: Date) = UserSim(userId, userCreationDate, this)
 }
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/ClientServiceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/ClientServiceSim.scala
deleted file mode 100644 (file)
index 7b8cea3..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright 2011 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *   1. Redistributions of source code must retain the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials
- *      provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-package gr.grnet.aquarium.user.simulation
-
-import gr.grnet.aquarium.util.date.MutableDateCalc
-import gr.grnet.aquarium.logic.events.ResourceEvent
-import java.util.Date
-import gr.grnet.aquarium.logic.accounting.dsl.OnOffCostPolicyValues
-import gr.grnet.aquarium.store.memory.MemStore
-import com.ckkloverdos.maybe.Maybe
-import gr.grnet.aquarium.store.RecordID
-
-/**
- * A simulator for an Aquarium client service, which is an event generator.
- *
- * @author Christos KK Loverdos <loverdos@gmail.com>
- */
-
-case class ClientServiceSim(clientId: String)(implicit uidGen: UIDGenerator) {
-  private[this] val UserProto      = UserSim("", new Date(0), new MemStore().resourceEventStore)
-  private[this] val VMTimeProto    = VMTimeSim(UserProto, "")
-  private[this] val DiskspaceProto = DiskspaceSim(UserProto, "")
-  private[this] val BandwidthProto = BandwidthSim(UserProto, "")
-
-  private[this] var _resources = List[ResourceSim]()
-
-  sealed abstract class ResourceSim(_resource: String, val owner: UserSim, val instanceId: String = "") {
-    def resource = _resource
-  }
-
-  case class VMTimeSim(override val owner: UserSim,
-                       override val instanceId: String = "")
-  extends ResourceSim("vmtime", owner, instanceId) {
-
-    def newON(occurredDate: Date): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val time = occurredDate.getTime
-      val occurredTime = time
-      val receivedTime = time
-      val event = ResourceEvent(
-        id,
-        occurredTime,
-        receivedTime,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        OnOffCostPolicyValues.ON,
-        Map())
-
-      owner._addResourceEvent(event)
-    }
-
-    def newON_OutOfSync(occuredDate: Date, outOfSyncHours: Int): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val occurredDateCalc = new MutableDateCalc(occuredDate)
-      val occurredTime = occurredDateCalc.toMillis
-      val receivedTime = occurredDateCalc.goPlusHours(outOfSyncHours).toMillis
-
-      val event = ResourceEvent(
-        id,
-        occurredTime,
-        receivedTime,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        OnOffCostPolicyValues.ON,
-        Map())
-
-      owner._addResourceEvent(event)
-    }
-
-    def newOFF(occurredDate: Date): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val time = occurredDate.getTime
-      val occurredTime = time
-      val receivedTime = time
-      val event = ResourceEvent(
-        id,
-        occurredTime,
-        receivedTime,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        OnOffCostPolicyValues.OFF,
-        Map())
-
-      owner._addResourceEvent(event)
-    }
-
-    def newOFF_OutOfSync(occuredDate: Date, outOfSyncHours: Int): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val occurredDateCalc = new MutableDateCalc(occuredDate)
-      val occurredTime = occurredDateCalc.toMillis
-      val receivedTime = occurredDateCalc.goPlusHours(outOfSyncHours).toMillis
-
-      val event = ResourceEvent(
-        id,
-        occurredTime,
-        receivedTime,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        OnOffCostPolicyValues.OFF,
-        Map())
-
-      owner._addResourceEvent(event)
-    }
-
-    def newONOFF(occurredDateForON: Date, totalVMTimeInHours: Int): (Maybe[RecordID], Maybe[RecordID]) = {
-      val onID = newON(occurredDateForON)
-      val offDate = new MutableDateCalc(occurredDateForON).goPlusHours(totalVMTimeInHours).toDate
-      val offID = newOFF(offDate)
-
-      (onID, offID)
-    }
-
-    def newONOFF_OutOfSync(occurredDateForON: Date,
-                           totalVMTimeInHours: Int,
-                           outOfSyncONHours: Int,
-                           outOfSyncOFFHours: Int): (Maybe[RecordID], Maybe[RecordID]) = {
-      val onID = newON_OutOfSync(occurredDateForON, outOfSyncONHours)
-      val occurredDateCalcForOFF = new MutableDateCalc(occurredDateForON).goPlusHours(totalVMTimeInHours)
-      val occurredDateForOFF = occurredDateCalcForOFF.toDate
-      val offID = newOFF_OutOfSync(occurredDateForOFF, outOfSyncOFFHours)
-
-      (onID, offID)
-    }
-  }
-
-  case class BandwidthSim(override val owner: UserSim,
-                          override val instanceId: String = "") extends ResourceSim("bandwidth", owner, instanceId) {
-
-    def useBandwidth(occurredDate: Date, megaBytes: Double): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val time = occurredDate.getTime
-      val event = ResourceEvent(
-        id,
-        time,
-        time,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        megaBytes,
-        Map()
-      )
-
-      owner._addResourceEvent(event)
-    }
-  }
-
-  case class DiskspaceSim(override val owner: UserSim,
-                          override val instanceId: String = "") extends ResourceSim("diskspace", owner, instanceId) {
-
-    def consumeMB(occurredDate: Date, megaBytes: Double): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val time = occurredDate.getTime
-      val event = ResourceEvent(
-        id,
-        time,
-        time,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        megaBytes,
-        Map()
-      )
-
-      owner._addResourceEvent(event)
-    }
-    
-    def freeMB(occurredDate: Date, megaBytes: Double): Maybe[RecordID] = {
-      consumeMB(occurredDate, -megaBytes)
-    }
-
-    def consumeMB_OutOfSync(occurredDate: Date, outOfSyncHours: Int, megaBytes: Double): Maybe[RecordID] = {
-      val id = uidGen.nextUID()
-      val occurredDateCalc = new MutableDateCalc(occurredDate)
-      val occurredTime = occurredDateCalc.toMillis
-      val receivedTime = occurredDateCalc.goPlusHours(outOfSyncHours).toMillis
-
-      val event = ResourceEvent(
-        id,
-        occurredTime,
-        receivedTime,
-        owner.userId,
-        clientId,
-        resource,
-        instanceId,
-        "1.0",
-        megaBytes,
-        Map()
-      )
-
-      owner._addResourceEvent(event)
-    }
-
-    def freeMB_OutOfSync(occurredDate: Date, outOfSyncHours: Int, megaBytes: Double): Maybe[RecordID] = {
-      consumeMB_OutOfSync(occurredDate, outOfSyncHours, -megaBytes)
-    }
-  }
-
-  private[simulation]
-  def _addVMTime(vmtime: VMTimeSim): VMTimeSim = {
-    _resources = vmtime :: _resources
-    vmtime
-  }
-
-  private[simulation]
-  def _addDiskspace(diskspace: DiskspaceSim): DiskspaceSim = {
-    _resources = diskspace :: _resources
-    diskspace
-  }
-
-  private[simulation]
-  def _addBandwidth(bandwidth: BandwidthSim): BandwidthSim = {
-    _resources = bandwidth :: _resources
-    bandwidth
-  }
-
-  def qualifyResource(resource: String, instanceId: String) = {
-    "%s/%s/%s".format(clientId, resource, instanceId)
-  }
-
-  def newVMTime(owner: UserSim, _instanceId: String): VMTimeSim = {
-    owner._addServiceClient(this)
-    _addVMTime(VMTimeSim(owner, this.qualifyResource(VMTimeProto.resource, _instanceId)))
-  }
-
-  def newDiskspace(owner: UserSim, _instanceId: String): DiskspaceSim = {
-    owner._addServiceClient(this)
-    _addDiskspace(DiskspaceSim(owner, this.qualifyResource(DiskspaceProto.resource, _instanceId)))
-  }
-
-  def newBandwidth(owner: UserSim, _instanceId: String): BandwidthSim = {
-    owner._addServiceClient(this)
-    _addBandwidth(BandwidthSim(owner, this.qualifyResource(BandwidthProto.resource, _instanceId)))
-  }
-
-  def myResources: List[ResourceSim] = _resources
-}
\ No newline at end of file
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/ClientSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/ClientSim.scala
new file mode 100644 (file)
index 0000000..24aca42
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+/**
+ * A simulator for an aquarium client system.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+case class ClientSim(clientId: String)(implicit val uidGen: UIDGenerator)
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/ResourceInstanceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/ResourceInstanceSim.scala
new file mode 100644 (file)
index 0000000..1de0c8e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import gr.grnet.aquarium.logic.events.ResourceEvent
+
+/**
+ * A simulator for a resource instance.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+class ResourceInstanceSim (val resource: ResourceSim,
+                           val instanceId: String,
+                           val owner: UserSim,
+                           val client: ClientSim) {
+
+  def uidGen = client.uidGen
+
+  def newResourceEvent(occurredMillis: Long,
+                       receivedMillis: Long,
+                       value: Double,
+                       details: ResourceEvent.Details,
+                       eventVersion: String = "1.0") = {
+
+    val event = ResourceEvent(
+      uidGen.nextUID(),
+      occurredMillis,
+      receivedMillis,
+      owner.userId,
+      client.clientId,
+      resource.name,
+      instanceId,
+      eventVersion,
+      value,
+      details
+    )
+
+    owner._addResourceEvent(event)
+  }
+}
+
+object ResourceInstanceSim {
+  def apply(resource: ResourceSim, instanceId: String, owner: UserSim, client: ClientSim) =
+    new ResourceInstanceSim(resource, instanceId, owner, client)
+}
\ No newline at end of file
index 2766985..72dd806 100644 (file)
 
 package gr.grnet.aquarium.user.simulation
 
-import gr.grnet.aquarium.logic.accounting.dsl.{DSLCostPolicy, DSLComplexResource}
+import gr.grnet.aquarium.logic.accounting.dsl.{DiscreteCostPolicy, ContinuousCostPolicy, OnOffCostPolicy, DSLCostPolicy, DSLComplexResource}
 
 
 /**
- * A resource simulator.
+ * A simulator for a resource.
  *
  * @author Christos KK Loverdos <loverdos@gmail.com>
  */
 
-case class ResourceSim(name: String, unit: String, costPolicy: DSLCostPolicy) {
+class ResourceSim(val name: String, val unit: String, val costPolicy: DSLCostPolicy) {
   def toDSLResource = DSLComplexResource(name, unit, costPolicy, "")
+
+  def newInstance(instanceId: String, owner: UserSim, client: ClientSim)=
+    new ResourceInstanceSim(this, instanceId, owner, client)
+}
+
+
+object ResourceSim {
+  def apply(name: String, unit: String, costPolicy: DSLCostPolicy) =
+    new ResourceSim(name, unit, costPolicy)
 }
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/StdBandwidthInstanceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/StdBandwidthInstanceSim.scala
new file mode 100644 (file)
index 0000000..c8435de
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import java.util.Date
+import com.ckkloverdos.maybe.Maybe
+import gr.grnet.aquarium.store.RecordID
+import gr.grnet.aquarium.logic.events.ResourceEvent
+
+/**
+ * A simulator for an instance of the standard `bandwidth` resource.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+case class StdBandwidthInstanceSim(override val instanceId: String,
+                                   override val owner: UserSim,
+                                   override val client: ClientSim)
+extends ResourceInstanceSim(StdBandwidthResourceSim, instanceId, owner, client) {
+  def useBandwidth(occurredDate: Date,
+                   megaBytes: Double,
+                   details: ResourceEvent.Details = Map(),
+                   eventVersion: String = "1.0"): Maybe[RecordID] = {
+
+    newResourceEvent(
+     occurredDate.getTime,
+     occurredDate.getTime,
+     megaBytes,
+     details,
+     eventVersion
+    )
+  }
+}
\ No newline at end of file
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/StdBandwidthResourceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/StdBandwidthResourceSim.scala
new file mode 100644 (file)
index 0000000..ad0dfc3
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import gr.grnet.aquarium.logic.accounting.dsl.DiscreteCostPolicy
+
+/**
+ * A simulator for the standard `bandwidth` resource.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+object StdBandwidthResourceSim extends ResourceSim("bandwidth", "MB/Hr", DiscreteCostPolicy) {
+  override def newInstance(instanceId: String, owner: UserSim, client: ClientSim) =
+    StdBandwidthInstanceSim(instanceId, owner, client)
+}
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/StdDiskspaceInstanceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/StdDiskspaceInstanceSim.scala
new file mode 100644 (file)
index 0000000..63b03de
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import gr.grnet.aquarium.logic.events.ResourceEvent
+import gr.grnet.aquarium.store.RecordID
+import com.ckkloverdos.maybe.Maybe
+import java.util.Date
+import gr.grnet.aquarium.util.date.MutableDateCalc
+
+/**
+ * A simulator for an instance of the standard `diskspace` resource.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+case class StdDiskspaceInstanceSim(override val instanceId: String,
+                                   override val owner: UserSim,
+                                   override val client: ClientSim)
+extends ResourceInstanceSim(StdDiskspaceResourceSim, instanceId, owner, client) {
+  def consumeMB(occurredDate: Date,
+                megaBytes: Double,
+                details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+                eventVersion: String = "1.0"): Maybe[RecordID] = {
+    newResourceEvent(
+      occurredDate.getTime,
+      occurredDate.getTime,
+      megaBytes,
+      details,
+      eventVersion
+    )
+  }
+
+
+  def freeMB(occurredDate: Date,
+             megaBytes: Double,
+             details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+             eventVersion: String = "1.0"): Maybe[RecordID] = {
+
+    consumeMB(occurredDate, -megaBytes)
+  }
+
+  def consumeMB_OutOfSync(occurredDate: Date,
+                          outOfSyncHours: Int,
+                          megaBytes: Double,
+                          details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+                          eventVersion: String = "1.0"): Maybe[RecordID] = {
+
+    val occurredDateCalc = new MutableDateCalc(occurredDate)
+    val occurredTime = occurredDateCalc.toMillis
+    val receivedTime = occurredDateCalc.goPlusHours(outOfSyncHours).toMillis
+
+    newResourceEvent(
+      occurredTime,
+      receivedTime,
+      megaBytes,
+      details,
+      eventVersion
+    )
+  }
+
+  def freeMB_OutOfSync(occurredDate: Date,
+                       outOfSyncHours: Int,
+                       megaBytes: Double,
+                       details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+                       eventVersion: String = "1.0"): Maybe[RecordID] = {
+
+    consumeMB_OutOfSync(occurredDate, outOfSyncHours, -megaBytes)
+  }
+}
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/StdDiskspaceResourceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/StdDiskspaceResourceSim.scala
new file mode 100644 (file)
index 0000000..cf8fa7e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import gr.grnet.aquarium.logic.accounting.dsl.ContinuousCostPolicy
+
+/**
+ * A simulator for the standard `diskspace` resource.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+object StdDiskspaceResourceSim extends ResourceSim("diskspace", "MB/Hr", ContinuousCostPolicy) {
+  override def newInstance(instanceId: String, owner: UserSim, client: ClientSim) =
+    StdDiskspaceInstanceSim(instanceId, owner, client)
+}
+
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/StdVMTimeInstanceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/StdVMTimeInstanceSim.scala
new file mode 100644 (file)
index 0000000..51e2b65
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import gr.grnet.aquarium.logic.accounting.dsl.OnOffCostPolicyValues
+import gr.grnet.aquarium.store.RecordID
+import com.ckkloverdos.maybe.Maybe
+import java.util.Date
+import gr.grnet.aquarium.util.date.MutableDateCalc
+import gr.grnet.aquarium.logic.events.ResourceEvent
+
+/**
+ * A simulator for an instance of the standard `vmtime` resource.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+case class StdVMTimeInstanceSim(override val instanceId: String,
+                                override val owner: UserSim,
+                                override val client: ClientSim)
+extends ResourceInstanceSim(StdVMTimeResourceSim, instanceId, owner, client) {
+
+  def newON(occurredDate: Date,
+            details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+            eventVersion: String = "1.0"): Maybe[RecordID] = {
+    newResourceEvent(
+      occurredDate.getTime,
+      occurredDate.getTime,
+      OnOffCostPolicyValues.ON,
+      details,
+      eventVersion
+    )
+  }
+
+  def newOFF(occurredDate: Date,
+             details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+             eventVersion: String = "1.0"): Maybe[RecordID] = {
+    newResourceEvent(
+      occurredDate.getTime,
+      occurredDate.getTime,
+      OnOffCostPolicyValues.OFF,
+      details,
+      eventVersion
+    )
+  }
+
+  def newONOFF(occurredDateForON: Date, totalVMTimeInHours: Int): (Maybe[RecordID], Maybe[RecordID]) = {
+    val onID = newON(occurredDateForON)
+    val offDate = new MutableDateCalc(occurredDateForON).goPlusHours(totalVMTimeInHours).toDate
+    val offID = newOFF(offDate)
+
+    (onID, offID)
+  }
+
+  def newOFF_OutOfSync(occuredDate: Date,
+                       outOfSyncHours: Int,
+                       details: ResourceEvent.Details = ResourceEvent.EmptyDetails,
+                       eventVersion: String = "1.0"): Maybe[RecordID] = {
+
+    val occurredDateCalc = new MutableDateCalc(occuredDate)
+    val occurredTime = occurredDateCalc.toMillis
+    val receivedTime = occurredDateCalc.goPlusHours(outOfSyncHours).toMillis
+
+    newResourceEvent(
+      occurredTime,
+      receivedTime,
+      OnOffCostPolicyValues.OFF,
+      details,
+      eventVersion
+    )
+  }
+}
diff --git a/src/main/scala/gr/grnet/aquarium/user/simulation/StdVMTimeResourceSim.scala b/src/main/scala/gr/grnet/aquarium/user/simulation/StdVMTimeResourceSim.scala
new file mode 100644 (file)
index 0000000..d1c4197
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ */
+
+package gr.grnet.aquarium.user.simulation
+
+import gr.grnet.aquarium.logic.accounting.dsl.OnOffCostPolicy
+
+/**
+ * A simulator for the standard `vmtime` resource.
+ *
+ * @author Christos KK Loverdos <loverdos@gmail.com>
+ */
+
+object StdVMTimeResourceSim extends ResourceSim("vmtime", "Hr", OnOffCostPolicy) {
+  override def newInstance(instanceId: String, owner: UserSim, client: ClientSim) =
+    StdVMTimeInstanceSim(instanceId, owner, client)
+}
index 12a28cb..8f3dc51 100644 (file)
@@ -46,39 +46,15 @@ import math.Ordering
  * @author Christos KK Loverdos <loverdos@gmail.com>
  */
 
-case class UserSim(userId: String, userCreationDate: Date, resourceEventStore: ResourceEventStore) { userSelf ⇒
-  private[this] var _serviceClients = List[ClientServiceSim]()
+case class UserSim(userId: String, userCreationDate: Date, aquarium: AquariumSim) { userSelf ⇒
+  private[this]
+  def resourceEventStore = aquarium.resourceEventStore
 
-  private[this] val myResourcesGen: () => List[ClientServiceSim#ResourceSim] = () => {
-    for {
-      serviceClient   <- _serviceClients
-      resource <- serviceClient.myResources if(resource.owner == this)
-    } yield {
-      resource
-    }
-  }
-
-  private[simulation]
-  def _addServiceClient(serviceClient: ClientServiceSim): ClientServiceSim = {
-    if(!_serviceClients.exists(_ == serviceClient)) {
-      _serviceClients = serviceClient :: _serviceClients
-    }
-    serviceClient
-  }
-  
   private[simulation]
   def _addResourceEvent(resourceEvent: ResourceEvent): Maybe[RecordID] = {
     resourceEventStore.storeResourceEvent(resourceEvent)
   }
 
-  def myServiceClients: List[ClientServiceSim] = {
-    _serviceClients
-  }
-
-  def myResources: List[ClientServiceSim#ResourceSim] = {
-    myResourcesGen.apply()
-  }
-
   def myResourceEvents: List[ResourceEvent] = {
     resourceEventStore.findResourceEventsByUserId(userId)(None)
   }
index 2055d52..30e3a3f 100644 (file)
@@ -9,7 +9,7 @@ import java.util.Date
 import gr.grnet.aquarium.logic.accounting.{Policy, Accounting}
 import gr.grnet.aquarium.util.{Loggable, ContextualLogger}
 import com.ckkloverdos.maybe.{Just, NoVal}
-import simulation.{AquariumSim, ResourceSim, ConcurrentVMLocalUIDGenerator, ClientServiceSim, UserSim}
+import simulation._
 
 
 /**
@@ -79,25 +79,20 @@ aquariumpolicy:
 
   // TODO: integrate this with the rest of the simulation stuff
   // TODO: since, right now, the resource strings have to be given twice
-  val VMTimeResource    = ResourceSim("vmtime",    "Hr",    OnOffCostPolicy)
-  val DiskspaceResource = ResourceSim("diskspace", "MB/Hr", ContinuousCostPolicy)
-  val BandwidthResource = ResourceSim("bandwidth", "MB/Hr", DiscreteCostPolicy)
-
-  val Aquarium = AquariumSim(List(VMTimeResource, DiskspaceResource, BandwidthResource))
-  val DefaultResourcesMap = Aquarium.resourcesMap
+  val VMTimeResource    = StdVMTimeResourceSim
+  val DiskspaceResource = StdDiskspaceResourceSim
+  val BandwidthResource = StdBandwidthResourceSim
 
   // There are two client services, synnefo and pithos.
   val TheUIDGenerator = new ConcurrentVMLocalUIDGenerator
-  val Synnefo = ClientServiceSim("synnefo")(TheUIDGenerator)
-  val Pithos  = ClientServiceSim("pithos")(TheUIDGenerator)
+  val Synnefo = ClientSim("synnefo")(TheUIDGenerator)
+  val Pithos  = ClientSim("pithos" )(TheUIDGenerator)
 
   @Test
   def testOne: Unit = {
     val clog = ContextualLogger.fromOther(NoVal, logger, "testOne()")
     val StartOfBillingYearDateCalc = new MutableDateCalc(2012, 1, 1)
-//    println("StartOfBillingYearDateCalc = %s".format(StartOfBillingYearDateCalc))
     val UserCreationDateCalc = StartOfBillingYearDateCalc.copy.goMinusMonths(2)
-//    println("UserCreationDateCalc = %s".format(UserCreationDateCalc))
 
     val computer = new UserStateComputations
 
@@ -114,24 +109,26 @@ aquariumpolicy:
     val policyValidToMillis   = StartOfBillingYearDateCalc.copy.goNextYear.toMillis
     policyStore.storePolicyEntry(DefaultPolicy.toPolicyEntry(policyOccurredMillis, policyValidFromMillis, policyValidToMillis))
 
+    val Aquarium = AquariumSim(List(VMTimeResource, DiskspaceResource, BandwidthResource), storeProvider.resourceEventStore)
+    val DefaultResourcesMap = Aquarium.resourcesMap
+
     // A new user is created on 2012-01-15 00:00:00.000
-    val UserCKKL  = UserSim("CKKL", UserCreationDateCalc.toDate, storeProvider.resourceEventStore)
+    val UserCKKL  = Aquarium.newUser("CKKL", UserCreationDateCalc.toDate)
 
     // By convention
     // - synnefo is for VMTime and Bandwidth
     // - pithos is for Diskspace
-    val VMTimeInstance    = Synnefo.newVMTime   (UserCKKL, "VM.1")
-    val BandwidthInstance = Synnefo.newBandwidth(UserCKKL, "3G.1")
-    val DiskInstance      = Pithos .newDiskspace(UserCKKL, "DISK.1")
+    val VMTimeInstance    = StdVMTimeInstanceSim   ("VM.1",   UserCKKL, Synnefo)
+    val BandwidthInstance = StdBandwidthInstanceSim("3G.1",   UserCKKL, Synnefo)
+    val DiskInstance      = StdDiskspaceInstanceSim("DISK.1", UserCKKL, Pithos)
 
     // Let's create our dates of interest
     val vmStartDateCalc = StartOfBillingYearDateCalc.copy.goPlusDays(1).goPlusHours(1)
-//    println("vmStartDateCalc = %s".format(vmStartDateCalc))
     // 2012-01-16 01:00:00.000
     val vmStartDate = vmStartDateCalc.toDate
 
     // Within January, create one VM ON-OFF ...
-    val onOff1_M = VMTimeInstance.newONOFF(vmStartDate, 9)
+    VMTimeInstance.newONOFF(vmStartDate, 9)
 
     val diskConsumptionDateCalc = StartOfBillingYearDateCalc.copy.goPlusHours(3)
     // 2012-01-16 04:00:00.000
@@ -141,8 +138,8 @@ aquariumpolicy:
     val diskConsumptionDate2 = diskConsumptionDateCalc2.toDate
 
     // ... and two diskspace changes
-    val consume1_M = DiskInstance.consumeMB(diskConsumptionDate1, 99)
-    val consume2_M = DiskInstance.consumeMB(diskConsumptionDate2, 23)
+    DiskInstance.consumeMB(diskConsumptionDate1, 99)
+    DiskInstance.consumeMB(diskConsumptionDate2, 23)
 
     // 100MB 3G bandwidth
     val bwDateCalc = diskConsumptionDateCalc2.copy.goPlusDays(1)