]
Bela Ban resolved JGRP-1941.
----------------------------
Resolution: Done
Unit test and sample is {{ForkChannelTest.testStateTransfer()}}
Fork channels: support state transfer
-------------------------------------
Key: JGRP-1941
URL:
https://issues.jboss.org/browse/JGRP-1941
Project: JGroups
Issue Type: Feature Request
Reporter: Bela Ban
Assignee: Bela Ban
Fix For: 3.6.5
Currently state transfer is not supported for ForkChannels: {{ForkChannel.getState()}}
throws an exception.
State transfer could be implemented by catching events {{STATE_TRANSFER_OUTPUTSTREAM}}
(get-state) and {{STATE_TRANSFER_INPUTSTREAM}} (set-state) in {{FORK}}.
When {{getState()}} is called (on the main or fork channel), the state provider gets a
get-state in {{FORK}}. It then asks the main channel and all fork channels to write their
states to the output stream, as follows:
{noformat}
| main-channel | state | fork-channel1 | state | fork-channel2 | state | ...
{noformat}
This is a list of \{channel-name | state\} pairs, where each state is prefixed with the
name of the channel.
This can be implemented by simply passing the {{STATE_TRANSFER_OUTPUTSTREAM}} event up
the main stack and each of its fork stacks.
On the state requester, the {{STATE_TRANSFER_INPUTSTREAM}} event is caught by {{FORK}}.
Each \{channel | state\} pair is parsed for the channel name and then the input stream is
passed to the corresponding channel for {{setState(InputStream)}} to be invoked.
This whole thing is designed as a one-shot state transfer, to be called *once* after the
main channel and all fork-channels have been created. It is not meant to be called
repeatedly (although this works).