Search in sources :

Example 1 with ESSearchTypeHandler

use of org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler in project graylog2-server by Graylog2.

the class ElasticsearchBackendTest method setup.

@BeforeClass
public static void setup() {
    Map<String, Provider<ESSearchTypeHandler<? extends SearchType>>> handlers = Maps.newHashMap();
    handlers.put(MessageList.NAME, () -> new ESMessageList(new QueryStringDecorators.Fake()));
    final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
    backend = new ElasticsearchBackend(handlers, null, mock(IndexLookup.class), new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false);
}
Also used : ESSearchTypeHandler(org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler) Period(org.joda.time.Period) SearchJob(org.graylog.plugins.views.search.SearchJob) ImmutableSet(com.google.common.collect.ImmutableSet) BeforeClass(org.junit.BeforeClass) Provider(javax.inject.Provider) Query(org.graylog.plugins.views.search.Query) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Maps(com.google.common.collect.Maps) RelativeRange(org.graylog2.plugin.indexer.searches.timeranges.RelativeRange) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) SearchType(org.graylog.plugins.views.search.SearchType) ESMessageList(org.graylog.storage.elasticsearch7.views.searchtypes.ESMessageList) Map(java.util.Map) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Search(org.graylog.plugins.views.search.Search) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) QueryResult(org.graylog.plugins.views.search.QueryResult) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) Mockito.mock(org.mockito.Mockito.mock) ESMessageList(org.graylog.storage.elasticsearch7.views.searchtypes.ESMessageList) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Provider(javax.inject.Provider) BeforeClass(org.junit.BeforeClass)

Example 2 with ESSearchTypeHandler

use of org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler in project graylog2-server by Graylog2.

the class ElasticsearchBackendTest method setup.

@BeforeClass
public static void setup() {
    Map<String, Provider<ESSearchTypeHandler<? extends SearchType>>> handlers = Maps.newHashMap();
    handlers.put(MessageList.NAME, () -> new ESMessageList(new QueryStringDecorators.Fake()));
    final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
    final QueryStringParser queryStringParser = new QueryStringParser();
    backend = new ElasticsearchBackend(handlers, null, mock(IndexLookup.class), new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false, new ObjectMapperProvider().get());
}
Also used : ESMessageList(org.graylog.storage.elasticsearch6.views.searchtypes.ESMessageList) ESSearchTypeHandler(org.graylog.storage.elasticsearch6.views.searchtypes.ESSearchTypeHandler) BeforeClass(org.junit.BeforeClass) Provider(javax.inject.Provider) Query(org.graylog.plugins.views.search.Query) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RelativeRange(org.graylog2.plugin.indexer.searches.timeranges.RelativeRange) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) SearchType(org.graylog.plugins.views.search.SearchType) Map(java.util.Map) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Search(org.graylog.plugins.views.search.Search) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) QueryResult(org.graylog.plugins.views.search.QueryResult) Period(org.joda.time.Period) SearchJob(org.graylog.plugins.views.search.SearchJob) ImmutableSet(com.google.common.collect.ImmutableSet) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Test(org.junit.Test) Maps(com.google.common.collect.Maps) QueryStringParser(org.graylog.plugins.views.search.elasticsearch.QueryStringParser) QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) Mockito.mock(org.mockito.Mockito.mock) ESMessageList(org.graylog.storage.elasticsearch6.views.searchtypes.ESMessageList) QueryStringParser(org.graylog.plugins.views.search.elasticsearch.QueryStringParser) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Provider(javax.inject.Provider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) BeforeClass(org.junit.BeforeClass)

Example 3 with ESSearchTypeHandler

use of org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler in project graylog2-server by Graylog2.

the class ElasticsearchBackend method generate.

