All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scassandra.server.cqlmessages.ProtocolVersion.scala Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2014 Christopher Batey and Dogan Narinc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.scassandra.server.cqlmessages

object ProtocolVersion {
  val ServerProtocolVersionThree : Byte = (0x81 & 0xFF).toByte
  val ClientProtocolVersionThree : Byte = 0x03

  val ServerProtocolVersionTwo : Byte = (0x82 & 0xFF).toByte
  val ClientProtocolVersionTwo : Byte = 0x02

  val ServerProtocolVersionOne : Byte = (0x81 & 0xFF).toByte
  val ClientProtocolVersionOne : Byte = 0x01


  def protocol(clientVersion: Byte) = {
    clientVersion match {
      case VersionThree.clientCode | VersionThree.serverCode => VersionThree
      case VersionTwo.clientCode | VersionTwo.serverCode => VersionTwo
      case VersionOne.clientCode | VersionOne.serverCode => VersionOne
    }
  }
}

abstract class ProtocolVersion(val clientCode : Byte, val serverCode: Byte, val version: Int)

case object VersionThree extends ProtocolVersion(
  ProtocolVersion.ClientProtocolVersionThree,
  ProtocolVersion.ServerProtocolVersionThree,
  3)

case object VersionTwo extends ProtocolVersion(
  ProtocolVersion.ClientProtocolVersionTwo,
  ProtocolVersion.ServerProtocolVersionTwo,
  2)

case object VersionOne extends ProtocolVersion(
  ProtocolVersion.ClientProtocolVersionOne,
  ProtocolVersion.ServerProtocolVersionOne,
  1)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy