Skip to content

Instantly share code, notes, and snippets.

@simbo1905
Created April 23, 2015 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simbo1905/6e40a070120091ec00a1 to your computer and use it in GitHub Desktop.
Save simbo1905/6e40a070120091ec00a1 to your computer and use it in GitHub Desktop.
scala.pickling.PicklingException: Tag scala.Some not recognized, looking for one of: scala.None.type, scala.Some[com.github.simbo1905.trex.internals.Accept]
// test case
import scala.pickling.Defaults._
import scala.pickling.shareNothing._
import scala.pickling.binary._
val p = PrepareAck(Identifier(1, ProposalNumber(2, 3), 4L), 5, Progress(ProposalNumber(6,7),Identifier(8,ProposalNumber(9,10),11L)), 12, 13, None)
val b = p.pickle.value
val pp = b.unpickle[PrepareAck]
pp match {
case `p` =>
}
// case classes
case class PrepareAck(request: Identifier, from: Int, progress: Progress, highestAcceptedIndex: Long, leaderHeartbeat: Long, highestUncommitted: Option[Accept]) extends PrepareResponse
case class Identifier(val from: Int, val number: ProposalNumber, val logIndex: Long) {
override def toString = f"I(f=$from,n=$number,s=$logIndex)"
}
case class ProposalNumber(counter: Int, nodeIdentifier: Int) {
def >(that: ProposalNumber) = if (this == that) false else if (this.counter > that.counter) true else if (this.counter < that.counter) false else this.nodeIdentifier > that.nodeIdentifier
def >=(that: ProposalNumber) = if (this == that) true else if (this.counter > that.counter) true else if (this.counter < that.counter) false else this.nodeIdentifier > that.nodeIdentifier
def <(that: ProposalNumber) = if (this == that) false else if (this.counter > that.counter) false else if (this.counter < that.counter) true else this.nodeIdentifier < that.nodeIdentifier
def <=(that: ProposalNumber) = if (this == that) true else if (this.counter > that.counter) false else if (this.counter < that.counter) true else this.nodeIdentifier < that.nodeIdentifier
override def toString = f"N(c=${counter.toLong-Int.MinValue},n=$nodeIdentifier)"
}
case class Accept(id: Identifier, value: Value) {
def from = id.number.nodeIdentifier
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment