hbase 클라이언트 사용 할 때, hbase 서버와의 버전을 반드시 확인해야 프로토콜 이슈가 없다.


하지만, cassandra는 최상위 버전인 3.1.4 버전의 클라이언트 라이브러를 사용해도 일부 하위 버전까지 하위 호환성을 유지한다..





https://github.com/datastax/java-driver


The Java client driver 3.1.4 (branch 3.1) is compatible with Apache Cassandra 1.2, 2.0, 2.1, 2.2 and 3.0 (see this pagefor the most up-to-date compatibility information).




http://datastax.github.io/java-driver/manual/native_protocol



Native protocol

The native protocol defines the format of the binary messages exchanged between the driver and Cassandra over TCP. As a driver user, you don’t need to know the fine details (although the protocol spec is in the Cassandra codebase if you’re curious); the most visible aspect is that some features are only available with specific protocol versions.

Compatibility matrix

By default, the protocol version is negotiated between the driver and Cassandra when the first connection is established. Both sides are backward-compatible with older versions:


 Cassandra: 1.2.x
(DSE 3.2)
2.0.x
(DSE 4.0 to 4.6)
2.1.x
(DSE 4.7)
2.2.x3.0.x
Driver: 1.0.xv1v1v1v1Unsupported (1)
2.0.x to 2.1.1v1v2v2v2Unsupported (1)
2.1.2 to 2.1.xv1v2v3v3Unsupported (2)
3.xv1v2v3v4v4

(1) Cassandra 3.0 does not support protocol versions v1 and v2

(2) There is a matching protocol version (v3), but the driver 2.1.x can’t read the new system table format of Cassandra 3.0

For example, if you use version 2.1.5 of the driver to connect to Cassandra 2.0.9, the maximum version you can use (and the one you’ll get by default) is protocol v2 (third row, second column). If you use the same version to connect to Cassandra 2.1.4, you can use protocol v3.




netty 버전과 이슈가 있을 수 있으니.아래 내용도 참고한다. 


https://github.com/datastax/java-driver/tree/3.1.x/manual/shaded_jar







참고로 cassandra 2.1에서 3.1로 올리는 테스트해보니 바로 되지 않는 부분이 있다.


LocalDate의 getTime 메소드 같은 경우는 아예 사라져 있다.


long startDate = row.getDate("date1").getTime();




다음과 같은 에러가 발생했다.


 (188): Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate]

com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [timestamp <-> com.datastax.driver.core.LocalDate]

        at com.datastax.driver.core.CodecRegistry.notFound(CodecRegistry.java:679) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry.createCodec(CodecRegistry.java:526) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry.findCodec(CodecRegistry.java:506) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry.access$200(CodecRegistry.java:140) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry$TypeCodecCacheLoader.load(CodecRegistry.java:211) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry$TypeCodecCacheLoader.load(CodecRegistry.java:208) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache.get(LocalCache.java:3934) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) ~[story-app.jar:na]

        at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry.lookupCodec(CodecRegistry.java:480) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry.codecFor(CodecRegistry.java:448) ~[story-app.jar:na]

        at com.datastax.driver.core.CodecRegistry.codecFor(CodecRegistry.java:430) ~[story-app.jar:na]

        at com.datastax.driver.core.AbstractGettableByIndexData.codecFor(AbstractGettableByIndexData.java:69) ~[story-app.jar:na]

        at com.datastax.driver.core.AbstractGettableByIndexData.getDate(AbstractGettableByIndexData.java:174) ~[story-app.jar:na]

        at com.datastax.driver.core.AbstractGettableData.getDate(AbstractGettableData.java:26) ~[story-app.jar:na]

        at com.datastax.driver.core.AbstractGettableData.getDate(AbstractGettableData.java:111) ~[story-app.jar:na]




다음 코드로 변경하면 잘 동작한다. 

row.getTimestamp("date1").getTime();



좋은 자료

