Review Board 1.7.22


FLUME-1827. Logging modifications to FlumeConfiguration

Review Request #8924 - Created Jan. 10, 2013 and updated

Hari Shreedharan
FLUME-1827
Reviewers
Flume
flume-git
Logging only change
Ran full build. Things look ok
flume-ng-configuration/src/main/java/org/apache/flume/conf/FlumeConfiguration.java
Revision 1662e56 New Change
[20] 84 lines
[+20] [+] public class FlumeConfiguration {
85

    
   
85

   
86
    // validate and remove improperly configured components
86
    // validate and remove improperly configured components
87
    validateConfiguration();
87
    validateConfiguration();
88

    
   
88

   
89
  }
89
  }

    
   
90

   

    
   
91
  public static void logDebug(String msg) {

    
   
92
    if(logger.isDebugEnabled()) {

    
   
93
      logger.debug(msg);

    
   
94
    }

    
   
95
  }
90
  /**
96
  /**
91
   * Creates a populated Flume Configuration object.
97
   * Creates a populated Flume Configuration object.
92
   */
98
   */
93
  public FlumeConfiguration(Map<String, String> properties) {
99
  public FlumeConfiguration(Map<String, String> properties) {
94
    agentConfigMap = new HashMap<String, AgentConfiguration>();
100
    agentConfigMap = new HashMap<String, AgentConfiguration>();
[+20] [20] 35 lines
[+20] [+] private void validateConfiguration() {
130
            FlumeConfigurationErrorType.AGENT_CONFIGURATION_INVALID,
136
            FlumeConfigurationErrorType.AGENT_CONFIGURATION_INVALID,
131
            ErrorOrWarning.ERROR));
137
            ErrorOrWarning.ERROR));
132

    
   
138

   
133
        it.remove();
139
        it.remove();
134
      }
140
      }
135
      logger.debug("Channels:" + aconf.channels + "\n");
141
      logDebug("Channels:" + aconf.channels + "\n");
136
      logger.debug("Sinks " + aconf.sinks + "\n");
142
      logDebug("Sinks " + aconf.sinks + "\n");
137
      logger.debug("Sources " + aconf.sources + "\n");
143
      logDebug("Sources " + aconf.sources + "\n");
138
    }
144
    }
139

    
   
145

   
140
    logger.info("Post-validation flume configuration contains configuration"
146
    logger.info("Post-validation flume configuration contains configuration"
141
        + " for agents: " + agentConfigMap.keySet());
147
        + " for agents: " + agentConfigMap.keySet());
142
  }
148
  }
