use of net.minecraft.server.v1_14_R1.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 net.minecraft.server.v1_14_R1.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 net.minecraft.server.v1_14_R1.Packet in project vespa by vespa-engine.
the class VdsStreamingSearcher method doSearch2.
@Override
public Result doSearch2(Query query, QueryPacket queryPacket, CacheKey cacheKey, Execution execution) {
// TODO refactor this method into smaller methods, it's hard to see the actual code
lazyTrace(query, 7, "Routing to storage cluster ", getStorageClusterRouteSpec());
if (route == null) {
route = Route.parse(getStorageClusterRouteSpec());
}
lazyTrace(query, 8, "Route is ", route);
lazyTrace(query, 7, "doSearch2(): query docsum class=", query.getPresentation().getSummary(), ", default docsum class=", getDefaultDocsumClass());
if (query.getPresentation().getSummary() == null) {
lazyTrace(query, 6, "doSearch2(): No summary class specified in query, using default: ", getDefaultDocsumClass());
query.getPresentation().setSummary(getDefaultDocsumClass());
} else {
lazyTrace(query, 6, "doSearch2(): Summary class has been specified in query: ", query.getPresentation().getSummary());
}
lazyTrace(query, 8, "doSearch2(): rank properties=", query.getRanking());
lazyTrace(query, 8, "doSearch2(): sort specification=", query.getRanking().getSorting() == null ? null : query.getRanking().getSorting().fieldOrders());
int documentSelectionQueryParameterCount = 0;
if (query.properties().getString(streamingUserid) != null)
documentSelectionQueryParameterCount++;
if (query.properties().getString(streamingGroupname) != null)
documentSelectionQueryParameterCount++;
if (query.properties().getString(streamingSelection) != null)
documentSelectionQueryParameterCount++;
if (documentSelectionQueryParameterCount != 1) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Streaming search needs one and " + "only one of these query parameters to be set: streaming.userid, streaming.groupname, " + "streaming.selection"));
}
query.trace("Routing to search cluster " + getSearchClusterConfigId(), 4);
Visitor visitor = visitorFactory.createVisitor(query, getSearchClusterConfigId(), route);
try {
visitor.doSearch();
} catch (ParseException e) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Failed to parse document selection string: " + e.getMessage() + "'."));
} catch (TokenMgrError e) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Failed to tokenize document selection string: " + e.getMessage() + "'."));
} catch (TimeoutException e) {
return new Result(query, ErrorMessage.createTimeout(e.getMessage()));
} catch (InterruptedException | IllegalArgumentException e) {
return new Result(query, ErrorMessage.createBackendCommunicationError(e.getMessage()));
}
lazyTrace(query, 8, "offset=", query.getOffset(), ", hits=", query.getHits());
Result result = new Result(query);
// Sorted on rank
List<SearchResult.Hit> hits = visitor.getHits();
Map<String, DocumentSummary.Summary> summaryMap = visitor.getSummaryMap();
lazyTrace(query, 7, "total hit count = ", visitor.getTotalHitCount(), ", returned hit count = ", hits.size(), ", summary count = ", summaryMap.size());
result.setTotalHitCount(visitor.getTotalHitCount());
query.trace(visitor.getStatistics().toString(), false, 2);
query.getContext(true).setProperty(STREAMING_STATISTICS, visitor.getStatistics());
Packet[] summaryPackets = new Packet[hits.size()];
int index = 0;
boolean skippedEarlierResult = false;
for (SearchResult.Hit hit : hits) {
if (!verifyDocId(hit.getDocId(), query, skippedEarlierResult)) {
skippedEarlierResult = true;
continue;
}
FastHit fastHit = buildSummaryHit(query, hit);
result.hits().add(fastHit);
DocumentSummary.Summary summary = summaryMap.get(hit.getDocId());
if (summary != null) {
DocsumPacket dp = new DocsumPacket(summary.getSummary());
// log.log(LogLevel.SPAM, "DocsumPacket: " + dp);
summaryPackets[index] = dp;
} else {
return new Result(query, ErrorMessage.createBackendCommunicationError("Did not find summary for hit with document id " + hit.getDocId()));
}
index++;
}
if (result.isFilled(query.getPresentation().getSummary())) {
lazyTrace(query, 8, "Result is filled for summary class ", query.getPresentation().getSummary());
} else {
lazyTrace(query, 8, "Result is not filled for summary class ", query.getPresentation().getSummary());
}
List<Grouping> groupingList = visitor.getGroupings();
lazyTrace(query, 8, "Grouping list=", groupingList);
if (!groupingList.isEmpty()) {
GroupingListHit groupHit = new GroupingListHit(groupingList, getDocsumDefinitionSet(query));
result.hits().add(groupHit);
}
int skippedHits;
try {
FillHitsResult fillHitsResult = fillHits(result, summaryPackets, query.getPresentation().getSummary());
skippedHits = fillHitsResult.skippedHits;
if (fillHitsResult.error != null) {
result.hits().addError(ErrorMessage.createTimeout(fillHitsResult.error));
return result;
}
} catch (TimeoutException e) {
result.hits().addError(ErrorMessage.createTimeout(e.getMessage()));
return result;
} catch (IOException e) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Error filling hits with summary fields"));
}
if (skippedHits == 0) {
// TODO: cache results or result.analyzeHits(); ?
query.trace("All hits have been filled", 4);
} else {
lazyTrace(query, 8, "Skipping some hits for query: ", result.getQuery());
}
lazyTrace(query, 8, "Returning result ", result);
if (skippedHits > 0) {
getLogger().info("skipping " + skippedHits + " hits for query: " + result.getQuery());
result.hits().addError(com.yahoo.search.result.ErrorMessage.createTimeout("Missing hit summary data for " + skippedHits + " hits"));
}
return result;
}
use of net.minecraft.server.v1_14_R1.Packet in project vespa by vespa-engine.
the class FastSearcher method doPartialFill.
/**
* Perform a partial docsum fill for a temporary result
* representing a partition of the complete fill request.
*
* @param result result containing a partition of the unfilled hits
* @param summaryClass the summary class we want to fill with
*/
protected void doPartialFill(Result result, String summaryClass) {
if (result.isFilled(summaryClass))
return;
Query query = result.getQuery();
traceQuery(getName(), "fill", query, query.getOffset(), query.getHits(), 2, quotedSummaryClass(summaryClass));
if (wantsRPCSummaryFill(query)) {
CompressionType compression = CompressionType.valueOf(query.properties().getString(dispatchCompression, "LZ4").toUpperCase());
fillSDDocName(result);
dispatcher.fill(result, summaryClass, compression);
return;
}
CacheKey cacheKey = null;
PacketWrapper packetWrapper = null;
if (getCacheControl().useCache(query)) {
cacheKey = fetchCacheKeyFromHits(result.hits(), summaryClass);
if (cacheKey == null) {
QueryPacket queryPacket = QueryPacket.create(query);
cacheKey = new CacheKey(queryPacket);
}
packetWrapper = cacheLookupTwoPhase(cacheKey, result, summaryClass);
}
FS4Channel channel = chooseBackend(query).openChannel();
channel.setQuery(query);
Packet[] receivedPackets;
try {
DocsumPacketKey[] packetKeys;
if (countFastHits(result) > 0) {
packetKeys = getPacketKeys(result, summaryClass, false);
if (packetKeys.length == 0) {
receivedPackets = new Packet[0];
} else {
try {
receivedPackets = fetchSummaries(channel, result, summaryClass);
} catch (InvalidChannelException e) {
result.hits().addError(ErrorMessage.createBackendCommunicationError("Invalid channel " + getName() + " (summary fetch)"));
return;
} catch (ChannelTimeoutException e) {
result.hits().addError(ErrorMessage.createTimeout("timeout waiting for summaries from " + getName()));
return;
} catch (IOException e) {
result.hits().addError(ErrorMessage.createBackendCommunicationError("IO error while talking on channel " + getName() + " (summary fetch): " + e.getMessage()));
return;
}
if (receivedPackets.length == 0) {
result.hits().addError(ErrorMessage.createBackendCommunicationError(getName() + " got no packets back (summary fetch)"));
return;
}
}
} else {
packetKeys = new DocsumPacketKey[0];
receivedPackets = new Packet[0];
}
int skippedHits;
try {
FillHitsResult fillHitsResult = fillHits(result, receivedPackets, summaryClass);
skippedHits = fillHitsResult.skippedHits;
if (fillHitsResult.error != null) {
result.hits().addError(ErrorMessage.createTimeout(fillHitsResult.error));
return;
}
} catch (TimeoutException e) {
result.hits().addError(ErrorMessage.createTimeout(e.getMessage()));
return;
} catch (IOException e) {
result.hits().addError(ErrorMessage.createBackendCommunicationError("Error filling hits with summary fields, source: " + getName() + " Exception thrown: " + e.getMessage()));
return;
}
if (skippedHits == 0 && packetWrapper != null) {
cacheControl.updateCacheEntry(cacheKey, query, packetKeys, receivedPackets);
}
if (skippedHits > 0)
result.hits().addError(com.yahoo.search.result.ErrorMessage.createEmptyDocsums("Missing hit data for summary '" + summaryClass + "' for " + skippedHits + " hits"));
result.analyzeHits();
if (query.getTraceLevel() >= 3) {
int hitNumber = 0;
for (Iterator<com.yahoo.search.result.Hit> i = hitIterator(result); i.hasNext(); ) {
com.yahoo.search.result.Hit hit = i.next();
if (!(hit instanceof FastHit))
continue;
FastHit fastHit = (FastHit) hit;
String traceMsg = "Hit: " + (hitNumber++) + " from " + (fastHit.isCached() ? "cache" : "backend");
if (!fastHit.isFilled(summaryClass))
traceMsg += ". Error, hit, not filled";
query.trace(traceMsg, false, 3);
}
}
} finally {
channel.close();
}
}
use of net.minecraft.server.v1_14_R1.Packet in project Ublisk by Derkades.
the class V1_14_R1 method sendActionBarMessage.
@Deprecated
@Override
public void sendActionBarMessage(final Player player, final String message) {
final IChatBaseComponent dummyComponent = ChatSerializer.a("{\"text\":\"herobrine1337\"}");
final PacketPlayOutChat packet = new PacketPlayOutChat(dummyComponent, ChatMessageType.GAME_INFO);
packet.components = new BaseComponent[] { new TextComponent(message) };
final CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().playerConnection.sendPacket(packet);
}
Aggregations