File: MarshalingFormat.txt

package info (click to toggle)
libjgroups-java 2.12.2.Final-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,712 kB
  • sloc: java: 109,098; xml: 9,423; sh: 149; makefile: 2
file content (60 lines) | stat: -rw-r--r-- 1,665 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

// Author: Bela Ban


Binary format for marshalled messages
=====================================

An org.jgroups.Message is marshalled to a byte stream as follows.

- version ID: short (2 bytes). Version.encode() encodes the major, minor and patch version into the short.
- flags (byte):
  - single message or list of messages (LIST)
    If single message --> SingleMessage, else MessageList
  - multicast (MULTICAST) or unicast message (for optimizations)

SingleMessage:
- leading: byte. Has bits set for null src and dest addresses, buf and headers
- flags: byte
- src address: Address
- [length of buf]: int
- [buf]: byte[] array
- [Headers]: list of headers --> Headers


MessageList:
- length: int. Number of messages in the list
- src address: Address
- 1-m Messages: --> SingleMessage, but with no src and dest addresses



Headers:
- length: int. Number of headers
- For each Header:
  - Key: UTF-8 string
  - Header


Header:
- magic_number (short)
- if magic number == -1 (not present):
  - no-op
- else
  - UTF-8 string (class name)
- size in bytes (short)
- contents (header-specific)


UTF-8 strings:
- All strings start with a short that is the length of the string (DataOutputStream.writeUTF(String))


Notes:

- In most cases, we don't need to send the dest address, because the sender knows whether the message
  was received on the unicast or multicast socket, and can thus set the dest address in an incoming
  message to its own local address, or multicast address

- This is currently as used by UDP. Once we move to Transport (e.g. including TCP), this needs to be
  revisited. Currently (2.2.8), TCP uses externalization, *not* Streamable.