@Override
public ESGeneratedQueryContext generate(SearchJob job, Query query, SearchConfig searchConfig) {
    final BackendQuery backendQuery = query.query();
    validateQueryTimeRange(query, searchConfig);
    final Set<SearchType> searchTypes = query.searchTypes();
    final String queryString = this.queryStringDecorators.decorate(backendQuery.queryString(), job, query);
    final QueryBuilder normalizedRootQuery = normalizeQueryString(queryString);
    final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().filter(normalizedRootQuery);
    // add the optional root query filters
    generateFilterClause(query.filter(), job, query).map(boolQuery::filter);
    final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(boolQuery).from(0).size(0);
    final ESGeneratedQueryContext queryContext = queryContextFactory.create(this, searchSourceBuilder, job, query);
    for (SearchType searchType : searchTypes) {
        final Optional<SearchTypeError> searchTypeError = validateSearchType(query, searchType, searchConfig);
        if (searchTypeError.isPresent()) {
            LOG.error("Invalid search type {} for elasticsearch backend, cannot generate query part. Skipping this search type.", searchType.type());
            queryContext.addError(searchTypeError.get());
            continue;
        }
        final SearchSourceBuilder searchTypeSourceBuilder = queryContext.searchSourceBuilder(searchType);
        final Set<String> effectiveStreamIds = searchType.effectiveStreams().isEmpty() ? query.usedStreamIds() : searchType.effectiveStreams();
        final BoolQueryBuilder searchTypeOverrides = QueryBuilders.boolQuery().must(searchTypeSourceBuilder.query()).must(Objects.requireNonNull(TimeRangeQueryFactory.create(query.effectiveTimeRange(searchType)), "Timerange for search type " + searchType.id() + " cannot be found in query or search type.")).must(QueryBuilders.termsQuery(Message.FIELD_STREAMS, effectiveStreamIds));
        searchType.query().ifPresent(searchTypeBackendQuery -> {
            final String searchTypeQueryString = this.queryStringDecorators.decorate(searchTypeBackendQuery.queryString(), job, query);
            final QueryBuilder normalizedSearchTypeQuery = normalizeQueryString(searchTypeQueryString);
            searchTypeOverrides.must(normalizedSearchTypeQuery);
        });
        searchTypeSourceBuilder.query(searchTypeOverrides);
        final String type = searchType.type();
        final Provider<ESSearchTypeHandler<? extends SearchType>> searchTypeHandler = elasticsearchSearchTypeHandlers.get(type);
        if (searchTypeHandler == null) {
            LOG.error("Unknown search type {} for elasticsearch backend, cannot generate query part. Skipping this search type.", type);
            queryContext.addError(new SearchTypeError(query, searchType.id(), "Unknown search type '" + type + "' for elasticsearch backend, cannot generate query"));
            continue;
        }
        searchTypeHandler.get().generateQueryPart(job, query, searchType, queryContext);
    }
    return queryContext;
}
Also used : SearchTypeError(org.graylog.plugins.views.search.errors.SearchTypeError) QueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder) BoolQueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.BoolQueryBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) BoolQueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.BoolQueryBuilder) ESSearchTypeHandler(org.graylog.storage.elasticsearch6.views.searchtypes.ESSearchTypeHandler) SearchType(org.graylog.plugins.views.search.SearchType) BackendQuery(org.graylog.plugins.views.search.engine.BackendQuery) GlobalOverride(org.graylog.plugins.views.search.GlobalOverride)

Example 4 with ESSearchTypeHandler

use of org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler in project graylog2-server by Graylog2.

the class ElasticsearchBackend method doRun.

