Deprecation

This document is DEPRECATED.

Please consider any information here as out of date. DO NOT use this document.

Instead, refer to http://infinispan.org/documentation.

Please update your bookmarks accordingly.

Skip to end of metadata
Go to start of metadata

Introduction

Starting with Infinispan 5.0, Hot Rod clients can be configured with a marshaller that produces plattform independent payloads using Apache Avro. This means that payloads generated by a Java, Avro-based, marshaller could be read by a Python, Avro-based, marshaller. When Hot Rod clients in other languages such as Python or Ruby become available, this will mean that for example, data stored via Java Hot Rod client will be readable by a Python Hot Rod client.

Languages Supported

Avro currently supports providing portable serialization payloads for the following languages:

  • C
  • C++
  • Java
  • Python
  • Ruby

So interoperability of payloads is limited to these languages. The choice of Avro over other existing portable serialization libraries (i.e. Google Protocol Buffers, Apache Thrift, MessagePack...etc) was done based languages supported, ease of use, and payload size.

Object Types Supported

Avro based marshaller currently supports basic type and collection marshalling:

  • Basic types include:
    • UTF-8 string
    • Integer
    • Long
    • Float
    • Double
    • Boolean
    • Byte Array
  • Collections composed of the basic types :
    • Arrays
    • Lists
    • Maps
    • Sets

Marshalling of complex objects is not supported because it's not fully solvable as some language don't support some concepts other languages offer. Instead, it is recommended that for any complex object marshalling requirements, users serialize these complex objects into byte arrays using portable serialization libraries such as Google Protocol Buffers, Apache Thrift, MessagePack, or Apache Avro. Once the byte array has been created, simply pass it to the Hot Rod client API which will handle it accordingly.

Therefore, it's clear that users are free to use any portable serialization library to transform their complex objects into byte arrays, regardless of the fact that Infinispan uses Apache Avro for basic type and collection marshalling. The only limitation here is that the target language used to serialize complex objects needs to be amongst the languages that Apache Avro supports.

Short and Byte Java primitive types are not supported per se. Instead, clients should pass integers which will be encoded efficiently using variable-length zig zag coding. Primitive arrays not supported except byte arrays. Instead, use their object counter partners, i.e. Integer...etc.

Java Configuration

To configure a Java Hot Rod client with Avro marshaller, simply pass a infinispan.client.hotrod.marshaller property to the RemoteCacheManager constructor containing the value of org.infinispan.client.hotrod.marshall.ApacheAvroMarshaller. For example:

Note however that if all you're gonna be using are Java Hot Rod clients, there's no need to configure Avro based marshaller. The default marshaller is capable of transforming any Serializable or Externalizable java object into a byte array in a quick and efficient manner.

Please remember as well that when remote java clients are configured with the apache avro marshaller, the server's marshaller does not need changing. This is because the server does not make any attempt at unmarshalling the data that's been passed to it. Internally, it keeps the data as byte arrays.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Apr 10, 2013

    According to http://en.wikipedia.org/wiki/Apache_Avro, C# is also a supported language and definitely an important one.