Map<String, Object> m = (Map<String, Object>) evt.getArg();
info.putAll(m);
break;
case Event.GET_STATE_OK:
StateTransferInfo state_info = (StateTransferInfo) evt.getArg();
byte[] state = state_info.state;
try{
if(up_handler != null){
return up_handler.up(evt);
}
if(state != null){
String state_id = state_info.state_id;
if(receiver != null){
try{
if(receiver instanceof ExtendedReceiver && state_id != null)
((ExtendedReceiver) receiver).setState(state_id, state);
else
receiver.setState(state);
}catch(Throwable t){
if(log.isWarnEnabled())
log.warn("failed calling setState() in receiver", t);
}
}else{
try{
mq.add(new Event(Event.STATE_RECEIVED, state_info));
}
catch(Exception e) {
}
}
}
}
finally {
state_promise.setResult(state != null ? Boolean.TRUE : Boolean.FALSE);
}
break;
case Event.STATE_TRANSFER_INPUTSTREAM_CLOSED:
state_promise.setResult(Boolean.TRUE);
break;
case Event.STATE_TRANSFER_INPUTSTREAM:
StateTransferInfo sti=(StateTransferInfo)evt.getArg();
InputStream is=sti.inputStream;
//Oct 13,2006 moved to down() when Event.STATE_TRANSFER_INPUTSTREAM_CLOSED is received
//state_promise.setResult(is != null? Boolean.TRUE : Boolean.FALSE);
if(up_handler != null) {
return up_handler.up(evt);
}
if(is != null) {
if(receiver instanceof ExtendedReceiver) {
try {
if(sti.state_id == null)
((ExtendedReceiver)receiver).setState(is);
else
((ExtendedReceiver)receiver).setState(sti.state_id, is);
}
catch(Throwable t) {
if(log.isWarnEnabled())
log.warn("failed calling setState() in receiver", t);
}
}
else if(receiver instanceof Receiver){
if(log.isWarnEnabled()){
log.warn("Channel has STREAMING_STATE_TRANSFER, however," +
" application does not implement ExtendedMessageListener. State is not transfered");
Util.close(is);
}
}
else {
try {
mq.add(new Event(Event.STATE_TRANSFER_INPUTSTREAM, sti));
}
catch(Exception e) {
}
}
}
break;
case Event.SET_LOCAL_ADDRESS:
local_addr_promise.setResult((Address)evt.getArg());
break;
case Event.EXIT:
handleExit(evt);
return null; // no need to pass event up; already done in handleExit()
default:
break;
}
// If UpHandler is installed, pass all events to it and return (UpHandler is e.g. a building block)
if(up_handler != null) {
Object ret=up_handler.up(evt);
if(type == Event.UNBLOCK){
flush_unblock_promise.setResult(Boolean.TRUE);
}
return ret;
}
switch(type) {
case Event.MSG:
if(receiver != null) {
try {
receiver.receive((Message)evt.getArg());
}
catch(Throwable t) {
if(log.isWarnEnabled())
log.warn("failed calling receive() in receiver", t);
}
return null;
}
break;
case Event.VIEW_CHANGE:
if(receiver != null) {
try {
receiver.viewAccepted((View)evt.getArg());
}
catch(Throwable t) {
if(log.isWarnEnabled())
log.warn("failed calling viewAccepted() in receiver", t);
}
return null;
}
break;
case Event.SUSPECT:
if(receiver != null) {
try {
receiver.suspect((Address)evt.getArg());
}
catch(Throwable t) {
if(log.isWarnEnabled())
log.warn("failed calling suspect() in receiver", t);
}
return null;
}
break;
case Event.GET_APPLSTATE:
if(receiver != null) {
StateTransferInfo state_info=(StateTransferInfo)evt.getArg();
byte[] tmp_state=null;
String state_id=state_info.state_id;
try {
if(receiver instanceof ExtendedReceiver && state_id!=null) {
tmp_state=((ExtendedReceiver)receiver).getState(state_id);
}
else {
tmp_state=receiver.getState();
}
}
catch(Throwable t) {
if(log.isWarnEnabled())
log.warn("failed calling getState() in receiver", t);
}
return new StateTransferInfo(null, state_id, 0L, tmp_state);
}
break;
case Event.STATE_TRANSFER_OUTPUTSTREAM:
StateTransferInfo sti=(StateTransferInfo)evt.getArg();
OutputStream os=sti.outputStream;
if(receiver instanceof ExtendedReceiver) {
if(os != null) {
try {
if(sti.state_id == null)