Package org.apache.flume

Examples of org.apache.flume.ChannelException


      transaction.begin();
    }
    @Override
    protected void doPut(Event event) throws InterruptedException {
      if(!channel.open) {
        throw new ChannelException("Channel not open");
      }
      if(!channel.queueRemaining.tryAcquire(channel.keepAlive, TimeUnit.SECONDS)) {
        throw new ChannelException("Cannot acquire capacity");
      }
      RecoverableMemoryChannelEvent sequencedEvent =
          new RecoverableMemoryChannelEvent(event, channel.nextSequenceID());
      memoryChannel.put(sequencedEvent);
      events.add(sequencedEvent);
View Full Code Here


    }

    @Override
    protected Event doTake() throws InterruptedException {
      if(!channel.open) {
        throw new ChannelException("Channel not open");
      }
      RecoverableMemoryChannelEvent event = (RecoverableMemoryChannelEvent)memoryChannel.take();
      if(event != null) {
        sequenceIds.add(event.sequenceId);
        takes++;
View Full Code Here

    }

    @Override
    protected void doCommit() throws InterruptedException {
      if(!channel.open) {
        throw new ChannelException("Channel not open");
      }
      if(sequenceIds.size() > 0) {
        try {
          channel.commitSequenceID(sequenceIds);
        } catch (IOException e) {
          throw new ChannelException("Unable to commit", e);
        }
      }
      if(!events.isEmpty()) {
        try {
          channel.commitEvents(events);
        } catch (IOException e) {
          throw new ChannelException("Unable to commit", e);
        }
      }
      transaction.commit();
      channel.queueRemaining.release(takes);
    }
View Full Code Here

      return String.valueOf(getState());
    }
    @Override
    protected void doPut(Event event) throws InterruptedException {
      if(putList.remainingCapacity() == 0) {
        throw new ChannelException("Put queue for FileBackedTransaction " +
            "of capacity " + putList.size() + " full, consider " +
            "committing more frequently, increasing capacity or " +
            "increasing thread count");
      }
      if(!queueRemaining.tryAcquire(keepAlive, TimeUnit.SECONDS)) {
        throw new ChannelException("Cannot acquire capacity");
      }
      try {
        FlumeEventPointer ptr = log.put(transactionID, event);
        Preconditions.checkState(putList.offer(ptr));
      } catch (IOException e) {
        throw new ChannelException("Put failed due to IO error", e);
      }
    }
View Full Code Here

    }

    @Override
    protected Event doTake() throws InterruptedException {
      if(takeList.remainingCapacity() == 0) {
        throw new ChannelException("Take list for FileBackedTransaction, capacity " +
            takeList.size() + " full, consider committing more frequently, " +
            "increasing capacity, or increasing thread count");
      }
      FlumeEventPointer ptr = queue.removeHead();
      if(ptr != null) {
        try {
          // first add to takeList so that if write to disk
          // fails rollback actually does it's work
          Preconditions.checkState(takeList.offer(ptr));
          log.take(transactionID, ptr); // write take to disk
          Event event = log.get(ptr);
          return event;
        } catch (IOException e) {
          throw new ChannelException("Take failed due to IO error", e);
        }
      }
      return null;
    }
View Full Code Here

          }
        }
        try {
          log.commitPut(transactionID);
        } catch (IOException e) {
          throw new ChannelException("Commit failed due to IO error", e);
        }
      } else if(takes > 0) {
        try {
          log.commitTake(transactionID);
        } catch (IOException e) {
          throw new ChannelException("Commit failed due to IO error", e);
        }
        queueRemaining.release(takes);
      }
      putList.clear();
      takeList.clear();
View Full Code Here

      }
      queueRemaining.release(puts);
      try {
        log.rollback(transactionID);
      } catch (IOException e) {
        throw new ChannelException("Commit failed due to IO error", e);
      }
      putList.clear();
      takeList.clear();
    }
View Full Code Here

      } catch (ChannelException ex) {
        tx.rollback();
        throw ex;
      } catch (Exception e) {
        tx.rollback();
        throw new ChannelException("Unexpected error", e);
      } finally {
        if (tx != null) {
          tx.close();
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.flume.ChannelException

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.