當前位置: 首頁>>代碼示例>>Java>>正文


Java TimeValue.getMillis方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.unit.TimeValue.getMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java TimeValue.getMillis方法的具體用法?Java TimeValue.getMillis怎麽用?Java TimeValue.getMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.unit.TimeValue的用法示例。


在下文中一共展示了TimeValue.getMillis方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createInternal

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
@Override
protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException {
    DocValueFormat formatter;
    if (format != null) {
        formatter = new DocValueFormat.Decimal(format);
    } else {
        formatter = DocValueFormat.RAW;
    }
    Long xAxisUnits = null;
    if (units != null) {
        DateTimeUnit dateTimeUnit = DateHistogramAggregationBuilder.DATE_FIELD_UNITS.get(units);
        if (dateTimeUnit != null) {
            xAxisUnits = dateTimeUnit.field(DateTimeZone.UTC).getDurationField().getUnitMillis();
        } else {
            TimeValue timeValue = TimeValue.parseTimeValue(units, null, getClass().getSimpleName() + ".unit");
            if (timeValue != null) {
                xAxisUnits = timeValue.getMillis();
            }
        }
    }
    return new DerivativePipelineAggregator(name, bucketsPaths, formatter, gapPolicy, xAxisUnits, metaData);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:DerivativePipelineAggregationBuilder.java

示例2: parseDateVariable

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
private AbstractDistanceScoreFunction parseDateVariable(String fieldName, XContentParser parser, QueryParseContext parseContext,
        DateFieldMapper.DateFieldType dateFieldType, MultiValueMode mode) throws IOException {
    XContentParser.Token token;
    String parameterName = null;
    String scaleString = null;
    String originString = null;
    String offsetString = "0d";
    double decay = 0.5;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            parameterName = parser.currentName();
        } else if (parameterName.equals(DecayFunctionBuilder.SCALE)) {
            scaleString = parser.text();
        } else if (parameterName.equals(DecayFunctionBuilder.ORIGIN)) {
            originString = parser.text();
        } else if (parameterName.equals(DecayFunctionBuilder.DECAY)) {
            decay = parser.doubleValue();
        } else if (parameterName.equals(DecayFunctionBuilder.OFFSET)) {
            offsetString = parser.text();
        } else {
            throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName);
        }
    }
    long origin = SearchContext.current().nowInMillis();
    if (originString != null) {
        origin = dateFieldType.parseToMilliseconds(originString, false, null, null);
    }

    if (scaleString == null) {
        throw new ElasticsearchParseException("[{}] must be set for date fields.", DecayFunctionBuilder.SCALE);
    }
    TimeValue val = TimeValue.parseTimeValue(scaleString, TimeValue.timeValueHours(24), getClass().getSimpleName() + ".scale");
    double scale = val.getMillis();
    val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24), getClass().getSimpleName() + ".offset");
    double offset = val.getMillis();
    IndexNumericFieldData numericFieldData = parseContext.getForField(dateFieldType);
    return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:39,代碼來源:DecayFunctionParser.java

