Package org.apache.flume

Examples of org.apache.flume.ChannelException


      writeEvents = new LinkedList<Event>();

      try {
        outputStream = new FileOutputStream(currentOutputFile, true);
      } catch (FileNotFoundException e) {
        throw new ChannelException("Unable to open new output file:"
            + currentOutputFile, e);
      }

      writeInitialized = true;
    }
View Full Code Here


          // TODO: Write checksum.
          outputStream.write("---\n".getBytes());

          writeEvents.clear();
        } catch (IOException e) {
          throw new ChannelException("Unable to write to output file", e);
        }
      }

      if (readInitialized) {
        logger.debug("Freeing {} consumed events", readEvents.size());
View Full Code Here

      if (writeInitialized) {
        try {
          outputStream.close();
        } catch (IOException e) {
          throw new ChannelException("Unable to close current output file", e);
        }
      }

      if (readInitialized) {
        // TODO: Implement me!
View Full Code Here

            byte[] body = new byte[bytes.remaining()];
            bytes.get(body);
            Event event = EventBuilder.withBody(body);

            // process event
            ChannelException ex = null;
            try {
              source.getChannelProcessor().processEvent(event);
            } catch (ChannelException chEx) {
              ex = chEx;
            }

            if (ex == null) {
              counterGroup.incrementAndGet("events.processed");
              numProcessed++;
              if (true == ackEveryEvent) {
                writer.write("OK\n");
              }
            } else {
              counterGroup.incrementAndGet("events.failed");
              logger.warn("Error processing event. Exception follows.", ex);
              writer.write("FAILED: " + ex.getMessage() + "\n");
            }
            writer.flush();

            // advance position after data is consumed
            buffer.position(pos + 1); // skip newline
View Full Code Here

    verify(consumer).commit();
  }
  @SuppressWarnings("unchecked")
  @Test
  public void testProcessChannelProcessorThrowsChannelException() throws Exception {
    doThrow(new ChannelException("dummy"))
      .when(channelProcessor).processEventBatch(any(List.class));
    source.configure(context);
    source.start();
    Assert.assertEquals(Status.BACKOFF, source.process());
    verify(consumer).rollback();
View Full Code Here

          case THROW_ERROR:
            throw new TestError();
          case THROW_RUNTIME:
            throw new TestRuntimeException();
          case THROW_CHANNEL:
            throw new ChannelException("test");
          case SLEEP:
            Thread.sleep(300000);
            break;
        }
      }
View Full Code Here

    for (int i = 0; i < 10; i++) {
      source.process();
    }

    // 1 failed call, 10 successful
    doThrow(new ChannelException("stub")).when(
        mockProcessor).processEvent(getEvent(source));
    source.process();
    doNothing().when(mockProcessor).processEvent(getEvent(source));
    for (int i = 0; i < 10; i++) {
      source.process();
    }

    // 1 failed call, 50 succesful
    doThrow(new ChannelException("stub")).when(
        mockProcessor).processEvent(getEvent(source));
    source.process();
    doNothing().when(mockProcessor).processEvent(getEvent(source));
    for (int i = 0; i < 50; i++) {
      source.process();
View Full Code Here

    openDirectory = new File(directory, "open");
    completeDirectory = new File(directory, "complete");

    if (!openDirectory.mkdirs()) {
      throw new ChannelException("Unable to create open file directory:"
          + openDirectory);
    }

    if (!completeDirectory.mkdirs()) {
      throw new ChannelException("Unable to create complete file directory:"
          + completeDirectory);
    }

    shouldRotate = false;
    isInitialized = true;
View Full Code Here

      writeEvents = new LinkedList<Event>();

      try {
        outputStream = new FileOutputStream(currentOutputFile, true);
      } catch (FileNotFoundException e) {
        throw new ChannelException("Unable to open new output file:"
            + currentOutputFile, e);
      }

      writeInitialized = true;
    }
View Full Code Here

          // TODO: Write checksum.
          outputStream.write("---\n".getBytes());

          writeEvents.clear();
        } catch (IOException e) {
          throw new ChannelException("Unable to write to output file", e);
        }
      }

      if (readInitialized) {
        logger.debug("Freeing {} consumed events", readEvents.size());
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.