use of com.yahoo.fs4.BasicPacket in project vespa by vespa-engine.
the class MockFSChannel method receivePackets.
public BasicPacket[] receivePackets(long timeout, int packetCount) {
List<BasicPacket> packets = new java.util.ArrayList<>();
if (lastReceived instanceof QueryPacket) {
lastQueryPacket = (QueryPacket) lastReceived;
QueryResultPacket result = QueryResultPacket.create();
result.setDocstamp(docstamp);
result.setChannel(0);
result.setTotalDocumentCount(2);
result.setOffset(lastQueryPacket.getOffset());
if (lastQueryPacket.getOffset() == 0 && lastQueryPacket.getLastOffset() >= 1) {
result.addDocument(new DocumentInfo(DocsumDefinitionTestCase.createGlobalId(123), 2003, 234, 1000));
}
if (lastQueryPacket.getOffset() <= 1 && lastQueryPacket.getLastOffset() >= 2) {
result.addDocument(new DocumentInfo(DocsumDefinitionTestCase.createGlobalId(456), 1855, 234, 1001));
}
packets.add(result);
} else if (lastReceived instanceof GetDocSumsPacket) {
addDocsums(packets, lastQueryPacket);
} else if (lastReceived instanceof PingPacket) {
packets.add(new PongPacket(activeDocuments));
}
while (packetCount >= 0 && packets.size() > packetCount) {
packets.remove(packets.size() - 1);
}
return packets.toArray(new BasicPacket[packets.size()]);
}
use of com.yahoo.fs4.BasicPacket in project vespa by vespa-engine.
the class PacketCacheTestCase method createCacheEntry.
/**
* Creates a 64-byte packet in an array wrapped in a PacketWrapper
*/
private PacketWrapper createCacheEntry(CacheKey key) throws BufferTooSmallException {
ByteBuffer data = ByteBuffer.allocate(length);
data.put(queryResultPacketData);
data.flip();
BasicPacket[] content = new BasicPacket[] { PacketDecoder.extractPacket(data).packet };
return new PacketWrapper(key, content);
}
Aggregations