Package org.apache.flume.source.avro

Examples of org.apache.flume.source.avro.Status


    return Status.OK;
  }

  @Override
  public Status appendBatch(List<AvroFlumeEvent> events) throws AvroRemoteException {
    Status status = Status.OK;
    for (AvroFlumeEvent event : events) {
      Status stat = append(event);
      if (stat.equals(Status.FAILED) || stat.equals(Status.UNKNOWN) && (!status.equals(Status.FAILED))) {
        status = stat;
      }
    }
    return status;
  }
View Full Code Here


    AvroFlumeEvent avroEvent = new AvroFlumeEvent();

    avroEvent.setHeaders(new HashMap<CharSequence, CharSequence>());
    avroEvent.setBody(ByteBuffer.wrap("Hello avro".getBytes()));

    Status status = client.append(avroEvent);

    Assert.assertEquals(Status.OK, status);

    Transaction transaction = channel.getTransaction();
    transaction.begin();
View Full Code Here

    AvroFlumeEvent avroEvent = new AvroFlumeEvent();

    avroEvent.setHeaders(new HashMap<CharSequence, CharSequence>());
    avroEvent.setBody(ByteBuffer.wrap("Hello avro ssl".getBytes()));

    Status status = client.append(avroEvent);

    Assert.assertEquals(Status.OK, status);

    Transaction transaction = channel.getTransaction();
    transaction.begin();
