public String dumpHistory() { StringBuilder sb = new StringBuilder(); for (String line : history) { sb.append(line + "\n"); } return sb.toString(); }
@ManagedOperation public String printPreviousViews() { StringBuilder sb = new StringBuilder(); for (Tuple<View, Long> tmp : prev_views) sb.append(new Date(tmp.getVal2())).append(": ").append(tmp.getVal1()).append("\n"); return sb.toString(); }
/** * Send all fragments as separate messages (with same ID !). Example: * * <pre> * Given the generated ID is 2344, number of fragments=3, message {dst,src,buf} * would be fragmented into: * * [2344,3,0]{dst,src,buf1}, * [2344,3,1]{dst,src,buf2} and * [2344,3,2]{dst,src,buf3} * </pre> */ private void fragment(Message msg) { try { byte[] buffer = msg.getRawBuffer(); List<Range> fragments = Util.computeFragOffsets(msg.getOffset(), msg.getLength(), frag_size); int num_frags = fragments.size(); num_sent_frags.addAndGet(num_frags); if (log.isTraceEnabled()) { Address dest = msg.getDest(); StringBuilder sb = new StringBuilder("fragmenting packet to "); sb.append((dest != null ? dest.toString() : "<all members>")) .append(" (size=") .append(buffer.length); sb.append(") into ") .append(num_frags) .append(" fragment(s) [frag_size=") .append(frag_size) .append(']'); log.trace(sb.toString()); } long frag_id = getNextId(); // used as a seqno for (int i = 0; i < fragments.size(); i++) { Range r = fragments.get(i); // don't copy the buffer, only src, dest and headers. Only copy the headers one time ! Message frag_msg = msg.copy(false, i == 0); frag_msg.setBuffer(buffer, (int) r.low, (int) r.high); FragHeader hdr = new FragHeader(frag_id, i, num_frags); frag_msg.putHeader(this.id, hdr); down_prot.down(new Event(Event.MSG, frag_msg)); } } catch (Exception e) { if (log.isErrorEnabled()) log.error("fragmentation failure", e); } }
public String dumpQueue() { StringBuilder sb = new StringBuilder(); List v = queue.values(); for (Iterator it = v.iterator(); it.hasNext(); ) { sb.append(it.next() + "\n"); } return sb.toString(); }
public String toString() { StringBuilder ret = new StringBuilder(); ret.append("[tot_frags=") .append(fragments.length) .append(", number_of_frags_recvd=") .append(number_of_frags_recvd) .append(']'); return ret.toString(); }
@ManagedOperation public String printPreviousMembers() { StringBuilder sb = new StringBuilder(); if (prev_members != null) { for (Address addr : prev_members) { sb.append(addr).append("\n"); } } return sb.toString(); }
public String toString() { StringBuilder sb = new StringBuilder("GmsHeader"); sb.append('[' + type2String(type) + ']'); switch (type) { case JOIN_REQ: case LEAVE_REQ: case GET_DIGEST_REQ: sb.append(": mbr=" + mbr); break; case JOIN_RSP: sb.append(": join_rsp=" + join_rsp); break; case VIEW: case VIEW_ACK: sb.append(": view=" + view); break; case MERGE_REQ: sb.append(": merge_id=" + merge_id).append(", mbrs=" + mbrs); break; case MERGE_RSP: sb.append(": view=" + view + ", digest=" + my_digest + ", merge_id=" + merge_id); if (merge_rejected) sb.append(", merge_rejected=" + merge_rejected); break; case INSTALL_MERGE_VIEW: case GET_DIGEST_RSP: case INSTALL_DIGEST: sb.append(": view=" + view + ", digest=" + my_digest); break; case CANCEL_MERGE: sb.append(", <merge cancelled>, merge_id=" + merge_id); break; } return sb.toString(); }