public StateTransferInfo copy() { return new StateTransferInfo(target, timeout, state); }
StateTransferInfo tmp_info=info.copy(); tmp_info.state_id=substate_id; Event tmpEvt=new Event(evt.getType(), tmp_info);
return new StateTransferInfo(null, 0L, tmp_state); case Event.BLOCK: receiver.block();
StateTransferInfo state_info=new StateTransferInfo(target, timeout); long start=System.currentTimeMillis(); down(new Event(Event.GET_STATE, state_info));
up_prot.up(new Event(Event.GET_STATE_OK, new StateTransferInfo()));
tmp_state=output.toByteArray(); return new StateTransferInfo(null, 0L, tmp_state);
public StateTransferInfo copy() { if(inputStream!=null){ return new StateTransferInfo(target,inputStream,state_id); } else if(outputStream!=null){ return new StateTransferInfo(target,outputStream,state_id); } else{ return new StateTransferInfo(target, state_id, timeout, state); } }
public StateTransferInfo copy() { return new StateTransferInfo(target, timeout, state); }
/** * Returns a substate as indicated by state_id * @param state * @param state_id */ public void returnState(byte[] state, String state_id) { try { StateTransferInfo info=new StateTransferInfo(null, state_id, 0L, state); applstate_exchanger.exchange(info); } catch(InterruptedException e) { Thread.currentThread().interrupt(); } }
/** * Called by the application is response to receiving a <code>getState()</code> object when * calling <code>receive()</code>. * When the application receives a getState() message on the receive() method, * it should call returnState() to reply with the state of the application * @param state The state of the application as a byte buffer * (to send over the network). */ public void returnState(byte[] state) { try { StateTransferInfo info=new StateTransferInfo(null, null, 0L, state); applstate_exchanger.exchange(info); } catch(InterruptedException e) { Thread.currentThread().interrupt(); } }
private Object handleStateRequest(Event evt) { StateTransferInfo info=(StateTransferInfo)evt.getArg(); String id=info.state_id; String original_id=id; Address requester=info.target; // the sender of the state request try { int index=id.indexOf(SEPARATOR); if(index > -1) { info.state_id=id.substring(index + SEPARATOR_LEN); id=id.substring(0, index); // similar reuse as above... } else { info.state_id=null; } MuxChannel mux_ch=services.get(id); if(mux_ch == null) throw new IllegalArgumentException("didn't find service with ID=" + id + " to fetch state from"); // state_id will be null, get regular state from the service named state_id StateTransferInfo ret=(StateTransferInfo)passToMuxChannel(mux_ch, evt, fifo_queue, requester, id, true); if(ret != null) ret.state_id=original_id; return ret; } catch(Throwable ex) { if(log.isErrorEnabled()) log.error("failed returning the application state, will return null", ex); return new StateTransferInfo(null, original_id, 0L, null); } }
private void requestApplicationStates(Address requester, boolean open_barrier) { Set appl_ids=new HashSet(state_requesters.keySet()); String id; List<StateTransferInfo> responses=new LinkedList<StateTransferInfo>(); for(Iterator it=appl_ids.iterator(); it.hasNext();) { id=(String)it.next(); StateTransferInfo info=new StateTransferInfo(requester, id, 0L, null); StateTransferInfo rsp=(StateTransferInfo)up_prot.up(new Event(Event.GET_APPLSTATE, info)); responses.add(rsp); } if(open_barrier) down_prot.down(new Event(Event.OPEN_BARRIER)); for(StateTransferInfo rsp: responses) { sendApplicationStateResponse(rsp); } }
StateTransferInfo sti = new StateTransferInfo(stateRequester, wrapper, state_id); up_prot.up(new Event(Event.STATE_TRANSFER_OUTPUTSTREAM, sti)); }catch(IOException e){
return new StateTransferInfo(null, 0L, tmp_state); case Event.BLOCK: receiver.block();
sti = new StateTransferInfo(hdr.sender, wrapper, tmp_state_id); }catch(IOException e){ if(log.isWarnEnabled()){ sti = new StateTransferInfo(hdr.sender, is, tmp_state_id); }finally{ if(!socket.isConnected()){
StateTransferInfo info=new StateTransferInfo(state_sender, id, 0L, state); up_prot.up(new Event(Event.GET_STATE_OK, info));
/** * Retrieves a substate (or partial state) from the target. * @param target State provider. If null, coordinator is used * @param state_id The ID of the substate. If null, the entire state will be transferred * @param timeout the number of milliseconds to wait for the operation to complete successfully. 0 waits until * the state has been received * @return * @throws ChannelNotConnectedException * @throws ChannelClosedException */ public boolean getState(Address target, String state_id, long timeout) throws ChannelNotConnectedException, ChannelClosedException { if(target == null) target=determineCoordinator(); if(target != null && local_addr != null && target.equals(local_addr)) { if(log.isTraceEnabled()) log.trace("cannot get state from myself (" + target + "): probably the first member"); return false; } StateTransferInfo info=new StateTransferInfo(target, state_id, timeout); boolean rc=_getState(new Event(Event.GET_STATE, info), info); if(rc == false) down(new Event(Event.RESUME_STABLE)); return rc; }
up_prot.up(new Event(Event.GET_STATE_OK, new StateTransferInfo()));
if(log.isDebugEnabled()) log.debug("GET_STATE: first member (no state)"); up_prot.up(new Event(Event.GET_STATE_OK, new StateTransferInfo())); }else{ boolean successfulFlush = false;
StateTransferInfo state_info=new StateTransferInfo(target, timeout); long start=System.currentTimeMillis(); down(new Event(Event.GET_STATE, state_info));