<commit_before>package eventstore
package cluster

import java.net.InetSocketAddress
import akka.actor.ActorSystem
import org.joda.time.DateTime
import scala.concurrent._

case class ClusterInfo(serverAddress: InetSocketAddress, members: List[MemberInfo]) {
  lazy val bestNode: Option[MemberInfo] = {
    val xs = members.filter { x => x.isAlive && x.state.isAllowedToConnect }
    if (xs.isEmpty) None else Some(xs.maxBy(_.state))
  }
}

object ClusterInfo {

  type FutureFunc = InetSocketAddress => Future[ClusterInfo]

  def futureFunc(implicit system: ActorSystem): FutureFunc = {
    import ClusterProtocol._
    import system.dispatcher
    import spray.client.pipelining._
    import spray.http._
    import spray.httpx.SprayJsonSupport._

    val pipeline = sendReceive ~> unmarshal[ClusterInfo]

    (address: InetSocketAddress) => {
      val host = address.getHostString
      val port = address.getPort
      val uri = Uri(s"http://$host:$port/gossip?format=json")
      pipeline(Get(uri))
    }
  }
}

case class MemberInfo(
    instanceId: Uuid,
    timestamp: DateTime,
    state: NodeState,
    isAlive: Boolean,
    internalTcp: InetSocketAddress,
    externalTcp: InetSocketAddress,
    internalSecureTcp: InetSocketAddress,
    externalSecureTcp: InetSocketAddress,
    internalHttp: InetSocketAddress,
    externalHttp: InetSocketAddress,
    lastCommitPosition: Long,
    writerCheckpoint: Long,
    chaserCheckpoint: Long,
    epochPosition: Long,
    epochNumber: Int,
    epochId: Uuid,
    nodePriority: Int) extends Ordered[MemberInfo] {

  def compare(that: MemberInfo) = this.state compare that.state

  def like(other: MemberInfo): Boolean = this.instanceId == other.instanceId

  override def toString = s"MemberInfo($instanceId, $state)"
}<commit_msg>use full info of MemberInfo in toString<commit_after>package eventstore
package cluster

import java.net.InetSocketAddress
import akka.actor.ActorSystem
import org.joda.time.DateTime
import scala.concurrent._

case class ClusterInfo(serverAddress: InetSocketAddress, members: List[MemberInfo]) {
  lazy val bestNode: Option[MemberInfo] = {
    val xs = members.filter { x => x.isAlive && x.state.isAllowedToConnect }
    if (xs.isEmpty) None else Some(xs.maxBy(_.state))
  }
}

object ClusterInfo {

  type FutureFunc = InetSocketAddress => Future[ClusterInfo]

  def futureFunc(implicit system: ActorSystem): FutureFunc = {
    import ClusterProtocol._
    import system.dispatcher
    import spray.client.pipelining._
    import spray.http._
    import spray.httpx.SprayJsonSupport._

    val pipeline = sendReceive ~> unmarshal[ClusterInfo]

    (address: InetSocketAddress) => {
      val host = address.getHostString
      val port = address.getPort
      val uri = Uri(s"http://$host:$port/gossip?format=json")
      pipeline(Get(uri))
    }
  }
}

case class MemberInfo(
    instanceId: Uuid,
    timestamp: DateTime,
    state: NodeState,
    isAlive: Boolean,
    internalTcp: InetSocketAddress,
    externalTcp: InetSocketAddress,
    internalSecureTcp: InetSocketAddress,
    externalSecureTcp: InetSocketAddress,
    internalHttp: InetSocketAddress,
    externalHttp: InetSocketAddress,
    lastCommitPosition: Long,
    writerCheckpoint: Long,
    chaserCheckpoint: Long,
    epochPosition: Long,
    epochNumber: Int,
    epochId: Uuid,
    nodePriority: Int) extends Ordered[MemberInfo] {

  def compare(that: MemberInfo) = this.state compare that.state

  def like(other: MemberInfo): Boolean = this.instanceId == other.instanceId
}
{'fraction_non_alphanumeric': 0.09229898074745187, 'fraction_numerical': 0.0, 'mean_word_length': 4.06160458452722, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1557542', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1067, 'n_words': 253}