diff --git a/app/controllers/ClusterOverviewController.scala b/app/controllers/ClusterOverviewController.scala index b7c072bf4bcdbf4e441682a186d5ca788f81b509..5d253dbeab671cf1603649dbd975b72dac73c14c 100644 --- a/app/controllers/ClusterOverviewController.scala +++ b/app/controllers/ClusterOverviewController.scala @@ -4,20 +4,45 @@ import javax.inject.Inject import controllers.auth.AuthenticationModule import elastic.{ElasticClient, Error} +import models.overview.ClusterOverview import models.{CerebroResponse, Hosts, ShardStats} -import services.overview.DataService import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future class ClusterOverviewController @Inject()(val authentication: AuthenticationModule, val hosts: Hosts, - client: ElasticClient, - data: DataService) extends BaseController { + client: ElasticClient) extends BaseController { def index = process { request => - data.getOverviewData(request.target).map { overview => - CerebroResponse(200, overview) + Future.sequence( + Seq( + client.clusterState(request.target), + client.nodesStats(Seq("jvm","fs","os","process"), request.target), + client.indicesStats(request.target), + client.clusterSettings(request.target), + client.aliases(request.target), + client.clusterHealth(request.target), + client.nodes(Seq("os","jvm"), request.target), + client.main(request.target) + ) + ).map { responses => + val failed = responses.find(_.isInstanceOf[Error]) + failed match { + case Some(f) => CerebroResponse(f.status, f.body) + case None => + val overview = ClusterOverview( + responses(0).body, + responses(1).body, + responses(2).body, + responses(3).body, + responses(4).body, + responses(5).body, + responses(6).body, + responses(7).body + ) + CerebroResponse(200, overview) + } } } @@ -77,7 +102,7 @@ class ClusterOverviewController @Inject()(val authentication: AuthenticationModu def getShardStats = process { request => val index = request.get("index") - val shard = request.get("shard").toInt // TODO ES return as Int? + val shard = request.getInt("shard") val node = request.get("node") Future.sequence( Seq( @@ -99,7 +124,7 @@ class ClusterOverviewController @Inject()(val authentication: AuthenticationModu def relocateShard = process { request => val index = request.get("index") - val shard = request.get("shard").toInt // TODO ES return as Int? + val shard = request.getInt("shard") val from = request.get("from") val to = request.get("to") val server = request.target diff --git a/app/models/ShardStats.scala b/app/models/ShardStats.scala index e16331b4d48c2db805943baa9a40d412625d50f3..85c308431ece2b2f2791c6037130559743f30f41 100644 --- a/app/models/ShardStats.scala +++ b/app/models/ShardStats.scala @@ -9,20 +9,20 @@ object ShardStats { shardStats.getOrElse(getShardRecovery(index, node, shard, recovery).getOrElse(JsNull)) } - private def matchesNode(node: String, shardNode: String): Boolean = { - shardNode.equals(node) || shardNode.startsWith(node) - } - private def getShardStats(index: String, node: String, shard: Int, stats: JsValue): Option[JsValue] = (stats \ "indices" \ index \ "shards" \ shard.toString).asOpt[JsArray] match { - case Some(JsArray(shards)) => shards.find(s => matchesNode(node, (s \ "routing" \ "node").as[String])) + case Some(JsArray(shards)) => shards.collectFirst { + case s if (s \ "routing" \ "node").as[String].equals(node) => s + } case _ => None } + private def getShardRecovery(index: String, node: String, shard: Int, recovery: JsValue): Option[JsValue] = (recovery \ index \ "shards").asOpt[JsArray] match { - case Some(JsArray(recoveries)) => - recoveries.find(r => matchesNode(node, (r \ "target" \ "id").as[String]) && (r \ "id").as[Int] == shard) + case Some(JsArray(recoveries)) => recoveries.collectFirst { + case r if (r \ "target" \ "id").as[String].equals(node) && (r \ "id").as[Int].equals(shard) => r + } case _ => None } diff --git a/app/models/commons/NodeRoles.scala b/app/models/commons/NodeRoles.scala index 9cd27a38a2c0d0be20a38cd25a2de8f46d2f57d8..4f7bb8f476521a3f589690bbe99704543debcfda 100644 --- a/app/models/commons/NodeRoles.scala +++ b/app/models/commons/NodeRoles.scala @@ -48,8 +48,4 @@ object NodeRoles { ) } } - - def apply(roles: String): NodeRoles = - NodeRoles(roles.contains("m"), roles.contains("d"), roles.contains("i")) - } diff --git a/app/models/overview/ClosedIndices.scala b/app/models/overview/ClosedIndices.scala new file mode 100644 index 0000000000000000000000000000000000000000..16a49b9fee9dbcd26fb74895c70eb438fadcab1e --- /dev/null +++ b/app/models/overview/ClosedIndices.scala @@ -0,0 +1,18 @@ +package models.overview + +import play.api.libs.json._ + +object ClosedIndices { + + def apply(clusterState: JsValue) = { + val blocks = (clusterState \ "blocks" \ "indices").asOpt[JsObject].getOrElse(Json.obj()) + blocks.keys.collect { + case index if (blocks \ index \ "4").asOpt[JsObject].isDefined => + Json.obj( + "name" -> JsString(index), + "closed" -> JsBoolean(true), + "special" -> JsBoolean(index.startsWith(".")) + ) + } + } +} diff --git a/app/models/overview/ClusterOverview.scala b/app/models/overview/ClusterOverview.scala new file mode 100644 index 0000000000000000000000000000000000000000..e53e9307c945a0a6ea7cca1a2f607c4726f70c9d --- /dev/null +++ b/app/models/overview/ClusterOverview.scala @@ -0,0 +1,64 @@ +package models.overview + +import play.api.libs.json._ + +object ClusterOverview { + + def apply(clusterState: JsValue, nodesStats: JsValue, indicesStats: JsValue, + clusterSettings: JsValue, aliases: JsValue, clusterHealth: JsValue, + nodesInfo: JsValue, main: JsValue): JsValue = { + + val indices = buildIndices(clusterState, indicesStats, aliases) + + val masterNodeId = (clusterState \ "master_node").as[String] + + val persistentAllocation = (clusterSettings \ "persistent" \ "cluster" \ "routing" \ "allocation" \ "enable").asOpt[String].getOrElse("all") + val transientAllocation = (clusterSettings \ "transient" \ "cluster" \ "routing" \ "allocation" \ "enable").asOpt[String] + val shardAllocation = transientAllocation.getOrElse(persistentAllocation).equals("all") + + JsObject(Seq( + // clusterHealth + "cluster_name" -> (clusterHealth \ "cluster_name").as[JsString], + "status" -> (clusterHealth \ "status").as[JsString], + "number_of_nodes" -> (clusterHealth \ "number_of_nodes").as[JsNumber], + "active_primary_shards" -> (clusterHealth \ "active_primary_shards").as[JsNumber], + "active_shards" -> (clusterHealth \ "active_shards").as[JsNumber], + "relocating_shards" -> (clusterHealth \ "relocating_shards").as[JsNumber], + "initializing_shards" -> (clusterHealth \ "initializing_shards").as[JsNumber], + "unassigned_shards" -> (clusterHealth \ "unassigned_shards").as[JsNumber], + // indicesStats + "docs_count" -> (indicesStats \ "_all" \ "primaries" \ "docs" \ "count").asOpt[JsNumber].getOrElse(JsNumber(0)), + "size_in_bytes" -> (indicesStats \ "_all" \ "total" \ "store" \ "size_in_bytes").asOpt[JsNumber].getOrElse(JsNumber(0)), + "total_indices" -> JsNumber(indices.size), + "closed_indices" -> JsNumber(indices.count { idx => (idx \ "closed").as[Boolean] }), + "special_indices" -> JsNumber(indices.count { idx => (idx \ "special").as[Boolean] }), + "indices" -> JsArray(indices), + "nodes" -> buildNodes(masterNodeId, nodesInfo, nodesStats), + "shard_allocation" -> JsBoolean(shardAllocation) + )) + } + + def buildNodes(masterNodeId: String, nodesInfo: JsValue, nodesStats: JsValue): JsArray = + JsArray( + (nodesInfo \ "nodes").as[JsObject].value.map { + case (id, info) => + val stats = (nodesStats \ "nodes" \ id).as[JsObject] + Node(id, info, stats, masterNodeId) + }.toSeq + ) + + def buildIndices(clusterState: JsValue, indicesStats: JsValue, aliases: JsValue): Seq[JsValue] = { + val routingTable = (clusterState \ "routing_table" \ "indices").as[JsObject] + val routingNodes = (clusterState \ "routing_nodes" \ "nodes").as[JsObject] + val openIndices = routingTable.value.map { case (index, shards) => + val indexStats = (indicesStats \ "indices" \ index).asOpt[JsObject].getOrElse(Json.obj()) + val indexAliases = (aliases \ index \ "aliases").asOpt[JsObject].getOrElse(Json.obj()) // 1.4 < does not return aliases obj + + Index(index, indexStats, shards, indexAliases, routingNodes) + }.toSeq + + val closedIndices = ClosedIndices(clusterState) + openIndices ++ closedIndices + } + +} diff --git a/app/models/overview/Index.scala b/app/models/overview/Index.scala new file mode 100644 index 0000000000000000000000000000000000000000..d44a9b73f523adc0d22edf255c16ec4aba453f8a --- /dev/null +++ b/app/models/overview/Index.scala @@ -0,0 +1,49 @@ +package models.overview + +import play.api.libs.json._ + +object Index { + + def apply(name: String, stats: JsValue, shards: JsValue, aliases: JsObject, routingNodes: JsValue): JsValue = { + + val unassignedShards = (shards \ "shards").as[JsObject].values.flatMap { + case JsArray(shards) => + shards.filter { shard => + (shard \ "node").asOpt[String].isEmpty + } + case _ => Nil + } + + val shardsAllocation = routingNodes.as[JsObject].value.mapValues { + case JsArray(shards) => JsArray(shards.filter { shard => (shard \ "index").as[String].equals(name) }) + case _ => JsArray() + }.toSeq ++ Seq("unassigned" -> JsArray(unassignedShards.toSeq)) + + val numShards = (shards \ "shards").as[JsObject].keys.size + val numReplicas = (shards \ "shards" \ "0").as[JsArray].value.size - 1 + + val special = name.startsWith(".") + + JsObject(Seq( + "name" -> JsString(name), + "closed" -> JsBoolean(false), + "special" -> JsBoolean(special), + "unhealthy" -> JsBoolean(unhealthyIndex(shardsAllocation)), + "doc_count" -> (stats \ "primaries" \ "docs" \ "count").asOpt[JsNumber].getOrElse(JsNumber(0)), + "deleted_docs" -> (stats \ "primaries" \ "docs" \ "deleted").asOpt[JsNumber].getOrElse(JsNumber(0)), + "size_in_bytes" -> (stats \ "primaries" \ "store" \ "size_in_bytes").asOpt[JsNumber].getOrElse(JsNumber(0)), + "total_size_in_bytes" -> (stats \ "total" \ "store" \ "size_in_bytes").asOpt[JsNumber].getOrElse(JsNumber(0)), + "aliases" -> JsArray(aliases.keys.map(JsString(_)).toSeq), // 1.4 < does not return aliases obj + "num_shards" -> JsNumber(numShards), + "num_replicas" -> JsNumber(numReplicas), + "shards" -> JsObject(shardsAllocation) + )) + } + + private def unhealthyIndex(shardAllocation: Seq[(String, JsArray)]): Boolean = + shardAllocation.exists { + case ("unassigned", _) => true + case (_, JsArray(shards)) => shards.exists(!_.\("state").as[String].equals("STARTED")) + } + +} diff --git a/app/models/overview/Node.scala b/app/models/overview/Node.scala new file mode 100644 index 0000000000000000000000000000000000000000..0086ee53fc7bce8d2acaf1761030ec076a9726d7 --- /dev/null +++ b/app/models/overview/Node.scala @@ -0,0 +1,67 @@ +package models.overview + +import models.commons.NodeRoles +import play.api.libs.json._ + +object Node { + + def apply(id: String, info: JsValue, stats: JsValue, masterNodeId: String) = { + val nodeRoles = NodeRoles(info) + + + // AWS nodes return no host/ip info + val host = (info \ "host").asOpt[JsString].getOrElse(JsNull) + val ip = (info \ "ip").asOpt[JsString].getOrElse(JsNull) + val jvmVersion = (info \ "jvm" \ "version").asOpt[JsString].getOrElse(JsNull) + + Json.obj( + "id" -> JsString(id), + "current_master" -> JsBoolean(id.equals(masterNodeId)), + "name" -> (info \ "name").as[JsString], + "host" -> host, + "ip" -> ip, + "es_version" -> (info \ "version").as[JsString], + "jvm_version" -> jvmVersion, + "load_average" -> loadAverage(stats), + "available_processors" -> (info \ "os" \ "available_processors").as[JsNumber], + "cpu_percent" -> cpuPercent(stats), + "master" -> JsBoolean(nodeRoles.master), + "data" -> JsBoolean(nodeRoles.data), + "coordinating" -> JsBoolean(nodeRoles.coordinating), + "ingest" -> JsBoolean(nodeRoles.ingest), + "heap" -> Json.obj( + "used" -> (stats \ "jvm" \ "mem" \ "heap_used_in_bytes").as[JsNumber], + "committed" -> (stats \ "jvm" \ "mem" \ "heap_committed_in_bytes").as[JsNumber], + "used_percent" -> (stats \ "jvm" \ "mem" \ "heap_used_percent").as[JsNumber], + "max" -> (stats \ "jvm" \ "mem" \ "heap_max_in_bytes").as[JsNumber] + ), + "disk" -> disk(stats) + ) + } + + def disk(stats: JsValue): JsObject = { + val totalInBytes = (stats \ "fs" \ "total" \ "total_in_bytes").asOpt[Long].getOrElse(0l) + val freeInBytes = (stats \ "fs" \ "total" \ "free_in_bytes").asOpt[Long].getOrElse(0l) + val usedPercent = 100 - (100 * (freeInBytes.toFloat / totalInBytes.toFloat)).toInt + Json.obj( + "total" -> JsNumber(totalInBytes), + "free" -> JsNumber(freeInBytes), + "used_percent" -> JsNumber(usedPercent) + ) + } + + def loadAverage(nodeStats: JsValue): JsNumber = { + val load = (nodeStats \ "os" \ "cpu" \ "load_average" \ "1m").asOpt[Float].getOrElse(// 5.X + (nodeStats \ "os" \ "load_average").asOpt[Float].getOrElse(0f) // FIXME: 2.X + ) + JsNumber(BigDecimal(load.toDouble)) + } + + def cpuPercent(nodeStats: JsValue): JsNumber = { + val cpu = (nodeStats \ "os" \ "cpu" \ "percent").asOpt[Int].getOrElse(// 5.X + (nodeStats \ "os" \ "cpu_percent").asOpt[Int].getOrElse(0) // FIXME 2.X + ) + JsNumber(BigDecimal(cpu)) + } + +} diff --git a/app/services/overview/ClusterOverview.scala b/app/services/overview/ClusterOverview.scala deleted file mode 100644 index d6a08aeba0fce6e2013c6c7ee81a3627bf4221f4..0000000000000000000000000000000000000000 --- a/app/services/overview/ClusterOverview.scala +++ /dev/null @@ -1,93 +0,0 @@ -package services.overview - -import _root_.util.DataSize -import play.api.libs.json._ - -import scala.collection.mutable - -object ClusterOverview { - - def apply(clusterSettings: JsValue, health: JsValue, - nodes: JsValue, indices: JsValue, shards: JsValue, aliases: JsValue): JsValue = { - - val persistentAllocation = (clusterSettings \ "persistent" \ "cluster" \ "routing" \ "allocation" \ "enable").asOpt[String].getOrElse("all") - val transientAllocation = (clusterSettings \ "transient" \ "cluster" \ "routing" \ "allocation" \ "enable").asOpt[String] - val shardAllocation = transientAllocation.getOrElse(persistentAllocation).equals("all") - - def updateShardState(state: String) = __.json.update( - __.read[JsObject].map{ o => o ++ Json.obj( "state" -> JsString(state) ) } - ) - - val unhealthyIndices = mutable.Set[String]() - - val shardMap = (shards.as[JsArray].value.flatMap { - case shard => - val index = (shard \ "index").as[String] - val node = (shard \ "node").asOpt[String].getOrElse("unassigned") - // TODO: prune node/index from shard? - if (node.equals("unassigned")) - unhealthyIndices.add(index) - if ((shard \ "state").as[String].equals("RELOCATING")) { - unhealthyIndices.add(index) - val relocation = node.split(" ") - val origin = relocation.head - val target = relocation.last - val initializingShard = shard.transform(updateShardState("INITIALIZING")) match { - case JsSuccess(data, _) => data - case JsError(error) => throw new RuntimeException("boom") // TODO proper exception - } - Seq( - (index -> (origin -> shard)), - (index -> (target -> initializingShard)) - ) - } else { - Seq(index -> (node -> shard)) - } - }).groupBy(_._1).mapValues(v => v.map(_._2).groupBy(_._1).mapValues(v => JsArray(v.map(_._2)))) - - val aliasesMap = aliases.as[JsArray].value.map { - alias => (alias \ "index").as[String] -> (alias \ "alias").as[JsValue] - }.groupBy(_._1).mapValues(a => JsArray(a.map(_._2))) - - def addAliasAndShards(index: String) = __.json.update { - val aliases = JsObject(Map("aliases" -> aliasesMap.getOrElse(index, JsNull))) - val shards = JsObject(Map("shards" -> JsObject(shardMap.getOrElse(index, Map())))) - val healthy = JsObject(Map("unhealthy" -> JsBoolean(unhealthyIndices.contains(index)))) - __.read[JsObject].map { o => o ++ aliases ++ shards ++ healthy} - } - - var sizeInBytes = 0l - var docsCount = 0 - var closedIndices = 0 - var specialIndices = 0 - - val withIndices = indices.as[JsArray].value.map { index => - val indexName = (index \ "index").as[String] - // TODO if ES returned a number - docsCount = docsCount + (index \ "docs.count").asOpt[String].map(_.toInt).getOrElse(0) - // TODO if ES returned in bytes... - sizeInBytes = sizeInBytes + (index \ "store.size").asOpt[String].map(DataSize.apply).getOrElse(0l) - if ((index \ "status").as[String].equals("close")) - closedIndices = closedIndices + 1 - if (indexName.startsWith(".")) - specialIndices = specialIndices + 1 - - index.transform(addAliasAndShards(indexName)) match { - case JsSuccess(data, _) => data - case JsError(error) => throw new RuntimeException("boom") // TODO proper exception - } - } - - JsObject(Seq( - "health" -> health, - "indices" -> JsArray(withIndices), - "nodes" -> nodes, - "shard_allocation" -> JsBoolean(shardAllocation), - "docs_count" -> JsNumber(BigDecimal(docsCount)), - "size_in_bytes" -> JsNumber(BigDecimal(sizeInBytes)), - "closed_indices" -> JsNumber(BigDecimal(closedIndices)), - "special_indices" -> JsNumber(BigDecimal(specialIndices)) - )) - } - -} diff --git a/app/services/overview/DataService.scala b/app/services/overview/DataService.scala deleted file mode 100644 index f5cd58f380135384b59c31fdee22803c819e7def..0000000000000000000000000000000000000000 --- a/app/services/overview/DataService.scala +++ /dev/null @@ -1,62 +0,0 @@ -package services.overview - -import com.google.inject.Inject -import elastic.{ElasticClient, Error} -import models.ElasticServer -import play.api.libs.json.JsValue -import services.exception.RequestFailedException - -import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.Future - -class DataService @Inject()(client: ElasticClient) { - - val NodesHeaders = Seq( - "id", - "ip", - "version", - "jdk", - "disk.total", - "disk.avail", - "disk.used_percent", - "heap.current", - "heap.percent", - "heap.max", - "cpu", - "load_1m", - "node.role", - "master", - "name" - ) - - val apis = Seq( - "_cluster/settings", - "_cluster/health", - s"_cat/nodes?h=${NodesHeaders.mkString(",")}&format=json", - "_cat/indices?format=json", - "_cat/shards?format=json&h=index,shard,prirep,node,state", - "_cat/aliases?h=alias,index&format=json" - ) - - def getOverviewData(target: ElasticServer): Future[JsValue] = { - Future.sequence( - apis.map(client.executeRequest("GET", _, None, target)) - ).map { responses => - responses.zipWithIndex.find(_._1.isInstanceOf[Error]) match { - case Some((response, idx)) => - throw RequestFailedException(apis(idx), response.status, response.body.toString) - - case None => - ClusterOverview( - responses(0).body, - responses(1).body, - responses(2).body, - responses(3).body, - responses(4).body, - responses(5).body - ) - } - } - } - -} diff --git a/app/services/overview/Index.scala b/app/services/overview/Index.scala deleted file mode 100644 index 1f43dbac87a5d8baeb65dc3c92ae42a854759ea4..0000000000000000000000000000000000000000 --- a/app/services/overview/Index.scala +++ /dev/null @@ -1,44 +0,0 @@ -package services.overview - -import play.api.libs.json._ - -object Index { - - def apply(data: JsValue, shardsData: Seq[JsValue], aliases: Seq[JsString]): JsValue = { - - val special = (data \ "index").as[String].startsWith(".") - - val shards = shardsData.map { - case shard => - val node = (shard \ "node").asOpt[String].getOrElse("unassigned") - node -> Json.obj( - "shard" -> (shard \ "shard").as[JsValue], - "primary" -> (shard \ "prirep").asOpt[String].contains("p"), - "index" -> (shard \ "index").as[JsValue], - "state" -> (shard \ "state").as[JsValue] - ) - }.groupBy(_._1).mapValues(v => JsArray(v.map(_._2))) - - JsObject(Seq( - "name" -> (data \ "index").as[JsValue], - "closed" -> JsBoolean((data \ "status").as[String].equals("close")), - "special" -> JsBoolean(special), - "unhealthy" -> JsBoolean(unhealthyIndex(shards)), - "doc_count" -> (data \ "docs.count").as[JsValue], - "deleted_docs" -> (data \ "docs.deleted").as[JsValue], - "size_in_bytes" -> (data \ "pri.store.size").as[JsValue], - "total_size_in_bytes" -> (data \ "store.size").as[JsValue], - "aliases" -> JsArray(aliases), - "num_shards" -> (data \ "pri").as[JsValue], - "num_replicas" -> (data \ "rep").as[JsValue], - "shards" -> JsObject(shards) - )) - } - - private def unhealthyIndex(shards: Map[String, JsArray]): Boolean = - shards.exists { - case ("unassigned", _) => true - case (_, JsArray(s)) => s.exists(!_.\("state").as[String].equals("STARTED")) - } - -} diff --git a/app/services/overview/Node.scala b/app/services/overview/Node.scala deleted file mode 100644 index 28356834357575db56eb996db6db204691ffb071..0000000000000000000000000000000000000000 --- a/app/services/overview/Node.scala +++ /dev/null @@ -1,47 +0,0 @@ -package services.overview - -import models.commons.NodeRoles -import play.api.libs.json._ - -object Node { - - def apply(data: JsValue) = { - - val nodeRoles = NodeRoles((data \ "node.role").as[String]) - - // Not available on AWS - val ip = (data \ "ip").asOpt[JsValue].getOrElse(JsNull) - val jdk = (data \ "jdk").asOpt[JsValue].getOrElse(JsNull) - - // Not available on ES < 5.5 - val load = (data \ "load_1m").asOpt[JsValue].getOrElse(JsNull) - val diskTotal = (data \ "disk.total").asOpt[JsValue].getOrElse(JsNull) - val diskPercent = (data \ "disk.used_percent").asOpt[JsValue].getOrElse(JsNull) - - Json.obj( - "id" -> (data \ "id").as[JsValue], - "current_master" -> JsBoolean((data \ "master").as[String].equals("*")), - "name" -> (data \ "name").as[JsValue], - "ip" -> ip, - "jvm_version" -> jdk, - "es_version" -> (data\ "version").as[JsValue], - "load_1m" -> load, - "cpu" -> (data \ "cpu").as[JsValue], - "master" -> JsBoolean(nodeRoles.master), - "data" -> JsBoolean(nodeRoles.data), - "coordinating" -> JsBoolean(nodeRoles.coordinating), - "ingest" -> JsBoolean(nodeRoles.ingest), - "heap" -> Json.obj( - "current" -> (data \ "heap.current").as[JsValue], - "percent" -> (data \ "heap.percent").as[JsValue], - "max" -> (data \ "heap.max").as[JsValue] - ), - "disk" -> Json.obj( - "total" -> diskTotal, - "avail" -> (data \ "disk.avail").as[JsValue], - "percent" -> diskPercent - ) - ) - } - -} diff --git a/app/util/DataSize.scala b/app/util/DataSize.scala deleted file mode 100644 index 3110950b9071ec95cf997e4e9545f747ad1b10b2..0000000000000000000000000000000000000000 --- a/app/util/DataSize.scala +++ /dev/null @@ -1,20 +0,0 @@ -package util - -object DataSize { - - final val Units = Seq( - ("pb" -> 1024 * 1024 * 1024 * 1024 * 1024), - ("tb" -> 1024 * 1024 * 1024 * 1024), - ("gb" -> 1024 * 1024 * 1024), - ("mb" -> 1024 * 1024), - ("kb" -> 1024), - ("b" -> 1) - ) - - def apply(size: String): Long = { - Units.collectFirst { - case unit if (size.endsWith(unit._1)) => (size.substring(0, size.indexOf(unit._1)).toFloat * unit._2).toLong - }.getOrElse(0l) - } - -} diff --git a/public/js/app.js b/public/js/app.js index a9ff7cdeb8087a2b82d2654dbf9af6fd5130f7ab..3af99ce4c293a1c5c9e0e8e99dbeaa98fb577ef8 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -811,18 +811,20 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', function($scope, $http, $window, $location, OverviewDataService, AlertService, ModalService, RefreshService) { - $scope.data = undefined; // raw response - $scope.indices = undefined; // visible indices - $scope.nodes = undefined; // visible nodes + $scope.data = undefined; + + $scope.indices = undefined; + $scope.nodes = undefined; + $scope.unassigned_shards = 0; + $scope.relocating_shards = 0; + $scope.initializing_shards = 0; + $scope.closed_indices = 0; + $scope.special_indices = 0; $scope.shardAllocation = true; $scope.indices_filter = new IndexFilter('', false, false, true, true, 0); $scope.nodes_filter = new NodeFilter('', true, false, false, false, 0); - $scope.shardAsInt = function(shard) { // TODO if ES returned shard as Int... - return parseInt(shard.shard); - }; - $scope.getPageSize = function() { return Math.max(Math.round($window.innerWidth / 280), 1); }; @@ -831,8 +833,8 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', 1, $scope.getPageSize(), [], - $scope.indices_filter - ); + $scope.indices_filter) + ; $scope.page = $scope.paginator.getPage(); @@ -858,6 +860,11 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.data = data; $scope.setIndices(data.indices); $scope.setNodes(data.nodes); + $scope.unassigned_shards = data.unassigned_shards; + $scope.relocating_shards = data.relocating_shards; + $scope.initializing_shards = data.initializing_shards; + $scope.closed_indices = data.closed_indices; + $scope.special_indices = data.special_indices; $scope.shardAllocation = data.shard_allocation; }, function(error) { @@ -865,6 +872,11 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.data = undefined; $scope.indices = undefined; $scope.nodes = undefined; + $scope.unassigned_shards = 0; + $scope.relocating_shards = 0; + $scope.initializing_shards = 0; + $scope.closed_indices = 0; + $scope.special_indices = 0; $scope.shardAllocation = true; } ); @@ -1096,7 +1108,7 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.relocateShard = function(node) { var s = $scope.relocatingShard; - OverviewDataService.relocateShard(s.shard, s.index, s.node, node.name, + OverviewDataService.relocateShard(s.shard, s.index, s.node, node.id, function(response) { $scope.relocatingShard = undefined; RefreshService.refresh(); @@ -1117,8 +1129,8 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.canReceiveShard = function(index, node) { var shard = $scope.relocatingShard; if (shard && index) { // in case num indices < num columns - if (shard.node !== node.name && shard.index === index.index) { - var shards = index.shards[node.name]; + if (shard.node !== node.id && shard.index === index.name) { + var shards = index.shards[node.id]; if (shards) { var sameShard = function(s) { return s.shard === shard.shard; @@ -1957,9 +1969,9 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { case 'name': return function(a, b) { if (asc) { - return a.index.localeCompare(b.index); + return a.name.localeCompare(b.name); } else { - return b.index.localeCompare(a.index); + return b.name.localeCompare(a.name); } }; default: @@ -2002,10 +2014,10 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { this.matches = function(index) { var matches = true; - if (!this.special && index.index.indexOf('.') === 0) { + if (!this.special && index.special) { matches = false; } - if (!this.closed && index.status === 'close') { + if (!this.closed && index.closed) { matches = false; } // Hide healthy == show unhealthy only @@ -2015,7 +2027,7 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { if (matches && this.name) { try { var regExp = new RegExp(this.name.trim(), 'i'); - matches = regExp.test(index.index); + matches = regExp.test(index.name); if (!matches && index.aliases) { for (var idx = 0; idx < index.aliases.length; idx++) { if ((matches = regExp.test(index.aliases[idx]))) { @@ -2025,7 +2037,7 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { } } catch (err) { // if not valid regexp, still try normal matching - matches = index.index.indexOf(this.name.toLowerCase()) != -1; + matches = index.name.indexOf(this.name.toLowerCase()) != -1; if (!matches) { for (var _idx = 0; _idx < index.aliases.length; _idx++) { var alias = index.aliases[_idx].toLowerCase(); @@ -2087,10 +2099,10 @@ function NodeFilter(name, data, master, ingest, coordinating, timestamp) { this.matchesType = function(node) { return ( - node['node.role'].indexOf('d') !== -1 && this.data || - node['node.role'].indexOf('m') !== -1 && this.master || - node['node.role'].indexOf('i') !== -1 && this.ingest || - node['node.role'].indexOf('-') !== -1 && this.coordinating + node.data && this.data || + node.master && this.master || + node.ingest && this.ingest || + node.coordinating && this.coordinating ); }; diff --git a/public/overview.html b/public/overview.html index f66f9e21d2dc260dba22617b668baf8927b5f6c3..cf9fee1c944f6771ce610e1c4ceb134a84f7ba10 100644 --- a/public/overview.html +++ b/public/overview.html @@ -11,14 +11,14 @@ <div class="col-lg-3 col-sm-3 col-xs-6 form-group"> <div class="checkbox"> <label> - <input type="checkbox" ng-model="paginator.filter.closed"> closed ({{data.closed_indices}}) + <input type="checkbox" ng-model="paginator.filter.closed"> closed ({{closed_indices}}) </label> </div> </div> <div class="col-lg-3 col-sm-3 col-xs-6 form-group"> <div class="checkbox"> <label> - <input type="checkbox" ng-model="paginator.filter.special"> .special ({{data.special_indices}}) + <input type="checkbox" ng-model="paginator.filter.special"> .special ({{special_indices}}) </label> </div> </div> @@ -95,48 +95,48 @@ </div> </div> </td> - <td ng-repeat="index in page.elements track by $index" ng-class="{'closed-index': index.status === 'close'}"> + <td ng-repeat="index in page.elements track by $index" ng-class="{'closed-index': index.closed}"> <div ng-show="index"> <div class="dropdown"> - <span class="title normal-action" type="button" id="drop_{{index.index}}" data-toggle="dropdown" + <span class="title normal-action" type="button" id="drop_{{index.name}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> - <i class="fa fa-caret-down pull-right"></i>{{index.index}} + <i class="fa fa-caret-down pull-right"></i>{{index.name}} </span> - <ul class="dropdown-menu" aria-labelledby="drop_{{index.index}}"> - <li ng-click="getIndexSettings(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <ul class="dropdown-menu" aria-labelledby="drop_{{index.name}}"> + <li ng-click="getIndexSettings(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-info-circle"> </i> show settings</a> </li> - <li ng-click="getIndexMapping(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="getIndexMapping(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-code"> </i> show mappings</a> </li> - <li ng-click="indexStats(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="indexStats(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-info"> </i> show stats</a> </li> - <li ng-show="index.status === 'close'" ng-click="openIndex(index.index)" data-toggle="modal" href="#confirm_dialog" + <li ng-show="index.closed" ng-click="openIndex(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-folder-open"> </i> open index</a> </li> - <li ng-hide="index.status === 'close'" ng-click="closeIndex(index.index)" data-toggle="modal" href="#confirm_dialog" + <li ng-hide="index.closed" ng-click="closeIndex(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-folder"> </i> close index</a> </li> - <li ng-click="forceMerge(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="forceMerge(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-wrench"> </i> force merge</a> </li> - <li ng-click="refreshIndex(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="refreshIndex(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-refresh"> </i> refresh index</a> </li> - <li ng-click="flushIndex(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="flushIndex(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-gavel"> </i> flush index</a> </li> - <li ng-click="clearIndexCache(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="clearIndexCache(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-circle-o"> </i> clear cache</a> </li> - <li ng-click="showIndexSettings(index.index)"> + <li ng-click="showIndexSettings(index.name)"> <a target="_self"><i class="fa fa-fw fa-cog"> </i> index settings</a> </li> <li class="divider"></li> - <li ng-click="deleteIndex(index.index)" data-toggle="modal" href="#confirm_dialog" target="_self"> + <li ng-click="deleteIndex(index.name)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-trash red"> </i> delete index</a> </li> </ul> @@ -149,9 +149,9 @@ </div> <div class="detail"> <span ng-hide="index.closed"> - <span><small>shards: {{index.pri}} * {{index.rep}}|</small></span> - <span><small>docs: {{index['docs.count']}} |</small></span> - <span><small>size: {{index['store.size']}}</small></span> + <span><small>shards: {{index.num_shards}} * {{index.num_replicas + 1}}|</small></span> + <span><small>docs: {{index.doc_count | number}} |</small></span> + <span><small>size: {{index.size_in_bytes | bytes}}</small></span> </span> <span ng-show="index.closed"> <span><small><i>index closed</i></small></span> @@ -162,16 +162,16 @@ </tr> </thead> <tbody> - <tr ng-show="data.health.unassigned_shards > 0 || data.health.relocating_shards > 0 || data.health.initializing_shards > 0"> + <tr ng-show="unassigned_shards > 0 || relocating_shards > 0 || initializing_shards > 0"> <td> - <div class="subtitle" ng-show="data.health.unassigned_shards > 0"> - <i class="fa fa-warning alert-warning"> </i> {{data.health.unassigned_shards}} unassigned shards + <div class="subtitle" ng-show="unassigned_shards > 0"> + <i class="fa fa-warning alert-warning"> </i> {{unassigned_shards}} unassigned shards </div> - <div class="subtitle" ng-show="data.health.relocating_shards > 0"> - <i class="fa fa-refresh fa-spin"> </i> {{data.health.relocating_shards}} relocating shards + <div class="subtitle" ng-show="relocating_shards > 0"> + <i class="fa fa-refresh fa-spin"> </i> {{relocating_shards}} relocating shards </div> - <div class="subtitle" ng-show="data.health.initializing_shards > 0"> - <i class="fa fa-spinner fa-spin"> </i> {{data.health.initializing_shards}} initializing shards + <div class="subtitle" ng-show="initializing_shards > 0"> + <i class="fa fa-spinner fa-spin"> </i> {{initializing_shards}} initializing shards </div> <div> <span class="normal-action" ng-show="indices_filter.healthy" ng-click="indices_filter.healthy = false"><i><small>show only affected indices</small></i></span> @@ -179,7 +179,7 @@ </div> </td> <td ng-repeat="index in page.elements track by $index"> - <span ng-repeat="shard in index.shards.unassigned | orderBy:shardAsInt track by $index"> + <span ng-repeat="shard in index.shards.unassigned | orderBy:'shard' track by $index"> <span class="shard shard-unassigned"> <small>{{shard.shard}}</small> </span> @@ -191,71 +191,81 @@ <div class="row"> <div class="col-lg-12"> <div class="node-badges title"> - <div ng-show="node['node.role'].indexOf('m') >= 0"> - <i ng-show="node.master === '*'" class="fa fa-fw fa-star" title="current master"></i> - <i ng-show="node.master === '-'" class="fa fa-fw fa-star-o" title="master eligible"></i> + <div ng-show="node.master"> + <i ng-show="node.current_master" class="fa fa-fw fa-star" title="current master"></i> + <i ng-show="!node.current_master" class="fa fa-fw fa-star-o" title="master eligible"></i> </div> - <div ng-show="node['node.role'].indexOf('d') >= 0"> + <div ng-show="node.data"> <i class="fa fa-fw fa-hdd-o" title="data node"></i> </div> - <div ng-show="node['node.role'].indexOf('i') >= 0"> + <div ng-show="node.ingest"> <i class="fa fa-fw fa-crop" title="ingest node"></i> </div> </div> <div class="node-info"> <div class="title"> - <span class="normal-action" type="button" ng-click="nodeStats(node.name)" data-toggle="modal" + <span class="normal-action" type="button" ng-click="nodeStats(node.id)" data-toggle="modal" href="#confirm_dialog" target="_self"> {{node.name}} </span> </div> <div> - <small>{{node.ip}}</small> - </div> - <div> - <small> - Disk avail.: {{node['disk.avail']}} - Load 1m: {{node.load_1m}} - </small> + <small>{{node.host}}</small> </div> </div> </div> </div> <div class="row row-condensed"> - <div class="col-lg-6 col-condensed"> + <div class="col-lg-3 col-condensed"> <ng-progress - value="node['heap.percent']" + value="node.heap.used_percent" max="100" text="'heap'" - tooltip="'heap usage: ' + node['heap.percent'] + '%'" + tooltip="'used: ' + (node.heap.used | bytes) + '\nmax: ' + (node.heap.max | bytes)" /> </div> - <div class="col-lg-6 col-condensed"> + <div class="col-lg-3 col-condensed"> <ng-progress - value="node.cpu" + value="node.disk.used_percent" + max="100" + text="'disk'" + tooltip="'free: ' + (node.disk.free | bytes) + '\ntotal: ' + (node.disk.total | bytes)" + /> + </div> + <div class="col-lg-3 col-condensed"> + <ng-progress + value="node.cpu_percent" max="100" text="'cpu'" - tooltip="'process cpu: ' + node.cpu + '%'" + tooltip="'process cpu: ' + node.cpu_percent + '%'" + /> + </div> + <div class="col-lg-3 col-condensed"> + <ng-progress + value="node.load_average" + max="node.available_processors" + text="'load'" + tooltip="'1min avg.: ' + (node.load_average | number:2)" /> </div> </div> <div ng-show="expandedView" class="node-labels"> - <span class="label label-details">JVM: {{node.jdk}}</span> - <span class="label label-details">ES: {{node.version}}</span> + <span class="label label-details">JVM: {{node.jvm_version}}</span> + <span class="label label-details">ES: {{node.es_version}}</span> </div> </td> <td ng-repeat="index in page.elements track by $index"> - <span ng-repeat="shard in index.shards[node.name] | orderBy:'shard' track by $index"> + <span ng-repeat="shard in index.shards[node.id] | orderBy:'shard' track by $index"> <span class="dropdown"> <span class="shard shard-{{shard.state | lowercase}} normal-action" - ng-class="{'shard-replica': shard.prirep === 'r'}" + ng-class="{'shard-replica': !shard.primary && shard.node}" data-toggle="dropdown" - id="{{shard.shard}}_{{node.name}}_{{index.index}}"> + id="{{shard.shard}}_{{shard.node}}_{{shard.index}}"> <small>{{shard.shard}}</small> </span> <ul class="dropdown-menu" - aria-labelledby="{{shard.shard}}_{{node.name}}_{{index.index}}"> - <li ng-click="shardStats(index.index, node.id, shard.shard)" data-toggle="modal" href="#confirm_dialog" target="_self"> + aria-labelledby="{{shard.shard}}_{{shard.node}}_{{shard.index}}"> + <li ng-click="shardStats(shard.index, shard.node, shard.shard)" data-toggle="modal" href="#confirm_dialog" target="_self"> <a target="_self"><i class="fa fa-fw fa-info-circle"> </i> display shard stats</a> </li> <li ng-click="select(shard)" ng-hide="isSelected(shard)"> diff --git a/public/stats.html b/public/stats.html index d89d968b8af612a02c3c0d29f4c0a5fcbbeb4385..79e9d0d72e022e328f3b31636508b87180eabbc7 100644 --- a/public/stats.html +++ b/public/stats.html @@ -5,14 +5,14 @@ <div class="col-lg-2"> <span class="stat"> <span class="stat-value"> - {{data.health.cluster_name}} + {{data.cluster_name}} </span> </span> </div> <div class="col-lg-2"> <span class="stat"> <span class="stat-value"> - {{data.health.number_of_nodes | number:0}} + {{data.number_of_nodes | number:0}} </span> <span> nodes @@ -32,7 +32,7 @@ <div class="col-lg-2"> <span class="stat"> <span class="stat-value"> - {{data.health.active_shards + data.health.initializing_shards + data.health.relocating_shards + data.health.unassigned_shards | number:0}} + {{data.active_shards + data.initializing_shards + data.relocating_shards + data.unassigned_shards | number:0}} </span> <span> shards diff --git a/src/app/components/overview/controller.js b/src/app/components/overview/controller.js index e4433c4fe277d1e74a9beb65b2796313cfc185d0..98689528d01f677d75f915dd1a898625921ba2ac 100644 --- a/src/app/components/overview/controller.js +++ b/src/app/components/overview/controller.js @@ -4,18 +4,20 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', function($scope, $http, $window, $location, OverviewDataService, AlertService, ModalService, RefreshService) { - $scope.data = undefined; // raw response - $scope.indices = undefined; // visible indices - $scope.nodes = undefined; // visible nodes + $scope.data = undefined; + + $scope.indices = undefined; + $scope.nodes = undefined; + $scope.unassigned_shards = 0; + $scope.relocating_shards = 0; + $scope.initializing_shards = 0; + $scope.closed_indices = 0; + $scope.special_indices = 0; $scope.shardAllocation = true; $scope.indices_filter = new IndexFilter('', false, false, true, true, 0); $scope.nodes_filter = new NodeFilter('', true, false, false, false, 0); - $scope.shardAsInt = function(shard) { // TODO if ES returned shard as Int... - return parseInt(shard.shard); - }; - $scope.getPageSize = function() { return Math.max(Math.round($window.innerWidth / 280), 1); }; @@ -24,8 +26,8 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', 1, $scope.getPageSize(), [], - $scope.indices_filter - ); + $scope.indices_filter) + ; $scope.page = $scope.paginator.getPage(); @@ -51,6 +53,11 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.data = data; $scope.setIndices(data.indices); $scope.setNodes(data.nodes); + $scope.unassigned_shards = data.unassigned_shards; + $scope.relocating_shards = data.relocating_shards; + $scope.initializing_shards = data.initializing_shards; + $scope.closed_indices = data.closed_indices; + $scope.special_indices = data.special_indices; $scope.shardAllocation = data.shard_allocation; }, function(error) { @@ -58,6 +65,11 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.data = undefined; $scope.indices = undefined; $scope.nodes = undefined; + $scope.unassigned_shards = 0; + $scope.relocating_shards = 0; + $scope.initializing_shards = 0; + $scope.closed_indices = 0; + $scope.special_indices = 0; $scope.shardAllocation = true; } ); @@ -289,7 +301,7 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.relocateShard = function(node) { var s = $scope.relocatingShard; - OverviewDataService.relocateShard(s.shard, s.index, s.node, node.name, + OverviewDataService.relocateShard(s.shard, s.index, s.node, node.id, function(response) { $scope.relocatingShard = undefined; RefreshService.refresh(); @@ -310,8 +322,8 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http', $scope.canReceiveShard = function(index, node) { var shard = $scope.relocatingShard; if (shard && index) { // in case num indices < num columns - if (shard.node !== node.name && shard.index === index.index) { - var shards = index.shards[node.name]; + if (shard.node !== node.id && shard.index === index.name) { + var shards = index.shards[node.id]; if (shards) { var sameShard = function(s) { return s.shard === shard.shard; diff --git a/src/app/shared/index_filter.js b/src/app/shared/index_filter.js index cea5b6a7e6eb4851907bdd805bc6dd4d6ec6ce14..fd92f2b07cd97401dd2a8fc74f90321dfd9c0427 100644 --- a/src/app/shared/index_filter.js +++ b/src/app/shared/index_filter.js @@ -13,9 +13,9 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { case 'name': return function(a, b) { if (asc) { - return a.index.localeCompare(b.index); + return a.name.localeCompare(b.name); } else { - return b.index.localeCompare(a.index); + return b.name.localeCompare(a.name); } }; default: @@ -58,10 +58,10 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { this.matches = function(index) { var matches = true; - if (!this.special && index.index.indexOf('.') === 0) { + if (!this.special && index.special) { matches = false; } - if (!this.closed && index.status === 'close') { + if (!this.closed && index.closed) { matches = false; } // Hide healthy == show unhealthy only @@ -71,7 +71,7 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { if (matches && this.name) { try { var regExp = new RegExp(this.name.trim(), 'i'); - matches = regExp.test(index.index); + matches = regExp.test(index.name); if (!matches && index.aliases) { for (var idx = 0; idx < index.aliases.length; idx++) { if ((matches = regExp.test(index.aliases[idx]))) { @@ -81,7 +81,7 @@ function IndexFilter(name, closed, special, healthy, asc, timestamp) { } } catch (err) { // if not valid regexp, still try normal matching - matches = index.index.indexOf(this.name.toLowerCase()) != -1; + matches = index.name.indexOf(this.name.toLowerCase()) != -1; if (!matches) { for (var _idx = 0; _idx < index.aliases.length; _idx++) { var alias = index.aliases[_idx].toLowerCase(); diff --git a/src/app/shared/node_filter.js b/src/app/shared/node_filter.js index 98a269b725624233fa44fa0d18151573fb5fe9fa..6a466b261fc117acec664ea83507b15a6af0d5d5 100644 --- a/src/app/shared/node_filter.js +++ b/src/app/shared/node_filter.js @@ -43,10 +43,10 @@ function NodeFilter(name, data, master, ingest, coordinating, timestamp) { this.matchesType = function(node) { return ( - node['node.role'].indexOf('d') !== -1 && this.data || - node['node.role'].indexOf('m') !== -1 && this.master || - node['node.role'].indexOf('i') !== -1 && this.ingest || - node['node.role'].indexOf('-') !== -1 && this.coordinating + node.data && this.data || + node.master && this.master || + node.ingest && this.ingest || + node.coordinating && this.coordinating ); }; diff --git a/test/controllers/OverviewControllerSpec.scala b/test/controllers/OverviewControllerSpec.scala index 0b57e1acfb26cb901a0fdd87ab3333d06693da11..fff44ed3d5517bec47f8a6f8fd18df3546f59461 100644 --- a/test/controllers/OverviewControllerSpec.scala +++ b/test/controllers/OverviewControllerSpec.scala @@ -201,7 +201,7 @@ object OverviewControllerSpec extends MockedServices { } def shardStats = { - val body = Json.obj("host" -> "somehost", "index" -> "someIndex", "node" -> "MCGlWc6ERF2N9pO0uh7-tA", "shard" -> "1") + val body = Json.obj("host" -> "somehost", "index" -> "someIndex", "node" -> "MCGlWc6ERF2N9pO0uh7-tA", "shard" -> 1) client.getShardStats("someIndex", ElasticServer("somehost", None)) returns Future.successful(Success(200, expectedStats)) client.getIndexRecovery("someIndex", ElasticServer("somehost", None)) returns Future.successful(Success(200, expectedRecovery)) val result = route(application, FakeRequest(POST, "/overview/get_shard_stats").withBody(body)).get @@ -209,19 +209,19 @@ object OverviewControllerSpec extends MockedServices { } def missingIndexToFetchShardStats = { - val body = Json.obj("host" -> "somehost", "shard" -> "1", "node" -> "MCGlWc6ERF2N9pO0uh7-tA") + val body = Json.obj("host" -> "somehost") val result = route(application, FakeRequest(POST, "/overview/get_shard_stats").withBody(body)).get ensure(result, 400, Json.obj("error" -> "Missing required parameter index")) } def missingShardToFetchShardStats = { - val body = Json.obj("host" -> "somehost", "index" -> "foo", "node" -> "MCGlWc6ERF2N9pO0uh7-tA") + val body = Json.obj("host" -> "somehost", "index" -> "foo") val result = route(application, FakeRequest(POST, "/overview/get_shard_stats").withBody(body)).get ensure(result, 400, Json.obj("error" -> "Missing required parameter shard")) } def missingNodeToFetchShardStats = { - val body = Json.obj("host" -> "somehost", "index" -> "foo", "shard" -> "1") + val body = Json.obj("host" -> "somehost", "index" -> "foo", "shard" -> 1) val result = route(application, FakeRequest(POST, "/overview/get_shard_stats").withBody(body)).get ensure(result, 400, Json.obj("error" -> "Missing required parameter node")) } diff --git a/test/services/overview/ClusterDisabledAllocation.scala b/test/models/overview/ClusterDisabledAllocation.scala similarity index 84% rename from test/services/overview/ClusterDisabledAllocation.scala rename to test/models/overview/ClusterDisabledAllocation.scala index f638d92b1f769569d2448a249b2f5ab043d5c414..4801bb420f13a73f9946eea3847774240c75e9f4 100644 --- a/test/services/overview/ClusterDisabledAllocation.scala +++ b/test/models/overview/ClusterDisabledAllocation.scala @@ -1,10 +1,10 @@ -package services.overview +package models.overview import play.api.libs.json.Json object ClusterDisabledAllocation extends ClusterWithData { - override val settings = Json.parse( + override val clusterSettings = Json.parse( """ |{ | "persistent" : { }, diff --git a/test/models/overview/ClusterInitializingShards.scala b/test/models/overview/ClusterInitializingShards.scala new file mode 100644 index 0000000000000000000000000000000000000000..5fba37af4c7f098edfa192258e09acb687981455 --- /dev/null +++ b/test/models/overview/ClusterInitializingShards.scala @@ -0,0 +1,721 @@ +package models.overview + +import play.api.libs.json.Json + +object ClusterInitializingShards { + + def apply() = ClusterOverview(clusterState, nodesStats, indicesStats, clusterSettings, aliases, clusterHealth, nodes, main) + + val clusterState = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "master_node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "blocks" : { }, + | "routing_table" : { + | "indices" : { + | "hello" : { + | "shards" : { + | "1" : [ { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 1, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "rNdtAPz_RhKVBp6dpAH1cw" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 1, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "hlwc94lZRvOoBoaxyEWIGg" + | } + | } ], + | "4" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 10, + | "allocation_id" : { + | "id" : "Kyne0gDVQEasq9VxUUsxbg" + | } + | }, { + | "state" : "UNASSIGNED", + | "primary" : false, + | "node" : null, + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 10, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | } ], + | "2" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 15, + | "allocation_id" : { + | "id" : "rN62kibSRZq0RxcwxEHKKw" + | } + | }, { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 15, + | "allocation_id" : { + | "id" : "2G3Hs3CnT5uvhpeOmHZyYg" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | } ], + | "3" : [ { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 11, + | "allocation_id" : { + | "id" : "NhG91IW6RCW1KAbSx67O9g" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 11, + | "allocation_id" : { + | "id" : "b4Gdtk7uTuSINaZ_YdaJdg" + | } + | } ], + | "0" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 0, + | "index" : "hello", + | "version" : 17, + | "allocation_id" : { + | "id" : "13mrI6FhRjGEk7xG7xYJvg" + | } + | }, { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 0, + | "index" : "hello", + | "version" : 17, + | "allocation_id" : { + | "id" : "FbfzrPiySEaOzGMRZRDf7w" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | } ] + | } + | } + | } + | }, + | "routing_nodes" : { + | "unassigned" : [ { + | "state" : "UNASSIGNED", + | "primary" : false, + | "node" : null, + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 10, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | } ], + | "nodes" : { + | "VOiMU2k5SuStH3-X1uuBGw" : [ { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 1, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "rNdtAPz_RhKVBp6dpAH1cw" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 15, + | "allocation_id" : { + | "id" : "rN62kibSRZq0RxcwxEHKKw" + | } + | }, { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 11, + | "allocation_id" : { + | "id" : "NhG91IW6RCW1KAbSx67O9g" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 0, + | "index" : "hello", + | "version" : 17, + | "allocation_id" : { + | "id" : "13mrI6FhRjGEk7xG7xYJvg" + | } + | } ], + | "cPsT9o5FQ3WRnvqSTXHiVQ" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 1, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "hlwc94lZRvOoBoaxyEWIGg" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 10, + | "allocation_id" : { + | "id" : "Kyne0gDVQEasq9VxUUsxbg" + | } + | }, { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 15, + | "allocation_id" : { + | "id" : "2G3Hs3CnT5uvhpeOmHZyYg" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 11, + | "allocation_id" : { + | "id" : "b4Gdtk7uTuSINaZ_YdaJdg" + | } + | }, { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 0, + | "index" : "hello", + | "version" : 17, + | "allocation_id" : { + | "id" : "FbfzrPiySEaOzGMRZRDf7w" + | }, + | "unassigned_info" : { + | "reason" : "REPLICA_ADDED", + | "at" : "2016-03-19T14:13:39.833Z" + | } + | } ] + | } + | } + |} + """.stripMargin + ) + + val nodesStats = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "nodes" : { + | "VOiMU2k5SuStH3-X1uuBGw" : { + | "timestamp" : 1458396821721, + | "name" : "Random", + | "transport_address" : "127.0.0.1:9301", + | "host" : "127.0.0.1", + | "ip" : [ "127.0.0.1:9301", "NONE" ], + | "os" : { + | "timestamp" : 1458396821721, + | "load_average" : 3.48583984375, + | "mem" : { + | "total_in_bytes" : 8589934592, + | "free_in_bytes" : 57360384, + | "used_in_bytes" : 8532574208, + | "free_percent" : 1, + | "used_percent" : 99 + | }, + | "swap" : { + | "total_in_bytes" : 2147483648, + | "free_in_bytes" : 1292369920, + | "used_in_bytes" : 855113728 + | } + | }, + | "process" : { + | "timestamp" : 1458396821721, + | "open_file_descriptors" : 283, + | "max_file_descriptors" : 10240, + | "cpu" : { + | "percent" : 0, + | "total_in_millis" : 204184 + | }, + | "mem" : { + | "total_virtual_in_bytes" : 5328396288 + | } + | }, + | "jvm" : { + | "timestamp" : 1458396821721, + | "uptime_in_millis" : 1013104, + | "mem" : { + | "heap_used_in_bytes" : 65155904, + | "heap_used_percent" : 6, + | "heap_committed_in_bytes" : 259522560, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_used_in_bytes" : 68894384, + | "non_heap_committed_in_bytes" : 70033408, + | "pools" : { + | "young" : { + | "used_in_bytes" : 17017328, + | "max_in_bytes" : 286326784, + | "peak_used_in_bytes" : 71630848, + | "peak_max_in_bytes" : 286326784 + | }, + | "survivor" : { + | "used_in_bytes" : 2022296, + | "max_in_bytes" : 35782656, + | "peak_used_in_bytes" : 8912896, + | "peak_max_in_bytes" : 35782656 + | }, + | "old" : { + | "used_in_bytes" : 46116280, + | "max_in_bytes" : 715849728, + | "peak_used_in_bytes" : 46116280, + | "peak_max_in_bytes" : 715849728 + | } + | } + | }, + | "threads" : { + | "count" : 99, + | "peak_count" : 103 + | }, + | "gc" : { + | "collectors" : { + | "young" : { + | "collection_count" : 173, + | "collection_time_in_millis" : 861 + | }, + | "old" : { + | "collection_count" : 1, + | "collection_time_in_millis" : 16 + | } + | } + | }, + | "buffer_pools" : { + | "direct" : { + | "count" : 126, + | "used_in_bytes" : 20107771, + | "total_capacity_in_bytes" : 20107771 + | }, + | "mapped" : { + | "count" : 7, + | "used_in_bytes" : 531368, + | "total_capacity_in_bytes" : 531368 + | } + | } + | }, + | "fs" : { + | "timestamp" : 1458396821721, + | "total" : { + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 41476603904, + | "available_in_bytes" : 41214459904 + | }, + | "data" : [ { + | "path" : "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/1", + | "mount" : "/ (/dev/disk1)", + | "type" : "hfs", + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 41476603904, + | "available_in_bytes" : 41214459904 + | } ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ" : { + | "timestamp" : 1458396821720, + | "name" : "Cecilia Reyes", + | "transport_address" : "127.0.0.1:9300", + | "host" : "127.0.0.1", + | "ip" : [ "127.0.0.1:9300", "NONE" ], + | "os" : { + | "timestamp" : 1458396821720, + | "load_average" : 3.48583984375, + | "mem" : { + | "total_in_bytes" : 8589934592, + | "free_in_bytes" : 57360384, + | "used_in_bytes" : 8532574208, + | "free_percent" : 1, + | "used_percent" : 99 + | }, + | "swap" : { + | "total_in_bytes" : 2147483648, + | "free_in_bytes" : 1292369920, + | "used_in_bytes" : 855113728 + | } + | }, + | "process" : { + | "timestamp" : 1458396821720, + | "open_file_descriptors" : 309, + | "max_file_descriptors" : 10240, + | "cpu" : { + | "percent" : 0, + | "total_in_millis" : 439157 + | }, + | "mem" : { + | "total_virtual_in_bytes" : 5336465408 + | } + | }, + | "jvm" : { + | "timestamp" : 1458396821721, + | "uptime_in_millis" : 12257739, + | "mem" : { + | "heap_used_in_bytes" : 152293128, + | "heap_used_percent" : 14, + | "heap_committed_in_bytes" : 259522560, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_used_in_bytes" : 80998704, + | "non_heap_committed_in_bytes" : 82624512, + | "pools" : { + | "young" : { + | "used_in_bytes" : 42576208, + | "max_in_bytes" : 286326784, + | "peak_used_in_bytes" : 71630848, + | "peak_max_in_bytes" : 286326784 + | }, + | "survivor" : { + | "used_in_bytes" : 4755944, + | "max_in_bytes" : 35782656, + | "peak_used_in_bytes" : 8912896, + | "peak_max_in_bytes" : 35782656 + | }, + | "old" : { + | "used_in_bytes" : 104965192, + | "max_in_bytes" : 715849728, + | "peak_used_in_bytes" : 104965192, + | "peak_max_in_bytes" : 715849728 + | } + | } + | }, + | "threads" : { + | "count" : 102, + | "peak_count" : 106 + | }, + | "gc" : { + | "collectors" : { + | "young" : { + | "collection_count" : 252, + | "collection_time_in_millis" : 1611 + | }, + | "old" : { + | "collection_count" : 1, + | "collection_time_in_millis" : 12 + | } + | } + | }, + | "buffer_pools" : { + | "direct" : { + | "count" : 206, + | "used_in_bytes" : 28678155, + | "total_capacity_in_bytes" : 28678155 + | }, + | "mapped" : { + | "count" : 9, + | "used_in_bytes" : 536675, + | "total_capacity_in_bytes" : 536675 + | } + | }, + | "classes" : { + | "current_loaded_count" : 7623, + | "total_loaded_count" : 7623, + | "total_unloaded_count" : 0 + | } + | }, + | "fs" : { + | "timestamp" : 1458396821721, + | "total" : { + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 41476603904, + | "available_in_bytes" : 41214459904 + | }, + | "data" : [ { + | "path" : "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/0", + | "mount" : "/ (/dev/disk1)", + | "type" : "hfs", + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 41476603904, + | "available_in_bytes" : 41214459904 + | } ] + | } + | } + | } + |} + """.stripMargin + ) + + val indicesStats = Json.parse( + """ + |{ + | "_shards" : { + | "total" : 10, + | "successful" : 5, + | "failed" : 0 + | }, + | "_all" : { + | "primaries" : { + | "docs" : { + | "count" : 108680, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 2026271, + | "throttle_time_in_millis" : 0 + | } + | }, + | "total" : { + | "docs" : { + | "count" : 108680, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 2026271, + | "throttle_time_in_millis" : 0 + | } + | } + | }, + | "indices" : { + | "hello" : { + | "primaries" : { + | "docs" : { + | "count" : 108680, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 2026271, + | "throttle_time_in_millis" : 0 + | } + | }, + | "total" : { + | "docs" : { + | "count" : 108680, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 2026271, + | "throttle_time_in_millis" : 0 + | } + | } + | } + | } + |} + """.stripMargin + ) + + val clusterSettings = Json.parse( + """ + |{ + | "persistent" : { }, + | "transient" : { } + |} + """.stripMargin + ) + + val aliases = Json.parse( + """ + |{ + | "hello" : { + | "aliases" : { } + | } + |} + """.stripMargin + ) + + val clusterHealth = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "status" : "yellow", + | "timed_out" : false, + | "number_of_nodes" : 2, + | "number_of_data_nodes" : 2, + | "active_primary_shards" : 5, + | "active_shards" : 5, + | "relocating_shards" : 0, + | "initializing_shards" : 4, + | "unassigned_shards" : 1, + | "delayed_unassigned_shards" : 0, + | "number_of_pending_tasks" : 0, + | "number_of_in_flight_fetch" : 0, + | "task_max_waiting_in_queue_millis" : 0, + | "active_shards_percent_as_number" : 50 + |} + """.stripMargin + ) + + val nodes = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "nodes" : { + | "VOiMU2k5SuStH3-X1uuBGw" : { + | "name" : "Random", + | "transport_address" : "127.0.0.1:9301", + | "host" : "127.0.0.1", + | "ip" : "127.0.0.1", + | "version" : "2.1.0", + | "build" : "72cd1f1", + | "http_address" : "127.0.0.1:9201", + | "os" : { + | "refresh_interval_in_millis" : 1000, + | "available_processors" : 8, + | "allocated_processors" : 8 + | }, + | "jvm" : { + | "pid" : 16419, + | "version" : "1.8.0_72", + | "vm_name" : "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version" : "25.72-b15", + | "vm_vendor" : "Oracle Corporation", + | "start_time_in_millis" : 1458393717991, + | "mem" : { + | "heap_init_in_bytes" : 268435456, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_init_in_bytes" : 2555904, + | "non_heap_max_in_bytes" : 0, + | "direct_max_in_bytes" : 1037959168 + | }, + | "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ], + | "memory_pools" : [ "Code Cache", "Metaspace", "Compressed Class Space", "Par Eden Space", "Par Survivor Space", "CMS Old Gen" ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ" : { + | "name" : "Cecilia Reyes", + | "transport_address" : "127.0.0.1:9300", + | "host" : "127.0.0.1", + | "ip" : "127.0.0.1", + | "version" : "2.1.0", + | "build" : "72cd1f1", + | "http_address" : "127.0.0.1:9200", + | "os" : { + | "refresh_interval_in_millis" : 1000, + | "name" : "Mac OS X", + | "arch" : "x86_64", + | "version" : "10.11.3", + | "available_processors" : 8, + | "allocated_processors" : 8 + | }, + | "jvm" : { + | "pid" : 60169, + | "version" : "1.8.0_72", + | "vm_name" : "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version" : "25.72-b15", + | "vm_vendor" : "Oracle Corporation", + | "start_time_in_millis" : 1458345474505, + | "mem" : { + | "heap_init_in_bytes" : 268435456, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_init_in_bytes" : 2555904, + | "non_heap_max_in_bytes" : 0, + | "direct_max_in_bytes" : 1037959168 + | }, + | "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ], + | "memory_pools" : [ "Code Cache", "Metaspace", "Compressed Class Space", "Par Eden Space", "Par Survivor Space", "CMS Old Gen" ] + | } + | } + | } + |} + """.stripMargin + ) + + val main = Json.parse( + """ + |{ + | "name" : "Cecilia Reyes", + | "cluster_name" : "elasticsearch", + | "version" : { + | "number" : "2.1.0", + | "build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87", + | "build_timestamp" : "2015-11-18T22:40:03Z", + | "build_snapshot" : false, + | "lucene_version" : "5.3.1" + | }, + | "tagline" : "You Know, for Search" + |} + """.stripMargin + ) + +} diff --git a/test/services/overview/ClusterOverviewSpec.scala b/test/models/overview/ClusterOverviewSpec.scala similarity index 51% rename from test/services/overview/ClusterOverviewSpec.scala rename to test/models/overview/ClusterOverviewSpec.scala index c54df3fcf64ae7ef57796e5207b54453d3254d78..f99721c0868655f605e6d6e2d24f4b89244f58e8 100644 --- a/test/services/overview/ClusterOverviewSpec.scala +++ b/test/models/overview/ClusterOverviewSpec.scala @@ -1,4 +1,4 @@ -package services.overview +package models.overview import org.specs2.Specification @@ -17,6 +17,7 @@ object ClusterOverviewSpec extends Specification { return number of unassigned shards $unassignedShards return cluster doc count $docsCount return cluster size in bytes $sizeInBytes + return number of indices $totalIndices return number of closed indices $closedIndices return number of special indices $specialIndices return state of shard allocation $shardAllocation @@ -29,66 +30,73 @@ object ClusterOverviewSpec extends Specification { val clusterDiabledAllocation = ClusterDisabledAllocation() def clusterName = { - (clusterWithoutData \ "health" \ "cluster_name").as[String] mustEqual "elasticsearch" - (clusterWithData \ "health" \ "cluster_name").as[String] mustEqual "elasticsearch" - (clusterInitializing \ "health" \ "cluster_name").as[String] mustEqual "elasticsearch" - (clusterRelocating \ "health" \ "cluster_name").as[String] mustEqual "elasticsearch" + (clusterWithoutData \ "cluster_name").as[String] mustEqual "elasticsearch" + (clusterWithData \ "cluster_name").as[String] mustEqual "elasticsearch" + (clusterInitializing \ "cluster_name").as[String] mustEqual "elasticsearch" + (clusterRelocating \ "cluster_name").as[String] mustEqual "elasticsearch" } def numberOfNodes = { - (clusterWithoutData \ "health" \ "number_of_nodes").as[Int] mustEqual 2 - (clusterWithData \ "health" \ "number_of_nodes").as[Int] mustEqual 2 - (clusterInitializing \ "health" \ "number_of_nodes").as[Int] mustEqual 2 - (clusterRelocating \ "health" \ "number_of_nodes").as[Int] mustEqual 2 + (clusterWithoutData \ "number_of_nodes").as[Int] mustEqual 2 + (clusterWithData \ "number_of_nodes").as[Int] mustEqual 2 + (clusterInitializing \ "number_of_nodes").as[Int] mustEqual 2 + (clusterRelocating \ "number_of_nodes").as[Int] mustEqual 3 } def activePrimaryShards = { - (clusterWithoutData \ "health" \ "active_primary_shards").as[Int] mustEqual 0 - (clusterWithData \ "health" \ "active_primary_shards").as[Int] mustEqual 8 - (clusterInitializing \ "health" \ "active_primary_shards").as[Int] mustEqual 5 - (clusterRelocating \ "health" \ "active_primary_shards").as[Int] mustEqual 5 + (clusterWithoutData \ "active_primary_shards").as[Int] mustEqual 0 + (clusterWithData \ "active_primary_shards").as[Int] mustEqual 8 + (clusterInitializing \ "active_primary_shards").as[Int] mustEqual 5 + (clusterRelocating \ "active_primary_shards").as[Int] mustEqual 5 } def activeShards = { - (clusterWithoutData \ "health" \ "active_shards").as[Int] mustEqual 0 - (clusterWithData \ "health" \ "active_shards").as[Int] mustEqual 11 - (clusterInitializing \ "health" \ "active_shards").as[Int] mustEqual 5 - (clusterRelocating \ "health" \ "active_primary_shards").as[Int] mustEqual 5 + (clusterWithoutData \ "active_shards").as[Int] mustEqual 0 + (clusterWithData \ "active_shards").as[Int] mustEqual 11 + (clusterInitializing \ "active_shards").as[Int] mustEqual 5 + (clusterRelocating \ "active_primary_shards").as[Int] mustEqual 5 } def relocatingShards = { - (clusterWithoutData \ "health" \ "relocating_shards").as[Int] mustEqual 0 - (clusterWithData \ "health" \ "relocating_shards").as[Int] mustEqual 0 - (clusterInitializing \ "health" \ "relocating_shards").as[Int] mustEqual 0 - (clusterRelocating \ "health" \ "relocating_shards").as[Int] mustEqual 1 + (clusterWithoutData \ "relocating_shards").as[Int] mustEqual 0 + (clusterWithData \ "relocating_shards").as[Int] mustEqual 0 + (clusterInitializing \ "relocating_shards").as[Int] mustEqual 0 + (clusterRelocating \ "relocating_shards").as[Int] mustEqual 2 } def initializingShards = { - (clusterWithoutData \ "health" \ "initializing_shards").as[Int] mustEqual 0 - (clusterWithData \ "health" \ "initializing_shards").as[Int] mustEqual 0 - (clusterInitializing \ "health" \ "initializing_shards").as[Int] mustEqual 4 - (clusterRelocating \ "health" \ "initializing_shards").as[Int] mustEqual 0 + (clusterWithoutData \ "initializing_shards").as[Int] mustEqual 0 + (clusterWithData \ "initializing_shards").as[Int] mustEqual 0 + (clusterInitializing \ "initializing_shards").as[Int] mustEqual 4 + (clusterRelocating \ "initializing_shards").as[Int] mustEqual 0 } def unassignedShards = { - (clusterWithoutData \ "health" \ "unassigned_shards").as[Int] mustEqual 0 - (clusterWithData \ "health" \ "unassigned_shards").as[Int] mustEqual 0 - (clusterInitializing \ "health" \ "unassigned_shards").as[Int] mustEqual 1 - (clusterRelocating \ "health" \ "unassigned_shards").as[Int] mustEqual 0 + (clusterWithoutData \ "unassigned_shards").as[Int] mustEqual 0 + (clusterWithData \ "unassigned_shards").as[Int] mustEqual 0 + (clusterInitializing \ "unassigned_shards").as[Int] mustEqual 1 + (clusterRelocating \ "unassigned_shards").as[Int] mustEqual 0 } def docsCount = { (clusterWithoutData \ "docs_count").as[Int] mustEqual 0 (clusterWithData \ "docs_count").as[Int] mustEqual 3 (clusterInitializing \ "docs_count").as[Int] mustEqual 108680 - (clusterRelocating \ "docs_count").as[Int] mustEqual 0 + (clusterRelocating \ "docs_count").as[Int] mustEqual 108680 } def sizeInBytes = { (clusterWithoutData \ "size_in_bytes").as[Int] mustEqual 0 (clusterWithData \ "size_in_bytes").as[Int] mustEqual 16184 (clusterInitializing \ "size_in_bytes").as[Int] mustEqual 2026271 - (clusterRelocating \ "size_in_bytes").as[Int] mustEqual 650 + (clusterRelocating \ "size_in_bytes").as[Int] mustEqual 4052542 + } + + def totalIndices = { + (clusterWithoutData \ "total_indices").as[Int] mustEqual 0 + (clusterWithData \ "total_indices").as[Int] mustEqual 3 + (clusterInitializing \ "total_indices").as[Int] mustEqual 1 + (clusterRelocating \ "total_indices").as[Int] mustEqual 1 } def closedIndices = { diff --git a/test/models/overview/ClusterRelocatingShards.scala b/test/models/overview/ClusterRelocatingShards.scala new file mode 100644 index 0000000000000000000000000000000000000000..4a0974e794dbb985a823b08ea27f02eaf11f070c --- /dev/null +++ b/test/models/overview/ClusterRelocatingShards.scala @@ -0,0 +1,862 @@ +package models.overview + +import play.api.libs.json.Json + +object ClusterRelocatingShards extends ClusterStub { + + val clusterState = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "master_node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "blocks" : { }, + | "routing_table" : { + | "indices" : { + | "hello" : { + | "shards" : { + | "1" : [ { + | "state" : "RELOCATING", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : "xIcHb7CPRH-_m4VGCtBV-w", + | "shard" : 1, + | "index" : "hello", + | "version" : 18, + | "expected_shard_size_in_bytes" : 407699, + | "allocation_id" : { + | "id" : "rNdtAPz_RhKVBp6dpAH1cw", + | "relocation_id" : "avGC6WQeTzqRnQyBE9O_bQ" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 1, + | "index" : "hello", + | "version" : 18, + | "allocation_id" : { + | "id" : "hlwc94lZRvOoBoaxyEWIGg" + | } + | } ], + | "4" : [ { + | "state" : "STARTED", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "A4Dfk71HTriXU1OVBFQIeA" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "Kyne0gDVQEasq9VxUUsxbg" + | } + | } ], + | "2" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "rN62kibSRZq0RxcwxEHKKw" + | } + | }, { + | "state" : "STARTED", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "2G3Hs3CnT5uvhpeOmHZyYg" + | } + | } ], + | "3" : [ { + | "state" : "STARTED", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "NhG91IW6RCW1KAbSx67O9g" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "b4Gdtk7uTuSINaZ_YdaJdg" + | } + | } ], + | "0" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 0, + | "index" : "hello", + | "version" : 19, + | "allocation_id" : { + | "id" : "13mrI6FhRjGEk7xG7xYJvg" + | } + | }, { + | "state" : "RELOCATING", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : "xIcHb7CPRH-_m4VGCtBV-w", + | "shard" : 0, + | "index" : "hello", + | "version" : 19, + | "expected_shard_size_in_bytes" : 405582, + | "allocation_id" : { + | "id" : "FbfzrPiySEaOzGMRZRDf7w", + | "relocation_id" : "fU5MEf2SSyGi40BscFJQsw" + | } + | } ] + | } + | } + | } + | }, + | "routing_nodes" : { + | "unassigned" : [ ], + | "nodes" : { + | "VOiMU2k5SuStH3-X1uuBGw" : [ { + | "state" : "RELOCATING", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : "xIcHb7CPRH-_m4VGCtBV-w", + | "shard" : 1, + | "index" : "hello", + | "version" : 18, + | "expected_shard_size_in_bytes" : 407699, + | "allocation_id" : { + | "id" : "rNdtAPz_RhKVBp6dpAH1cw", + | "relocation_id" : "avGC6WQeTzqRnQyBE9O_bQ" + | } + | }, { + | "state" : "STARTED", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "A4Dfk71HTriXU1OVBFQIeA" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "rN62kibSRZq0RxcwxEHKKw" + | } + | }, { + | "state" : "STARTED", + | "primary" : false, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "NhG91IW6RCW1KAbSx67O9g" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "VOiMU2k5SuStH3-X1uuBGw", + | "relocating_node" : null, + | "shard" : 0, + | "index" : "hello", + | "version" : 19, + | "allocation_id" : { + | "id" : "13mrI6FhRjGEk7xG7xYJvg" + | } + | } ], + | "xIcHb7CPRH-_m4VGCtBV-w" : [ { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "xIcHb7CPRH-_m4VGCtBV-w", + | "relocating_node" : "VOiMU2k5SuStH3-X1uuBGw", + | "shard" : 1, + | "index" : "hello", + | "version" : 18, + | "expected_shard_size_in_bytes" : 407699, + | "allocation_id" : { + | "id" : "avGC6WQeTzqRnQyBE9O_bQ", + | "relocation_id" : "rNdtAPz_RhKVBp6dpAH1cw" + | } + | }, { + | "state" : "INITIALIZING", + | "primary" : false, + | "node" : "xIcHb7CPRH-_m4VGCtBV-w", + | "relocating_node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "shard" : 0, + | "index" : "hello", + | "version" : 19, + | "expected_shard_size_in_bytes" : 405582, + | "allocation_id" : { + | "id" : "fU5MEf2SSyGi40BscFJQsw", + | "relocation_id" : "FbfzrPiySEaOzGMRZRDf7w" + | } + | } ], + | "cPsT9o5FQ3WRnvqSTXHiVQ" : [ { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 1, + | "index" : "hello", + | "version" : 18, + | "allocation_id" : { + | "id" : "hlwc94lZRvOoBoaxyEWIGg" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 4, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "Kyne0gDVQEasq9VxUUsxbg" + | } + | }, { + | "state" : "STARTED", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 2, + | "index" : "hello", + | "version" : 16, + | "allocation_id" : { + | "id" : "2G3Hs3CnT5uvhpeOmHZyYg" + | } + | }, { + | "state" : "STARTED", + | "primary" : true, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : null, + | "shard" : 3, + | "index" : "hello", + | "version" : 12, + | "allocation_id" : { + | "id" : "b4Gdtk7uTuSINaZ_YdaJdg" + | } + | }, { + | "state" : "RELOCATING", + | "primary" : false, + | "node" : "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node" : "xIcHb7CPRH-_m4VGCtBV-w", + | "shard" : 0, + | "index" : "hello", + | "version" : 19, + | "expected_shard_size_in_bytes" : 405582, + | "allocation_id" : { + | "id" : "FbfzrPiySEaOzGMRZRDf7w", + | "relocation_id" : "fU5MEf2SSyGi40BscFJQsw" + | } + | } ] + | } + | } + |} + """.stripMargin + ) + + val nodesStats = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "nodes" : { + | "VOiMU2k5SuStH3-X1uuBGw" : { + | "timestamp" : 1458467882703, + | "name" : "Random", + | "transport_address" : "127.0.0.1:9301", + | "host" : "127.0.0.1", + | "ip" : [ "127.0.0.1:9301", "NONE" ], + | "os" : { + | "timestamp" : 1458467882703, + | "load_average" : 3.46435546875, + | "mem" : { + | "total_in_bytes" : 8589934592, + | "free_in_bytes" : 160845824, + | "used_in_bytes" : 8429088768, + | "free_percent" : 2, + | "used_percent" : 98 + | }, + | "swap" : { + | "total_in_bytes" : 3221225472, + | "free_in_bytes" : 1782317056, + | "used_in_bytes" : 1438908416 + | } + | }, + | "process" : { + | "timestamp" : 1458467882703, + | "open_file_descriptors" : 341, + | "max_file_descriptors" : 10240, + | "cpu" : { + | "percent" : 0, + | "total_in_millis" : 221649 + | }, + | "mem" : { + | "total_virtual_in_bytes" : 5311496192 + | } + | }, + | "jvm" : { + | "timestamp" : 1458467882703, + | "uptime_in_millis" : 2812465, + | "mem" : { + | "heap_used_in_bytes" : 109357464, + | "heap_used_percent" : 10, + | "heap_committed_in_bytes" : 259522560, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_used_in_bytes" : 70464888, + | "non_heap_committed_in_bytes" : 71409664, + | "pools" : { + | "young" : { + | "used_in_bytes" : 60805240, + | "max_in_bytes" : 286326784, + | "peak_used_in_bytes" : 71630848, + | "peak_max_in_bytes" : 286326784 + | }, + | "survivor" : { + | "used_in_bytes" : 2424584, + | "max_in_bytes" : 35782656, + | "peak_used_in_bytes" : 8912896, + | "peak_max_in_bytes" : 35782656 + | }, + | "old" : { + | "used_in_bytes" : 46127640, + | "max_in_bytes" : 715849728, + | "peak_used_in_bytes" : 46127640, + | "peak_max_in_bytes" : 715849728 + | } + | } + | }, + | "threads" : { + | "count" : 81, + | "peak_count" : 103 + | }, + | "gc" : { + | "collectors" : { + | "young" : { + | "collection_count" : 174, + | "collection_time_in_millis" : 866 + | }, + | "old" : { + | "collection_count" : 1, + | "collection_time_in_millis" : 16 + | } + | } + | }, + | "buffer_pools" : { + | "direct" : { + | "count" : 125, + | "used_in_bytes" : 20117010, + | "total_capacity_in_bytes" : 20117010 + | }, + | "mapped" : { + | "count" : 16, + | "used_in_bytes" : 1065237, + | "total_capacity_in_bytes" : 1065237 + | } + | } + | }, + | "fs" : { + | "timestamp" : 1458467882703, + | "total" : { + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 40472023040, + | "available_in_bytes" : 40209879040 + | }, + | "data" : [ { + | "path" : "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/1", + | "mount" : "/ (/dev/disk1)", + | "type" : "hfs", + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 40472023040, + | "available_in_bytes" : 40209879040 + | } ] + | } + | }, + | "xIcHb7CPRH-_m4VGCtBV-w" : { + | "timestamp" : 1458467882703, + | "name" : "Force", + | "transport_address" : "127.0.0.1:9302", + | "host" : "127.0.0.1", + | "ip" : [ "127.0.0.1:9302", "NONE" ], + | "os" : { + | "timestamp" : 1458467882703, + | "load_average" : 3.46435546875, + | "mem" : { + | "total_in_bytes" : 8589934592, + | "free_in_bytes" : 160845824, + | "used_in_bytes" : 8429088768, + | "free_percent" : 2, + | "used_percent" : 98 + | }, + | "swap" : { + | "total_in_bytes" : 3221225472, + | "free_in_bytes" : 1782317056, + | "used_in_bytes" : 1438908416 + | } + | }, + | "process" : { + | "timestamp" : 1458467882703, + | "open_file_descriptors" : 287, + | "max_file_descriptors" : 10240, + | "cpu" : { + | "percent" : 0, + | "total_in_millis" : 9698 + | }, + | "mem" : { + | "total_virtual_in_bytes" : 5304852480 + | } + | }, + | "jvm" : { + | "timestamp" : 1458467882703, + | "uptime_in_millis" : 20926, + | "mem" : { + | "heap_used_in_bytes" : 61247544, + | "heap_used_percent" : 5, + | "heap_committed_in_bytes" : 259522560, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_used_in_bytes" : 45875264, + | "non_heap_committed_in_bytes" : 46505984, + | "pools" : { + | "young" : { + | "used_in_bytes" : 42389104, + | "max_in_bytes" : 286326784, + | "peak_used_in_bytes" : 71630848, + | "peak_max_in_bytes" : 286326784 + | }, + | "survivor" : { + | "used_in_bytes" : 7531480, + | "max_in_bytes" : 35782656, + | "peak_used_in_bytes" : 8912888, + | "peak_max_in_bytes" : 35782656 + | }, + | "old" : { + | "used_in_bytes" : 11326960, + | "max_in_bytes" : 715849728, + | "peak_used_in_bytes" : 11326960, + | "peak_max_in_bytes" : 715849728 + | } + | } + | }, + | "threads" : { + | "count" : 78, + | "peak_count" : 78 + | }, + | "gc" : { + | "collectors" : { + | "young" : { + | "collection_count" : 4, + | "collection_time_in_millis" : 52 + | }, + | "old" : { + | "collection_count" : 1, + | "collection_time_in_millis" : 16 + | } + | } + | }, + | "buffer_pools" : { + | "direct" : { + | "count" : 79, + | "used_in_bytes" : 16786963, + | "total_capacity_in_bytes" : 16786963 + | }, + | "mapped" : { + | "count" : 0, + | "used_in_bytes" : 0, + | "total_capacity_in_bytes" : 0 + | } + | } + | }, + | "fs" : { + | "timestamp" : 1458467882704, + | "total" : { + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 40471994368, + | "available_in_bytes" : 40209850368 + | }, + | "data" : [ { + | "path" : "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/2", + | "mount" : "/ (/dev/disk1)", + | "type" : "hfs", + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 40471994368, + | "available_in_bytes" : 40209850368 + | } ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ" : { + | "timestamp" : 1458467882703, + | "name" : "Cecilia Reyes", + | "transport_address" : "127.0.0.1:9300", + | "host" : "127.0.0.1", + | "ip" : [ "127.0.0.1:9300", "NONE" ], + | "os" : { + | "timestamp" : 1458467882703, + | "load_average" : 3.46435546875, + | "mem" : { + | "total_in_bytes" : 8589934592, + | "free_in_bytes" : 160845824, + | "used_in_bytes" : 8429088768, + | "free_percent" : 2, + | "used_percent" : 98 + | }, + | "swap" : { + | "total_in_bytes" : 3221225472, + | "free_in_bytes" : 1782317056, + | "used_in_bytes" : 1438908416 + | } + | }, + | "process" : { + | "timestamp" : 1458467882703, + | "open_file_descriptors" : 356, + | "max_file_descriptors" : 10240, + | "cpu" : { + | "percent" : 0, + | "total_in_millis" : 461242 + | }, + | "mem" : { + | "total_virtual_in_bytes" : 5319544832 + | } + | }, + | "jvm" : { + | "timestamp" : 1458467882703, + | "uptime_in_millis" : 14057100, + | "mem" : { + | "heap_used_in_bytes" : 80014736, + | "heap_used_percent" : 7, + | "heap_committed_in_bytes" : 259522560, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_used_in_bytes" : 81637648, + | "non_heap_committed_in_bytes" : 83148800, + | "pools" : { + | "young" : { + | "used_in_bytes" : 61420544, + | "max_in_bytes" : 286326784, + | "peak_used_in_bytes" : 71630848, + | "peak_max_in_bytes" : 286326784 + | }, + | "survivor" : { + | "used_in_bytes" : 1478648, + | "max_in_bytes" : 35782656, + | "peak_used_in_bytes" : 8912896, + | "peak_max_in_bytes" : 35782656 + | }, + | "old" : { + | "used_in_bytes" : 17115544, + | "max_in_bytes" : 715849728, + | "peak_used_in_bytes" : 104965192, + | "peak_max_in_bytes" : 715849728 + | } + | } + | }, + | "threads" : { + | "count" : 85, + | "peak_count" : 106 + | }, + | "gc" : { + | "collectors" : { + | "young" : { + | "collection_count" : 254, + | "collection_time_in_millis" : 1635 + | }, + | "old" : { + | "collection_count" : 2, + | "collection_time_in_millis" : 134 + | } + | } + | }, + | "buffer_pools" : { + | "direct" : { + | "count" : 173, + | "used_in_bytes" : 28642823, + | "total_capacity_in_bytes" : 28642823 + | }, + | "mapped" : { + | "count" : 15, + | "used_in_bytes" : 891872, + | "total_capacity_in_bytes" : 891872 + | } + | }, + | "classes" : { + | "current_loaded_count" : 7609, + | "total_loaded_count" : 7623, + | "total_unloaded_count" : 14 + | } + | }, + | "fs" : { + | "timestamp" : 1458467882703, + | "total" : { + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 40472023040, + | "available_in_bytes" : 40209879040 + | }, + | "data" : [ { + | "path" : "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/0", + | "mount" : "/ (/dev/disk1)", + | "type" : "hfs", + | "total_in_bytes" : 249804886016, + | "free_in_bytes" : 40472023040, + | "available_in_bytes" : 40209879040 + | } ] + | } + | } + | } + |} + """.stripMargin + ) + + val indicesStats = Json.parse( + """ + |{ + | "_shards" : { + | "total" : 10, + | "successful" : 10, + | "failed" : 0 + | }, + | "_all" : { + | "primaries" : { + | "docs" : { + | "count" : 108680, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 2026271, + | "throttle_time_in_millis" : 0 + | } + | }, + | "total" : { + | "docs" : { + | "count" : 217360, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 4052542, + | "throttle_time_in_millis" : 0 + | } + | } + | }, + | "indices" : { + | "hello" : { + | "primaries" : { + | "docs" : { + | "count" : 108680, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 2026271, + | "throttle_time_in_millis" : 0 + | } + | }, + | "total" : { + | "docs" : { + | "count" : 217360, + | "deleted" : 0 + | }, + | "store" : { + | "size_in_bytes" : 4052542, + | "throttle_time_in_millis" : 0 + | } + | } + | } + | } + |} + """.stripMargin + ) + + val clusterSettings = Json.parse( + """ + |{ + | "persistent" : { }, + | "transient" : { } + |} + """.stripMargin + ) + + val aliases = Json.parse( + """ + |{ + | "hello" : { + | "aliases" : { } + | } + |} + """.stripMargin + ) + + val clusterHealth = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "status" : "green", + | "timed_out" : false, + | "number_of_nodes" : 3, + | "number_of_data_nodes" : 3, + | "active_primary_shards" : 5, + | "active_shards" : 10, + | "relocating_shards" : 2, + | "initializing_shards" : 0, + | "unassigned_shards" : 0, + | "delayed_unassigned_shards" : 0, + | "number_of_pending_tasks" : 0, + | "number_of_in_flight_fetch" : 0, + | "task_max_waiting_in_queue_millis" : 0, + | "active_shards_percent_as_number" : 100 + |} + """.stripMargin + ) + + val nodes = Json.parse( + """ + |{ + | "cluster_name" : "elasticsearch", + | "nodes" : { + | "VOiMU2k5SuStH3-X1uuBGw" : { + | "name" : "Random", + | "transport_address" : "127.0.0.1:9301", + | "host" : "127.0.0.1", + | "ip" : "127.0.0.1", + | "version" : "2.1.0", + | "build" : "72cd1f1", + | "http_address" : "127.0.0.1:9201", + | "os" : { + | "refresh_interval_in_millis" : 1000, + | "available_processors" : 8, + | "allocated_processors" : 8 + | }, + | "jvm" : { + | "pid" : 16419, + | "version" : "1.8.0_72", + | "vm_name" : "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version" : "25.72-b15", + | "vm_vendor" : "Oracle Corporation", + | "start_time_in_millis" : 1458393717991, + | "mem" : { + | "heap_init_in_bytes" : 268435456, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_init_in_bytes" : 2555904, + | "non_heap_max_in_bytes" : 0, + | "direct_max_in_bytes" : 1037959168 + | }, + | "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ], + | "memory_pools" : [ "Code Cache", "Metaspace", "Compressed Class Space", "Par Eden Space", "Par Survivor Space", "CMS Old Gen" ] + | } + | }, + | "xIcHb7CPRH-_m4VGCtBV-w" : { + | "name" : "Force", + | "transport_address" : "127.0.0.1:9302", + | "host" : "127.0.0.1", + | "ip" : "127.0.0.1", + | "version" : "2.1.0", + | "build" : "72cd1f1", + | "http_address" : "127.0.0.1:9202", + | "os" : { + | "refresh_interval_in_millis" : 1000, + | "available_processors" : 8, + | "allocated_processors" : 8 + | }, + | "jvm" : { + | "pid" : 76352, + | "version" : "1.8.0_72", + | "vm_name" : "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version" : "25.72-b15", + | "vm_vendor" : "Oracle Corporation", + | "start_time_in_millis" : 1458467861836, + | "mem" : { + | "heap_init_in_bytes" : 268435456, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_init_in_bytes" : 2555904, + | "non_heap_max_in_bytes" : 0, + | "direct_max_in_bytes" : 1037959168 + | }, + | "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ], + | "memory_pools" : [ "Code Cache", "Metaspace", "Compressed Class Space", "Par Eden Space", "Par Survivor Space", "CMS Old Gen" ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ" : { + | "name" : "Cecilia Reyes", + | "transport_address" : "127.0.0.1:9300", + | "host" : "127.0.0.1", + | "ip" : "127.0.0.1", + | "version" : "2.1.0", + | "build" : "72cd1f1", + | "http_address" : "127.0.0.1:9200", + | "os" : { + | "refresh_interval_in_millis" : 1000, + | "name" : "Mac OS X", + | "arch" : "x86_64", + | "version" : "10.11.3", + | "available_processors" : 8, + | "allocated_processors" : 8 + | }, + | "jvm" : { + | "pid" : 60169, + | "version" : "1.8.0_72", + | "vm_name" : "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version" : "25.72-b15", + | "vm_vendor" : "Oracle Corporation", + | "start_time_in_millis" : 1458345474505, + | "mem" : { + | "heap_init_in_bytes" : 268435456, + | "heap_max_in_bytes" : 1037959168, + | "non_heap_init_in_bytes" : 2555904, + | "non_heap_max_in_bytes" : 0, + | "direct_max_in_bytes" : 1037959168 + | }, + | "gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ], + | "memory_pools" : [ "Code Cache", "Metaspace", "Compressed Class Space", "Par Eden Space", "Par Survivor Space", "CMS Old Gen" ] + | } + | } + | } + |} + """.stripMargin + ) + + val main = Json.parse( + """ + |{ + | "name" : "Cecilia Reyes", + | "cluster_name" : "elasticsearch", + | "version" : { + | "number" : "2.1.0", + | "build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87", + | "build_timestamp" : "2015-11-18T22:40:03Z", + | "build_snapshot" : false, + | "lucene_version" : "5.3.1" + | }, + | "tagline" : "You Know, for Search" + |} + """.stripMargin + ) + +} diff --git a/test/models/overview/ClusterStub.scala b/test/models/overview/ClusterStub.scala new file mode 100644 index 0000000000000000000000000000000000000000..650b87d1167a224f7e3ed353d66acaa58190544c --- /dev/null +++ b/test/models/overview/ClusterStub.scala @@ -0,0 +1,25 @@ +package models.overview + +import play.api.libs.json.JsValue + +trait ClusterStub { + + def apply() = ClusterOverview(clusterState, nodesStats, indicesStats, clusterSettings, aliases, clusterHealth, nodes, main) + + val clusterState: JsValue + + val nodesStats: JsValue + + val indicesStats: JsValue + + val clusterSettings: JsValue + + val aliases: JsValue + + val clusterHealth: JsValue + + val nodes: JsValue + + val main: JsValue + +} diff --git a/test/models/overview/ClusterWithData.scala b/test/models/overview/ClusterWithData.scala new file mode 100644 index 0000000000000000000000000000000000000000..304260df8ff63aeb2e34e3d59d878878ac071663 --- /dev/null +++ b/test/models/overview/ClusterWithData.scala @@ -0,0 +1,715 @@ +package models.overview + +import play.api.libs.json.Json + +trait ClusterWithData extends ClusterStub { + + val clusterState = Json.parse( + """ + |{ + | "cluster_name": "elasticsearch", + | "master_node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "blocks" : { + | "indices" : { + | "foo" : { + | "4" : { + | "description" : "index closed", + | "retryable" : false, + | "levels" : [ "read", "write" ] + | } + | } + | } + | }, + | "routing_table": { + | "indices": { + | "bar": { + | "shards": { + | "0": [ + | { + | "state": "STARTED", + | "primary": false, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 0, + | "index": "bar", + | "version": 3, + | "allocation_id": { + | "id": "ns_A3bOnS26LHP9aMMoNqQ" + | } + | }, + | { + | "state": "STARTED", + | "primary": true, + | "node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node": null, + | "shard": 0, + | "index": "bar", + | "version": 3, + | "allocation_id": { + | "id": "KpTuITnDRju5huuD7K42JQ" + | } + | } + | ] + | } + | }, + | ".foobar": { + | "shards": { + | "0": [ + | { + | "state": "STARTED", + | "primary": true, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 0, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "av2CBQ7ZR6mpYP4hN45SFQ" + | } + | } + | ], + | "1": [ + | { + | "state": "STARTED", + | "primary": true, + | "node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node": null, + | "shard": 1, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "WA41NgmPRdyuV1Bdf3xAIw" + | } + | } + | ], + | "2": [ + | { + | "state": "STARTED", + | "primary": true, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 2, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "9i-1Ze0iTyyGreKtd6uNlQ" + | } + | } + | ], + | "3": [ + | { + | "state": "STARTED", + | "primary": true, + | "node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node": null, + | "shard": 3, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "QqhRDD_DST6P0By3QaKjug" + | } + | } + | ], + | "4": [ + | { + | "state": "STARTED", + | "primary": true, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 4, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "w30rCs_vRIeWWNdPD6yinA" + | } + | } + | ] + | } + | } + | } + | }, + | "routing_nodes": { + | "unassigned": [], + | "nodes": { + | "MoDcZdJkQGK2RpYTvJhQlA": [ + | { + | "state": "STARTED", + | "primary": false, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 0, + | "index": "bar", + | "version": 3, + | "allocation_id": { + | "id": "ns_A3bOnS26LHP9aMMoNqQ" + | } + | }, + | { + | "state": "STARTED", + | "primary": true, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 4, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "w30rCs_vRIeWWNdPD6yinA" + | } + | }, + | { + | "state": "STARTED", + | "primary": true, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 2, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "9i-1Ze0iTyyGreKtd6uNlQ" + | } + | }, + | { + | "state": "STARTED", + | "primary": true, + | "node": "MoDcZdJkQGK2RpYTvJhQlA", + | "relocating_node": null, + | "shard": 0, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "av2CBQ7ZR6mpYP4hN45SFQ" + | } + | } + | ], + | "cPsT9o5FQ3WRnvqSTXHiVQ": [ + | { + | "state": "STARTED", + | "primary": true, + | "node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node": null, + | "shard": 0, + | "index": "bar", + | "version": 3, + | "allocation_id": { + | "id": "KpTuITnDRju5huuD7K42JQ" + | } + | }, + | { + | "state": "STARTED", + | "primary": true, + | "node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node": null, + | "shard": 1, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "WA41NgmPRdyuV1Bdf3xAIw" + | } + | }, + | { + | "state": "STARTED", + | "primary": true, + | "node": "cPsT9o5FQ3WRnvqSTXHiVQ", + | "relocating_node": null, + | "shard": 3, + | "index": ".foobar", + | "version": 2, + | "allocation_id": { + | "id": "QqhRDD_DST6P0By3QaKjug" + | } + | } + | ] + | } + | } + |} + """.stripMargin + ) + + val nodesStats = Json.parse( + """ + |{ + | "cluster_name": "elasticsearch", + | "nodes": { + | "MoDcZdJkQGK2RpYTvJhQlA": { + | "timestamp": 1458349671429, + | "name": "Solara", + | "transport_address": "127.0.0.1:9301", + | "host": "127.0.0.1", + | "ip": [ + | "127.0.0.1:9301", + | "NONE" + | ], + | "os": { + | "timestamp": 1458349670762, + | "load_average": 3.34326171875, + | "mem": { + | "total_in_bytes": 8589934592, + | "free_in_bytes": 33009664, + | "used_in_bytes": 8556924928, + | "free_percent": 0, + | "used_percent": 100 + | }, + | "swap": { + | "total_in_bytes": 2147483648, + | "free_in_bytes": 1729626112, + | "used_in_bytes": 417857536 + | } + | }, + | "process": { + | "timestamp": 1458349670762, + | "open_file_descriptors": 271, + | "max_file_descriptors": 10240, + | "cpu": { + | "percent": 0, + | "total_in_millis": 46412 + | }, + | "mem": { + | "total_virtual_in_bytes": 5282828288 + | } + | }, + | "jvm": { + | "timestamp": 1458349670762, + | "uptime_in_millis": 4187845, + | "mem": { + | "heap_used_in_bytes": 86912928, + | "heap_used_percent": 8, + | "heap_committed_in_bytes": 259522560, + | "heap_max_in_bytes": 1037959168, + | "non_heap_used_in_bytes": 54344920, + | "non_heap_committed_in_bytes": 55156736, + | "pools": { + | "young": { + | "used_in_bytes": 67421744, + | "max_in_bytes": 286326784, + | "peak_used_in_bytes": 71630848, + | "peak_max_in_bytes": 286326784 + | }, + | "survivor": { + | "used_in_bytes": 6942440, + | "max_in_bytes": 35782656, + | "peak_used_in_bytes": 8912888, + | "peak_max_in_bytes": 35782656 + | }, + | "old": { + | "used_in_bytes": 12548744, + | "max_in_bytes": 715849728, + | "peak_used_in_bytes": 12548744, + | "peak_max_in_bytes": 715849728 + | } + | } + | }, + | "threads": { + | "count": 71, + | "peak_count": 87 + | }, + | "gc": { + | "collectors": { + | "young": { + | "collection_count": 5, + | "collection_time_in_millis": 76 + | }, + | "old": { + | "collection_count": 1, + | "collection_time_in_millis": 18 + | } + | } + | }, + | "buffer_pools": { + | "direct": { + | "count": 79, + | "used_in_bytes": 14167303, + | "total_capacity_in_bytes": 14167303 + | }, + | "mapped": { + | "count": 0, + | "used_in_bytes": 0, + | "total_capacity_in_bytes": 0 + | } + | } + | }, + | "fs": { + | "timestamp": 1458349670762, + | "total": { + | "total_in_bytes": 249804886016, + | "free_in_bytes": 41525211136, + | "available_in_bytes": 41263067136 + | }, + | "data": [ + | { + | "path": "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/1", + | "mount": "/ (/dev/disk1)", + | "type": "hfs", + | "total_in_bytes": 249804886016, + | "free_in_bytes": 41525211136, + | "available_in_bytes": 41263067136 + | } + | ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ": { + | "timestamp": 1458349671429, + | "name": "Cecilia Reyes", + | "transport_address": "127.0.0.1:9300", + | "host": "127.0.0.1", + | "ip": [ + | "127.0.0.1:9300", + | "NONE" + | ], + | "os": { + | "timestamp": 1458349670762, + | "load_average": 3.34326171875, + | "mem": { + | "total_in_bytes": 8589934592, + | "free_in_bytes": 33009664, + | "used_in_bytes": 8556924928, + | "free_percent": 0, + | "used_percent": 100 + | }, + | "swap": { + | "total_in_bytes": 2147483648, + | "free_in_bytes": 1729626112, + | "used_in_bytes": 417857536 + | } + | }, + | "process": { + | "timestamp": 1458349670762, + | "open_file_descriptors": 280, + | "max_file_descriptors": 10240, + | "cpu": { + | "percent": 0, + | "total_in_millis": 49096 + | }, + | "mem": { + | "total_virtual_in_bytes": 5301309440 + | } + | }, + | "jvm": { + | "timestamp": 1458349670762, + | "uptime_in_millis": 4196395, + | "mem": { + | "heap_used_in_bytes": 70134792, + | "heap_used_percent": 6, + | "heap_committed_in_bytes": 259522560, + | "heap_max_in_bytes": 1037959168, + | "non_heap_used_in_bytes": 61118128, + | "non_heap_committed_in_bytes": 62324736, + | "pools": { + | "young": { + | "used_in_bytes": 52733792, + | "max_in_bytes": 286326784, + | "peak_used_in_bytes": 71630848, + | "peak_max_in_bytes": 286326784 + | }, + | "survivor": { + | "used_in_bytes": 2375848, + | "max_in_bytes": 35782656, + | "peak_used_in_bytes": 8912896, + | "peak_max_in_bytes": 35782656 + | }, + | "old": { + | "used_in_bytes": 15025152, + | "max_in_bytes": 715849728, + | "peak_used_in_bytes": 15025152, + | "peak_max_in_bytes": 715849728 + | } + | } + | }, + | "threads": { + | "count": 77, + | "peak_count": 106 + | }, + | "gc": { + | "collectors": { + | "young": { + | "collection_count": 7, + | "collection_time_in_millis": 93 + | }, + | "old": { + | "collection_count": 1, + | "collection_time_in_millis": 12 + | } + | } + | }, + | "buffer_pools": { + | "direct": { + | "count": 153, + | "used_in_bytes": 23280699, + | "total_capacity_in_bytes": 23280699 + | }, + | "mapped": { + | "count": 0, + | "used_in_bytes": 0, + | "total_capacity_in_bytes": 0 + | } + | }, + | "classes": { + | "current_loaded_count": 7446, + | "total_loaded_count": 7446, + | "total_unloaded_count": 0 + | } + | }, + | "fs": { + | "timestamp": 1458349670762, + | "total": { + | "total_in_bytes": 249804886016, + | "free_in_bytes": 41525211136, + | "available_in_bytes": 41263067136 + | }, + | "data": [ + | { + | "path": "/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/0", + | "mount": "/ (/dev/disk1)", + | "type": "hfs", + | "total_in_bytes": 249804886016, + | "free_in_bytes": 41525211136, + | "available_in_bytes": 41263067136 + | } + | ] + | } + | } + | } + |} + """.stripMargin + ) + + val indicesStats = Json.parse( + """ + |{ + | "_shards": { + | "total": 11, + | "successful": 11, + | "failed": 0 + | }, + | "_all": { + | "primaries": { + | "docs": { + | "count": 3, + | "deleted": 0 + | }, + | "store": { + | "size_in_bytes": 9902, + | "throttle_time_in_millis": 0 + | } + | }, + | "total": { + | "docs": { + | "count": 5, + | "deleted": 0 + | }, + | "store": { + | "size_in_bytes": 16184, + | "throttle_time_in_millis": 0 + | } + | } + | }, + | "indices": { + | "bar": { + | "primaries": { + | "docs": { + | "count": 1, + | "deleted": 0 + | }, + | "store": { + | "size_in_bytes": 3076, + | "throttle_time_in_millis": 0 + | } + | }, + | "total": { + | "docs": { + | "count": 2, + | "deleted": 0 + | }, + | "store": { + | "size_in_bytes": 6152, + | "throttle_time_in_millis": 0 + | } + | } + | }, + | ".foobar": { + | "primaries": { + | "docs": { + | "count": 1, + | "deleted": 0 + | }, + | "store": { + | "size_in_bytes": 3620, + | "throttle_time_in_millis": 0 + | } + | }, + | "total": { + | "docs": { + | "count": 1, + | "deleted": 0 + | }, + | "store": { + | "size_in_bytes": 3620, + | "throttle_time_in_millis": 0 + | } + | } + | } + | } + |} + """.stripMargin + ) + + val clusterSettings = Json.parse( + """ + |{ + | "persistent": {}, + | "transient": {} + |} + """.stripMargin + ) + + val aliases = Json.parse( + """ + |{ + | "bar": { + | "aliases": { + | "active": {} + | } + | }, + | ".foobar": { + | "aliases": {} + | } + |} + """.stripMargin + ) + + val clusterHealth = Json.parse( + """ + |{ + | "cluster_name": "elasticsearch", + | "status": "green", + | "timed_out": false, + | "number_of_nodes": 2, + | "number_of_data_nodes": 2, + | "active_primary_shards": 8, + | "active_shards": 11, + | "relocating_shards": 0, + | "initializing_shards": 0, + | "unassigned_shards": 0, + | "delayed_unassigned_shards": 0, + | "number_of_pending_tasks": 0, + | "number_of_in_flight_fetch": 0, + | "task_max_waiting_in_queue_millis": 0, + | "active_shards_percent_as_number": 100 + |} + """.stripMargin + ) + + val nodes = Json.parse( + """ + |{ + | "cluster_name": "elasticsearch", + | "nodes": { + | "MoDcZdJkQGK2RpYTvJhQlA": { + | "name": "Solara", + | "transport_address": "127.0.0.1:9301", + | "host": "127.0.0.1", + | "ip": "127.0.0.1", + | "version": "2.1.0", + | "build": "72cd1f1", + | "http_address": "127.0.0.1:9201", + | "os": { + | "refresh_interval_in_millis": 1000, + | "available_processors": 8, + | "allocated_processors": 8 + | }, + | "jvm": { + | "pid": 60238, + | "version": "1.8.0_72", + | "vm_name": "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version": "25.72-b15", + | "vm_vendor": "Oracle Corporation", + | "start_time_in_millis": 1458345483045, + | "mem": { + | "heap_init_in_bytes": 268435456, + | "heap_max_in_bytes": 1037959168, + | "non_heap_init_in_bytes": 2555904, + | "non_heap_max_in_bytes": 0, + | "direct_max_in_bytes": 1037959168 + | }, + | "gc_collectors": [ + | "ParNew", + | "ConcurrentMarkSweep" + | ], + | "memory_pools": [ + | "Code Cache", + | "Metaspace", + | "Compressed Class Space", + | "Par Eden Space", + | "Par Survivor Space", + | "CMS Old Gen" + | ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ": { + | "name": "Cecilia Reyes", + | "transport_address": "127.0.0.1:9300", + | "host": "127.0.0.1", + | "ip": "127.0.0.1", + | "version": "2.1.0", + | "build": "72cd1f1", + | "http_address": "127.0.0.1:9200", + | "os": { + | "refresh_interval_in_millis": 1000, + | "name": "Mac OS X", + | "arch": "x86_64", + | "version": "10.11.3", + | "available_processors": 8, + | "allocated_processors": 8 + | }, + | "jvm": { + | "pid": 60169, + | "version": "1.8.0_72", + | "vm_name": "Java HotSpot(TM) 64-Bit Server VM", + | "vm_version": "25.72-b15", + | "vm_vendor": "Oracle Corporation", + | "start_time_in_millis": 1458345474505, + | "mem": { + | "heap_init_in_bytes": 268435456, + | "heap_max_in_bytes": 1037959168, + | "non_heap_init_in_bytes": 2555904, + | "non_heap_max_in_bytes": 0, + | "direct_max_in_bytes": 1037959168 + | }, + | "gc_collectors": [ + | "ParNew", + | "ConcurrentMarkSweep" + | ], + | "memory_pools": [ + | "Code Cache", + | "Metaspace", + | "Compressed Class Space", + | "Par Eden Space", + | "Par Survivor Space", + | "CMS Old Gen" + | ] + | } + | } + | } + |} + """.stripMargin + ) + + val main = Json.parse( + """ + |{ + | "name": "Cecilia Reyes", + | "cluster_name": "elasticsearch", + | "version": { + | "number": "2.1.0", + | "build_hash": "72cd1f1a3eee09505e036106146dc1949dc5dc87", + | "build_timestamp": "2015-11-18T22:40:03Z", + | "build_snapshot": false, + | "lucene_version": "5.3.1" + | }, + | "tagline": "You Know, for Search" + |} + """.stripMargin + ) + +} + +object ClusterWithData extends ClusterWithData diff --git a/test/models/overview/ClusterWithoutData.scala b/test/models/overview/ClusterWithoutData.scala new file mode 100644 index 0000000000000000000000000000000000000000..2398e93aa5b3931e5f5f8c6a0c5afe1a5a0d8da8 --- /dev/null +++ b/test/models/overview/ClusterWithoutData.scala @@ -0,0 +1,462 @@ +package models.overview + +import play.api.libs.json.Json + +object ClusterWithoutData extends ClusterStub { + + val clusterState = Json.parse( + """ + |{ + | "cluster_name":"elasticsearch", + | "master_node":"cPsT9o5FQ3WRnvqSTXHiVQ", + | "blocks":{ + | + | }, + | "routing_table":{ + | "indices":{ + | + | } + | }, + | "routing_nodes":{ + | "unassigned":[ + | + | ], + | "nodes":{ + | "MoDcZdJkQGK2RpYTvJhQlA":[ + | + | ], + | "cPsT9o5FQ3WRnvqSTXHiVQ":[ + | + | ] + | } + | } + |} + """.stripMargin + ) + + val nodesStats = Json.parse( + """ + |{ + | "cluster_name":"elasticsearch", + | "nodes":{ + | "MoDcZdJkQGK2RpYTvJhQlA":{ + | "timestamp":1458346589015, + | "name":"Solara", + | "transport_address":"127.0.0.1:9301", + | "host":"127.0.0.1", + | "ip":[ + | "127.0.0.1:9301", + | "NONE" + | ], + | "os":{ + | "timestamp":1458346589015, + | "load_average":3.17138671875, + | "mem":{ + | "total_in_bytes":8589934592, + | "free_in_bytes":101085184, + | "used_in_bytes":8488849408, + | "free_percent":1, + | "used_percent":99 + | }, + | "swap":{ + | "total_in_bytes":2147483648, + | "free_in_bytes":1736966144, + | "used_in_bytes":410517504 + | } + | }, + | "process":{ + | "timestamp":1458346589015, + | "open_file_descriptors":257, + | "max_file_descriptors":10240, + | "cpu":{ + | "percent":0, + | "total_in_millis":24084 + | }, + | "mem":{ + | "total_virtual_in_bytes":5274689536 + | } + | }, + | "jvm":{ + | "timestamp":1458346589015, + | "uptime_in_millis":1106048, + | "mem":{ + | "heap_used_in_bytes":28420720, + | "heap_used_percent":2, + | "heap_committed_in_bytes":259522560, + | "heap_max_in_bytes":1037959168, + | "non_heap_used_in_bytes":50725848, + | "non_heap_committed_in_bytes":51486720, + | "pools":{ + | "young":{ + | "used_in_bytes":8929536, + | "max_in_bytes":286326784, + | "peak_used_in_bytes":71630848, + | "peak_max_in_bytes":286326784 + | }, + | "survivor":{ + | "used_in_bytes":6942440, + | "max_in_bytes":35782656, + | "peak_used_in_bytes":8912888, + | "peak_max_in_bytes":35782656 + | }, + | "old":{ + | "used_in_bytes":12548744, + | "max_in_bytes":715849728, + | "peak_used_in_bytes":12548744, + | "peak_max_in_bytes":715849728 + | } + | } + | }, + | "threads":{ + | "count":67, + | "peak_count":87 + | }, + | "gc":{ + | "collectors":{ + | "young":{ + | "collection_count":5, + | "collection_time_in_millis":76 + | }, + | "old":{ + | "collection_count":1, + | "collection_time_in_millis":18 + | } + | } + | }, + | "buffer_pools":{ + | "direct":{ + | "count":71, + | "used_in_bytes":13640062, + | "total_capacity_in_bytes":13640062 + | }, + | "mapped":{ + | "count":0, + | "used_in_bytes":0, + | "total_capacity_in_bytes":0 + | } + | } + | }, + | "fs":{ + | "timestamp":1458346589015, + | "total":{ + | "total_in_bytes":249804886016, + | "free_in_bytes":41567444992, + | "available_in_bytes":41305300992 + | }, + | "data":[ + | { + | "path":"/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/1", + | "mount":"/ (/dev/disk1)", + | "type":"hfs", + | "total_in_bytes":249804886016, + | "free_in_bytes":41567444992, + | "available_in_bytes":41305300992 + | } + | ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ":{ + | "timestamp":1458346589015, + | "name":"Cecilia Reyes", + | "transport_address":"127.0.0.1:9300", + | "host":"127.0.0.1", + | "ip":[ + | "127.0.0.1:9300", + | "NONE" + | ], + | "os":{ + | "timestamp":1458346589015, + | "load_average":3.17138671875, + | "mem":{ + | "total_in_bytes":8589934592, + | "free_in_bytes":101085184, + | "used_in_bytes":8488849408, + | "free_percent":1, + | "used_percent":99 + | }, + | "swap":{ + | "total_in_bytes":2147483648, + | "free_in_bytes":1736966144, + | "used_in_bytes":410517504 + | } + | }, + | "process":{ + | "timestamp":1458346589015, + | "open_file_descriptors":265, + | "max_file_descriptors":10240, + | "cpu":{ + | "percent":0, + | "total_in_millis":23221 + | }, + | "mem":{ + | "total_virtual_in_bytes":5287575552 + | } + | }, + | "jvm":{ + | "timestamp":1458346589015, + | "uptime_in_millis":1114598, + | "mem":{ + | "heap_used_in_bytes":24190184, + | "heap_used_percent":2, + | "heap_committed_in_bytes":259522560, + | "heap_max_in_bytes":1037959168, + | "non_heap_used_in_bytes":53616440, + | "non_heap_committed_in_bytes":54919168, + | "pools":{ + | "young":{ + | "used_in_bytes":4830480, + | "max_in_bytes":286326784, + | "peak_used_in_bytes":71630848, + | "peak_max_in_bytes":286326784 + | }, + | "survivor":{ + | "used_in_bytes":4334552, + | "max_in_bytes":35782656, + | "peak_used_in_bytes":8912896, + | "peak_max_in_bytes":35782656 + | }, + | "old":{ + | "used_in_bytes":15025152, + | "max_in_bytes":715849728, + | "peak_used_in_bytes":15025152, + | "peak_max_in_bytes":715849728 + | } + | } + | }, + | "threads":{ + | "count":72, + | "peak_count":106 + | }, + | "gc":{ + | "collectors":{ + | "young":{ + | "collection_count":6, + | "collection_time_in_millis":85 + | }, + | "old":{ + | "collection_count":1, + | "collection_time_in_millis":12 + | } + | } + | }, + | "buffer_pools":{ + | "direct":{ + | "count":122, + | "used_in_bytes":18508157, + | "total_capacity_in_bytes":18508157 + | }, + | "mapped":{ + | "count":0, + | "used_in_bytes":0, + | "total_capacity_in_bytes":0 + | } + | }, + | "classes":{ + | "current_loaded_count":6988, + | "total_loaded_count":6988, + | "total_unloaded_count":0 + | } + | }, + | "fs":{ + | "timestamp":1458346589015, + | "total":{ + | "total_in_bytes":249804886016, + | "free_in_bytes":41567444992, + | "available_in_bytes":41305300992 + | }, + | "data":[ + | { + | "path":"/Users/leonardo.menezes/Downloads/elasticsearch-2.1.0/data/elasticsearch/nodes/0", + | "mount":"/ (/dev/disk1)", + | "type":"hfs", + | "total_in_bytes":249804886016, + | "free_in_bytes":41567444992, + | "available_in_bytes":41305300992 + | } + | ] + | } + | } + | } + |} + """.stripMargin + ) + + val indicesStats = Json.parse( + """ + |{ + | "_shards":{ + | "total":0, + | "successful":0, + | "failed":0 + | }, + | "_all":{ + | "primaries":{ + | + | }, + | "total":{ + | + | } + | }, + | "indices":{ + | + | } + |} + """.stripMargin + ) + + val clusterSettings = Json.parse( + """ + |{ + | "persistent":{ + | + | }, + | "transient":{ + | + | } + |} + """.stripMargin + ) + + val aliases = Json.parse( + """ + |{ + | + |} + """.stripMargin + ) + + val clusterHealth = Json.parse( + """ + |{ + | "cluster_name":"elasticsearch", + | "status":"green", + | "timed_out":false, + | "number_of_nodes":2, + | "number_of_data_nodes":2, + | "active_primary_shards":0, + | "active_shards":0, + | "relocating_shards":0, + | "initializing_shards":0, + | "unassigned_shards":0, + | "delayed_unassigned_shards":0, + | "number_of_pending_tasks":0, + | "number_of_in_flight_fetch":0, + | "task_max_waiting_in_queue_millis":0, + | "active_shards_percent_as_number":100 + |} + """.stripMargin + ) + + val nodes = Json.parse( + """ + |{ + | "cluster_name":"elasticsearch", + | "nodes":{ + | "MoDcZdJkQGK2RpYTvJhQlA":{ + | "name":"Solara", + | "transport_address":"127.0.0.1:9301", + | "host":"127.0.0.1", + | "ip":"127.0.0.1", + | "version":"2.1.0", + | "build":"72cd1f1", + | "http_address":"127.0.0.1:9201", + | "os":{ + | "refresh_interval_in_millis":1000, + | "available_processors":8, + | "allocated_processors":8 + | }, + | "jvm":{ + | "pid":60238, + | "version":"1.8.0_72", + | "vm_name":"Java HotSpot(TM) 64-Bit Server VM", + | "vm_version":"25.72-b15", + | "vm_vendor":"Oracle Corporation", + | "start_time_in_millis":1458345483045, + | "mem":{ + | "heap_init_in_bytes":268435456, + | "heap_max_in_bytes":1037959168, + | "non_heap_init_in_bytes":2555904, + | "non_heap_max_in_bytes":0, + | "direct_max_in_bytes":1037959168 + | }, + | "gc_collectors":[ + | "ParNew", + | "ConcurrentMarkSweep" + | ], + | "memory_pools":[ + | "Code Cache", + | "Metaspace", + | "Compressed Class Space", + | "Par Eden Space", + | "Par Survivor Space", + | "CMS Old Gen" + | ] + | } + | }, + | "cPsT9o5FQ3WRnvqSTXHiVQ":{ + | "name":"Cecilia Reyes", + | "transport_address":"127.0.0.1:9300", + | "host":"127.0.0.1", + | "ip":"127.0.0.1", + | "version":"2.1.0", + | "build":"72cd1f1", + | "http_address":"127.0.0.1:9200", + | "os":{ + | "refresh_interval_in_millis":1000, + | "name":"Mac OS X", + | "arch":"x86_64", + | "version":"10.11.3", + | "available_processors":8, + | "allocated_processors":8 + | }, + | "jvm":{ + | "pid":60169, + | "version":"1.8.0_72", + | "vm_name":"Java HotSpot(TM) 64-Bit Server VM", + | "vm_version":"25.72-b15", + | "vm_vendor":"Oracle Corporation", + | "start_time_in_millis":1458345474505, + | "mem":{ + | "heap_init_in_bytes":268435456, + | "heap_max_in_bytes":1037959168, + | "non_heap_init_in_bytes":2555904, + | "non_heap_max_in_bytes":0, + | "direct_max_in_bytes":1037959168 + | }, + | "gc_collectors":[ + | "ParNew", + | "ConcurrentMarkSweep" + | ], + | "memory_pools":[ + | "Code Cache", + | "Metaspace", + | "Compressed Class Space", + | "Par Eden Space", + | "Par Survivor Space", + | "CMS Old Gen" + | ] + | } + | } + | } + |} + """.stripMargin + ) + + val main = Json.parse( + """ + |{ + | "name":"Cecilia Reyes", + | "cluster_name":"elasticsearch", + | "version":{ + | "number":"2.1.0", + | "build_hash":"72cd1f1a3eee09505e036106146dc1949dc5dc87", + | "build_timestamp":"2015-11-18T22:40:03Z", + | "build_snapshot":false, + | "lucene_version":"5.3.1" + | }, + | "tagline":"You Know, for Search" + |} + """.stripMargin + ) + +} diff --git a/test/models/overview/NodeSpec.scala b/test/models/overview/NodeSpec.scala new file mode 100644 index 0000000000000000000000000000000000000000..cb5d9fbe16092db667ea0fb4d089c8048e5f1acd --- /dev/null +++ b/test/models/overview/NodeSpec.scala @@ -0,0 +1,88 @@ +package models.overview + +import org.specs2.Specification +import play.api.libs.json.Json + +object NodeSpec extends Specification { + + def is = + s2""" + Node should + + parse a >= 5.0 ES node $nodeInfo5 + parse a AWS nods $awsNode + """ + + def nodeInfo5 = { + val expected = Json.parse( + """ + |{ + | "id": "nodeId", + | "current_master": false, + | "name": "Solara", + | "host": "127.0.0.1", + | "ip": "127.0.0.1", + | "es_version": "2.1.0", + | "jvm_version": "1.8.0_72", + | "load_average": 3.17138671875, + | "available_processors": 8, + | "cpu_percent": 0, + | "master": true, + | "data": true, + | "coordinating": false, + | "ingest": false, + | "heap": { + | "used": 28420720, + | "committed": 259522560, + | "used_percent": 2, + | "max": 1037959168 + | }, + | "disk": { + | "total": 249804886016, + | "free": 41567444992, + | "used_percent": 84 + | } + |} + """.stripMargin + ) + val node = Node("nodeId", NodesInfo.nodeInfo5, NodeStats.nodeStats5, "otherId") + node mustEqual expected + } + + def awsNode = { + val expected = Json.parse( + """ + |{ + | "id": "nodeId", + | "current_master": false, + | "name": "Solara", + | "host": null, + | "ip": null, + | "es_version": "2.1.0", + | "jvm_version": null, + | "load_average": 3.17138671875, + | "available_processors": 8, + | "cpu_percent": 0, + | "master": true, + | "data": true, + | "coordinating": false, + | "ingest": false, + | "heap": { + | "used": 28420720, + | "committed": 259522560, + | "used_percent": 2, + | "max": 1037959168 + | }, + | "disk": { + | "total": 249804886016, + | "free": 41567444992, + | "used_percent": 84 + | } + |} + """.stripMargin + ) + val node = Node("nodeId", NodesInfo.awsInfo, NodeStats.awsNodeStats5, "otherId") + node mustEqual expected + } + +} diff --git a/test/services/overview/NodeStats.scala b/test/models/overview/NodeStats.scala similarity index 99% rename from test/services/overview/NodeStats.scala rename to test/models/overview/NodeStats.scala index 7624318691a8bf92f46970f5a68aa5d7cdb4e4d1..f813ba2b3eede5cc5db61ff2657876a57ae4d5b7 100644 --- a/test/services/overview/NodeStats.scala +++ b/test/models/overview/NodeStats.scala @@ -1,4 +1,4 @@ -package services.overview +package models.overview import play.api.libs.json.Json diff --git a/test/models/overview/NodesInfo.scala b/test/models/overview/NodesInfo.scala new file mode 100644 index 0000000000000000000000000000000000000000..dc1530b50f913d3fb72c02d7d8020989d98b851c --- /dev/null +++ b/test/models/overview/NodesInfo.scala @@ -0,0 +1,95 @@ +package models.overview + +import play.api.libs.json.Json + +object NodesInfo { + + val nodeInfo5 = Json.parse( + """ + |{ + | "name":"Solara", + | "transport_address":"127.0.0.1:9301", + | "host":"127.0.0.1", + | "ip":"127.0.0.1", + | "version":"2.1.0", + | "build":"72cd1f1", + | "http_address":"127.0.0.1:9201", + | "os":{ + | "refresh_interval_in_millis":1000, + | "available_processors":8, + | "allocated_processors":8 + | }, + | "jvm":{ + | "pid":60238, + | "version":"1.8.0_72", + | "vm_name":"Java HotSpot(TM) 64-Bit Server VM", + | "vm_version":"25.72-b15", + | "vm_vendor":"Oracle Corporation", + | "start_time_in_millis":1458345483045, + | "mem":{ + | "heap_init_in_bytes":268435456, + | "heap_max_in_bytes":1037959168, + | "non_heap_init_in_bytes":2555904, + | "non_heap_max_in_bytes":0, + | "direct_max_in_bytes":1037959168 + | }, + | "gc_collectors":[ + | "ParNew", + | "ConcurrentMarkSweep" + | ], + | "memory_pools":[ + | "Code Cache", + | "Metaspace", + | "Compressed Class Space", + | "Par Eden Space", + | "Par Survivor Space", + | "CMS Old Gen" + | ] + | } + |} + """.stripMargin + ) + + val awsInfo = Json.parse( + """ + |{ + | "name":"Solara", + | "version":"2.1.0", + | "build":"72cd1f1", + | "os":{ + | "refresh_interval_in_millis":1000, + | "available_processors":8, + | "allocated_processors":8 + | }, + | "jvm":{ + | "pid":60238, + | "vm_name":"Java HotSpot(TM) 64-Bit Server VM", + | "vm_version":"25.72-b15", + | "vm_vendor":"Oracle Corporation", + | "start_time_in_millis":1458345483045, + | "mem":{ + | "heap_init_in_bytes":268435456, + | "heap_max_in_bytes":1037959168, + | "non_heap_init_in_bytes":2555904, + | "non_heap_max_in_bytes":0, + | "direct_max_in_bytes":1037959168 + | }, + | "gc_collectors":[ + | "ParNew", + | "ConcurrentMarkSweep" + | ], + | "memory_pools":[ + | "Code Cache", + | "Metaspace", + | "Compressed Class Space", + | "Par Eden Space", + | "Par Survivor Space", + | "CMS Old Gen" + | ] + | } + |} + """.stripMargin + ) + + +} diff --git a/test/services/overview/ClusterInitializingShards.scala b/test/services/overview/ClusterInitializingShards.scala deleted file mode 100644 index 87ead5ac1d85c9d3d34b5afadce634f817a5521b..0000000000000000000000000000000000000000 --- a/test/services/overview/ClusterInitializingShards.scala +++ /dev/null @@ -1,167 +0,0 @@ -package services.overview - -import play.api.libs.json.Json - -object ClusterInitializingShards { - - def apply() = ClusterOverview(settings, health, nodes, indices, shards, aliases) - - val settings = Json.parse( - """ - |{ - | "persistent" : { }, - | "transient" : { } - |} - """.stripMargin - ) - - val health = Json.parse( - """ - |{ - | "cluster_name" : "elasticsearch", - | "status" : "yellow", - | "timed_out" : false, - | "number_of_nodes" : 2, - | "number_of_data_nodes" : 2, - | "active_primary_shards" : 5, - | "active_shards" : 5, - | "relocating_shards" : 0, - | "initializing_shards" : 4, - | "unassigned_shards" : 1, - | "delayed_unassigned_shards" : 0, - | "number_of_pending_tasks" : 0, - | "number_of_in_flight_fetch" : 0, - | "task_max_waiting_in_queue_millis" : 0, - | "active_shards_percent_as_number" : 50 - |} - """.stripMargin - ) - - val nodes = Json.parse( - """ - |[ - | { - | "id": "rtOe", - | "ip": "127.0.0.1", - | "version": "5.3.0", - | "jdk": "1.8.0_92", - | "disk.avail": "114.5gb", - | "heap.current": "403.7mb", - | "heap.percent": "20", - | "heap.max": "1.9gb", - | "cpu": "23", - | "load_1m": "3.45", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm" - | } - |] - """.stripMargin) - - val indices = Json.parse( - """ - |[ - | { - | "health": "yellow", - | "status": "open", - | "index": "bar", - | "uuid": "UXV_U1tTSK62OCRHVw3HaA", - | "pri": "5", - | "rep": "1", - | "docs.count": "0", - | "docs.deleted": "0", - | "store.size": "650b", - | "pri.store.size": "650b" - | } - |] - """.stripMargin) - - - val shards = Json.parse( - """ - |[ - | { - | "index": "bar", - | "shard": "2", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "2", - | "prirep": "r", - | "node": null, - | "state": "UNASSIGNED" - | }, - | { - | "index": "bar", - | "shard": "3", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "3", - | "prirep": "r", - | "node": null, - | "state": "UNASSIGNED" - | }, - | { - | "index": "bar", - | "shard": "1", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "1", - | "prirep": "r", - | "node": null, - | "state": "UNASSIGNED" - | }, - | { - | "index": "bar", - | "shard": "4", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "4", - | "prirep": "r", - | "node": null, - | "state": "INITIALIZING" - | }, - | { - | "index": "bar", - | "shard": "0", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "0", - | "prirep": "r", - | "node": null, - | "state": "UNASSIGNED" - | } - |] - """.stripMargin) - - val aliases = Json.parse( - """ - |[ - | { - | "alias": "qux", - | "index": "foo" - | } - |] - """.stripMargin) - - -} diff --git a/test/services/overview/ClusterRelocatingShards.scala b/test/services/overview/ClusterRelocatingShards.scala deleted file mode 100644 index 2a4da1b06a5003f43870b4c04e0f9a0a43993e25..0000000000000000000000000000000000000000 --- a/test/services/overview/ClusterRelocatingShards.scala +++ /dev/null @@ -1,147 +0,0 @@ -package services.overview - -import play.api.libs.json.Json - -object ClusterRelocatingShards { - - def apply() = ClusterOverview(settings, health, nodes, indices, shards, aliases) - - val settings = Json.parse( - """ - |{ - | "persistent" : { }, - | "transient" : { } - |} - """.stripMargin - ) - - val health = Json.parse( - """ - |{ - | "cluster_name" : "elasticsearch", - | "status" : "yellow", - | "timed_out" : false, - | "number_of_nodes" : 2, - | "number_of_data_nodes" : 2, - | "active_primary_shards" : 5, - | "active_shards" : 5, - | "relocating_shards" : 1, - | "initializing_shards" : 0, - | "unassigned_shards" : 0, - | "delayed_unassigned_shards" : 0, - | "number_of_pending_tasks" : 0, - | "number_of_in_flight_fetch" : 0, - | "task_max_waiting_in_queue_millis" : 0, - | "active_shards_percent_as_number" : 50 - |} - """.stripMargin - ) - - val nodes = Json.parse( - """ - |[ - | { - | "id": "rtOe", - | "ip": "127.0.0.1", - | "version": "5.3.0", - | "jdk": "1.8.0_92", - | "disk.avail": "114.5gb", - | "heap.current": "403.7mb", - | "heap.percent": "20", - | "heap.max": "1.9gb", - | "cpu": "23", - | "load_1m": "3.45", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm" - | }, - | { - | "id": "rtOe2", - | "ip": "127.0.0.1", - | "version": "5.3.0", - | "jdk": "1.8.0_92", - | "disk.avail": "114.5gb", - | "heap.current": "403.7mb", - | "heap.percent": "20", - | "heap.max": "1.9gb", - | "cpu": "23", - | "load_1m": "3.45", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm2" - | } - |] - """.stripMargin) - - val indices = Json.parse( - """ - |[ - | { - | "health": "yellow", - | "status": "open", - | "index": "bar", - | "uuid": "UXV_U1tTSK62OCRHVw3HaA", - | "pri": "5", - | "rep": "1", - | "docs.count": "0", - | "docs.deleted": "0", - | "store.size": "650b", - | "pri.store.size": "650b" - | } - |] - """.stripMargin) - - - val shards = Json.parse( - """ - |[ - | { - | "index": "bar", - | "shard": "2", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "3", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "1", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "4", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "0", - | "prirep": "p", - | "node": "rtOejLm -> rtOejLm2", - | "state": "RELOCATING" - | } - |] - """.stripMargin) - - val aliases = Json.parse( - """ - |[ - | { - | "alias": "qux", - | "index": "foo" - | } - |] - """.stripMargin) - - -} diff --git a/test/services/overview/ClusterStub.scala b/test/services/overview/ClusterStub.scala deleted file mode 100644 index 66d137ff39a2fad16f1299f1a39b686f3116ace2..0000000000000000000000000000000000000000 --- a/test/services/overview/ClusterStub.scala +++ /dev/null @@ -1,21 +0,0 @@ -package services.overview - -import play.api.libs.json.JsValue - -trait ClusterStub { - - def apply() = ClusterOverview(settings, health, nodes, indices, shards, aliases) - - val settings: JsValue - - val health: JsValue - - val nodes: JsValue - - val indices: JsValue - - val shards: JsValue - - val aliases: JsValue - -} diff --git a/test/services/overview/ClusterWithData.scala b/test/services/overview/ClusterWithData.scala deleted file mode 100644 index 1d203a1972bc0243c4734b0df675c1c47e36cdec..0000000000000000000000000000000000000000 --- a/test/services/overview/ClusterWithData.scala +++ /dev/null @@ -1,134 +0,0 @@ -package services.overview - -import play.api.libs.json.Json - -trait ClusterWithData { - - def apply() = ClusterOverview(settings, health, nodes, indices, shards, aliases) - - val settings = Json.parse( - """ - |{ - | "persistent" : { }, - | "transient" : { } - |} - """.stripMargin - ) - - val health = Json.parse( - """ - |{ - | "cluster_name" : "elasticsearch", - | "status" : "green", - | "timed_out" : false, - | "number_of_nodes" : 1, - | "number_of_data_nodes" : 1, - | "active_primary_shards" : 5, - | "active_shards" : 5, - | "relocating_shards" : 0, - | "initializing_shards" : 0, - | "unassigned_shards" : 0, - | "delayed_unassigned_shards" : 0, - | "number_of_pending_tasks" : 0, - | "number_of_in_flight_fetch" : 0, - | "task_max_waiting_in_queue_millis" : 0, - | "active_shards_percent_as_number" : 50 - |} - """.stripMargin - ) - - val nodes = Json.parse( - """ - |[ - | { - | "id": "rtOe", - | "ip": "127.0.0.1", - | "version": "5.3.0", - | "jdk": "1.8.0_92", - | "disk.avail": "114.5gb", - | "heap.current": "403.7mb", - | "heap.percent": "20", - | "heap.max": "1.9gb", - | "cpu": "23", - | "load_1m": "3.45", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm" - | } - |] - """.stripMargin) - - val indices = Json.parse( - """ - |[ - | { - | "health": "green", - | "status": "open", - | "index": "bar", - | "uuid": "UXV_U1tTSK62OCRHVw3HaA", - | "pri": "5", - | "rep": "0", - | "docs.count": "0", - | "docs.deleted": "0", - | "store.size": "650b", - | "pri.store.size": "650b" - | } - |] - """.stripMargin) - - - val shards = Json.parse( - """ - |[ - | { - | "index": "bar", - | "shard": "2", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "3", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "1", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "4", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | }, - | { - | "index": "bar", - | "shard": "0", - | "prirep": "p", - | "node": "rtOejLm", - | "state": "STARTED" - | } - |] - """.stripMargin) - - val aliases = Json.parse( - """ - |[ - | { - | "alias": "qux", - | "index": "foo" - | } - |] - """.stripMargin) - - -} - -object ClusterWithData extends ClusterWithData diff --git a/test/services/overview/ClusterWithoutData.scala b/test/services/overview/ClusterWithoutData.scala deleted file mode 100644 index 6fb9084487b14b736339f7b8fe7be74183499ee6..0000000000000000000000000000000000000000 --- a/test/services/overview/ClusterWithoutData.scala +++ /dev/null @@ -1,81 +0,0 @@ -package services.overview - -import play.api.libs.json.Json - -object ClusterWithoutData { - - def apply() = ClusterOverview(settings, health, nodes, indices, shards, aliases) - - val settings = Json.parse( - """ - |{ - | "persistent" : { }, - | "transient" : { } - |} - """.stripMargin - ) - - val health = Json.parse( - """ - |{ - | "cluster_name" : "elasticsearch", - | "status" : "green", - | "timed_out" : false, - | "number_of_nodes" : 1, - | "number_of_data_nodes" : 1, - | "active_primary_shards" : 0, - | "active_shards" : 0, - | "relocating_shards" : 0, - | "initializing_shards" : 0, - | "unassigned_shards" : 0, - | "delayed_unassigned_shards" : 0, - | "number_of_pending_tasks" : 0, - | "number_of_in_flight_fetch" : 0, - | "task_max_waiting_in_queue_millis" : 0, - | "active_shards_percent_as_number" : 50 - |} - """.stripMargin - ) - - val nodes = Json.parse( - """ - |[ - | { - | "id": "rtOe", - | "ip": "127.0.0.1", - | "version": "5.3.0", - | "jdk": "1.8.0_92", - | "disk.avail": "114.5gb", - | "heap.current": "403.7mb", - | "heap.percent": "20", - | "heap.max": "1.9gb", - | "cpu": "23", - | "load_1m": "3.45", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm" - | } - |] - """.stripMargin) - - val indices = Json.parse( - """ - |[ - |] - """.stripMargin) - - - val shards = Json.parse( - """ - |[ - |] - """.stripMargin) - - val aliases = Json.parse( - """ - |[ - |] - """.stripMargin) - - -} diff --git a/test/services/overview/NodeSpec.scala b/test/services/overview/NodeSpec.scala deleted file mode 100644 index 8fd349237756e81f571fa2e39d3705914b5ac737..0000000000000000000000000000000000000000 --- a/test/services/overview/NodeSpec.scala +++ /dev/null @@ -1,82 +0,0 @@ -package services.overview - -import org.specs2.Specification -import play.api.libs.json.Json - -object NodeSpec extends Specification { - - def is = - s2""" - Node should - - parse a >= 5.0 ES node $nodeInfo5 - parse a AWS nods $awsNode - """ - - def nodeInfo5 = { - val expected = Json.parse( - """ - |{ - | "id": "rtOe", - | "current_master": true, - | "name": "rtOejLm", - | "ip": "127.0.0.1", - | "jvm_version": "1.8.0_92", - | "es_version": "5.3.0", - | "load_1m": "2.34", - | "cpu": "24", - | "master": true, - | "data": true, - | "coordinating": false, - | "ingest": true, - | "heap": { - | "current": "461.6mb", - | "percent": "23", - | "max": "1.9gb" - | }, - | "disk": { - | "total": null, - | "avail": "114.5gb", - | "percent": null - | } - |} - """.stripMargin - ) - val node = Node(NodesInfo.node5) - node mustEqual expected - } - - def awsNode = { - val expected = Json.parse( - """ - |{ - | "id": "rtOe", - | "current_master": true, - | "name": "rtOejLm", - | "ip": null, - | "jvm_version": null, - | "es_version": "5.3.0", - | "load_1m": "2.34", - | "cpu": "24", - | "master": true, - | "data": true, - | "coordinating": false, - | "ingest": true, - | "heap": { - | "current": "461.6mb", - | "percent": "23", - | "max": "1.9gb" - | }, - | "disk": { - | "total": null, - | "avail": "114.5gb", - | "percent": null - | } - |} - """.stripMargin - ) - val node = Node(NodesInfo.awsInfo) - node mustEqual expected - } - -} diff --git a/test/services/overview/NodesInfo.scala b/test/services/overview/NodesInfo.scala deleted file mode 100644 index 10523a09495abaade3bd421509b43aac7ce4a35b..0000000000000000000000000000000000000000 --- a/test/services/overview/NodesInfo.scala +++ /dev/null @@ -1,48 +0,0 @@ -package services.overview - -import play.api.libs.json.Json - -object NodesInfo { - - val node5 = Json.parse( - """ - | { - | "id": "rtOe", - | "ip": "127.0.0.1", - | "version": "5.3.0", - | "jdk": "1.8.0_92", - | "disk.avail": "114.5gb", - | "heap.current": "461.6mb", - | "heap.percent": "23", - | "heap.max": "1.9gb", - | "cpu": "24", - | "load_1m": "2.34", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm" - | } - """.stripMargin - ) - - val awsInfo = Json.parse( - """ - | { - | "id": "rtOe", - | "ip": null, - | "version": "5.3.0", - | "jdk": null, - | "disk.avail": "114.5gb", - | "heap.current": "461.6mb", - | "heap.percent": "23", - | "heap.max": "1.9gb", - | "cpu": "24", - | "load_1m": "2.34", - | "node.role": "mdi", - | "master": "*", - | "name": "rtOejLm" - | } - """.stripMargin - ) - - -} diff --git a/tests/common/index_filter.js b/tests/common/index_filter.js index d58dd6d80d575c7f684d4197e6ca59ae4a81d3c7..28e6c06d7ba0ec1bc169667877924359a8a49124 100644 --- a/tests/common/index_filter.js +++ b/tests/common/index_filter.js @@ -1,6 +1,6 @@ QUnit.test("Filters out special indices", function(assert) { var filter = new IndexFilter("", true, false, true, true, 0); - var index = {index: ".index_name", status: 'open', unhealthy: false, aliases: []}; + var index = {index: "index_name", status: 'open', unhealthy: false, aliases: []}; assert.ok(!filter.matches(index), "Filters out special indices"); }); diff --git a/tests/controllers/overview.tests.js b/tests/controllers/overview.tests.js index 5c08908eb85085aca39e3ca60d7e10c9901f9483..e237c9f88c10caa2eaff914a9268a121fe5cd95b 100644 --- a/tests/controllers/overview.tests.js +++ b/tests/controllers/overview.tests.js @@ -18,9 +18,14 @@ describe('OverviewController', function() { })); it('should have intial state correctly set', function() { - expect(this.scope.data).toEqual(undefined); expect(this.scope.indices).toEqual(undefined); expect(this.scope.nodes).toEqual(undefined); + expect(this.scope.unassigned_shards).toEqual(0); + expect(this.scope.initializing_shards).toEqual(0); + expect(this.scope.relocating_shards).toEqual(0); + expect(this.scope.shardAllocation).toEqual(true); + expect(this.scope.closed_indices).toEqual(0); + expect(this.scope.special_indices).toEqual(0); expect(this.scope.shardAllocation).toEqual(true); // index filter expect(this.scope.indices_filter.name).toEqual(''); @@ -77,7 +82,11 @@ describe('OverviewController', function() { spyOn(this.scope, 'setNodes').and.returnValue(true); this.scope.refresh(); expect(this.OverviewDataService.getOverview).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function)); - expect(this.scope.data).toEqual(data); + expect(this.scope.unassigned_shards).toEqual(1); + expect(this.scope.initializing_shards).toEqual(3); + expect(this.scope.relocating_shards).toEqual(2); + expect(this.scope.closed_indices).toEqual(2); + expect(this.scope.special_indices).toEqual(3); expect(this.scope.shardAllocation).toEqual(true); expect(this.scope.setIndices).toHaveBeenCalledWith(indices); expect(this.scope.setNodes).toHaveBeenCalledWith(nodes); @@ -89,12 +98,14 @@ describe('OverviewController', function() { function() { this.OverviewDataService.getOverview = function(success, error) { error('kaput'); - }; + } spyOn(this.OverviewDataService, 'getOverview').and.callThrough(); spyOn(this.AlertService, 'error').and.returnValue(); this.scope.refresh(); expect(this.OverviewDataService.getOverview).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function)); - expect(this.scope.data).toEqual(undefined); + expect(this.scope.unassigned_shards).toEqual(0); + expect(this.scope.closed_indices).toEqual(0); + expect(this.scope.special_indices).toEqual(0); expect(this.scope.shardAllocation).toEqual(true); expect(this.AlertService.error).toHaveBeenCalledWith('Error while loading data', 'kaput'); } @@ -184,7 +195,7 @@ describe('OverviewController', function() { spyOn(this.OverviewDataService, 'relocateShard').and.callThrough(); spyOn(this.AlertService, 'info').and.returnValue(true); spyOn(this.RefreshService, 'refresh').and.returnValue(true); - this.scope.relocateShard({name: 'n2'}); + this.scope.relocateShard({id: 'n2'}); expect(this.OverviewDataService.relocateShard).toHaveBeenCalledWith( 1, 'i', 'n', 'n2', jasmine.any(Function), jasmine.any(Function) ); @@ -204,7 +215,7 @@ describe('OverviewController', function() { }; spyOn(this.OverviewDataService, 'relocateShard').and.callThrough(); spyOn(this.AlertService, 'error').and.returnValue(true); - this.scope.relocateShard({name: 'n2'}); + this.scope.relocateShard({id: 'n2'}); expect(this.OverviewDataService.relocateShard).toHaveBeenCalledWith( 1, 'i', 'n', 'n2', jasmine.any(Function), jasmine.any(Function) ); @@ -219,33 +230,33 @@ describe('OverviewController', function() { describe('canReceiveShard', function() { it('can receive if same index and different node', function() { - var index = {index: 'i', shards: {n: [{shard: 1}]}}; + var index = {name: 'i', shards: {n: [{shard: 1}]}}; this.scope.relocatingShard = {shard: 1, index: 'i', node: 'n'}; - var receive = this.scope.canReceiveShard(index, {name: 'n2'}); + var receive = this.scope.canReceiveShard(index, {id: 'n2'}); expect(receive).toEqual(true); } ); it('cannot receive if same index and different node but containing shard', function() { - var index = {index: 'i', shards: {n: [{shard: 1}], n2: [{shard: 1}]}}; + var index = {name: 'i', shards: {n: [{shard: 1}], n2: [{shard: 1}]}}; this.scope.relocatingShard = {shard: 1, index: 'i', node: 'n'}; - var receive = this.scope.canReceiveShard(index, {name: 'n2'}); + var receive = this.scope.canReceiveShard(index, {id: 'n2'}); expect(receive).toEqual(false); } ); it('cannot receive if same node', function() { - var index = {index: 'i', shards: {n: [{shard: 1}]}}; + var index = {name: 'i', shards: {n: [{shard: 1}]}}; this.scope.relocatingShard = {shard: 1, index: 'i2', node: 'n'}; - var receive = this.scope.canReceiveShard(index, {name: 'n'}); + var receive = this.scope.canReceiveShard(index, {id: 'n'}); expect(receive).toEqual(false); } ); it('cannot receive if different index', function() { - var index = {index: 'i2', shards: {n: [{shard: 1}]}}; + var index = {name: 'i2', shards: {n: [{shard: 1}]}}; this.scope.relocatingShard = {shard: 1, index: 'i', node: 'n'}; - var receive = this.scope.canReceiveShard(index, {name: 'n2'}); + var receive = this.scope.canReceiveShard(index, {id: 'n2'}); expect(receive).toEqual(false); } );