jdk.jfr.internal.Utils Java Examples

The following examples show how to use jdk.jfr.internal.Utils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DCmdDump.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException {
    try (PlatformRecording r = newSnapShot(recorder, recording, pathToGcRoots)) {
        r.filter(beginTime, endTime, maxSize);
        if (r.getChunks().isEmpty()) {
            throw new DCmdException("Dump failed. No data found in the specified interval.");
        }
        SafePath dumpFile = resolvePath(recording, filename);

        // Needed for JVM
        Utils.touch(dumpFile.toPath());
        r.dumpStopped(new WriteableUserPath(dumpFile.toPath()));
        reportOperationComplete("Dumped", name, dumpFile);
    } catch (IOException | InvalidPathException e) {
        throw new DCmdException("Dump failed. Could not copy recording data. %s", e.getMessage());
    }
}
 
Example #2
Source File: ValueDescriptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray) {
    Objects.requireNonNull(annotations);
    Utils.checkRegisterPermission();
    if (!allowArray) {
        if (type.isArray()) {
            throw new IllegalArgumentException("Array types are not allowed");
        }
    }
    this.name = Objects.requireNonNull(name, "Name of value descriptor can't be null");
    this.type = Objects.requireNonNull(Utils.getValidType(Objects.requireNonNull(type), Objects.requireNonNull(name)));
    this.annotationConstruct = new AnnotationConstruct(annotations);
    this.javaFieldName = name; // Needed for dynamic events
    this.isArray = type.isArray();
    // Assume we always want to store String and Thread in constant pool
    this.constantPool = type == Class.class || type == Thread.class;
}
 
Example #3
Source File: ThresholdSetting.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String combine(Set<String> values) {
    Long min = null;
    String text = null;
    for (String value : values) {
        long l = Utils.parseTimespanWithInfinity(value);
        // always accept first value
        if (min == null) {
            min = l;
            text = value;
        } else {
            if (l < min) {
                text = value;
                min = l;
            }
        }
    }
    return text == null ? "0 ns" : text;
}
 
Example #4
Source File: DCmdDump.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute JFR.dump.
 *
 * @param recordingText name or id of the recording to dump, or
 *        <code>null</code>
 *
 * @param textPath file path where recording should be written.
 *
 * @return result output
 *
 * @throws DCmdException if the dump could not be completed
 */
public String execute(String recordingText, String textPath,  Boolean pathToGcRoots) throws DCmdException {
    if (textPath == null) {
        throw new DCmdException("Failed to dump %s, missing filename.", recordingText);
    }
    Recording recording = findRecording(recordingText);
    try {
        SafePath dumpFile = resolvePath(textPath, "Failed to dump %s");
        // create file for JVM
        Utils.touch(dumpFile.toPath());
        PlatformRecording r = PrivateAccess.getInstance().getPlatformRecording(recording);
        WriteableUserPath wup = new WriteableUserPath(dumpFile.toPath());

        Map<String, String> overlay = new HashMap<>();
        Utils.updateSettingPathToGcRoots(overlay, pathToGcRoots);

        r.copyTo(wup, "Dumped by user", overlay);
        reportOperationComplete("Dumped", recording, dumpFile);
    } catch (IOException | InvalidPathException e) {
        throw new DCmdException("Failed to dump %s. Could not copy recording for dump. %s", recordingText, e.getMessage());
    }
    return getResult();
}
 
Example #5
Source File: DCmdCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void printGeneral(Recording recording) {
    print("Recording " + recording.getId() + ": name=" + recording.getName());

    Duration duration = recording.getDuration();
    if (duration != null) {
        print(" duration=");
        printTimespan(duration, "");
    }

    long maxSize = recording.getMaxSize();
    if (maxSize != 0) {
        print(" maxsize=");
        print(Utils.formatBytesCompact(maxSize));
    }
    Duration maxAge = recording.getMaxAge();
    if (maxAge != null) {
        print(" maxage=");
        printTimespan(maxAge, "");
    }

    print(" (" + recording.getState().toString().toLowerCase() + ")");
    println();
}
 
