Tools

File Channel Integrity Tool

File Channel Integrity tool verifies the integrity of individual Events in the File channeland removes corrupted Events.

The tools can be run as follows:

  1. $bin/flume-ng tool --conf ./conf FCINTEGRITYTOOL -l ./datadir

where datadir is the comma separated list of data directory to be verified.

Following are the options available

Option NameDescription
h/helpDisplays help
l/dataDirsComma-separated list of data directories which the tool must verify

Event Validator Tool

Event validator tool can be used to validate the File Channel Event’s in application specific way.The tool applies the user provider validation login on each event and drop the event which do notconfirm to the logic.

The tools can be run as follows:

  1. $bin/flume-ng tool --conf ./conf FCINTEGRITYTOOL -l ./datadir -e org.apache.flume.MyEventValidator -DmaxSize 2000

where datadir is the comma separated list of data directory to be verified.

Following are the options available

Option NameDescription
h/helpDisplays help
l/dataDirsComma-separated list of data directories which the tool must verify
e/eventValidatorFully Qualified Name of Event Validator Implementation. The jar mustbe on Flume classpath

The Event validator implementation must implement EventValidator interface. It’s recommendednot to throw any exception from the implementation as they are treated as invalid events.Additional parameters can be passed to EventValitor implementation via -D options.

Let’s see an example of simple size based Event Validator, which shall reject event’s largerthan maximum size specified.

  1. public static class MyEventValidator implements EventValidator {
  2.  
  3. private int value = 0;
  4.  
  5. private MyEventValidator(int val) {
  6. value = val;
  7. }
  8.  
  9. @Override
  10. public boolean validateEvent(Event event) {
  11. return event.getBody() <= value;
  12. }
  13.  
  14. public static class Builder implements EventValidator.Builder {
  15.  
  16. private int sizeValidator = 0;
  17.  
  18. @Override
  19. public EventValidator build() {
  20. return new DummyEventVerifier(sizeValidator);
  21. }
  22.  
  23. @Override
  24. public void configure(Context context) {
  25. binaryValidator = context.getInteger("maxSize");
  26. }
  27. }
  28. }