示例3: onRefreshSettings

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
@Override
public void onRefreshSettings(Settings settings) {
    TimeValue newUpdateFrequency = settings.getAsTime(
            INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL,
            InternalClusterInfoService.this.settings.getAsTime(
                    INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL));
    // ClusterInfoService is only enabled if the DiskThresholdDecider is enabled
    Boolean newEnabled = settings.getAsBoolean(
            DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED,
            DiskThresholdDecider.DEFAULT_THRESHOLD_ENABLED);

    if (newUpdateFrequency != null && !updateFrequency.equals(newUpdateFrequency)) {
        if (newUpdateFrequency.getMillis() < TimeValue.timeValueSeconds(10).getMillis()) {
            logger.warn("[{}] set too low [{}] (< 10s)", INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, newUpdateFrequency);
            throw new IllegalStateException("Unable to set " + INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL + " less than 10 seconds");
        } else {
            logger.info("updating [{}] from [{}] to [{}]", INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, updateFrequency, newUpdateFrequency);
            InternalClusterInfoService.this.updateFrequency = newUpdateFrequency;
        }
    }

    TimeValue newFetchTimeout = settings.getAsTime(INTERNAL_CLUSTER_INFO_TIMEOUT,
            InternalClusterInfoService.this.settings.getAsTime(INTERNAL_CLUSTER_INFO_TIMEOUT, DEFAULT_TIMEOUT)
    );
    if (newFetchTimeout != null && !fetchTimeout.equals(newFetchTimeout)) {
        logger.info("updating fetch timeout [{}] from [{}] to [{}]", INTERNAL_CLUSTER_INFO_TIMEOUT, fetchTimeout, newFetchTimeout);
        InternalClusterInfoService.this.fetchTimeout = newFetchTimeout;
    }


    // We don't log about enabling it here, because the DiskThresholdDecider will already be logging about enable/disable
    if (newEnabled != InternalClusterInfoService.this.enabled) {
        InternalClusterInfoService.this.enabled = newEnabled;
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:36,代碼來源:InternalClusterInfoService.java

示例4: parseDateVariable

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
private AbstractDistanceScoreFunction parseDateVariable(XContentParser parser, QueryShardContext context,
        MappedFieldType dateFieldType, MultiValueMode mode) throws IOException {
    XContentParser.Token token;
    String parameterName = null;
    String scaleString = null;
    String originString = null;
    String offsetString = "0d";
    double decay = 0.5;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            parameterName = parser.currentName();
        } else if (DecayFunctionBuilder.SCALE.equals(parameterName)) {
            scaleString = parser.text();
        } else if (DecayFunctionBuilder.ORIGIN.equals(parameterName)) {
            originString = parser.text();
        } else if (DecayFunctionBuilder.DECAY.equals(parameterName)) {
            decay = parser.doubleValue();
        } else if (DecayFunctionBuilder.OFFSET.equals(parameterName)) {
            offsetString = parser.text();
        } else {
            throw new ElasticsearchParseException("parameter [{}] not supported!", parameterName);
        }
    }
    long origin;
    if (originString == null) {
        origin = context.nowInMillis();
    } else {
        origin = ((DateFieldMapper.DateFieldType) dateFieldType).parseToMilliseconds(originString, false, null, null, context);
    }

    if (scaleString == null) {
        throw new ElasticsearchParseException("[{}] must be set for date fields.", DecayFunctionBuilder.SCALE);
    }
    TimeValue val = TimeValue.parseTimeValue(scaleString, TimeValue.timeValueHours(24),
            DecayFunctionParser.class.getSimpleName() + ".scale");
    double scale = val.getMillis();
    val = TimeValue.parseTimeValue(offsetString, TimeValue.timeValueHours(24), DecayFunctionParser.class.getSimpleName() + ".offset");
    double offset = val.getMillis();
    IndexNumericFieldData numericFieldData = context.getForField(dateFieldType);
    return new NumericFieldDataScoreFunction(origin, scale, decay, offset, getDecayFunction(), numericFieldData, mode);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:42,代碼來源:DecayFunctionBuilder.java

示例5: setGCDeletes

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
private void setGCDeletes(TimeValue timeValue) {
    this.gcDeletesInMillis = timeValue.getMillis();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:IndexSettings.java

示例6: warnAboutSlowTaskIfNeeded

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
private void warnAboutSlowTaskIfNeeded(TimeValue executionTime, String source) {
    if (executionTime.getMillis() > slowTaskLoggingThreshold.getMillis()) {
        logger.warn("cluster state update task [{}] took [{}] above the warn threshold of {}", source, executionTime,
                slowTaskLoggingThreshold);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:7,代碼來源:ClusterService.java

示例7: client

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
public synchronized Compute client() {
    if (refreshInterval != null && refreshInterval.millis() != 0) {
        if (client != null &&
            (refreshInterval.millis() < 0 || (System.currentTimeMillis() - lastRefresh) < refreshInterval.millis())) {
            if (logger.isTraceEnabled()) logger.trace("using cache to retrieve client");
            return client;
        }
        lastRefresh = System.currentTimeMillis();
    }

    try {
        gceJsonFactory = new JacksonFactory();

        logger.info("starting GCE discovery service");
        // Forcing Google Token API URL as set in GCE SDK to
        //      http://metadata/computeMetadata/v1/instance/service-accounts/default/token
        // See https://developers.google.com/compute/docs/metadata#metadataserver
        String tokenServerEncodedUrl = GceMetadataService.GCE_HOST.get(settings) +
            "/computeMetadata/v1/instance/service-accounts/default/token";
        ComputeCredential credential = new ComputeCredential.Builder(getGceHttpTransport(), gceJsonFactory)
            .setTokenServerEncodedUrl(tokenServerEncodedUrl)
            .build();

        // hack around code messiness in GCE code
        // TODO: get this fixed
        Access.doPrivilegedIOException(credential::refreshToken);

        logger.debug("token [{}] will expire in [{}] s", credential.getAccessToken(), credential.getExpiresInSeconds());
        if (credential.getExpiresInSeconds() != null) {
            refreshInterval = TimeValue.timeValueSeconds(credential.getExpiresInSeconds() - 1);
        }


        Compute.Builder builder = new Compute.Builder(getGceHttpTransport(), gceJsonFactory, null).setApplicationName(VERSION)
            .setRootUrl(GCE_ROOT_URL.get(settings));

        if (RETRY_SETTING.exists(settings)) {
            TimeValue maxWait = MAX_WAIT_SETTING.get(settings);
            RetryHttpInitializerWrapper retryHttpInitializerWrapper;

            if (maxWait.getMillis() > 0) {
                retryHttpInitializerWrapper = new RetryHttpInitializerWrapper(credential, maxWait);
            } else {
                retryHttpInitializerWrapper = new RetryHttpInitializerWrapper(credential);
            }
            builder.setHttpRequestInitializer(retryHttpInitializerWrapper);

        } else {
            builder.setHttpRequestInitializer(credential);
        }

        this.client = builder.build();
    } catch (Exception e) {
        logger.warn("unable to start GCE discovery service", e);
        throw new IllegalArgumentException("unable to start GCE discovery service", e);
    }

    return this.client;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:60,代碼來源:GceInstancesServiceImpl.java

示例8: validate

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
private TimeValue validate(TimeValue value) {
    if (value.getMillis() < setting.minValue().getMillis() || value.getMillis() > setting.maxValue().getMillis()) {
        throw invalidException();
    }
    return value;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:7,代碼來源:SettingsAppliers.java

示例9: parse

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
@Override
public PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, SearchContext context) throws IOException {
    XContentParser.Token token;
    String currentFieldName = null;
    String[] bucketsPaths = null;
    String format = null;
    String units = null;
    GapPolicy gapPolicy = GapPolicy.SKIP;

    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token == XContentParser.Token.VALUE_STRING) {
            if (context.parseFieldMatcher().match(currentFieldName, FORMAT)) {
                format = parser.text();
            } else if (context.parseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
                bucketsPaths = new String[] { parser.text() };
            } else if (context.parseFieldMatcher().match(currentFieldName, GAP_POLICY)) {
                gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation());
            } else if (context.parseFieldMatcher().match(currentFieldName, UNIT)) {
                units = parser.text();
            } else {
                throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: ["
                        + currentFieldName + "].", parser.getTokenLocation());
            }
        } else if (token == XContentParser.Token.START_ARRAY) {
            if (context.parseFieldMatcher().match(currentFieldName, BUCKETS_PATH)) {
                List<String> paths = new ArrayList<>();
                while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                    String path = parser.text();
                    paths.add(path);
                }
                bucketsPaths = paths.toArray(new String[paths.size()]);
            } else {
                throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: ["
                        + currentFieldName + "].", parser.getTokenLocation());
            }
        } else {
            throw new SearchParseException(context, "Unexpected token " + token + " in [" + pipelineAggregatorName + "].",
                    parser.getTokenLocation());
        }
    }

    if (bucketsPaths == null) {
        throw new SearchParseException(context, "Missing required field [" + BUCKETS_PATH.getPreferredName()
                + "] for derivative aggregation [" + pipelineAggregatorName + "]", parser.getTokenLocation());
    }

    ValueFormatter formatter = null;
    if (format != null) {
        formatter = ValueFormat.Patternable.Number.format(format).formatter();
    } else {
        formatter = ValueFormatter.RAW;
    }

    Long xAxisUnits = null;
    if (units != null) {
        DateTimeUnit dateTimeUnit = DateHistogramParser.DATE_FIELD_UNITS.get(units);
        if (dateTimeUnit != null) {
            xAxisUnits = dateTimeUnit.field().getDurationField().getUnitMillis();
        } else {
            TimeValue timeValue = TimeValue.parseTimeValue(units, null, getClass().getSimpleName() + ".unit");
            if (timeValue != null) {
                xAxisUnits = timeValue.getMillis();
            }
        }
    }

    return new DerivativePipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, formatter, gapPolicy, xAxisUnits);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:71,代碼來源:DerivativeParser.java

示例10: warnAboutSlowTaskIfNeeded

import org.elasticsearch.common.unit.TimeValue; //導入方法依賴的package包/類
private void warnAboutSlowTaskIfNeeded(TimeValue executionTime, String source) {
    if (executionTime.getMillis() > slowTaskLoggingThreshold.getMillis()) {
        logger.warn("cluster state update task [{}] took {} above the warn threshold of {}", source, executionTime, slowTaskLoggingThreshold);
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:6,代碼來源:InternalClusterService.java


注:本文中的org.elasticsearch.common.unit.TimeValue.getMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。