Search in sources :

Example 1 with Packet

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);
}
Also used : Packet(ejip123.Packet)

Example 2 with Packet

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);
}
Also used : Packet(ejip123.Packet)

Example 3 with Packet

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;
}
Also used : Query(com.yahoo.search.Query) ConfigurationException(com.yahoo.prelude.ConfigurationException) ConfigurationException(com.yahoo.prelude.ConfigurationException) IOException(java.io.IOException) DocumentInfo(com.yahoo.fs4.DocumentInfo)

Example 4 with Packet

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();
        }
    }
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket)

Example 5 with Packet

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;
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) BasicPacket(com.yahoo.fs4.BasicPacket)

Aggregations

Test (org.junit.Test)14 ByteBuffer (java.nio.ByteBuffer)12 BasicPacket (com.yahoo.fs4.BasicPacket)10 QueryPacket (com.yahoo.fs4.QueryPacket)10 Query (com.yahoo.search.Query)9 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)8 IOException (java.io.IOException)5 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)4 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)4 Packet (com.yahoo.fs4.Packet)4 PacketDecoder (com.yahoo.fs4.PacketDecoder)4 DecodedPacket (com.yahoo.fs4.PacketDecoder.DecodedPacket)4 Location (org.bukkit.Location)4 DocumentInfo (com.yahoo.fs4.DocumentInfo)3 PingPacket (com.yahoo.fs4.PingPacket)3 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)3 Packet (ejip123.Packet)3 BufferTooSmallException (com.yahoo.fs4.BufferTooSmallException)2 DocsumPacket (com.yahoo.fs4.DocsumPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2