@Override public FetchResponse fetch(FetchRequest request) { scala.collection.Traversable<Tuple2<TopicAndPartition, PartitionFetchInfo>> requestInfo = request.requestInfo(); java.util.Map<TopicAndPartition, Short> errorMap = new HashMap<>(); while (requestInfo.headOption().isDefined()) { // jfim: IntelliJ erroneously thinks the following line is an incompatible type error, but it's only because // it doesn't understand scala covariance when called from Java (ie. it thinks head() is of type A even though // it's really of type Tuple2[TopicAndPartition, PartitionFetchInfo]) Tuple2<TopicAndPartition, PartitionFetchInfo> t2 = requestInfo.head(); TopicAndPartition topicAndPartition = t2._1(); PartitionFetchInfo partitionFetchInfo = t2._2(); if (!topicAndPartition.topic().equals(topicName)) { errorMap.put(topicAndPartition, Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); } else if (partitionLeaderIndices.length < topicAndPartition.partition()) { errorMap.put(topicAndPartition, Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); } else if (partitionLeaderIndices[topicAndPartition.partition()] != index) { errorMap.put(topicAndPartition, Errors.NOT_LEADER_FOR_PARTITION.code()); } else { // Do nothing, we'll generate a fake message } requestInfo = requestInfo.tail(); } return new MockFetchResponse(errorMap); }
/** * Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints. * * If no HTTP/2 endpoint exists this throws an IllegalArgumentException. */ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) { final scala.collection.Traversable<ServerEndpoint> possibleEndpoints = serverEndpoints.endpoints().filter(func(e -> e.expectedHttpVersions().contains("2"))); if (possibleEndpoints.size() == 0) { throw new IllegalArgumentException(String.format( "gRPC client can't automatically find HTTP/2 connection: " + "no valid endpoints available. %s", serverEndpoints )); } else if (possibleEndpoints.size() == 1) { return possibleEndpoints.head(); } else { // TODO: the decision on which HTTP/2 endpoint to use should be based on config (e.g. maybe the user set // `akka.grpc.client."".use-tls` to false for gRPC so this should return the non-TLS HTTP/2 endpoint on the list. return possibleEndpoints.filter(endpoint -> endpoint.ssl().isDefined()).head(); } }
/** * Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints. * * If no HTTP/2 endpoint exists this throws an IllegalArgumentException. */ public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) { final scala.collection.Traversable<ServerEndpoint> possibleEndpoints = serverEndpoints.endpoints().filter(func(e->e.expectedHttpVersions().contains("2"))); if (possibleEndpoints.size() != 1) { throw new IllegalArgumentException(String.format( "gRPC client can't automatically find HTTP/2 connection: " + "%s valid endpoints available: %s", possibleEndpoints.size(), serverEndpoints )); } return possibleEndpoints.head(); }
Production p = (Production) s; if (p.items().size() == 3) { Terminal t = (Terminal) p.items().tail().head(); ul.separator = t.value(); ul.klabel = p.klabel().get();
Production p = (Production) s; if (p.items().size() == 3) { Terminal t = (Terminal) p.items().tail().head(); ul.separator = t.value(); ul.klabel = p.klabel().get().name();
final ProductionItem body; if (cfgInfo.isLeafCell(p.sort())) { body = p.items().tail().head(); } else { body = NonTerminal(Sorts.Bag());