org.elasticsearch.common.Nullable Java Examples

The following examples show how to use org.elasticsearch.common.Nullable. 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: BulkProcessor.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
BulkProcessor(Client client, BackoffPolicy backoffPolicy, Listener listener, @Nullable String name, int concurrentRequests, int bulkActions, ByteSizeValue bulkSize, @Nullable TimeValue flushInterval) {
    this.bulkActions = bulkActions;
    this.bulkSize = bulkSize.bytes();

    this.bulkRequest = new BulkRequest();
    this.bulkRequestHandler = (concurrentRequests == 0) ? BulkRequestHandler.syncHandler(client, backoffPolicy, listener) : BulkRequestHandler.asyncHandler(client, backoffPolicy, listener, concurrentRequests);

    if (flushInterval != null) {
        this.scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, EsExecutors.daemonThreadFactory(client.settings(), (name != null ? "[" + name + "]" : "") + "bulk_processor"));
        this.scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
        this.scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
        this.scheduledFuture = this.scheduler.scheduleWithFixedDelay(new Flush(), flushInterval.millis(), flushInterval.millis(), TimeUnit.MILLISECONDS);
    } else {
        this.scheduler = null;
        this.scheduledFuture = null;
    }
}
 
Example #2
Source File: BlobRecoverySource.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public BlobRecoverySource(Settings settings, TransportService transportService, IndicesService indicesService,
                          RecoverySettings recoverySettings, ClusterService clusterService,
                          BlobTransferTarget blobTransferTarget, BlobIndices blobIndices) {
    super(settings);
    this.transportService = transportService;
    this.indicesService = indicesService;
    this.clusterService = clusterService;
    this.blobTransferTarget = blobTransferTarget;
    this.blobIndices = blobIndices;
    this.indicesService.indicesLifecycle().addListener(new IndicesLifecycle.Listener() {
        @Override
        public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard,
                                           Settings indexSettings) {
            if (indexShard != null) {
                ongoingRecoveries.cancel(indexShard, "shard is closed");
            }
        }
    });

    this.recoverySettings = recoverySettings;

}
 
Example #3
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats indices,
                 @Nullable OsStats os, @Nullable ProcessStats process, @Nullable JvmStats jvm, @Nullable ThreadPoolStats threadPool,
                 @Nullable FsInfo fs, @Nullable TransportStats transport, @Nullable HttpStats http,
                 @Nullable AllCircuitBreakerStats breaker,
                 @Nullable ScriptStats scriptStats) {
    super(node);
    this.timestamp = timestamp;
    this.indices = indices;
    this.os = os;
    this.process = process;
    this.jvm = jvm;
    this.threadPool = threadPool;
    this.fs = fs;
    this.transport = transport;
    this.http = http;
    this.breaker = breaker;
    this.scriptStats = scriptStats;
}
 
Example #4
Source File: IndexQueryParserService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public IndexQueryParserService(Index index, IndexSettingsService indexSettingsService,
                               IndicesQueriesRegistry indicesQueriesRegistry,
                               ScriptService scriptService, AnalysisService analysisService,
                               MapperService mapperService, IndexCache indexCache, IndexFieldDataService fieldDataService,
                               BitsetFilterCache bitsetFilterCache,
                               @Nullable SimilarityService similarityService) {
    super(index, indexSettingsService.getSettings());
    this.indexSettingsService = indexSettingsService;
    this.scriptService = scriptService;
    this.analysisService = analysisService;
    this.mapperService = mapperService;
    this.similarityService = similarityService;
    this.indexCache = indexCache;
    this.fieldDataService = fieldDataService;
    this.bitsetFilterCache = bitsetFilterCache;

    Settings indexSettings = indexSettingsService.getSettings();
    this.defaultField = indexSettings.get(DEFAULT_FIELD, AllFieldMapper.NAME);
    this.queryStringLenient = indexSettings.getAsBoolean(QUERY_STRING_LENIENT, false);
    this.parseFieldMatcher = new ParseFieldMatcher(indexSettings);
    this.defaultAllowUnmappedFields = indexSettings.getAsBoolean(ALLOW_UNMAPPED, true);
    this.indicesQueriesRegistry = indicesQueriesRegistry;
}
 