Example #6
Source File: ThresholdSetting.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String combine(Set<String> values) {
    Long min = null;
    String text = null;
    for (String value : values) {
        long l = Utils.parseTimespanWithInfinity(value);
        // always accept first value
        if (min == null) {
            min = l;
            text = value;
        } else {
            if (l < min) {
                text = value;
                min = l;
            }
        }
    }
    return text == null ? "0 ns" : text;
}
 
Example #7
Source File: DCmdCheck.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void printGeneral(Recording recording) {
    print("Recording " + recording.getId() + ": name=" + recording.getName());

    Duration duration = recording.getDuration();
    if (duration != null) {
        print(" duration=");
        printTimespan(duration, "");
    }

    long maxSize = recording.getMaxSize();
    if (maxSize != 0) {
        print(" maxsize=");
        print(Utils.formatBytesCompact(maxSize));
    }
    Duration maxAge = recording.getMaxAge();
    if (maxAge != null) {
        print(" maxage=");
        printTimespan(maxAge, "");
    }

    print(" (" + recording.getState().toString().toLowerCase() + ")");
    println();
}
 
Example #8
Source File: DCmdDump.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException {
    try (PlatformRecording r = newSnapShot(recorder, recording, pathToGcRoots)) {
        r.filter(beginTime, endTime, maxSize);
        if (r.getChunks().isEmpty()) {
            throw new DCmdException("Dump failed. No data found in the specified interval.");
        }
        SafePath dumpFile = resolvePath(recording, filename);

        // Needed for JVM
        Utils.touch(dumpFile.toPath());
        r.dumpStopped(new WriteableUserPath(dumpFile.toPath()));
        reportOperationComplete("Dumped", name, dumpFile);
    } catch (IOException | InvalidPathException e) {
        throw new DCmdException("Dump failed. Could not copy recording data. %s", e.getMessage());
    }
}
 
Example #9
Source File: ValueDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray) {
    Objects.requireNonNull(annotations);
    Utils.checkRegisterPermission();
    if (!allowArray) {
        if (type.isArray()) {
            throw new IllegalArgumentException("Array types are not allowed");
        }
    }
    this.name = Objects.requireNonNull(name, "Name of value descriptor can't be null");
    this.type = Objects.requireNonNull(Utils.getValidType(Objects.requireNonNull(type), Objects.requireNonNull(name)));
    this.annotationConstruct = new AnnotationConstruct(annotations);
    this.javaFieldName = name; // Needed for dynamic events
    this.isArray = type.isArray();
    // Assume we always want to store String and Thread in constant pool
    this.constantPool = type == Class.class || type == Thread.class;
}
 
Example #10
Source File: ValueDescriptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray) {
    Objects.requireNonNull(annotations);
    Utils.checkRegisterPermission();
    if (!allowArray) {
        if (type.isArray()) {
            throw new IllegalArgumentException("Array types are not allowed");
        }
    }
    this.name = Objects.requireNonNull(name, "Name of value descriptor can't be null");
    this.type = Objects.requireNonNull(Utils.getValidType(Objects.requireNonNull(type), Objects.requireNonNull(name)));
    this.annotationConstruct = new AnnotationConstruct(annotations);
    this.javaFieldName = name; // Needed for dynamic events
    this.isArray = type.isArray();
    // Assume we always want to store String and Thread in constant pool
    this.constantPool = type == Class.class || type == Thread.class;
}
 
Example #11
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Flight Recorder for the platform.
 *
 * @return a Flight Recorder instance, not {@code null}
 *
 * @throws IllegalStateException if Flight Recorder can't be created (for
 *         example, if the Java Virtual Machine (JVM) lacks Flight Recorder
 *         support, or if the file repository can't be created or accessed)
 *
 * @throws SecurityException if a security manager exists and the caller does
 *         not have {@code FlightRecorderPermission("accessFlightRecorder")}
 */
