Examples of FetchResponse


Examples of com.google.step2.http.FetchResponse

  public void testGet_syntaxError() throws Exception {
    String host = "host.com";
    FetchRequest request =
        FetchRequest.createGetRequest(new URI("http://host.com/host-meta"));
    FetchResponse response = new FakeFetchResponse(200,
        "Link: <http://foo.com/bar>; rel=foobar type=foo\n");

    expect(http.fetch(request)).andReturn(response);

    control.replay();
View Full Code Here

Examples of com.google.step2.http.FetchResponse

  public void testGet_httpErrorCode() throws Exception {
    String host = "host.com";
    FetchRequest request =
        FetchRequest.createGetRequest(new URI("http://host.com/host-meta"));
    FetchResponse response = new FakeFetchResponse(400, "error");

    expect(http.fetch(request)).andReturn(response);

    control.replay();
    try {
View Full Code Here

Examples of kafka.javaapi.FetchResponse

        String topic = config.topic;
        int partitionId = partition.partition;
        FetchRequestBuilder builder = new FetchRequestBuilder();
        FetchRequest fetchRequest = builder.addFetch(topic, partitionId, offset, config.fetchSizeBytes).
                clientId(config.clientId).maxWait(config.fetchMaxWait).build();
        FetchResponse fetchResponse;
        try {
            fetchResponse = consumer.fetch(fetchRequest);
        } catch (Exception e) {
            if (e instanceof ConnectException ||
                    e instanceof SocketTimeoutException ||
                    e instanceof IOException ||
                    e instanceof UnresolvedAddressException
                    ) {
                LOG.warn("Network error when fetching messages:", e);
                throw new FailedFetchException(e);
            } else {
                throw new RuntimeException(e);
            }
        }
        if (fetchResponse.hasError()) {
            KafkaError error = KafkaError.getError(fetchResponse.errorCode(topic, partitionId));
            if (error.equals(KafkaError.OFFSET_OUT_OF_RANGE) && config.useStartOffsetTimeIfOffsetOutOfRange) {
                LOG.warn("Got fetch request with offset out of range: [" + offset + "]; " +
                        "retrying with default start offset time from configuration. " +
                        "configured start offset time: [" + config.startOffsetTime + "]");
                throw new UpdateOffsetException();
            } else {
                String message = "Error fetching data from [" + partition + "] for topic [" + topic + "]: [" + error + "]";
                LOG.error(message);
                throw new FailedFetchException(message);
            }
        } else {
            msgs = fetchResponse.messageSet(topic, partitionId);
        }
        return msgs;
    }
View Full Code Here

Examples of kafka.javaapi.FetchResponse

        int partitionId = partition.partition;
        for (int errors = 0; errors < 2 && msgs == null; errors++) {
            FetchRequestBuilder builder = new FetchRequestBuilder();
            FetchRequest fetchRequest = builder.addFetch(topic, partitionId, offset, config.fetchSizeBytes).
                    clientId(config.clientId).build();
            FetchResponse fetchResponse;
            try {
                fetchResponse = consumer.fetch(fetchRequest);
            } catch (Exception e) {
                if (e instanceof ConnectException) {
                    throw new FailedFetchException(e);
                } else {
                    throw new RuntimeException(e);
                }
            }
            if (fetchResponse.hasError()) {
                KafkaError error = KafkaError.getError(fetchResponse.errorCode(topic, partitionId));
                if (error.equals(KafkaError.OFFSET_OUT_OF_RANGE) && config.useStartOffsetTimeIfOffsetOutOfRange && errors == 0) {
                    long startOffset = getOffset(consumer, topic, partitionId, config.startOffsetTime);
                    LOG.warn("Got fetch request with offset out of range: [" + offset + "]; " +
                            "retrying with default start offset time from configuration. " +
                            "configured start offset time: [" + config.startOffsetTime + "] offset: [" + startOffset + "]");
                    offset = startOffset;
                } else {
                    String message = "Error fetching data from [" + partition + "] for topic [" + topic + "]: [" + error + "]";
                    LOG.error(message);
                    throw new FailedFetchException(message);
                }
            } else {
                msgs = fetchResponse.messageSet(topic, partitionId);
            }
        }
        return msgs;
    }
View Full Code Here

Examples of kafka.javaapi.FetchResponse

        final String clientName = getClientName(topicPartition);
        kafka.api.FetchRequest request = new FetchRequestBuilder().clientId(clientName)
                .addFetch(topicPartition.getTopic(), topicPartition.getPartition(), offset,
                          MAX_MESSAGE_SIZE_BYTES)
                .build();
        FetchResponse response = consumer.fetch(request);
        if (response.hasError()) {
            consumer.close();
            throw new RuntimeException("Error fetching offset data. Reason: " +
                    response.errorCode(topicPartition.getTopic(), topicPartition.getPartition()));
        }
        MessageAndOffset messageAndOffset = response.messageSet(
                topicPartition.getTopic(), topicPartition.getPartition()).iterator().next();
        ByteBuffer payload = messageAndOffset.message().payload();
        byte[] payloadBytes = new byte[payload.limit()];
        payload.get(payloadBytes);
        return new Message(topicPartition.getTopic(), topicPartition.getPartition(),
View Full Code Here

Examples of org.apache.james.imap.message.response.FetchResponse

                if (selected.isRecent(uid)) {
                    resultFlags.add(Flags.Flag.RECENT);
                }
              
                final FetchResponse response;
                // For more informations related to the FETCH response see
                //
                // RFC4551 3.2. STORE and UID STORE Commands
                if (silent && (unchangedSince != -1 || qresyncEnabled || condstoreEnabled)) {
                    // We need to return an FETCH response which contains the mod-sequence of the message even if FLAGS.SILENT was used
                    response = new FetchResponse(msn, null, resultUid, modSeqs.get(uid), null, null, null, null, null, null);
                } else if (!silent && (unchangedSince != -1 || qresyncEnabled || condstoreEnabled)){
                    //
                    // Use a FETCH response which contains the mod-sequence and the flags
                    response = new FetchResponse(msn, resultFlags, resultUid, modSeqs.get(uid), null, null, null, null, null, null);
                } else {
                    // Use a FETCH response which only contains the flags as no CONDSTORE was used
                    response = new FetchResponse(msn, resultFlags, resultUid, null, null, null, null, null, null, null);
                }
                responder.respond(response);
            }

            if (unchangedSince != -1) {
View Full Code Here

Examples of org.apache.james.imap.message.response.FetchResponse

        return (message instanceof FetchResponse);
    }

    protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
        if (acceptableMessage instanceof FetchResponse) {
            final FetchResponse fetchResponse = (FetchResponse) acceptableMessage;
            final long messageNumber = fetchResponse.getMessageNumber();
           
          composer.untagged().message(messageNumber).message(ImapConstants.FETCH_COMMAND_NAME).openParen();

           
            encodeModSeq(composer, fetchResponse);
            encodeFlags(composer, fetchResponse);
            encodeInternalDate(composer, fetchResponse);
            encodeSize(composer, fetchResponse);
            encodeEnvelope(composer, fetchResponse);
            encodeBody(composer, fetchResponse.getBody(), session);
            encodeBodyStructure(composer, fetchResponse.getBodyStructure(), session);
            encodeUid(composer, fetchResponse);
            encodeBodyElements(composer, fetchResponse.getElements());
           
            composer.closeParen().end();
        }
    }
