2 * Copyright 2011 GRNET S.A. All rights reserved.
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials
15 * provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
30 * The views and conclusions contained in the software and
31 * documentation are those of the authors and should not be
32 * interpreted as representing official policies, either expressed
33 * or implied, of GRNET S.A.
36 package gr.grnet.aquarium
39 import logic.accounting.dsl.{DSLResource, DSLAgreement}
40 import collection.mutable
41 import logic.events.WalletEntry
45 * Snapshot of data that are user-related.
47 * @author Christos KK Loverdos <loverdos@gmail.com>
50 sealed trait UserDataSnapshot[T] extends DataSnapshot[T]
52 case class CreditSnapshot(data: Double, snapshotTime: Long) extends UserDataSnapshot[Double]
54 case class AgreementSnapshot(data: DSLAgreement, snapshotTime: Long) extends UserDataSnapshot[DSLAgreement]
56 case class RolesSnapshot(data: List[String], snapshotTime: Long) extends UserDataSnapshot[List[String]]
58 case class PaymentOrdersSnapshot(data: List[AnyRef], snapshotTime: Long) extends UserDataSnapshot[List[AnyRef]]
60 case class OwnedGroupsSnapshot(data: List[String], snapshotTime: Long) extends UserDataSnapshot[List[String]]
62 case class GroupMembershipsSnapshot(data: List[String], snapshotTime: Long) extends UserDataSnapshot[List[String]]
65 * Maintains the current state of resources owned by the user. In order to have a
66 * uniform representation of the resource state for all resource types
67 * (complex or simple) the following convention applies:
69 * * If the resource is complex, then `data.get(AResource)` returns a Map of
70 * `("instance-id" -> current_resource_value)`, as expected.
71 * * If the resource is simple, then `data.get(AResource)` returns
72 * `("1" -> current_resource_value)`. This means that simple resources are
73 * always stored with key 1 as `instance-id`.
75 case class OwnedResourcesSnapshot(data: Map[DSLResource, Map[String, Float]], snapshotTime: Long)
76 extends UserDataSnapshot[Map[DSLResource, Map[String, Float]]]
79 * Bandwidth is counted in MB (?)
81 * @author Christos KK Loverdos <loverdos@gmail.com>
83 case class BandwidthUpSnapshot(data: Double, snapshotTime: Long) extends UserDataSnapshot[Double]
86 * Bandwidth is counted in MB (?)
88 * @author Christos KK Loverdos <loverdos@gmail.com>
90 case class BandwidthDownSnapshot(data: Double, snapshotTime: Long) extends UserDataSnapshot[Double]
93 * Time is counted in seconds (?)
95 * @author Christos KK Loverdos <loverdos@gmail.com>
97 case class VMTimeSnapshot(data: Double, snapshotTime: Long) extends UserDataSnapshot[Double]
101 * Disk space is counted in MB (?)
103 * @author Christos KK Loverdos <loverdos@gmail.com>
105 case class DiskSpaceSnapshot(data: Double, snapshotTime: Long) extends UserDataSnapshot[Double]
108 * A generic exception thrown when errors occur in dealing with user data snapshots
110 * @author Georgios Gousios <gousiosg@gmail.com>
112 class UserDataSnapshotException(msg: String) extends Exception(msg)