AutoBuffer putUdp (UDP.udp type) { assert _bb.position()==0; putSp(1+2); _bb.put ((byte)type.ordinal()); _bb.putChar((char)H2O.H2O_PORT); // Outgoing port is always the sender's (me) port assert _bb.position()==1+2; return this; }
public static void record_IOclose( long start_ns, long start_io_ms, int r_w, long size, int flavor ) { long block_ns = System.nanoTime() - start_ns; long io_ms = System.currentTimeMillis() - start_io_ms; // First long word going out has sender-port and a 'bad' control packet long b0 = UDP.udp.i_o.ordinal(); // Special flag to indicate io-record and not a rpc-record b0 |= H2O.SELF._key.udp_port()<<8; b0 |= flavor<<24; // I/O flavor; one of the Value.persist backends b0 |= io_ms<<32; // msec from start-to-finish, including non-i/o overheads record2(H2O.SELF,block_ns,true,r_w,0,b0,size); }
/** * Only for debugging. * Prints local timeline to stdout. * * To be used in case of an error when global timeline can not be relied upon as we might not be able to talk to other nodes. */ public static void printMyTimeLine(){ long [] s = TimeLine.snapshot(); System.err.println("===================================<TIMELINE>=============================================="); for(int i = 0; i < TimeLine.length(); ++i) { long lo = TimeLine.l0(s, i),hi = TimeLine.l8(s, i); int port = (int)((lo >> 8) & 0xFFFF); String op = TimeLine.send_recv(s,i) == 0?"SEND":"RECV"; if(!TimeLine.isEmpty(s, i) && (lo & 0xFF) == UDP.udp.exec.ordinal()) System.err.println(TimeLine.ms(s, i) + ": " + op + " " + (((TimeLine.ns(s, i) & 4) != 0)?"TCP":"UDP") + TimeLine.inet(s, i) + ":" + port + " | " + UDP.printx16(lo, hi)); } System.err.println("==========================================================================================="); } }
new AutoBuffer(ab._h2o).putTask(UDP.udp.ackack.ordinal(),task).close();
@Override public void compute2() { _ab.getPort(); // skip past the port if( _ctrl <= UDP.udp.ack.ordinal() ) UDP.udp.UDPS[_ctrl]._udp.call(_ab).close(); else RPC.remote_exec(_ab); tryComplete(); } /** Exceptional completion path; mostly does printing if the exception was
public static void record_IOclose( AutoBuffer b, int flavor ) { H2ONode h2o = b._h2o==null ? H2O.SELF : b._h2o; // First long word going out has sender-port and a 'bad' control packet long b0 = UDP.udp.i_o.ordinal(); // Special flag to indicate io-record and not a rpc-record b0 |= H2O.SELF._key.udp_port()<<8; b0 |= flavor<<24; // I/O flavor; one of the Value.persist backends long iotime = b._time_start_ms > 0 ? (b._time_close_ms - b._time_start_ms) : 0; b0 |= iotime<<32; // msec from start-to-finish, including non-i/o overheads long b8 = b._size; // byte's transfered in this I/O long ns = b._time_io_ns; // nano's blocked doing I/O record2(h2o,ns,true,b.readMode()?1:0,0,b0,b8); }
public final int is_io() { int udp_type = (int) (dataLo() & 0xff); // First byte is UDP packet type return UDP.udp.i_o.ordinal() == udp_type ? (int)((dataLo()>>24)&0xFF) : -1; } // ms doing I/O
public static void checkForSuicide(int first_byte, AutoBuffer ab) { if( first_byte != UDP.udp.rebooted.ordinal() ) return; int type = ab.get1(); suicide( T.values()[type], ab._h2o); }
AutoBuffer call(AutoBuffer ab) { int tnum = ab.getTask(); RPC<?> t = ab._h2o.taskGet(tnum); assert t== null || t._tasknum == tnum; if( t != null ) t.response(ab); // Do the 2nd half of this task, includes ACKACK else ab.close(); // Else forgotten task, but still must ACKACK return new AutoBuffer(ab._h2o).putTask(UDP.udp.ackack.ordinal(),tnum); }