ehcache

net.sf.ehcache.distribution
Class PayloadUtil

java.lang.Object
  extended by net.sf.ehcache.distribution.PayloadUtil

final class PayloadUtil
extends java.lang.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 cache peers to be replicated.

Version:
$Id: PayloadUtil.java 519 2007-07-27 07:11:45Z gregluck $
Author:
Greg Luck

Field Summary
static int MTU
          The maximum transmission unit.
static java.lang.String URL_DELIMITER
          Delmits URLS sent via heartbeats over sockets
 
Method Summary
static byte[] assembleUrlList(java.util.List localCachePeers)
          Assembles a list of URLs
static byte[] gzip(byte[] ungzipped)
          Gzips a byte[].
static byte[] ungzip(byte[] gzipped)
          The fastest Ungzip implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

See Also:
Constant Field Values

URL_DELIMITER

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

See Also:
Constant Field Values
Method Detail

assembleUrlList

public static byte[] assembleUrlList(java.util.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[]

ehcache