View Full Code Here

      while ((line = reader.readLine()) != null) {
        // logger.debug("read:{}", line);

        if (eventBuffer.size() >= 1000) {
          Status status = client.appendBatch(eventBuffer);

          if (!status.equals(Status.OK)) {
            logger.error("Unable to send batch size:{} status:{}",
                eventBuffer.size(), status);
          }

          eventBuffer.clear();
        }

        AvroFlumeEvent avroEvent = new AvroFlumeEvent();

        avroEvent.headers = new HashMap<CharSequence, CharSequence>();
        avroEvent.body = ByteBuffer.wrap(line.getBytes());

        eventBuffer.add(avroEvent);

        sentBytes += avroEvent.body.capacity();
        sent++;

        long now = System.currentTimeMillis();

        if (now >= lastCheck + 5000) {
          logger.debug("Packed {} bytes, {} events", sentBytes, sent);
          lastCheck = now;
        }
      }

      if (eventBuffer.size() > 0) {
        Status status = client.appendBatch(eventBuffer);

        if (!status.equals(Status.OK)) {
          logger.error("Unable to send batch size:{} status:{}",
              eventBuffer.size(), status);
        }

        eventBuffer.clear();
View Full Code Here

    AvroFlumeEvent avroEvent = new AvroFlumeEvent();

    avroEvent.headers = new HashMap<CharSequence, CharSequence>();
    avroEvent.body = ByteBuffer.wrap("Hello avro".getBytes());

    Status status = client.append(avroEvent);

    Assert.assertEquals(Status.OK, status);

    Transaction transaction = channel.getTransaction();
    transaction.begin();
View Full Code Here

        String msg = "Error writing to " + getName();

        do {
            try {
                Status status = (batch == null) ? client.append(avroEvent) : client.appendBatch(batch);
                if (!status.equals(Status.OK)) {
                    throw new AvroRemoteException("RPC communication failed to " + agents[current].getHost() +
                        ":" + agents[current].getPort());
                }
                return;
            } catch (Exception ex) {
                if (i == retries - 1) {
                    msg = "Error writing to " + getName() + " at " + agents[current].getHost() + ":" +
                        agents[current].getPort();
                    LOGGER.warn(msg, ex);
                    break;
                }
                sleep(delay);
            }
        } while (++i < retries);

        for (int index = 0; index < agents.length; ++index) {
            if (index == current) {
                continue;
            }
            Agent agent = agents[index];
            i = 0;
            do {
                try {
                    transceiver = null;
                    AvroSourceProtocol c = connect(agent.getHost(), agent.getPort());
                    Status status = (batch == null) ? c.append(avroEvent) : c.appendBatch(batch);
                    if (!status.equals(Status.OK)) {
                        if (i == retries - 1) {
                            String warnMsg = "RPC communication failed to " + getName() + " at " +
                                agent.getHost() + ":" + agent.getPort();
                            LOGGER.warn(warnMsg);
                        }
View Full Code Here

   * @throws EventDeliveryException If there is a timeout or if Status != OK
   */
  private static void waitForStatusOK(CallFuture<Status> callFuture,
      long timeout, TimeUnit tu) throws EventDeliveryException {
    try {
      Status status = callFuture.get(timeout, tu);
      if (status != Status.OK) {
        logger.error("Status (" + status + ") is not OK");
        throw new EventDeliveryException("Status (" + status + ") is not OK");
      }
    } catch (CancellationException ex) {
View Full Code Here

        String msg = "Error writing to " + getName();

        do {
            try {
                Status status = (batch == null) ? client.append(avroEvent) : client.appendBatch(batch);
                if (!status.equals(Status.OK)) {
                    throw new AvroRemoteException("RPC communication failed to " + agents[current].getHost() +
                        ":" + agents[current].getPort());
                }
                return;
            } catch (Exception ex) {
                if (i == retries - 1) {
                    msg = "Error writing to " + getName() + " at " + agents[current].getHost() + ":" +
                        agents[current].getPort();
                    LOGGER.warn(msg, ex);
                    break;
                }
                sleep(delay);
            }
        } while (++i < retries);

        for (int index = 0; index < agents.length; ++index) {
            if (index == current) {
                continue;
            }
            Agent agent = agents[index];
            i = 0;
            do {
                try {
                    transceiver = null;
                    AvroSourceProtocol c = connect(agent.getHost(), agent.getPort());
                    Status status = (batch == null) ? c.append(avroEvent) : c.appendBatch(batch);
                    if (!status.equals(Status.OK)) {
                        if (i == retries - 1) {
                            String warnMsg = "RPC communication failed to " + getName() + " at " +
                                agent.getHost() + ":" + agent.getPort();
                            LOGGER.warn(warnMsg);
                        }
View Full Code Here

            msg = "Error writing to " + getName();

            do {
                try {
                    final Status status = (batch == null) ? client.append(avroEvent) : client.appendBatch(batch);
                    if (!status.equals(Status.OK)) {
                        throw new AvroRemoteException("RPC communication failed to " + agents[current].getHost() +
                            ":" + agents[current].getPort());
                    }
                    return;
                } catch (final Exception ex) {
                    if (i == retries - 1) {
                        msg = "Error writing to " + getName() + " at " + agents[current].getHost() + ":" +
                            agents[current].getPort();
                        LOGGER.warn(msg, ex);
                        break;
                    }
                    sleep(delay);
                }
            } while (++i < retries);

            for (int index = 0; index < agents.length; ++index) {
                if (index == current) {
                    continue;
                }
                final Agent agent = agents[index];
                i = 0;
                do {
                    try {
                        transceiver = null;
                        final AvroSourceProtocol c = connect(agent.getHost(), agent.getPort());
                        final Status status = (batch == null) ? c.append(avroEvent) : c.appendBatch(batch);
                        if (!status.equals(Status.OK)) {
                            if (i == retries - 1) {
                                final String warnMsg = "RPC communication failed to " + getName() + " at " +
                                    agent.getHost() + ":" + agent.getPort();
                                LOGGER.warn(warnMsg);
                            }
View Full Code Here

        String msg = "Error writing to " + getName();

        do {
            try {
                Status status = (batch == null) ? client.append(avroEvent) : client.appendBatch(batch);
                if (!status.equals(Status.OK)) {
                    throw new AvroRemoteException("RPC communication failed to " + agents[current].getHost() +
                        ":" + agents[current].getPort());
                }
                return;
            } catch (Exception ex) {
                if (i == retries - 1) {
                    msg = "Error writing to " + getName() + " at " + agents[current].getHost() + ":" +
                        agents[current].getPort();
                    LOGGER.warn(msg, ex);
                    break;
                }
                sleep(delay);
            }
        } while (++i < retries);

        for (int index = 0; index < agents.length; ++index) {
            if (index == current) {
                continue;
            }
            Agent agent = agents[index];
            i = 0;
            do {
                try {
                    transceiver = null;
                    AvroSourceProtocol c = connect(agent.getHost(), agent.getPort());
                    Status status = (batch == null) ? c.append(avroEvent) : c.appendBatch(batch);
                    if (!status.equals(Status.OK)) {
                        if (i == retries - 1) {
                            String warnMsg = "RPC communication failed to " + getName() + " at " +
                                agent.getHost() + ":" + agent.getPort();
                            LOGGER.warn(warnMsg);
                        }
View Full Code Here

TOP

Related Classes of org.apache.flume.source.avro.Status

Copyright © 2018 www.massapicom. 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.