NIFI-79 - Introduces the ability to set Bulletin Level to NONE

This commit is contained in:
Andre F de Miranda 2017-03-25 09:47:42 +11:00 committed by Matt Gilman
parent 457df93dd6
commit a7bf683a0d
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
4 changed files with 25 additions and 18 deletions

View File

@ -23,5 +23,6 @@ public enum LogLevel {
INFO,
WARN,
ERROR,
FATAL;
FATAL,
NONE;
}

View File

@ -16,6 +16,15 @@
*/
package org.apache.nifi.logging.repository;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.logging.LogLevel;
import org.apache.nifi.logging.LogMessage;
import org.apache.nifi.logging.LogObserver;
import org.apache.nifi.logging.LogRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -23,16 +32,6 @@ import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.logging.LogLevel;
import org.apache.nifi.logging.LogMessage;
import org.apache.nifi.logging.LogObserver;
import org.apache.nifi.logging.LogRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
public class StandardLogRepository implements LogRepository {
public static final int DEFAULT_MAX_CAPACITY_PER_LEVEL = 10;
@ -118,8 +117,8 @@ public class StandardLogRepository implements LogRepository {
}
}
// at this point, the observer should have been found
throw new IllegalStateException("The specified observer identifier does not exist.");
// at this point, the LogLevel must be NONE since we don't register observers for NONE
return LogLevel.NONE;
} finally {
readLock.unlock();
}
@ -136,12 +135,15 @@ public class StandardLogRepository implements LogRepository {
final LogLevel[] allLevels = LogLevel.values();
for (int i = minimumLevel.ordinal(); i < allLevels.length; i++) {
Collection<LogObserver> collection = observers.get(allLevels[i]);
if (collection == null) {
collection = new ArrayList<>();
observers.put(allLevels[i], collection);
// no need to register an observer for NONE since that level will never be logged to by a component
if (i != LogLevel.NONE.ordinal()) {
Collection<LogObserver> collection = observers.get(allLevels[i]);
if (collection == null) {
collection = new ArrayList<>();
observers.put(allLevels[i], collection);
}
collection.add(observer);
}
collection.add(observer);
}
observerLookup.put(observerIdentifier, observer);
} finally {

View File

@ -345,6 +345,7 @@
<xs:enumeration value="WARN"></xs:enumeration>
<xs:enumeration value="ERROR"></xs:enumeration>
<xs:enumeration value="FATAL"></xs:enumeration>
<xs:enumeration value="NONE"></xs:enumeration>
</xs:restriction>
</xs:simpleType>

View File

@ -590,6 +590,9 @@
}, {
text: 'ERROR',
value: 'ERROR'
}, {
text: 'NONE',
value: 'NONE'
}]
});