Example #5
Source File: ShardUpsertRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public ShardUpsertRequest(ShardId shardId,
                          @Nullable String[] updateColumns,
                          @Nullable Reference[] insertColumns,
                          @Nullable String routing,
                          UUID jobId) {
    super(shardId, routing, jobId);
    assert updateColumns != null || insertColumns != null
            : "Missing updateAssignments, whether for update nor for insert";
    this.updateColumns = updateColumns;
    this.insertColumns = insertColumns;
    if (insertColumns != null) {
        insertValuesStreamer = new Streamer[insertColumns.length];
        for (int i = 0; i < insertColumns.length; i++) {
            insertValuesStreamer[i] = insertColumns[i].valueType().streamer();
        }
    }
}
 
Example #6
Source File: DateFieldMapper.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public long parseToMilliseconds(Object value, boolean inclusive, @Nullable DateTimeZone zone, @Nullable DateMathParser forcedDateParser) {
    DateMathParser dateParser = dateMathParser();
    if (forcedDateParser != null) {
        dateParser = forcedDateParser;
    }
    String strValue;
    if (value instanceof BytesRef) {
        strValue = ((BytesRef) value).utf8ToString();
    } else {
        strValue = value.toString();
    }
    return dateParser.parse(strValue, now(), inclusive, zone);
}
 
Example #7
Source File: ShardUpsertRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Builder(TimeValue timeout,
               boolean overwriteDuplicates,
               boolean continueOnError,
               @Nullable String[] assignmentsColumns,
               @Nullable Reference[] missingAssignmentsColumns,
               UUID jobId) {
    this(timeout, overwriteDuplicates, continueOnError, assignmentsColumns, missingAssignmentsColumns, jobId, true);
}
 
Example #8
Source File: MetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Nullable
private static ImmutableOpenMap<String, IndexTemplateMetaData> updateTemplates(
        ESLogger logger, ImmutableOpenMap<String, IndexTemplateMetaData> templates) {

    ImmutableOpenMap.Builder<String, IndexTemplateMetaData> builder = null;
    for (ObjectObjectCursor<String, IndexTemplateMetaData> cursor : templates) {
        IndexTemplateMetaData templateMetaData = cursor.value;
        Settings currentSettings = templateMetaData.getSettings();
        Settings newSettings = addDefaultUnitsIfNeeded(
                MetaDataIndexUpgradeService.INDEX_TIME_SETTINGS,
                MetaDataIndexUpgradeService.INDEX_BYTES_SIZE_SETTINGS,
                logger,
                currentSettings);


        if (newSettings != currentSettings) {
            if (builder == null) {
                builder = ImmutableOpenMap.builder();
                builder.putAll(templates);
            }
            builder.put(cursor.key, new IndexTemplateMetaData(
                    templateMetaData.name(),
                    templateMetaData.order(),
                    templateMetaData.template(),
                    newSettings,
                    templateMetaData.mappings(),
                    templateMetaData.aliases(),
                    templateMetaData.customs(),
                    templateMetaData.templateOwnerTenantId()
            ));
        }
    }
    if (builder == null) {
        return null;
    }
    return builder.build();
}
 
Example #9
Source File: InternalClusterService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void onAllNodesAcked(@Nullable Throwable t) {
    try {
        listener.onAllNodesAcked(t);
    } catch (Exception e) {
        logger.error("exception thrown by listener while notifying on all nodes acked [{}]", e, t);
    }
}
 
Example #10
Source File: GeohashCellQuery.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new geohash filter for a given set of geohashes. In general this method
 * returns a boolean filter combining the geohashes OR-wise.
 *
 * @param context     Context of the filter
 * @param fieldType field mapper for geopoints
 * @param geohash     mandatory geohash
 * @param geohashes   optional array of additional geohashes
 * @return a new GeoBoundinboxfilter
 */
