書籍 Getting Started with Hazelcast (Kindle版であればAmazon.co.jpでも購入できます)の内容を理解するために, 書籍の内容を私が書き写したものです. ただし, 書籍が対象としているHazelcastのバージョンが2.6であるのに対し, 私が用いているバージョンは現時点での最新版3.4であるため修正している箇所もあります.
なお, 出版社のページから正式なコードをダウンロードすることができます(私は参照していませんが).
Hazelcast公式blogにWhat's new in Hazelcast 3?というエントリがありましたので, こちらも参考になるかもしれません.
また, マニュアルにはUpgrading from 2.x versionsというセクションがあります.
com.hazelcast.examples.TestApp というクラスは無くなり, 代わりに com.hazelcast.console.ConsoleApp というクラスになっています. おそらく3.3以降からの変更です. (参考: hazelcast/hazelcast#2683 )
引数の型や戻り値の型が大きく変わっています. おそらく3.0からの変更です. https://github.com/hazelcast/hazelcast/commit/c127cde52cfa89018605f361ea8f513b4a8da34f
cluster_wide_map_size という設定はなくなっています. https://github.com/hazelcast/hazelcast/commit/fcc78a596a58ac9c74380dcd18e5218dfccb3b58
ver.2では
- map_size_per_jvm
- cluster_wide_map_size
- partitions_wide_map_size
- used_heap_size
- used_heap_percentage
の5種類だったものが, ver.3では
- PER_NODE (上のURLの変更ではPER_JVMとなっていますが, それから更に変更されています)
- PER_PARTITION
- USED_HEAP_PERCENTAGE
- USED_HEAP_SIZE
の4種類になっていました.
本書の文脈的には, PER_NODE で置換すれば良いと思われます.
余談になりますが, マニュアルには下記の記述があります.
In 2.x releases, the default value for max-size eviction policy was cluster_wide_map_size. In 3.x releases, default is PER_NODE. After upgrading, the max-size should be set according to this new default, if it is not changed. Otherwise, it is likely that OutOfMemory exception may be thrown.
getTransaction() というメソッドは無くなっており, 代わりに newTransactionContext(TransactionOptions) を使用すべきであるように見えます. https://github.com/hazelcast/hazelcast/commit/6657a3dad1d1c5631f71f0d23f1ad397169a5666
マニュアルにコードサンプルがあるのですが, このように実装してもrepeatable readになりませんでした(transaction中の2回目のgetでConsoleAppの方で変更した内容に変わってしまう).
これについては#4414としてissueを挙げてみました.
[追記] ドキュメントの記述が誤りで, REPEATABLE_READではなく通常READ_COMMITEDで取り扱われます. そのようにドキュメントが修正されました. また, 以下の追記がなされています.
NOTE: The REPEATABLE_READ isolation level can also be exercised using the method getForUpdate() of TransactionalMap.
2つのメソッドが追加されていました.
なお, 次バージョンのv3.5でも変更が入るように見えます.
ここでは以下のjavadocコメントが追加されています.
This interface is here for backward compatibility reasons. For a most appropriate alternative please use/check link com.hazelcast.map.listener.MapListener interface.
DistributedObjectListener に名称変更されたようです.
https://github.com/hazelcast/hazelcast/commit/220818af62eb756aca41b2b883019e57c6144917
memberAttributeChanged メソッドが追加されています.
Upgrading from 2.x versions より:
Classes MultiTask and DistributedTask have been removed. All the functionality is supported by the newly presented interface IExecutorService. Please see the Executor Service section.
引数なしのgetExecutorServiceメソッドは削除されています.
同等の情報を取得する方法はわかりませんでした.