public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException {
    synchronized (PlatformRecorder.class) {
        Utils.checkAccessFlightRecorder();
        JVMSupport.ensureWithIllegalStateException();
        if (platformRecorder == null) {
            try {
                platformRecorder = new FlightRecorder(new PlatformRecorder());
            } catch (IllegalStateException ise) {
                throw ise;
            } catch (Exception e) {
                throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e);
            }
            // Must be in synchronized block to prevent instance leaking out
            // before initialization is done
            initialized = true;
            Logger.log(JFR, INFO, "Flight Recorder initialized");
            Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes");
            Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount());
            Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath());
            Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads());
            Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth());
            Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize());
            Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString());
            PlatformRecorder.notifyRecorderInitialized(platformRecorder);
        }
    }
    return platformRecorder;
}
 
Example #12
Source File: CutoffSetting.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static long parseValueSafe(String value) {
    if (value == null) {
        return 0L;
    }
    try {
        return isInfinity(value) ? Long.MAX_VALUE : Utils.parseTimespan(value);
    } catch (NumberFormatException nfe) {
        return 0L;
    }
}
 
Example #13
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a callback hook for a periodic event.
 *
 * @param hook the hook to remove, not {@code null}
 * @return {@code true} if hook is removed, {@code false} otherwise
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static boolean removePeriodicEvent(Runnable hook) throws SecurityException {
    Objects.requireNonNull(hook);
    Utils.checkRegisterPermission();
    if (JVMSupport.isNotAvailable()) {
        return false;
    }
    return RequestEngine.removeHook(hook);
}
 
Example #14
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Flight Recorder for the platform.
 *
 * @return a Flight Recorder instance, not {@code null}
 *
 * @throws IllegalStateException if the platform Flight Recorder couldn't be
 *         created (for example, if the file repository can't be created or
 *         accessed)
 *
 * @throws SecurityException if a security manager exists and the caller does
 *         not have {@code FlightRecorderPermission("accessFlightRecorder")}
 */
public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException {
    synchronized (PlatformRecorder.class) {
        Utils.checkAccessFlightRecorder();
        JVMSupport.ensureWithIllegalStateException();
        if (platformRecorder == null) {
            try {
                platformRecorder = new FlightRecorder(new PlatformRecorder());
            } catch (IllegalStateException ise) {
                throw ise;
            } catch (Exception e) {
                throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e);
            }
            // Must be in synchronized block to prevent instance leaking out
            // before initialization is done
            initialized = true;
            Logger.log(JFR, INFO, "Flight Recorder initialized");
            Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes");
            Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount());
            Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath());
            Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads());
            Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth());
            Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize());
            Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString());
            PlatformRecorder.notifyRecorderInitialized(platformRecorder);
        }
    }
    return platformRecorder;
}
 
Example #15
Source File: ThresholdSetting.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String combine(Set<String> values) {
    long min = Long.MAX_VALUE;
    String text = "0 ns";
    for (String value : values) {
        long l = Utils.parseTimespan(value);
        if (l < min) {
            text = value;
            min = l;
        }
    }
    return text;
}
 
Example #16
Source File: PeriodSetting.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String combine(Set<String> values) {
    long min = Long.MAX_VALUE;
    boolean beginChunk = false;
    boolean endChunk = false;
    String text = EVERY_CHUNK;
    for (String value : values) {
        switch (value) {
        case EVERY_CHUNK:
            beginChunk = true;
            endChunk = true;
            break;
        case BEGIN_CHUNK:
            beginChunk = true;
            break;
        case END_CHUNK:
            endChunk = true;
            break;
        default:
            long l = Utils.parseTimespan(value);
            if (l < min) {
                text = value;
                min = l;
            }
        }
    }
    if (min != Long.MAX_VALUE) {
        return text;
    }
    if (beginChunk && !endChunk) {
        return BEGIN_CHUNK;
    }
    if (!beginChunk && endChunk) {
        return END_CHUNK;
    }
    return text;
}
 
