Skip to content

Commit de3a4e5

Browse files
kristomasetteclinedome-work
authored andcommitted
Add log size to SiriusPersistenceActor
* accessable via a message to the actor * also will be visible via jmx and in the sirius status
1 parent 22601e3 commit de3a4e5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/scala/com/comcast/xfinity/sirius/api/impl/state/SiriusPersistenceActor.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ object SiriusPersistenceActor {
3030
*/
3131
sealed trait LogQuery
3232

33+
case object GetLogSize extends LogQuery
3334
/**
3435
* Message for directly requesting a chunk of the log from a node.
3536
*
@@ -151,6 +152,9 @@ class SiriusPersistenceActor(stateActor: ActorRef,
151152
case GetNextLogSeq =>
152153
sender ! siriusLog.getNextSeq
153154

155+
case GetLogSize =>
156+
sender ! siriusLog.size
157+
154158
// XXX SiriusStateActor responds to writes with a SiriusResult, we don't really want this
155159
// anymore, and it should be eliminated in a future commit
156160
case _: SiriusResult =>
@@ -161,12 +165,12 @@ class SiriusPersistenceActor(stateActor: ActorRef,
161165
*/
162166
trait SiriusPersistenceActorInfoMBean {
163167
def getAveragePersistDuration: Double
168+
def getSiriusLogSize: Long
164169
}
165170

166171
class SiriusPersistenceActorInfo extends SiriusPersistenceActorInfoMBean {
167172

168-
169-
170173
def getAveragePersistDuration = cummWeightedAvg
174+
def getSiriusLogSize = siriusLog.size
171175
}
172176
}

src/test/scala/com/comcast/xfinity/sirius/api/impl/state/SiriusPersistenceActorTest.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class SiriusPersistenceActorTest extends NiceTest {
5353

5454
//TODO: Should have tests for calls to mockSiriusLog
5555

56+
it("should report log size"){
57+
when(mockSiriusLog.size).thenReturn(500L);
58+
59+
val senderProbe = TestProbe()(actorSystem)
60+
senderProbe.send(underTestActor, GetLogSize)
61+
senderProbe.expectMsg(500L)
62+
}
63+
5664
it ("should forward Put's to the state actor") {
5765
when(mockSiriusLog.getNextSeq).thenReturn(0)
5866

0 commit comments

Comments
 (0)