|
Akka/Scala example source code file (NodeMetricsSpec.scala)
The NodeMetricsSpec.scala Akka example source code/* * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package akka.cluster import org.scalatest.WordSpec import org.scalatest.Matchers import akka.actor.Address @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) class NodeMetricsSpec extends WordSpec with Matchers { val node1 = Address("akka.tcp", "sys", "a", 2554) val node2 = Address("akka.tcp", "sys", "a", 2555) "NodeMetrics must" must { "return correct result for 2 'same' nodes" in { (NodeMetrics(node1, 0) sameAs NodeMetrics(node1, 0)) should be(true) } "return correct result for 2 not 'same' nodes" in { (NodeMetrics(node1, 0) sameAs NodeMetrics(node2, 0)) should be(false) } "merge 2 NodeMetrics by most recent" in { val sample1 = NodeMetrics(node1, 1, Set(Metric.create("a", 10, None), Metric.create("b", 20, None)).flatten) val sample2 = NodeMetrics(node1, 2, Set(Metric.create("a", 11, None), Metric.create("c", 30, None)).flatten) val merged = sample1 merge sample2 merged.timestamp should be(sample2.timestamp) merged.metric("a").map(_.value) should be(Some(11)) merged.metric("b").map(_.value) should be(Some(20)) merged.metric("c").map(_.value) should be(Some(30)) } "not merge 2 NodeMetrics if master is more recent" in { val sample1 = NodeMetrics(node1, 1, Set(Metric.create("a", 10, None), Metric.create("b", 20, None)).flatten) val sample2 = NodeMetrics(node1, 0, Set(Metric.create("a", 11, None), Metric.create("c", 30, None)).flatten) val merged = sample1 merge sample2 // older and not same merged.timestamp should be(sample1.timestamp) merged.metrics should be(sample1.metrics) } } } Other Akka source code examplesHere is a short list of links related to this Akka NodeMetricsSpec.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.