Created
April 23, 2015 20:01
-
-
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]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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