Example #17
Source File: ManagementSupport.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static List<EventType> getEventTypes() {
    // would normally be checked when a Flight Recorder instance is created
    Utils.checkAccessFlightRecorder();
    if (JVMSupport.isNotAvailable()) {
        return new ArrayList<>();
    }
    JDKEvents.initialize(); // make sure JDK events are available
    return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes());
}
 
Example #18
Source File: CutoffSetting.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static long parseValueSafe(String value) {
    if (value == null) {
        return 0L;
    }
    try {
        return Utils.parseTimespanWithInfinity(value);
    } catch (NumberFormatException nfe) {
        return 0L;
    }
}
 
Example #19
Source File: FlightRecorder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the Flight Recorder for the platform.
 *
 * @return a Flight Recorder instance, not {@code null}
 *
 * @throws IllegalStateException if Flight Recorder can't be created (for
 *         example, if the Java Virtual Machine (JVM) lacks Flight Recorder
 *         support, or if the file repository can't be created or accessed)
 *
 * @throws SecurityException if a security manager exists and the caller does
 *         not have {@code FlightRecorderPermission("accessFlightRecorder")}
 */
public static FlightRecorder getFlightRecorder() throws IllegalStateException, SecurityException {
    synchronized (PlatformRecorder.class) {
        Utils.checkAccessFlightRecorder();
        JVMSupport.ensureWithIllegalStateException();
        if (platformRecorder == null) {
            try {
                platformRecorder = new FlightRecorder(new PlatformRecorder());
            } catch (IllegalStateException ise) {
                throw ise;
            } catch (Exception e) {
                throw new IllegalStateException("Can't create Flight Recorder. " + e.getMessage(), e);
            }
            // Must be in synchronized block to prevent instance leaking out
            // before initialization is done
            initialized = true;
            Logger.log(JFR, INFO, "Flight Recorder initialized");
            Logger.log(JFR, DEBUG, "maxchunksize: " + Options.getMaxChunkSize()+ " bytes");
            Logger.log(JFR, DEBUG, "memorysize: " + Options.getMemorySize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffersize: " + Options.getGlobalBufferSize()+ " bytes");
            Logger.log(JFR, DEBUG, "globalbuffercount: " + Options.getGlobalBufferCount());
            Logger.log(JFR, DEBUG, "dumppath: " + Options.getDumpPath());
            Logger.log(JFR, DEBUG, "samplethreads: " + Options.getSampleThreads());
            Logger.log(JFR, DEBUG, "stackdepth: " + Options.getStackDepth());
            Logger.log(JFR, DEBUG, "threadbuffersize: " + Options.getThreadBufferSize());
            Logger.log(JFR, LogLevel.INFO, "Created repository " + Repository.getRepository().getRepositoryPath().toString());
            PlatformRecorder.notifyRecorderInitialized(platformRecorder);
        }
    }
    return platformRecorder;
}
 
Example #20
Source File: FlightRecorder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a hook for a periodic event.
 *
 * @param hook the hook to remove, not {@code null}
 * @return {@code true} if hook is removed, {@code false} otherwise
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static boolean removePeriodicEvent(Runnable hook) throws SecurityException {
    Objects.requireNonNull(hook);
    Utils.checkRegisterPermission();
    if (JVMSupport.isNotAvailable()) {
        return false;
    }
    return RequestEngine.removeHook(hook);
}
 
Example #21
Source File: ManagementSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static List<EventType> getEventTypes() {
    // would normally be checked when a Flight Recorder instance is created
    Utils.checkAccessFlightRecorder();
    if (JVMSupport.isNotAvailable()) {
        return new ArrayList<>();
    }
    JDKEvents.initialize(); // make sure JDK events are available
    return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes());
}
 
