Java Code Examples for org.elasticsearch.common.unit.TimeValue#timeValueMinutes()

The following examples show how to use org.elasticsearch.common.unit.TimeValue#timeValueMinutes() . 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: Util.java    From flume-elasticsearch-sink with Apache License 2.0 6 votes vote down vote up
/**
 * Returns TimeValue based on the given interval
 * Interval can be in minutes, seconds, mili seconds
 */
public static TimeValue getTimeValue(String interval, String defaultValue) {
    TimeValue timeValue = null;
    String timeInterval = interval != null ? interval : defaultValue;
    logger.trace("Time interval is [{}] ", timeInterval);
    if (timeInterval != null) {
        Integer time = Integer.valueOf(timeInterval.substring(0, timeInterval.length() - 1));
        String unit = timeInterval.substring(timeInterval.length() - 1);
        UnitEnum unitEnum = UnitEnum.fromString(unit);
        switch (unitEnum) {
            case MINUTE:
                timeValue = TimeValue.timeValueMinutes(time);
                break;
            case SECOND:
                timeValue = TimeValue.timeValueSeconds(time);
                break;
            case MILI_SECOND:
                timeValue = TimeValue.timeValueMillis(time);
                break;
            default:
                logger.error("Unit is incorrect, please check the Time Value unit: " + unit);
        }
    }
    return timeValue;
}
 
Example 2
Source File: CrateTableSettings.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public TimeValue defaultValue() {
    return TimeValue.timeValueMinutes(30);
}
 
Example 3
Source File: CrateTableSettings.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public TimeValue defaultValue() {
    return TimeValue.timeValueMinutes(1);
}