Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.

Commit 737a202

Browse files
committed
refactor(supervisors): removes the state machine written inside the supervisors
This commit deletes the state machines in each actor supervisor (error-prone). Theirs codes are not sensitive, so we can easily process each message without to code the different states.
1 parent 6895fd3 commit 737a202

File tree

8 files changed

+7
-39
lines changed

8 files changed

+7
-39
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ script:
66
before_install:
77
- openssl aes-256-cbc -K $encrypted_48ebb0d1c0b9_key -iv $encrypted_48ebb0d1c0b9_iv
88
-in secrets.tar.enc -out secrets.tar -d
9-
- tar xvf secrets.tar
9+
- tar xf secrets.tar
1010
after_success:
1111
- sbt coverageReport
1212
- sbt coverageAggregate

powerapi-cli/src/main/scala/org/powerapi/app/PowerAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ object PowerAPI extends App {
128128
|Build a software-defined power meter. Do not forget to configure correctly the modules (see the documentation).
129129
|
130130
|usage: ./powerapi modules [cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-proces|powerspy|rapl,...] \
131-
| monitor --frequency [ms] --targets [pid, ..., app, ...)|all] --agg [max|min|geomean|logsum|mean|median|stdev|sum|variance] --[console,file [filepath],chart] \
131+
| monitor --frequency [ms] --targets [pid, ..., app, ...|all] --agg [max|min|geomean|logsum|mean|median|stdev|sum|variance] --[console,file [filepath],chart] \
132132
| duration [s]
133133
|
134134
|example: ./powerapi modules cpu-simple monitor --frequency 1000 --targets firefox --agg max --console monitor --targets chrome --agg max --console \

powerapi-core/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pomExtra := {
4444
<developer>
4545
<id>mcolmant</id>
4646
<name>Maxime Colmant</name>
47-
<url>http://researchers.lille.inria.fr/colmant/</url>
47+
<url>http://mcolmant.github.io/</url>
4848
</developer>
4949
<developer>
5050
<id>rouvoy</id>

powerapi-core/src/main/scala/org/powerapi/core/ClockActors.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@ class Clocks(eventBus: MessageBus) extends Supervisor {
108108
}
109109

110110
def receive: PartialFunction[Any, Unit] = LoggingReceive {
111-
case msg: ClockStart => {
112-
start(msg)
113-
context.become(running)
114-
}
115-
} orElse default
116-
117-
/**
118-
* Running state.
119-
*/
120-
def running: Actor.Receive = LoggingReceive {
121111
case msg: ClockStart => start(msg)
122112
case msg: ClockStop => stop(msg)
123113
case msg: ClockStopAll => stopAll(msg)

powerapi-core/src/main/scala/org/powerapi/core/MonitorActors.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,6 @@ class Monitors(eventBus: MessageBus) extends Supervisor with Configuration {
140140
}
141141

142142
def receive: PartialFunction[Any, Unit] = LoggingReceive {
143-
case msg: MonitorStart => {
144-
start(msg)
145-
context.become(running)
146-
}
147-
} orElse default
148-
149-
/**
150-
* Running state.
151-
*/
152-
def running: Actor.Receive = LoggingReceive {
153143
case msg: MonitorStart => start(msg)
154144
case msg: MonitorAggFunction => setAggregatingFunction(msg)
155145
case msg: MonitorStop => stop(msg)

powerapi-core/src/test/scala/org/powerapi/core/ClockSuite.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class ClockSuite(system: ActorSystem) extends UnitTest(system) {
6262
val _system = ActorSystem("ClockSuiteTest1", eventListener)
6363

6464
val frequency = 50.milliseconds
65-
val clocks = _system.actorOf(Props(classOf[Clocks], eventBus), "clocks1")
6665
val clock = _system.actorOf(Props(classOf[ClockChild], eventBus, frequency), "clock1")
6766

6867
EventFilter.warning(occurrences = 1, source = clock.path.toString).intercept({
@@ -89,12 +88,7 @@ class ClockSuite(system: ActorSystem) extends UnitTest(system) {
8988
EventFilter.info(occurrences = 1, source = clock.path.toString).intercept({
9089
clock ! ClockStop("test", frequency)
9190
})(_system)
92-
93-
EventFilter.warning(occurrences = 1, source = clocks.path.toString).intercept({
94-
stopClock(frequency)(eventBus)
95-
})(_system)
96-
97-
Await.result(gracefulStop(clocks, timeout.duration), timeout.duration)
91+
9892
Await.result(gracefulStop(clock, timeout.duration), timeout.duration)
9993
_system.shutdown()
10094
_system.awaitTermination(timeout.duration)

powerapi-core/src/test/scala/org/powerapi/core/MonitorSuite.scala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class MonitorSuite(system: ActorSystem) extends UnitTest(system) {
7373
val targets = List[Target](1)
7474

7575
val monitor = _system.actorOf(Props(classOf[MonitorChild], eventBus, muid, frequency, targets), "monitor1")
76-
val monitors = _system.actorOf(Props(classOf[Monitors], eventBus), "monitors1")
7776

7877
EventFilter.warning(occurrences = 1, source = monitor.path.toString).intercept({
7978
monitor ! MonitorStop("test", muid)
@@ -96,16 +95,11 @@ class MonitorSuite(system: ActorSystem) extends UnitTest(system) {
9695
monitor ! MonitorStop("test", UUID.randomUUID())
9796
})(_system)
9897

99-
EventFilter.warning(occurrences = 1, source = monitors.path.toString).intercept({
100-
stopMonitor(muid)(eventBus)
101-
})(_system)
102-
10398
receiveWhile(10.seconds, idle = 2.seconds) {
10499
case msg: MonitorTick => {}
105100
}
106101

107102
Await.result(gracefulStop(monitor, timeout.duration), timeout.duration)
108-
Await.result(gracefulStop(monitors, timeout.duration), timeout.duration)
109103
_system.shutdown()
110104
_system.awaitTermination(timeout.duration)
111105
}
@@ -458,8 +452,8 @@ class MonitorSuite(system: ActorSystem) extends UnitTest(system) {
458452
val monitor3 = new Monitor(eventBus, reporters)
459453

460454
val display = new PowerDisplay {
461-
def display(timestamp: Long, targets: Set[Target], devices: Set[String], power: Power): Unit = {
462-
testActor ! s"$timestamp, ${targets.mkString(",")}, ${devices.mkString(",")}, $power"
455+
def display(muid: UUID, timestamp: Long, targets: Set[Target], devices: Set[String], power: Power): Unit = {
456+
testActor ! s"$muid, $timestamp, ${targets.mkString(",")}, ${devices.mkString(",")}, $power"
463457
}
464458
}
465459

@@ -469,7 +463,7 @@ class MonitorSuite(system: ActorSystem) extends UnitTest(system) {
469463

470464
monitor.to(display)
471465
publishRawPowerReport(monitor.muid, 1, 15.W, "gpu", tickMock)(eventBus)
472-
expectMsgClass(classOf[String]) should equal(s"${tickMock.timestamp}, ${Process(1)}, gpu, ${15000.mW}")
466+
expectMsgClass(classOf[String]) should equal(s"${monitor.muid}, ${tickMock.timestamp}, ${Process(1)}, gpu, ${15000.mW}")
473467
reporters.actorSelection("user/*") ! Identify(None)
474468
val reporter = expectMsgClass(classOf[ActorIdentity]).getRef
475469

secrets.tar.enc

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)