Example #22
Source File: ManagementSupport.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static List<EventType> getEventTypes() {
    // would normally be checked when a Flight Recorder instance is created
    Utils.checkAccessFlightRecorder();
    if (JVMSupport.isNotAvailable()) {
        return new ArrayList<>();
    }
    JDKEvents.initialize(); // make sure JDK events are available
    return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes());
}
 
Example #23
Source File: CutoffSetting.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String combine(Set<String> values) {
    long max = 0;
    String text = "0 ns";
    for (String value : values) {
        long l =  Utils.parseTimespanWithInfinity(value);
        if (l > max) {
            text = value;
            max = l;
        }
    }
    return text;
}
 
Example #24
Source File: CutoffSetting.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static long parseValueSafe(String value) {
    if (value == null) {
        return 0L;
    }
    try {
        return Utils.parseTimespanWithInfinity(value);
    } catch (NumberFormatException nfe) {
        return 0L;
    }
}
 
Example #25
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a hook for a periodic event.
 *
 * @param hook the hook to remove, not {@code null}
 * @return {@code true} if hook is removed, {@code false} otherwise
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static boolean removePeriodicEvent(Runnable hook) throws SecurityException {
    Objects.requireNonNull(hook);
    Utils.checkRegisterPermission();
    if (JVMSupport.isNotAvailable()) {
        return false;
    }
    return RequestEngine.removeHook(hook);
}
 
Example #26
Source File: CutoffSetting.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String combine(Set<String> values) {
    long max = 0;
    String text = "0 ns";
    for (String value : values) {
        long l =  Utils.parseTimespanWithInfinity(value);
        if (l > max) {
            text = value;
            max = l;
        }
    }
    return text;
}
 
Example #27
Source File: CutoffSetting.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setValue(String value) {
    long l =  Utils.parseTimespanWithInfinity(value);
    this.value = value;
    eventType.setCutoff(l);
}
 
Example #28
Source File: PeriodSetting.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String combine(Set<String> values) {

    boolean beginChunk = false;
    boolean endChunk = false;
    Long min = null;
    String text = null;
    for (String value : values) {
        switch (value) {
        case EVERY_CHUNK:
            beginChunk = true;
            endChunk = true;
            break;
        case BEGIN_CHUNK:
            beginChunk = true;
            break;
        case END_CHUNK:
            endChunk = true;
            break;
        default:
            long l = Utils.parseTimespanWithInfinity(value);
            // Always accept first specified value
            if (min == null) {
                text = value;
                min = l;
            } else {
                if (l < min) {
                    text = value;
                    min = l;
                }
            }
        }
    }
    // A specified interval trumps *_CHUNK
    if (min != null) {
        return text;
    }
    if (beginChunk && !endChunk) {
        return BEGIN_CHUNK;
    }
    if (!beginChunk && endChunk) {
        return END_CHUNK;
    }
    return EVERY_CHUNK; // also default
}
 
Example #29
Source File: ThresholdSetting.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setValue(String value) {
    long l = Utils.parseTimespanWithInfinity(value);
    this.value = value;
    eventType.setThreshold(l);
}
 
Example #30
Source File: PeriodSetting.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String combine(Set<String> values) {

    boolean beginChunk = false;
    boolean endChunk = false;
    Long min = null;
    String text = null;
    for (String value : values) {
        switch (value) {
        case EVERY_CHUNK:
            beginChunk = true;
            endChunk = true;
            break;
        case BEGIN_CHUNK:
            beginChunk = true;
            break;
        case END_CHUNK:
            endChunk = true;
            break;
        default:
            long l = Utils.parseTimespanWithInfinity(value);
            // Always accept first specified value
            if (min == null) {
                text = value;
                min = l;
            } else {
                if (l < min) {
                    text = value;
                    min = l;
                }
            }
        }
    }
    // A specified interval trumps *_CHUNK
    if (min != null) {
        return text;
    }
    if (beginChunk && !endChunk) {
        return BEGIN_CHUNK;
    }
    if (!beginChunk && endChunk) {
        return END_CHUNK;
    }
    return EVERY_CHUNK; // also default
}