Package org.apache.flume

Examples of org.apache.flume.EventDeliveryException


    // client.append* calls unless the lock is acquired.
    ClientWrapper client = null;
    boolean destroyedClient = false;
    try {
      if (!isActive()) {
        throw new EventDeliveryException("Client was closed due to error. " +
          "Please create a new client");
      }
      client = connectionManager.checkout();
      final ThriftFlumeEvent thriftEvent = new ThriftFlumeEvent(event
        .getHeaders(), ByteBuffer.wrap(event.getBody()));
      doAppend(client, thriftEvent).get(requestTimeout, TimeUnit.MILLISECONDS);
    } catch (Throwable e) {
      if (e instanceof ExecutionException) {
        Throwable cause = e.getCause();
        if (cause instanceof EventDeliveryException) {
          throw (EventDeliveryException) cause;
        } else if (cause instanceof TimeoutException) {
          throw new EventDeliveryException("Append call timeout", cause);
        }
      }
      destroyedClient = true;
      // If destroy throws, we still don't want to reuse the client, so mark it
      // as destroyed before we actually do.
      if (client != null) {
        connectionManager.destroy(client);
      }
      if (e instanceof Error) {
        throw (Error) e;
      } else if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
      }
      throw new EventDeliveryException("Failed to send event. ", e);
    } finally {
      if (client != null && !destroyedClient) {
        connectionManager.checkIn(client);
      }
    }
View Full Code Here


    // client.append* calls unless the lock is acquired.
    ClientWrapper client = null;
    boolean destroyedClient = false;
    try {
      if (!isActive()) {
        throw new EventDeliveryException("Client was closed " +
          "due to error or is not yet configured.");
      }
      client = connectionManager.checkout();
      final List<ThriftFlumeEvent> thriftFlumeEvents = new ArrayList
        <ThriftFlumeEvent>();
      Iterator<Event> eventsIter = events.iterator();
      while (eventsIter.hasNext()) {
        thriftFlumeEvents.clear();
        for (int i = 0; i < batchSize && eventsIter.hasNext(); i++) {
          Event event = eventsIter.next();
          thriftFlumeEvents.add(new ThriftFlumeEvent(event.getHeaders(),
            ByteBuffer.wrap(event.getBody())));
        }
        if (!thriftFlumeEvents.isEmpty()) {
          doAppendBatch(client, thriftFlumeEvents).get(requestTimeout,
            TimeUnit.MILLISECONDS);
        }
      }
    } catch (Throwable e) {
      if (e instanceof ExecutionException) {
        Throwable cause = e.getCause();
        if (cause instanceof EventDeliveryException) {
          throw (EventDeliveryException) cause;
        } else if (cause instanceof TimeoutException) {
          throw new EventDeliveryException("Append call timeout", cause);
        }
      }
      destroyedClient = true;
      // If destroy throws, we still don't want to reuse the client, so mark it
      // as destroyed before we actually do.
      if (client != null) {
        connectionManager.destroy(client);
      }
      if (e instanceof Error) {
        throw (Error) e;
      } else if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
      }
      throw new EventDeliveryException("Failed to send event. ", e);
    } finally {
      if (client != null && !destroyedClient) {
        connectionManager.checkIn(client);
      }
    }
View Full Code Here

    return callTimeoutPool.submit(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        Status status = client.client.append(e);
        if (status != Status.OK) {
          throw new EventDeliveryException("Failed to deliver events. Server " +
            "returned status : " + status.name());
        }
        return null;
      }
    });
View Full Code Here

    return callTimeoutPool.submit(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        Status status = client.client.appendBatch(e);
        if (status != Status.OK) {
          throw new EventDeliveryException("Failed to deliver events. Server " +
            "returned status : " + status.name());
        }
        return null;
      }
    });
View Full Code Here

        LOGGER.warn("Failed to send event to host " + host, ex);
      }
    }

    if (!eventSent) {
      throw new EventDeliveryException("Unable to send event to any host");
    }
  }
View Full Code Here

        LOGGER.warn("Failed to send batch to host " + host, ex);
      }
    }

    if (!batchSent) {
      throw new EventDeliveryException("Unable to send batch to any host");
    }
  }
View Full Code Here

    return isOpen;
  }

  private void throwIfClosed() throws EventDeliveryException {
    if (!isOpen) {
      throw new EventDeliveryException("Rpc Client is closed");
    }
  }
View Full Code Here

      setState(ConnState.DEAD);
      if (t instanceof Error) {
        throw (Error) t;
      }
      if (t instanceof TimeoutException) {
        throw new EventDeliveryException(this + ": Failed to send event. " +
            "RPC request timed out after " + requestTimeout + "ms", t);
      }
      throw new EventDeliveryException(this + ": Failed to send event", t);
    }
  }
View Full Code Here

          avroClient.append(avroEvent, callFuture);
          return null;
        }
      });
    } catch (RejectedExecutionException ex) {
      throw new EventDeliveryException(this + ": Executor error", ex);
    }

    try {
      handshake.get(connectTimeout, TimeUnit.MILLISECONDS);
    } catch (TimeoutException ex) {
      throw new EventDeliveryException(this + ": Handshake timed out after " +
          connectTimeout + " ms", ex);
    } catch (InterruptedException ex) {
      throw new EventDeliveryException(this + ": Interrupted in handshake", ex);
    } catch (ExecutionException ex) {
      throw new EventDeliveryException(this + ": RPC request exception", ex);
    } catch (CancellationException ex) {
      throw new EventDeliveryException(this + ": RPC request cancelled", ex);
    } finally {
      if (!handshake.isDone()) {
        handshake.cancel(true);
      }
    }
View Full Code Here

      setState(ConnState.DEAD);
      if (t instanceof Error) {
        throw (Error) t;
      }
      if (t instanceof TimeoutException) {
        throw new EventDeliveryException(this + ": Failed to send event. " +
            "RPC request timed out after " + requestTimeout + " ms", t);
      }
      throw new EventDeliveryException(this + ": Failed to send batch", t);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.flume.EventDeliveryException

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.