@Override
public QueryResult doRun(SearchJob job, Query query, ESGeneratedQueryContext queryContext) {
    if (query.searchTypes().isEmpty()) {
        return QueryResult.builder().query(query).searchTypes(Collections.emptyMap()).errors(new HashSet<>(queryContext.errors())).build();
    }
    LOG.debug("Running query {} for job {}", query.id(), job.getId());
    final HashMap<String, SearchType.Result> resultsMap = Maps.newHashMap();
    final Set<String> affectedIndices = indexLookup.indexNamesForStreamsInTimeRange(query.usedStreamIds(), query.timerange());
    final Map<String, SearchSourceBuilder> searchTypeQueries = queryContext.searchTypeQueries();
    final List<String> searchTypeIds = new ArrayList<>(searchTypeQueries.keySet());
    final List<Search> searches = searchTypeIds.stream().map(searchTypeId -> {
        final Set<String> affectedIndicesForSearchType = query.searchTypes().stream().filter(s -> s.id().equalsIgnoreCase(searchTypeId)).findFirst().flatMap(searchType -> {
            if (searchType.effectiveStreams().isEmpty() && !query.globalOverride().flatMap(GlobalOverride::timerange).isPresent() && !searchType.timerange().isPresent()) {
                return Optional.empty();
            }
            final Set<String> usedStreamIds = searchType.effectiveStreams().isEmpty() ? query.usedStreamIds() : searchType.effectiveStreams();
            return Optional.of(indexLookup.indexNamesForStreamsInTimeRange(usedStreamIds, query.effectiveTimeRange(searchType)));
        }).orElse(affectedIndices);
        return new Search.Builder(searchTypeQueries.get(searchTypeId).toString()).addType(IndexMapping.TYPE_MESSAGE).addIndex(affectedIndicesForSearchType.isEmpty() ? Collections.singleton("") : affectedIndicesForSearchType).allowNoIndices(false).ignoreUnavailable(false).build();
    }).collect(Collectors.toList());
    final MultiSearch.Builder multiSearchBuilder = new MultiSearch.Builder(searches);
    final MultiSearchResult result = JestUtils.execute(jestClient, multiSearchBuilder.build(), () -> "Unable to perform search query: ");
    for (SearchType searchType : query.searchTypes()) {
        final String searchTypeId = searchType.id();
        final Provider<ESSearchTypeHandler<? extends SearchType>> handlerProvider = elasticsearchSearchTypeHandlers.get(searchType.type());
        if (handlerProvider == null) {
            LOG.error("Unknown search type '{}', cannot convert query result.", searchType.type());
            // no need to add another error here, as the query generation code will have added the error about the missing handler already
            continue;
        }
        if (isSearchTypeWithError(queryContext, searchTypeId)) {
            LOG.error("Failed search type '{}', cannot convert query result, skipping.", searchType.type());
            // no need to add another error here, as the query generation code will have added the error about the missing handler already
            continue;
        }
        // we create a new instance because some search type handlers might need to track information between generating the query and
        // processing its result, such as aggregations, which depend on the name and type
        final ESSearchTypeHandler<? extends SearchType> handler = handlerProvider.get();
        final int searchTypeIndex = searchTypeIds.indexOf(searchTypeId);
        final MultiSearchResult.MultiSearchResponse multiSearchResponse = result.getResponses().get(searchTypeIndex);
        if (multiSearchResponse.isError) {
            ElasticsearchException e = JestUtils.specificException(() -> "Search type returned error: ", multiSearchResponse.error);
            queryContext.addError(SearchTypeErrorParser.parse(query, searchTypeId, e));
        } else if (checkForFailedShards(multiSearchResponse.searchResult).isPresent()) {
            ElasticsearchException e = checkForFailedShards(multiSearchResponse.searchResult).get();
            queryContext.addError(SearchTypeErrorParser.parse(query, searchTypeId, e));
        } else {
            final SearchType.Result searchTypeResult = handler.extractResult(job, query, searchType, multiSearchResponse.searchResult, queryContext);
            if (searchTypeResult != null) {
                resultsMap.put(searchTypeId, searchTypeResult);
            }
        }
    }
    LOG.debug("Query {} ran for job {}", query.id(), job.getId());
    return QueryResult.builder().query(query).searchTypes(resultsMap).errors(new HashSet<>(queryContext.errors())).build();
}
Also used : AndFilter(org.graylog.plugins.views.search.filter.AndFilter) BackendQuery(org.graylog.plugins.views.search.engine.BackendQuery) QueryBackend(org.graylog.plugins.views.search.engine.QueryBackend) Provider(javax.inject.Provider) LoggerFactory(org.slf4j.LoggerFactory) MultiSearchResult(io.searchbox.core.MultiSearchResult) JestUtils(org.graylog.storage.elasticsearch6.jest.JestUtils) StreamFilter(org.graylog.plugins.views.search.filter.StreamFilter) Map(java.util.Map) IndexMapping(org.graylog2.indexer.IndexMapping) QueryBuilders(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilders) TimeRangeQueryFactory(org.graylog.storage.elasticsearch6.TimeRangeQueryFactory) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) JestUtils.checkForFailedShards(org.graylog.storage.elasticsearch6.jest.JestUtils.checkForFailedShards) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Filter(org.graylog.plugins.views.search.Filter) Optional(java.util.Optional) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) ESSearchTypeHandler(org.graylog.storage.elasticsearch6.views.searchtypes.ESSearchTypeHandler) Query(org.graylog.plugins.views.search.Query) SearchTypeErrorParser(org.graylog.plugins.views.search.errors.SearchTypeErrorParser) HashMap(java.util.HashMap) ElasticsearchException(org.graylog2.indexer.ElasticsearchException) ArrayList(java.util.ArrayList) JestClient(io.searchbox.client.JestClient) GlobalOverride(org.graylog.plugins.views.search.GlobalOverride) Inject(javax.inject.Inject) HashSet(java.util.HashSet) OrFilter(org.graylog.plugins.views.search.filter.OrFilter) SearchType(org.graylog.plugins.views.search.SearchType) QueryStringFilter(org.graylog.plugins.views.search.filter.QueryStringFilter) SearchTypeError(org.graylog.plugins.views.search.errors.SearchTypeError) QueryResult(org.graylog.plugins.views.search.QueryResult) QueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder) MultiSearch(io.searchbox.core.MultiSearch) SearchJob(org.graylog.plugins.views.search.SearchJob) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Search(io.searchbox.core.Search) Maps(com.google.common.collect.Maps) QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) Named(com.google.inject.name.Named) BoolQueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.BoolQueryBuilder) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) Message(org.graylog2.plugin.Message) Collections(java.util.Collections) Set(java.util.Set) HashSet(java.util.HashSet) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) QueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.QueryBuilder) BoolQueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.BoolQueryBuilder) ArrayList(java.util.ArrayList) ElasticsearchException(org.graylog2.indexer.ElasticsearchException) MultiSearchResult(io.searchbox.core.MultiSearchResult) QueryResult(org.graylog.plugins.views.search.QueryResult) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) MultiSearch(io.searchbox.core.MultiSearch) Search(io.searchbox.core.Search) SearchType(org.graylog.plugins.views.search.SearchType) HashSet(java.util.HashSet) MultiSearchResult(io.searchbox.core.MultiSearchResult) MultiSearch(io.searchbox.core.MultiSearch) GlobalOverride(org.graylog.plugins.views.search.GlobalOverride) ESSearchTypeHandler(org.graylog.storage.elasticsearch6.views.searchtypes.ESSearchTypeHandler) GlobalOverride(org.graylog.plugins.views.search.GlobalOverride)