[+20] [20] 165 lines
[+20] [+] public static class AgentConfiguration {
308
     * </p>
314
     * </p>
309
     *
315
     *
310
     * @return true if the configuration is valid, false otherwise
316
     * @return true if the configuration is valid, false otherwise
311
     */
317
     */
312
    private boolean isValid() {
318
    private boolean isValid() {
313
      logger.debug("Starting validation of configuration for agent: "
319
      logDebug("Starting validation of configuration for agent: "
314
          + agentName + ", initial-configuration: " +
320
          + agentName + ", initial-configuration: " +
315
          this.getPrevalidationConfig());
321
          this.getPrevalidationConfig());
316

    
   
322

   
317
      // Make sure that at least one channel is specified
323
      // Make sure that at least one channel is specified
318
      if (channels == null || channels.trim().length() == 0) {
324
      if (channels == null || channels.trim().length() == 0) {
[+20] [20] 47 lines
[+20] public static class AgentConfiguration {
366
      this.sources = getSpaceDelimitedList(sourceSet);
372
      this.sources = getSpaceDelimitedList(sourceSet);
367
      this.channels = getSpaceDelimitedList(channelSet);
373
      this.channels = getSpaceDelimitedList(channelSet);
368
      this.sinks = getSpaceDelimitedList(sinkSet);
374
      this.sinks = getSpaceDelimitedList(sinkSet);
369
      this.sinkgroups = getSpaceDelimitedList(sinkgroupSet);
375
      this.sinkgroups = getSpaceDelimitedList(sinkgroupSet);
370

    
   
376

   
371
      logger.debug("Post validation configuration for " + agentName + NEWLINE
377
      logDebug("Post validation configuration for " + agentName + NEWLINE
372
          + this.getPostvalidationConfig());
378
          + this.getPostvalidationConfig());
373

    
   
379

   
374
      return true;
380
      return true;
375
    }
381
    }
376

    
   
382

   
[+20] [20] 86 lines
[+20] [+] private SourceType getKnownSource(String type) {
463

    
   
469

   
464
          try {
470
          try {
465
            conf =
471
            conf =
466
                (ChannelConfiguration) ComponentConfigurationFactory.create(
472
                (ChannelConfiguration) ComponentConfigurationFactory.create(
467
                    channelName, config, ComponentType.CHANNEL);
473
                    channelName, config, ComponentType.CHANNEL);
468
            logger.debug("Created channel " + channelName);
474
            logDebug("Created channel " + channelName);
469
            if (conf != null) {
475
            if (conf != null) {
470
              conf.configure(channelContext);
476
              conf.configure(channelContext);
471
            }
477
            }
472
            if((configSpecified && conf.isNotFoundConfigClass()) ||
478
            if((configSpecified && conf.isNotFoundConfigClass()) ||
473
                !configSpecified){
479
                !configSpecified){
[+20] [20] 174 lines
[+20] private SourceType getKnownSource(String type) {
648
      while (iter.hasNext()) {
654
      while (iter.hasNext()) {
649
        String sinkName = iter.next();
655
        String sinkName = iter.next();
650
        Context sinkContext = sinkContextMap.get(sinkName.trim());
656
        Context sinkContext = sinkContextMap.get(sinkName.trim());
651
        if (sinkContext == null) {
657
        if (sinkContext == null) {
652
          iter.remove();
658
          iter.remove();
653
          logger.warn("no context for sink" + sinkName);

   
654
          errorList.add(new FlumeConfigurationError(agentName, sinkName,
659
          errorList.add(new FlumeConfigurationError(agentName, sinkName,
655
              FlumeConfigurationErrorType.CONFIG_ERROR, ErrorOrWarning.ERROR));
660
              FlumeConfigurationErrorType.CONFIG_ERROR, ErrorOrWarning.ERROR));
656
        } else {
661
        } else {
657
          String config = null;
662
          String config = null;
658
          boolean configSpecified = false;
663
          boolean configSpecified = false;
[+20] [20] 10 lines
[+20] private SourceType getKnownSource(String type) {
669
          } else {
674
          } else {
670
            config = sinkType.toString().toUpperCase();
675
            config = sinkType.toString().toUpperCase();
671
            configSpecified = true;
676
            configSpecified = true;
672
          }
677
          }
673
          try {
678
          try {
674
            logger.debug("Creating sink: " + sinkName + " using " + config);
679
            logDebug("Creating sink: " + sinkName + " using " + config);
675

    
   
680

   
676
            sinkConf =
681
            sinkConf =
677
                (SinkConfiguration) ComponentConfigurationFactory.create(
682
                (SinkConfiguration) ComponentConfigurationFactory.create(
678
                    sinkName, config, ComponentType.SINK);
683
                    sinkName, config, ComponentType.SINK);
679
            if (sinkConf != null) {
684
            if (sinkConf != null) {
[+20] [20] 245 lines
[+20] [+] private boolean addProperty(String key, String value) {
925

    
   
930

   
926
      // Check for sinks
931
      // Check for sinks
927
      if (key.equals(BasicConfigurationConstants.CONFIG_SINKS)) {
932
      if (key.equals(BasicConfigurationConstants.CONFIG_SINKS)) {
928
        if (sinks == null) {
933
        if (sinks == null) {
929
          sinks = value;
934
          sinks = value;
930
          logger.info("Added sinks: " + sinks + " Agent: " + this.agentName);

   
931
          return true;
935
          return true;
932
        } else {
936
        } else {
933
          logger.warn("Duplicate sink list specfied for agent: " + agentName);
937
          logger.warn("Duplicate sink list specfied for agent: " + agentName);
934
          errorList.add(new FlumeConfigurationError(agentName,
938
          errorList.add(new FlumeConfigurationError(agentName,
935
              BasicConfigurationConstants.CONFIG_SINKS,
939
              BasicConfigurationConstants.CONFIG_SINKS,
[+20] [20] 75 lines
[+20] private boolean addProperty(String key, String value) {
1011
          BasicConfigurationConstants.CONFIG_SINKS_PREFIX);
1015
          BasicConfigurationConstants.CONFIG_SINKS_PREFIX);
1012

    
   
1016

   
1013
      if (cnck != null) {
1017
      if (cnck != null) {
1014
        // it is a sink
1018
        // it is a sink
1015
        String name = cnck.getComponentName().trim();
1019
        String name = cnck.getComponentName().trim();
1016
        logger.info("Processing:" + name);
1020
        logDebug("Processing:" + name);
1017
        Context sinkConf = sinkContextMap.get(name);
1021
        Context sinkConf = sinkContextMap.get(name);
1018

    
   
1022

   
1019
        if (sinkConf == null) {
1023
        if (sinkConf == null) {
1020
          logger.debug("Created context for " + name + ": "
1024
          logDebug("Created context for " + name + ": "
1021
              + cnck.getConfigKey());
1025
              + cnck.getConfigKey());
1022
          sinkConf = new Context();
1026
          sinkConf = new Context();
1023
          sinkContextMap.put(name, sinkConf);
1027
          sinkContextMap.put(name, sinkConf);
1024
        }
1028
        }
1025

    
   
1029

   
[+20] [20] 71 lines
  1. flume-ng-configuration/src/main/java/org/apache/flume/conf/FlumeConfiguration.java: Loading...