net.sf.ehcache.distribution

Class PayloadUtil

final class PayloadUtil extends Object

This class provides utility methods for assembling and disassembling a heartbeat payload.

Care is taken to fit the payload into the MTU of ethernet, which is 1500 bytes. The algorithms in this class are capable of creating payloads for CacheManagers containing approximately 500 caches to be replicated.

Version: $Id: PayloadUtil.java 52 2006-04-24 14:50:03Z gregluck $

Author: Greg Luck

Field Summary
static intMTU
The maximum transmission unit.
static StringURL_DELIMITER
Delmits URLS sent via heartbeats over sockets
Method Summary
static byte[]assembleUrlList(List localCachePeers)
Assembles a list of URLs
static byte[]gzip(byte[] ungzipped)
Gzips a byte[].
static byte[]ungzip(byte[] gzipped)
The fastest Ungzip implementation.

Field Detail

MTU

public static final int MTU
The maximum transmission unit. This varies by link layer. For ethernet, fast ethernet and gigabit ethernet it is 1500 bytes, the value chosen.

Payloads are limited to this so that there is no fragmentation and no necessity for a complex reassembly protocol.

URL_DELIMITER

public static final String URL_DELIMITER
Delmits URLS sent via heartbeats over sockets

Method Detail

assembleUrlList

public static byte[] assembleUrlList(List localCachePeers)
Assembles a list of URLs

Parameters: localCachePeers

Returns: an uncompressed payload with catenated rmiUrls.

gzip

public static byte[] gzip(byte[] ungzipped)
Gzips a byte[]. For text, approximately 10:1 compression is achieved.

Parameters: ungzipped the bytes to be gzipped

Returns: gzipped bytes

ungzip

public static byte[] ungzip(byte[] gzipped)
The fastest Ungzip implementation. See PageInfoTest in ehcache-constructs. A high performance implementation, although not as fast as gunzip3. gunzips 100000 of ungzipped content in 9ms on the reference machine. It does not use a fixed size buffer and is therefore suitable for arbitrary length arrays.

Parameters: gzipped

Returns: a plain, uncompressed byte[]