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, INFO,
WARN, WARN,
ERROR, ERROR,
FATAL; FATAL,
NONE;
} }

View File

@ -16,6 +16,15 @@
*/ */
package org.apache.nifi.logging.repository; 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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -23,16 +32,6 @@ import java.util.Map;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock; 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 class StandardLogRepository implements LogRepository {
public static final int DEFAULT_MAX_CAPACITY_PER_LEVEL = 10; 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 // at this point, the LogLevel must be NONE since we don't register observers for NONE
throw new IllegalStateException("The specified observer identifier does not exist."); return LogLevel.NONE;
} finally { } finally {
readLock.unlock(); readLock.unlock();
} }
@ -136,6 +135,8 @@ public class StandardLogRepository implements LogRepository {
final LogLevel[] allLevels = LogLevel.values(); final LogLevel[] allLevels = LogLevel.values();
for (int i = minimumLevel.ordinal(); i < allLevels.length; i++) { for (int i = minimumLevel.ordinal(); i < allLevels.length; i++) {
// 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]); Collection<LogObserver> collection = observers.get(allLevels[i]);
if (collection == null) { if (collection == null) {
collection = new ArrayList<>(); collection = new ArrayList<>();
@ -143,6 +144,7 @@ public class StandardLogRepository implements LogRepository {
} }
collection.add(observer); collection.add(observer);
} }
}
observerLookup.put(observerIdentifier, observer); observerLookup.put(observerIdentifier, observer);
} finally { } finally {
writeLock.unlock(); writeLock.unlock();

View File

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

View File

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