Example 5 with ESSearchTypeHandler

use of org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler in project graylog2-server by Graylog2.

the class ElasticsearchBackend method generate.

@Override
public ESGeneratedQueryContext generate(SearchJob job, Query query, SearchConfig searchConfig) {
    final BackendQuery backendQuery = query.query();
    validateQueryTimeRange(query, searchConfig);
    final Set<SearchType> searchTypes = query.searchTypes();
    final String queryString = this.queryStringDecorators.decorate(backendQuery.queryString(), job, query);
    final QueryBuilder normalizedRootQuery = normalizeQueryString(queryString);
    final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().filter(normalizedRootQuery);
    // add the optional root query filters
    generateFilterClause(query.filter(), job, query).map(boolQuery::filter);
    final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(boolQuery).from(0).size(0).trackTotalHits(true);
    final ESGeneratedQueryContext queryContext = queryContextFactory.create(this, searchSourceBuilder, job, query);
    for (SearchType searchType : searchTypes) {
        final Optional<SearchTypeError> searchTypeError = validateSearchType(query, searchType, searchConfig);
        if (searchTypeError.isPresent()) {
            LOG.error("Invalid search type {} for elasticsearch backend, cannot generate query part. Skipping this search type.", searchType.type());
            queryContext.addError(searchTypeError.get());
            continue;
        }
        final SearchSourceBuilder searchTypeSourceBuilder = queryContext.searchSourceBuilder(searchType);
        final Set<String> effectiveStreamIds = searchType.effectiveStreams().isEmpty() ? query.usedStreamIds() : searchType.effectiveStreams();
        final BoolQueryBuilder searchTypeOverrides = QueryBuilders.boolQuery().must(searchTypeSourceBuilder.query()).must(Objects.requireNonNull(TimeRangeQueryFactory.create(query.effectiveTimeRange(searchType)), "Timerange for search type " + searchType.id() + " cannot be found in query or search type.")).must(QueryBuilders.termsQuery(Message.FIELD_STREAMS, effectiveStreamIds));
        searchType.query().ifPresent(searchTypeQuery -> {
            final String searchTypeQueryString = this.queryStringDecorators.decorate(searchTypeQuery.queryString(), job, query);
            final QueryBuilder normalizedSearchTypeQuery = normalizeQueryString(searchTypeQueryString);
            searchTypeOverrides.must(normalizedSearchTypeQuery);
        });
        searchTypeSourceBuilder.query(searchTypeOverrides);
        final String type = searchType.type();
        final Provider<ESSearchTypeHandler<? extends SearchType>> searchTypeHandler = elasticsearchSearchTypeHandlers.get(type);
        if (searchTypeHandler == null) {
            LOG.error("Unknown search type {} for elasticsearch backend, cannot generate query part. Skipping this search type.", type);
            queryContext.addError(new SearchTypeError(query, searchType.id(), "Unknown search type '" + type + "' for elasticsearch backend, cannot generate query"));
            continue;
        }
        if (isSearchTypeWithError(queryContext, searchType.id())) {
            LOG.error("Failed search type '{}', cannot convert query result, skipping.", searchType.type());
            // no need to add another error here, as the query generation code will have added the error about the missing handler already
            continue;
        }
        searchTypeHandler.get().generateQueryPart(job, query, searchType, queryContext);
    }
    return queryContext;
}
Also used : SearchTypeError(org.graylog.plugins.views.search.errors.SearchTypeError) BoolQueryBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder) QueryBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.search.builder.SearchSourceBuilder) BoolQueryBuilder(org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.BoolQueryBuilder) ESSearchTypeHandler(org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler) SearchType(org.graylog.plugins.views.search.SearchType) BackendQuery(org.graylog.plugins.views.search.engine.BackendQuery) GlobalOverride(org.graylog.plugins.views.search.GlobalOverride)

Aggregations

SearchType (org.graylog.plugins.views.search.SearchType)6 Maps (com.google.common.collect.Maps)4 Map (java.util.Map)4 Provider (javax.inject.Provider)4 GlobalOverride (org.graylog.plugins.views.search.GlobalOverride)4 Query (org.graylog.plugins.views.search.Query)4 QueryResult (org.graylog.plugins.views.search.QueryResult)4 SearchJob (org.graylog.plugins.views.search.SearchJob)4 IndexLookup (org.graylog.plugins.views.search.elasticsearch.IndexLookup)4 QueryStringDecorators (org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators)4 BackendQuery (org.graylog.plugins.views.search.engine.BackendQuery)4 SearchConfig (org.graylog.plugins.views.search.engine.SearchConfig)4 SearchTypeError (org.graylog.plugins.views.search.errors.SearchTypeError)4 ESSearchTypeHandler (org.graylog.storage.elasticsearch6.views.searchtypes.ESSearchTypeHandler)3 ESSearchTypeHandler (org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Named (com.google.inject.name.Named)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2