https://groups.google.com/a/lists.datastax.com/forum/#!topic/java-driver-user/pAoLlEzmGWA

https://datastax-oss.atlassian.net/browse/JAVA-1176




maven dependency 3.1과 2.1 비교 



cassandra 3.1

[INFO] +- com.datastax.cassandra:cassandra-driver-core:jar:3.1.3:compile

[INFO] |  +- io.netty:netty-handler:jar:4.0.37.Final:compile

[INFO] |  |  +- io.netty:netty-buffer:jar:4.0.37.Final:compile

[INFO] |  |  |  \- io.netty:netty-common:jar:4.0.37.Final:compile

[INFO] |  |  +- io.netty:netty-transport:jar:4.0.37.Final:compile

[INFO] |  |  |  \- (io.netty:netty-buffer:jar:4.0.37.Final:compile)

[INFO] |  |  \- io.netty:netty-codec:jar:4.0.37.Final:compile

[INFO] |  |     \- (io.netty:netty-transport:jar:4.0.37.Final:compile)

[INFO] |  +- (com.google.guava:guava:jar:16.0.1:compile)

[INFO] |  +- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile

[INFO] |  |  \- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.6)

[INFO] |  +- com.github.jnr:jnr-ffi:jar:2.0.7:compile

[INFO] |  |  +- com.github.jnr:jffi:jar:1.2.10:compile

[INFO] |  |  +- com.github.jnr:jffi:jar:native:1.2.10:runtime

[INFO] |  |  +- (org.ow2.asm:asm:jar:5.0.3:compile - omitted for conflict with 4.1)

[INFO] |  |  +- (org.ow2.asm:asm-commons:jar:5.0.3:compile - omitted for conflict with 4.1)

[INFO] |  |  +- org.ow2.asm:asm-analysis:jar:5.0.3:compile

[INFO] |  |  |  \- (org.ow2.asm:asm-tree:jar:5.0.3:compile)

[INFO] |  |  +- org.ow2.asm:asm-tree:jar:5.0.3:compile

[INFO] |  |  |  \- (org.ow2.asm:asm:jar:5.0.3:compile - omitted for conflict with 4.1)

[INFO] |  |  +- org.ow2.asm:asm-util:jar:5.0.3:compile

[INFO] |  |  |  \- (org.ow2.asm:asm-tree:jar:5.0.3:compile)

[INFO] |  |  \- com.github.jnr:jnr-x86asm:jar:1.0.2:compile

[INFO] |  \- com.github.jnr:jnr-posix:jar:3.0.27:compile

[INFO] |     +- (com.github.jnr:jnr-ffi:jar:2.0.7:compile)

[INFO] |     \- com.github.jnr:jnr-constants:jar:0.9.0:compile



cassandra 2.1



[INFO] +- com.datastax.cassandra:cassandra-driver-core:jar:2.1.9:compile

[INFO] |  +- io.netty:netty-handler:jar:4.0.27.Final:compile

[INFO] |  |  +- io.netty:netty-buffer:jar:4.0.27.Final:compile

[INFO] |  |  |  \- io.netty:netty-common:jar:4.0.27.Final:compile

[INFO] |  |  +- io.netty:netty-transport:jar:4.0.27.Final:compile

[INFO] |  |  |  \- (io.netty:netty-buffer:jar:4.0.27.Final:compile)

[INFO] |  |  \- io.netty:netty-codec:jar:4.0.27.Final:compile

[INFO] |  |     \- (io.netty:netty-transport:jar:4.0.27.Final:compile)

[INFO] |  +- (com.google.guava:guava:jar:14.0.1:compile - omitted for conflict with 16.0.1)

[INFO] |  \- com.codahale.metrics:metrics-core:jar:3.0.2:compile

[INFO] |     \- (org.slf4j:slf4j-api:jar:1.7.5:compile - omitted for conflict with 1.7.6)


Posted by '김용환'
,