public static Query create(QueryParseContext context, BaseGeoPointFieldMapper.GeoPointFieldType fieldType, String geohash,
                           @Nullable List<CharSequence> geohashes) {
    MappedFieldType geoHashMapper = fieldType.geoHashFieldType();
    if (geoHashMapper == null) {
        throw new IllegalArgumentException("geohash filter needs geohash_prefix to be enabled");
    }

    if (geohashes == null || geohashes.size() == 0) {
        return geoHashMapper.termQuery(geohash, context);
    } else {
        geohashes.add(geohash);
        return geoHashMapper.termsQuery(geohashes, context);
    }
}
 
Example #11
Source File: FsInfo.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Path(String path, @Nullable String mount, long total, long free, long available) {
    this.path = path;
    this.mount = mount;
    this.total = total;
    this.free = free;
    this.available = available;
}
 
Example #12
Source File: ClusterStatsNodeResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ClusterStatsNodeResponse(DiscoveryNode node, @Nullable ClusterHealthStatus clusterStatus, NodeInfo nodeInfo, NodeStats nodeStats, ShardStats[] shardsStats) {
    super(node);
    this.nodeInfo = nodeInfo;
    this.nodeStats = nodeStats;
    this.shardsStats = shardsStats;
    this.clusterStatus = clusterStatus;
}
 
Example #13
Source File: AnalysisService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public AnalysisService(Index index, IndexSettingsService indexSettingsService, @Nullable IndicesAnalysisService indicesAnalysisService,
                       @Nullable Map<String, AnalyzerProviderFactory> analyzerFactoryFactories,
                       @Nullable Map<String, TokenizerFactoryFactory> tokenizerFactoryFactories,
                       @Nullable Map<String, CharFilterFactoryFactory> charFilterFactoryFactories,
                       @Nullable Map<String, TokenFilterFactoryFactory> tokenFilterFactoryFactories) {
    this(index, indexSettingsService.getSettings(), indicesAnalysisService, analyzerFactoryFactories, tokenizerFactoryFactories,
            charFilterFactoryFactories, tokenFilterFactoryFactories);

}
 
Example #14
Source File: IndexMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Sometimes, the default mapping exists and an actual mapping is not created yet (introduced),
 * in this case, we want to return the default mapping in case it has some default mapping definitions.
 * <p>
 * Note, once the mapping type is introduced, the default mapping is applied on the actual typed MappingMetaData,
 * setting its routing, timestamp, and so on if needed.
 */
@Nullable
public MappingMetaData mappingOrDefault(String mappingType) {
    MappingMetaData mapping = mappings.get(mappingType);
    if (mapping != null) {
        return mapping;
    }
    return mappings.get(MapperService.DEFAULT_MAPPING);
}
 
Example #15
Source File: ShardUtils.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to extract the shard id from a reader if possible, when its not possible,
 * will return null.
 */
@Nullable
public static ShardId extractShardId(LeafReader reader) {
    final ElasticsearchLeafReader esReader = ElasticsearchLeafReader.getElasticsearchLeafReader(reader);
    if (esReader != null) {
        assert reader.getRefCount() > 0 : "ElasticsearchLeafReader is already closed";
        return esReader.shardId();
    }
    return null;
}
 
Example #16
Source File: TranslogRecoveryPerformer.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private static Engine.DeleteByQuery prepareDeleteByQuery(IndexQueryParserService queryParserService, MapperService mapperService, IndexAliasesService indexAliasesService, IndexCache indexCache, BytesReference source, @Nullable String[] filteringAliases, Engine.Operation.Origin origin, String... types) {
    long startTime = System.nanoTime();
    if (types == null) {
        types = Strings.EMPTY_ARRAY;
    }
    Query query;
    try {
        query = queryParserService.parseQuery(source).query();
    } catch (QueryParsingException ex) {
        // for BWC we try to parse directly the query since pre 1.0.0.Beta2 we didn't require a top level query field
        if (queryParserService.getIndexCreatedVersion().onOrBefore(Version.V_1_0_0_Beta2)) {
            try {
                XContentParser parser = XContentHelper.createParser(source);
                ParsedQuery parse = queryParserService.parse(parser);
                query = parse.query();
            } catch (Throwable t) {
                ex.addSuppressed(t);
                throw ex;
            }
        } else {
            throw ex;
        }
    }
    Query searchFilter = mapperService.searchFilter(types);
    if (searchFilter != null) {
        query = Queries.filtered(query, searchFilter);
    }

    Query aliasFilter = indexAliasesService.aliasFilter(filteringAliases);
    BitSetProducer parentFilter = mapperService.hasNested() ? indexCache.bitsetFilterCache().getBitSetProducer(Queries.newNonNestedFilter()) : null;
    return new Engine.DeleteByQuery(query, source, filteringAliases, aliasFilter, parentFilter, origin, startTime, types);
}
 
