Java Code Examples for jdk.jfr.internal.Utils#parseTimespanWithInfinity()

The following examples show how to use jdk.jfr.internal.Utils#parseTimespanWithInfinity() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
Source File: CutoffSetting.java    From openjdk-jdk8u 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 11
Source File: ThresholdSetting.java    From openjdk-jdk8u 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 12
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
}