View Full Code Here

Examples of org.apache.james.imap.message.response.FetchResponse

            if (selected.isRecent(uid)) {
                flags.add(Flags.Flag.RECENT);
            } else {
                flags.remove(Flags.Flag.RECENT);
            }
            final FetchResponse response;
           
            // Check if we also need to return the MODSEQ in the response. This is true if CONDSTORE or
            // if QRESYNC was enabled, and the mailbox supports the permant storage of mod-sequences
            if ((condstoreEnabled || qresyncEnabled) && mailbox.getMetaData(false, mailboxSession, FetchGroup.NO_COUNT).isModSeqPermanent()) {
                response = new FetchResponse(msn, flags, uidOut, mr.getModSeq(), null, null, null, null, null, null);
            } else {
                response = new FetchResponse(msn, flags, uidOut, null, null, null, null, null, null, null);
            }
            responder.respond(response);
        }
    }
View Full Code Here

Examples of org.apache.james.imap.message.response.FetchResponse

        for (int i = 0; i < ranges.size(); i++) {
            MessageResultIterator messages = mailbox.getMessages(ranges.get(i), resultToFetch, mailboxSession);
            while (messages.hasNext()) {
                final MessageResult result = messages.next();
                try {
                    final FetchResponse response = builder.build(fetch, result, mailbox, session, useUids);
                    responder.respond(response);
                } catch (MessageRangeException e) {
                    // we can't for whatever reason find the message so
                    // just skip it and log it to debug
                    if (session.getLog().isDebugEnabled()) {
View Full Code Here

Examples of org.apache.james.imap.message.response.FetchResponse

    public void setFlags(Flags flags) {
        this.flags = flags;
    }

    public FetchResponse build() {
        final FetchResponse result = new FetchResponse(msn, flags, uid, modSeq, internalDate, size, envelope, body, bodystructure, elements);
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.