use of com.yahoo.fs4.Packet in project jop by jop-devel.
the class Ppp method readIp.
/**
* get a Packet buffer and copy from receive buffer.
*/
void readIp() {
int i, j, k;
//PacketPool.getFreshRcvPacket(single);
Packet p = null;
if (p == null) {
Dbg.wr('!');
// try again later
return;
}
// buf blocks receive buffer :-<
int[] pb = p.buf;
// minus ppp header and checksum
cnt -= 6;
rbuf[cnt + 4] = 0;
rbuf[cnt + 4 + 1] = 0;
rbuf[cnt + 4 + 2] = 0;
// copy buffer
k = 0;
for (i = 0; i < cnt; i += 4) {
for (j = 0; j < 4; ++j) {
k <<= 8;
// after header
k += rbuf[i + j + 4];
}
pb[i >>> 2] = k;
}
p.setLen(cnt);
Dbg.wr('r');
Dbg.intVal(cnt);
/*
dbgIp(pb[3]);
dbgIp(pb[4]);
for (i=0; i<(cnt+4)>>2; ++i) Dbg.hexVal(pb[i]);
Dbg.wr('\n');
*/
cnt = 0;
ready = false;
// inform upper layer
p.setStatus(Packet.RCV);
}
use of com.yahoo.fs4.Packet in project jop by jop-devel.
the class Tftp method resend.
private static void resend() {
time <<= 1;
if (time > 64) {
Dbg.wr("TFTP give up");
tftpInit();
return;
}
Dbg.wr("TFTP resend ");
Dbg.intVal(block_out);
// retransmit DATA
timeout = Timer.getTimeoutSec(time);
Packet p = PacketPool.getFreshPacket();
// Packet p = PacketPool.getPacket(Packet.FREE, Packet.ALLOC, ipLink);
if (p == null) {
// got no free buffer!
Dbg.wr('!');
Dbg.wr('b');
return;
}
p.buf[Udp.DATA] = (DAT << 16) + block_out;
if (block_out == endBlock) {
// last block is zero length
p.setLen(Udp.DATA * 4 + 4);
} else {
read(p.buf, block_out);
p.setLen(Udp.DATA * 4 + 4 + 512);
}
Udp.send(p, srcIp, dstIp, dstPort);
}
use of com.yahoo.fs4.Packet in project vespa by vespa-engine.
the class VespaBackEndSearcher method addUnfilledHits.
/**
* Creates unfilled hits from a List of DocumentInfo instances. Do note
* cacheKey should be available if a cache is active, even if the hit is not
* created from a cache in the current call path.
*
* @param queryPacketData binary data from first phase of search, or null
* @param cacheKey the key this hit should match in the packet cache, or null
*/
protected boolean addUnfilledHits(Result result, List<DocumentInfo> documents, boolean fromCache, QueryPacketData queryPacketData, CacheKey cacheKey) {
boolean allHitsOK = true;
Query myQuery = result.getQuery();
for (DocumentInfo document : documents) {
try {
FastHit hit = new FastHit();
hit.setQuery(myQuery);
if (queryPacketData != null)
hit.setQueryPacketData(queryPacketData);
hit.setCacheKey(cacheKey);
hit.setUseRowInIndexUri(useRowInIndexUri(result));
hit.setFillable();
hit.setCached(fromCache);
extractDocumentInfo(hit, document);
result.hits().add(hit);
} catch (ConfigurationException e) {
allHitsOK = false;
getLogger().log(LogLevel.WARNING, "Skipping hit", e);
} catch (Exception e) {
allHitsOK = false;
getLogger().log(LogLevel.ERROR, "Skipping malformed hit", e);
}
}
return allHitsOK;
}
use of com.yahoo.fs4.Packet in project vespa by vespa-engine.
the class PacketWrapper method addResultPacket.
public void addResultPacket(QueryResultPacket resultPacket) {
// This function only keeps the internal list sorted according
// to offset
int insertionPoint;
QueryResultPacket r;
if (resultPacket.getDocumentCount() == 0) {
// do not add a packet which does not contain new info
return;
}
insertionPoint = Collections.binarySearch(resultPackets, resultPacket, resultPacketComparator);
if (insertionPoint < 0) {
// new offset
// (insertionPoint + 1) * -1;
insertionPoint = ~insertionPoint;
resultPackets.add(insertionPoint, resultPacket);
cleanResultPackets();
} else {
// there exists a packet with same offset
r = (QueryResultPacket) resultPackets.get(insertionPoint);
if (resultPacket.getDocumentCount() > r.getDocumentCount()) {
resultPackets.set(insertionPoint, resultPacket);
cleanResultPackets();
}
}
}
use of com.yahoo.fs4.Packet in project vespa by vespa-engine.
the class PacketWrapper method getPacketsSize.
public int getPacketsSize() {
int size = 0;
for (Iterator<BasicPacket> i = resultPackets.iterator(); i.hasNext(); ) {
QueryResultPacket r = (QueryResultPacket) i.next();
int l = r.getLength();
if (l < 0) {
log.warning("resultpacket length " + l);
l = 10240;
}
size += l;
}
for (Iterator<BasicPacket> i = packets.values().iterator(); i.hasNext(); ) {
BasicPacket packet = i.next();
int l = packet.getLength();
if (l < 0) {
log.warning("BasicPacket length " + l);
l = 10240;
}
size += l;
}
size += keySize;
return size;
}
Aggregations