Example #17
Source File: SettingsLoader.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static Map<String, String> loadNestedFromMap(@Nullable Map map) {
    Map<String, String> settings = newHashMap();
    if (map == null) {
        return settings;
    }
    StringBuilder sb = new StringBuilder();
    List<String> path = new ArrayList<>();
    serializeMap(settings, sb, path, map);
    return settings;
}
 
Example #18
Source File: BulkRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
BulkRequest internalAdd(IndexRequest request, @Nullable Object payload) {
    requests.add(request);
    addPayload(payload);
    // lack of source is validated in validate() method
    sizeInBytes += (request.source() != null ? request.source().length() : 0) + REQUEST_OVERHEAD;
    return this;
}
 
Example #19
Source File: TermVectorsRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public FilterSettings(@Nullable Integer maxNumTerms, @Nullable Integer minTermFreq, @Nullable Integer maxTermFreq,
                      @Nullable Integer minDocFreq, @Nullable Integer maxDocFreq, @Nullable Integer minWordLength,
                      @Nullable Integer maxWordLength) {
    this.maxNumTerms = maxNumTerms;
    this.minTermFreq = minTermFreq;
    this.maxTermFreq = maxTermFreq;
    this.minDocFreq = minDocFreq;
    this.maxDocFreq = maxDocFreq;
    this.minWordLength = minWordLength;
    this.maxWordLength = maxWordLength;
}
 
Example #20
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static Version parseVersion(@Nullable String version, Version defaultVersion, ESLogger logger) {
    if (version == null) {
        return defaultVersion;
    }
    try {
        return Version.parse(version);
    } catch (ParseException e) {
        logger.warn("no version match {}, default to {}", e, version, defaultVersion);
        return defaultVersion;
    }
}
 
Example #21
Source File: PartitionName.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * @return the encoded values of a partition
 */
@Nullable
public String ident() {
    if (ident == null) {
        ident = encodeIdent(values);
    }
    return ident;
}
 
Example #22
Source File: IdFieldMapper.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public Query termQuery(Object value, @Nullable QueryParseContext context) {
    if (indexOptions() != IndexOptions.NONE || context == null) {
        return super.termQuery(value, context);
    }
    final BytesRef[] uids = Uid.createUidsForTypesAndId(context.queryTypes(), value);
    return new TermsQuery(UidFieldMapper.NAME, uids);
}
 
Example #23
Source File: DiscoveryNodes.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Delta(@Nullable DiscoveryNode previousMasterNode, @Nullable DiscoveryNode newMasterNode, String localNodeId, List<DiscoveryNode> removed, List<DiscoveryNode> added) {
    this.previousMasterNode = previousMasterNode;
    this.newMasterNode = newMasterNode;
    this.localNodeId = localNodeId;
    this.removed = removed;
    this.added = added;
}
 
Example #24
Source File: StreamInput.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Nullable
public Text readOptionalText() throws IOException {
    int length = readInt();
    if (length == -1) {
        return null;
    }
    return new Text(readBytesReference(length));
}
 
Example #25
Source File: StreamOutput.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public void writeMap(@Nullable Map<String, Object> map) throws IOException {
    writeGenericValue(map);
}
 
Example #26
Source File: BlobEnvironment.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public File blobsPath() {
    return blobsPath;
}
 
Example #27
Source File: NodeInfo.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public PluginsAndModules getPlugins() {
    return this.plugins;
}
 
Example #28
Source File: CommonStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public SuggestStats getSuggest() {
    return suggest;
}
 
Example #29
Source File: GeoReferenceInfo.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public Integer treeLevels() {
    return treeLevels;
}
 
Example #30
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Indices level stats.
 */
@Nullable
public NodeIndicesStats getIndices() {
    return this.indices;
}