Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B5AB0200B92 for ; Wed, 14 Sep 2016 00:44:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B43A8160ADA; Tue, 13 Sep 2016 22:44:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9A2D2160AD2 for ; Wed, 14 Sep 2016 00:44:15 +0200 (CEST) Received: (qmail 31195 invoked by uid 500); 13 Sep 2016 22:44:14 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 31186 invoked by uid 99); 13 Sep 2016 22:44:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2016 22:44:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 44FC51864D9 for ; Tue, 13 Sep 2016 22:44:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id DxAm6vr4XhvU for ; Tue, 13 Sep 2016 22:43:59 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 50D955FC39 for ; Tue, 13 Sep 2016 22:43:51 +0000 (UTC) Received: (qmail 28391 invoked by uid 99); 13 Sep 2016 22:43:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2016 22:43:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6519DE03E2; Tue, 13 Sep 2016 22:43:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hiteshkhamesra@apache.org To: commits@geode.incubator.apache.org Date: Tue, 13 Sep 2016 22:44:40 -0000 Message-Id: <3ef7036f74614ca487ba2f746e17045e@git.apache.org> In-Reply-To: <69ace8383aae47d1b0c2dc7793e01b2a@git.apache.org> References: <69ace8383aae47d1b0c2dc7793e01b2a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [52/61] [abbrv] incubator-geode git commit: GEODE-37 change package name from com.gemstone.gemfire (for ./geode-lucene/src/main/java/com/gemstone/gemfire)to org.apache.geode for(to ./geode-lucene/src/main/java/org/apache/geode) archived-at: Tue, 13 Sep 2016 22:44:17 -0000 GEODE-37 change package name from com.gemstone.gemfire (for ./geode-lucene/src/main/java/com/gemstone/gemfire)to org.apache.geode for(to ./geode-lucene/src/main/java/org/apache/geode) Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/05e6d966 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/05e6d966 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/05e6d966 Branch: refs/heads/feature/GEODE-37_2 Commit: 05e6d966a2244ef48beb7e45f6b58b5b32a5b97d Parents: c47228e Author: Hitesh Khamesra Authored: Tue Sep 13 15:43:20 2016 -0700 Committer: Hitesh Khamesra Committed: Tue Sep 13 15:43:20 2016 -0700 ---------------------------------------------------------------------- .../gemfire/cache/lucene/LuceneIndex.java | 66 --- .../gemfire/cache/lucene/LuceneQuery.java | 66 --- .../cache/lucene/LuceneQueryException.java | 40 -- .../cache/lucene/LuceneQueryFactory.java | 98 ---- .../cache/lucene/LuceneQueryProvider.java | 47 -- .../cache/lucene/LuceneResultStruct.java | 61 --- .../gemfire/cache/lucene/LuceneService.java | 129 ----- .../cache/lucene/LuceneServiceProvider.java | 45 -- .../lucene/PageableLuceneQueryResults.java | 58 --- .../AbstractPartitionedRepositoryManager.java | 124 ----- .../cache/lucene/internal/IndexListener.java | 35 -- .../lucene/internal/IndexListenerAdapter.java | 41 -- .../lucene/internal/IndexRepositoryFactory.java | 66 --- .../lucene/internal/InternalLuceneIndex.java | 34 -- .../lucene/internal/InternalLuceneService.java | 29 -- .../lucene/internal/LuceneEventListener.java | 107 ----- .../internal/LuceneIndexCreationProfile.java | 172 ------- .../lucene/internal/LuceneIndexFactory.java | 30 -- .../LuceneIndexForPartitionedRegion.java | 176 ------- .../cache/lucene/internal/LuceneIndexImpl.java | 236 ---------- .../cache/lucene/internal/LuceneIndexStats.java | 202 -------- .../lucene/internal/LuceneQueryFactoryImpl.java | 71 --- .../cache/lucene/internal/LuceneQueryImpl.java | 148 ------ .../cache/lucene/internal/LuceneRawIndex.java | 43 -- .../lucene/internal/LuceneRawIndexFactory.java | 27 -- .../lucene/internal/LuceneResultStructImpl.java | 94 ---- .../lucene/internal/LuceneServiceImpl.java | 334 ------------- .../PageableLuceneQueryResultsImpl.java | 147 ------ .../internal/PartitionedRepositoryManager.java | 50 -- .../internal/RawIndexRepositoryFactory.java | 63 --- .../internal/RawLuceneRepositoryManager.java | 46 -- .../lucene/internal/StringQueryProvider.java | 116 ----- .../lucene/internal/cli/LuceneCliStrings.java | 79 ---- .../internal/cli/LuceneIndexCommands.java | 470 ------------------- .../lucene/internal/cli/LuceneIndexDetails.java | 153 ------ .../lucene/internal/cli/LuceneIndexInfo.java | 63 --- .../lucene/internal/cli/LuceneQueryInfo.java | 70 --- .../internal/cli/LuceneSearchResults.java | 76 --- .../functions/LuceneCreateIndexFunction.java | 112 ----- .../functions/LuceneDescribeIndexFunction.java | 74 --- .../cli/functions/LuceneListIndexFunction.java | 71 --- .../functions/LuceneSearchIndexFunction.java | 107 ----- .../internal/directory/DumpDirectoryFiles.java | 116 ----- .../internal/directory/FileIndexInput.java | 131 ------ .../internal/directory/RegionDirectory.java | 132 ------ .../lucene/internal/directory/package-info.java | 23 - .../internal/distributed/CollectorManager.java | 54 --- .../lucene/internal/distributed/EntryScore.java | 84 ---- .../internal/distributed/LuceneFunction.java | 126 ----- .../distributed/LuceneFunctionContext.java | 115 ----- .../lucene/internal/distributed/TopEntries.java | 135 ------ .../distributed/TopEntriesCollector.java | 102 ---- .../distributed/TopEntriesCollectorManager.java | 178 ------- .../TopEntriesFunctionCollector.java | 158 ------- .../internal/distributed/package-info.java | 25 - .../lucene/internal/filesystem/ChunkKey.java | 123 ----- .../cache/lucene/internal/filesystem/File.java | 170 ------- .../internal/filesystem/FileInputStream.java | 166 ------- .../internal/filesystem/FileOutputStream.java | 103 ---- .../lucene/internal/filesystem/FileSystem.java | 196 -------- .../internal/filesystem/FileSystemStats.java | 128 ----- .../filesystem/SeekableInputStream.java | 43 -- .../internal/filesystem/package-info.java | 26 - .../internal/management/LuceneIndexMetrics.java | 218 --------- .../management/LuceneIndexStatsMonitor.java | 93 ---- .../management/LuceneServiceBridge.java | 86 ---- .../internal/management/LuceneServiceMBean.java | 62 --- .../management/LuceneServiceMXBean.java | 59 --- .../management/ManagementIndexListener.java | 38 -- .../lucene/internal/management/StatsKey.java | 35 -- .../cache/lucene/internal/package-info.java | 23 - .../internal/repository/IndexRepository.java | 89 ---- .../repository/IndexRepositoryImpl.java | 182 ------- .../repository/IndexResultCollector.java | 47 -- .../internal/repository/RepositoryManager.java | 44 -- .../internal/repository/package-info.java | 25 - .../HeterogeneousLuceneSerializer.java | 107 ----- .../repository/serializer/LuceneSerializer.java | 35 -- .../serializer/PdxLuceneSerializer.java | 57 --- .../serializer/PrimitiveSerializer.java | 35 -- .../serializer/ReflectionLuceneSerializer.java | 85 ---- .../repository/serializer/SerializerUtil.java | 190 -------- .../repository/serializer/package-info.java | 23 - .../internal/xml/LuceneIndexCreation.java | 113 ----- .../internal/xml/LuceneIndexXmlGenerator.java | 70 --- .../internal/xml/LuceneServiceXmlGenerator.java | 39 -- .../lucene/internal/xml/LuceneXmlConstants.java | 32 -- .../lucene/internal/xml/LuceneXmlParser.java | 119 ----- .../cache/lucene/internal/xml/package-info.java | 24 - .../gemfire/cache/lucene/package-info.java | 32 -- .../apache/geode/cache/lucene/LuceneIndex.java | 66 +++ .../apache/geode/cache/lucene/LuceneQuery.java | 66 +++ .../cache/lucene/LuceneQueryException.java | 40 ++ .../geode/cache/lucene/LuceneQueryFactory.java | 98 ++++ .../geode/cache/lucene/LuceneQueryProvider.java | 47 ++ .../geode/cache/lucene/LuceneResultStruct.java | 61 +++ .../geode/cache/lucene/LuceneService.java | 129 +++++ .../cache/lucene/LuceneServiceProvider.java | 45 ++ .../lucene/PageableLuceneQueryResults.java | 58 +++ .../AbstractPartitionedRepositoryManager.java | 124 +++++ .../cache/lucene/internal/IndexListener.java | 35 ++ .../lucene/internal/IndexListenerAdapter.java | 41 ++ .../lucene/internal/IndexRepositoryFactory.java | 66 +++ .../lucene/internal/InternalLuceneIndex.java | 34 ++ .../lucene/internal/InternalLuceneService.java | 29 ++ .../lucene/internal/LuceneEventListener.java | 107 +++++ .../internal/LuceneIndexCreationProfile.java | 172 +++++++ .../lucene/internal/LuceneIndexFactory.java | 30 ++ .../LuceneIndexForPartitionedRegion.java | 176 +++++++ .../cache/lucene/internal/LuceneIndexImpl.java | 236 ++++++++++ .../cache/lucene/internal/LuceneIndexStats.java | 202 ++++++++ .../lucene/internal/LuceneQueryFactoryImpl.java | 71 +++ .../cache/lucene/internal/LuceneQueryImpl.java | 148 ++++++ .../cache/lucene/internal/LuceneRawIndex.java | 43 ++ .../lucene/internal/LuceneRawIndexFactory.java | 27 ++ .../lucene/internal/LuceneResultStructImpl.java | 94 ++++ .../lucene/internal/LuceneServiceImpl.java | 334 +++++++++++++ .../PageableLuceneQueryResultsImpl.java | 147 ++++++ .../internal/PartitionedRepositoryManager.java | 50 ++ .../internal/RawIndexRepositoryFactory.java | 63 +++ .../internal/RawLuceneRepositoryManager.java | 46 ++ .../lucene/internal/StringQueryProvider.java | 116 +++++ .../lucene/internal/cli/LuceneCliStrings.java | 79 ++++ .../internal/cli/LuceneIndexCommands.java | 470 +++++++++++++++++++ .../lucene/internal/cli/LuceneIndexDetails.java | 153 ++++++ .../lucene/internal/cli/LuceneIndexInfo.java | 63 +++ .../lucene/internal/cli/LuceneQueryInfo.java | 70 +++ .../internal/cli/LuceneSearchResults.java | 76 +++ .../functions/LuceneCreateIndexFunction.java | 112 +++++ .../functions/LuceneDescribeIndexFunction.java | 74 +++ .../cli/functions/LuceneListIndexFunction.java | 71 +++ .../functions/LuceneSearchIndexFunction.java | 107 +++++ .../internal/directory/DumpDirectoryFiles.java | 116 +++++ .../internal/directory/FileIndexInput.java | 131 ++++++ .../internal/directory/RegionDirectory.java | 132 ++++++ .../lucene/internal/directory/package-info.java | 23 + .../internal/distributed/CollectorManager.java | 54 +++ .../lucene/internal/distributed/EntryScore.java | 84 ++++ .../internal/distributed/LuceneFunction.java | 126 +++++ .../distributed/LuceneFunctionContext.java | 115 +++++ .../lucene/internal/distributed/TopEntries.java | 135 ++++++ .../distributed/TopEntriesCollector.java | 102 ++++ .../distributed/TopEntriesCollectorManager.java | 178 +++++++ .../TopEntriesFunctionCollector.java | 158 +++++++ .../internal/distributed/package-info.java | 25 + .../lucene/internal/filesystem/ChunkKey.java | 123 +++++ .../cache/lucene/internal/filesystem/File.java | 170 +++++++ .../internal/filesystem/FileInputStream.java | 166 +++++++ .../internal/filesystem/FileOutputStream.java | 103 ++++ .../lucene/internal/filesystem/FileSystem.java | 196 ++++++++ .../internal/filesystem/FileSystemStats.java | 128 +++++ .../filesystem/SeekableInputStream.java | 43 ++ .../internal/filesystem/package-info.java | 26 + .../internal/management/LuceneIndexMetrics.java | 218 +++++++++ .../management/LuceneIndexStatsMonitor.java | 93 ++++ .../management/LuceneServiceBridge.java | 86 ++++ .../internal/management/LuceneServiceMBean.java | 62 +++ .../management/LuceneServiceMXBean.java | 59 +++ .../management/ManagementIndexListener.java | 38 ++ .../lucene/internal/management/StatsKey.java | 35 ++ .../cache/lucene/internal/package-info.java | 23 + .../internal/repository/IndexRepository.java | 89 ++++ .../repository/IndexRepositoryImpl.java | 182 +++++++ .../repository/IndexResultCollector.java | 47 ++ .../internal/repository/RepositoryManager.java | 44 ++ .../internal/repository/package-info.java | 25 + .../HeterogeneousLuceneSerializer.java | 107 +++++ .../repository/serializer/LuceneSerializer.java | 35 ++ .../serializer/PdxLuceneSerializer.java | 57 +++ .../serializer/PrimitiveSerializer.java | 35 ++ .../serializer/ReflectionLuceneSerializer.java | 85 ++++ .../repository/serializer/SerializerUtil.java | 190 ++++++++ .../repository/serializer/package-info.java | 23 + .../internal/xml/LuceneIndexCreation.java | 113 +++++ .../internal/xml/LuceneIndexXmlGenerator.java | 70 +++ .../internal/xml/LuceneServiceXmlGenerator.java | 39 ++ .../lucene/internal/xml/LuceneXmlConstants.java | 32 ++ .../lucene/internal/xml/LuceneXmlParser.java | 119 +++++ .../cache/lucene/internal/xml/package-info.java | 24 + .../apache/geode/cache/lucene/package-info.java | 32 ++ 180 files changed, 8572 insertions(+), 8572 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneIndex.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneIndex.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneIndex.java deleted file mode 100644 index 6b1a4b4..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneIndex.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.gemstone.gemfire.cache.lucene; - -import java.util.Map; - -import org.apache.lucene.analysis.Analyzer; - -import com.gemstone.gemfire.annotations.Experimental; - - -/** - * An lucene index is built over the data stored in a GemFire Region. - *

- * An index is specified using a index name, field names, region name. - *

- * The index name and region name together uniquely identifies the lucene index. - *

- * - */ -@Experimental -public interface LuceneIndex { - - /** - * @return the index name of this index - */ - public String getName(); - - /** - * @return the region name for this index - */ - public String getRegionPath(); - - /** - * @return the indexed field names in a Set - */ - public String[] getFieldNames(); - - /** - * @return the field to analyzer map - */ - public Map getFieldAnalyzers(); - - /* - * wait until the current entries in cache are indexed - * @param maxWaitInMilliseconds max wait time in millisecond - * @return if entries are flushed within maxWait - */ - public boolean waitUntilFlushed(int maxWaitInMillisecond); - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQuery.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQuery.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQuery.java deleted file mode 100644 index 7cc0977..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQuery.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene; - -import java.util.Collection; -import java.util.List; - -import com.gemstone.gemfire.annotations.Experimental; - -/** - * Provides wrapper object of Lucene's Query object and execute the search. - *

Instances of this interface are created using - * {@link LuceneQueryFactory#create}. - * - */ -@Experimental -public interface LuceneQuery { - /** - * Execute search and return keys. - */ - public Collection findKeys() throws LuceneQueryException; - - /** - * Execute search and return values. - */ - public Collection findValues() throws LuceneQueryException; - - /** - * Execute search and return list of LuceneResultStruct. - */ - public List> findResults() throws LuceneQueryException; - /** - * Execute the search and get results. - */ - public PageableLuceneQueryResults findPages() throws LuceneQueryException; - - /** - * Get page size setting of current query. - */ - public int getPageSize(); - - /** - * Get limit size setting of current query. - */ - public int getLimit(); - - /** - * Get projected fields setting of current query. - */ - public String[] getProjectedFieldNames(); - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryException.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryException.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryException.java deleted file mode 100644 index fb03b4a..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene; - -import com.gemstone.gemfire.GemFireCheckedException; - -/** - * Thrown when a lucene query fails. - */ -public class LuceneQueryException extends GemFireCheckedException { - - public LuceneQueryException(final String message) { - super(message); - } - - public LuceneQueryException(final String message, final Throwable cause) { - super(message, cause); - } - - public LuceneQueryException(final Throwable cause) { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java deleted file mode 100644 index 8e36bbb..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryFactory.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene; - -import org.apache.lucene.queryparser.classic.ParseException; - -import com.gemstone.gemfire.annotations.Experimental; - -/** - * Factory for creating instances of {@link LuceneQuery}. - * To get an instance of this factory call {@link LuceneService#createLuceneQueryFactory}. - *

- * To use this factory configure it with the set methods and then - * call {@link #create} to produce a {@link LuceneQuery} instance. - * - */ -@Experimental -public interface LuceneQueryFactory { - - /** - * Default query result limit is 100 - */ - public static final int DEFAULT_LIMIT = 100; - - /** - * Default page size of result is 0, which means no pagination - */ - public static final int DEFAULT_PAGESIZE = 0; - - /** - * Set page size for a query result. The default page size is 0 which means no pagination. - * If specified negative value, throw IllegalArgumentException - * @param pageSize - * @return itself - */ - LuceneQueryFactory setPageSize(int pageSize); - - /** - * Set max limit of result for a query - * If specified limit is less or equal to zero, throw IllegalArgumentException - * @param limit - * @return itself - */ - LuceneQueryFactory setResultLimit(int limit); - - /** - * Set a list of fields for result projection. - * - * @param fieldNames - * @return itself - * - * @deprecated TODO This feature is not yet implemented - */ - @Deprecated - LuceneQueryFactory setProjectionFields(String... fieldNames); - - /** - * Create wrapper object for lucene's QueryParser object using default standard analyzer. - * The queryString is using lucene QueryParser's syntax. QueryParser is for easy-to-use - * with human understandable syntax. - * - * @param regionName region name - * @param indexName index name - * @param queryString query string in lucene QueryParser's syntax - * @param defaultField default field used by the Lucene Query Parser - * @param the key type in the query results - * @param the value type in the query results - * @return LuceneQuery object - */ - public LuceneQuery create(String indexName, String regionName, String queryString, String defaultField); - - /** - * Creates a wrapper object for Lucene's Query object. This {@link LuceneQuery} builder method could be used in - * advanced cases, such as cases where Lucene's Query object construction needs Lucene's API over query string. - * - * @param indexName index name - * @param regionName region name - * @param provider constructs and provides a Lucene Query object - * @param the key type in the query results - * @param the value type in the query results - * @return LuceneQuery object - */ - public LuceneQuery create(String indexName, String regionName, LuceneQueryProvider provider); -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java deleted file mode 100644 index 7f1c269..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneQueryProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene; - -import java.io.Serializable; - -import org.apache.lucene.search.Query; - -import com.gemstone.gemfire.annotations.Experimental; -import com.gemstone.gemfire.cache.query.QueryException; - -/** - * The instances of this class will be used for distributing Lucene Query objects and re-constructing the Query object. - * If necessary the implementation needs to take care of serializing and de-serializing Lucene Query object. Geode - * respects the DataSerializable contract to provide optimal object serialization. For instance, - * {@link LuceneQueryProvider}'s toData method will be used to serialize it when it is sent to another member of the - * distributed system. Implementation of DataSerializable can provide a zero-argument constructor that will be invoked - * when they are read with DataSerializer.readObject. - */ -@Experimental -public interface LuceneQueryProvider extends Serializable { - /** - * @return A Lucene Query object which could be used for executing Lucene Search on indexed data - * @param index local lucene index the query is being constructed against. - * @throws LuceneQueryException if the provider fails to construct the query object - */ - - public Query getQuery(LuceneIndex index) throws LuceneQueryException; - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneResultStruct.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneResultStruct.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneResultStruct.java deleted file mode 100644 index bc587f5..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneResultStruct.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene; - -import com.gemstone.gemfire.annotations.Experimental; - -/** - *

- * Abstract data structure for one item in query result. - * - */ -@Experimental -public interface LuceneResultStruct { - /** - * Return the value associated with the given field name - * - * @param fieldName the String name of the field - * @return the value associated with the specified field - * @throws IllegalArgumentException If this struct does not have a field named fieldName - */ - public Object getProjectedField(String fieldName); - - /** - * Return key of the entry - * - * @return key - * @throws IllegalArgumentException If this struct does not contain key - */ - public K getKey(); - - /** - * Return value of the entry - * - * @return value the whole domain object - * @throws IllegalArgumentException If this struct does not contain value - */ - public V getValue(); - - /** - * Return score of the query - * - * @return score - * @throws IllegalArgumentException If this struct does not contain score - */ - public float getScore(); -} - http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java deleted file mode 100644 index cf1f735..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneService.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene; - -import java.util.Collection; -import java.util.Map; - -import org.apache.lucene.analysis.Analyzer; - -import com.gemstone.gemfire.annotations.Experimental; -import com.gemstone.gemfire.cache.GemFireCache; -import com.gemstone.gemfire.cache.lucene.internal.LuceneIndexCreationProfile; - -/** - * LuceneService instance is a singleton for each cache. - * - * It provides handle for managing the {@link LuceneIndex} and create the {@link LuceneQuery} - * via {@link LuceneQueryFactory} - * - *

- * Example:
- * - *
- * At client and server JVM, initializing cache will create the LuceneServiceImpl object, 
- * which is a singleton at each JVM. 
- * 
- * At each server JVM, for data region to create index, create the index on fields with default analyzer:
- * LuceneIndex index = luceneService.createIndex(indexName, regionName, "field1", "field2", "field3"); 
- * or create index on fields with specified analyzer:
- * LuceneIndex index = luceneService.createIndex(indexName, regionName, analyzerPerField);
- * 
- * We can also create index via cache.xml or gfsh.
- * 
- * At client side, create query and run the search:
- * 
- * LuceneQuery query = luceneService.createLuceneQueryFactory().setLimit(200).setPageSize(20)
- * .setResultTypes(SCORE, VALUE, KEY).setFieldProjection("field1", "field2")
- * .create(indexName, regionName, querystring, analyzer);
- * 
- * The querystring is using lucene's queryparser syntax, such as "field1:zhou* AND field2:gzhou@pivotal.io"
- *  
- * PageableLuceneQueryResults results = query.search();
- * 
- * If pagination is not specified:
- * List list = results.getNextPage(); // return all results in one getNextPage() call
- * or if paging is specified:
- * if (results.hasNextPage()) {
- *   List page = results.nextPage(); // return resules page by page
- * }
- * 
- * The item of the list is either the domain object or instance of {@link LuceneResultStruct}
- * 
- * - * - */ -@Experimental -public interface LuceneService { - - /** - * A special field name that indicates that the entire region value should - * be indexed. This will only work if the region value is a String or Number, in - * which case a lucene document will be created with a single field with this name. - */ - String REGION_VALUE_FIELD = "__REGION_VALUE_FIELD"; - - /** - * Create a lucene index using default analyzer. - * @param fields The fields of the object to index. Only fields listed here will be stored - * in the index. Fields should map to PDX fieldNames if the object is serialized with PDX, or - * to java fields on the object otherwise. The special field name {{@link #REGION_VALUE_FIELD}} - * indicates that the entire value should be stored as a single field in the index. - */ - public void createIndex(String indexName, String regionPath, String... fields); - - /** - * Create a lucene index using specified analyzer per field - * - * @param indexName index name - * @param regionPath region name - * @param analyzerPerField A map of fields to analyzers. See {{@link #createIndex(String, String, String...)}} - * for details on valid values for fields. Each field will be tokenized using the provided Analyzer. - */ - public void createIndex(String indexName, String regionPath, - Map analyzerPerField); - - /** - * Destroy the lucene index - * - * @param index index object - * @deprecated TODO This feature is not yet implemented - */ - @Deprecated - public void destroyIndex(LuceneIndex index); - - /** - * Get the lucene index object specified by region name and index name - * @param indexName index name - * @param regionPath region name - * @return LuceneIndex object - */ - public LuceneIndex getIndex(String indexName, String regionPath); - - /** - * get all the lucene indexes. - * @return all index objects in a Collection - */ - public Collection getAllIndexes(); - - /** - * create LuceneQueryFactory - * @return LuceneQueryFactory object - */ - public LuceneQueryFactory createLuceneQueryFactory(); - - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java deleted file mode 100644 index f83dffa..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/LuceneServiceProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene; - -import com.gemstone.gemfire.annotations.Experimental; -import com.gemstone.gemfire.cache.GemFireCache; -import com.gemstone.gemfire.cache.lucene.internal.InternalLuceneService; -import com.gemstone.gemfire.internal.cache.InternalCache; - -/** - * Class for retrieving or creating the currently running - * instance of the LuceneService. - * - */ -@Experimental -public class LuceneServiceProvider { - /** - * Retrieve or create the lucene service for this cache - */ - public static LuceneService get(GemFireCache cache) { - InternalCache internalCache = (InternalCache) cache; - return internalCache.getService(InternalLuceneService.class); - } - - private LuceneServiceProvider() { - - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/PageableLuceneQueryResults.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/PageableLuceneQueryResults.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/PageableLuceneQueryResults.java deleted file mode 100644 index c2def44..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/PageableLuceneQueryResults.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene; - -import java.util.Iterator; -import java.util.List; - -import com.gemstone.gemfire.annotations.Experimental; - -/** - *

- * Defines the interface for a container of lucene query result collected from function execution.
- * - * - * @param The type of the key - * @param The type of the value - */ -@Experimental -public interface PageableLuceneQueryResults extends Iterator>> { - /** - * @return total number of hits for this query - */ - public int size(); - - /** - * Returns the maximum score value encountered. Note that in case scores are not tracked, this returns {@link Float#NaN}. - */ - public float getMaxScore(); - - /** - * Get the next page of results. - * - * @return a page of results, or null if there are no more pages - */ - public List> next(); - - /** - * True if there another page of results. - */ - public boolean hasNext(); -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/AbstractPartitionedRepositoryManager.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/AbstractPartitionedRepositoryManager.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/AbstractPartitionedRepositoryManager.java deleted file mode 100755 index 1dc716c..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/AbstractPartitionedRepositoryManager.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene.internal; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import com.gemstone.gemfire.InternalGemFireError; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.execute.RegionFunctionContext; -import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository; -import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager; -import com.gemstone.gemfire.cache.lucene.internal.repository.serializer.LuceneSerializer; -import com.gemstone.gemfire.internal.cache.BucketNotFoundException; -import com.gemstone.gemfire.internal.cache.BucketRegion; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.cache.execute.InternalRegionFunctionContext; - -public abstract class AbstractPartitionedRepositoryManager implements RepositoryManager { - - /** map of the parent bucket region to the index repository - * - * This is based on the BucketRegion in case a bucket is rebalanced, we don't want to - * return a stale index repository. If a bucket moves off of this node and - * comes back, it will have a new BucketRegion object. - * - * It is weak so that the old BucketRegion will be garbage collected. - */ - protected final ConcurrentHashMap indexRepositories = new ConcurrentHashMap(); - - /** The user region for this index */ - protected final PartitionedRegion userRegion; - protected final LuceneSerializer serializer; - protected final LuceneIndexImpl index; - - public AbstractPartitionedRepositoryManager( - LuceneIndexImpl index, - LuceneSerializer serializer) { - this.index = index; - this.userRegion = (PartitionedRegion)index.getCache().getRegion(index.getRegionPath()); - this.serializer = serializer; - } - - @Override - public IndexRepository getRepository(Region region, Object key, - Object callbackArg) throws BucketNotFoundException { - BucketRegion userBucket = userRegion.getBucketRegion(key, callbackArg); - if(userBucket == null) { - throw new BucketNotFoundException("User bucket was not found for region " + region + "key " + key + " callbackarg " + callbackArg); - } - - return getRepository(userBucket.getId()); - } - - @Override - public Collection getRepositories(RegionFunctionContext ctx) throws BucketNotFoundException { - Region region = ctx.getDataSet(); - Set buckets = ((InternalRegionFunctionContext) ctx).getLocalBucketSet(region); - ArrayList repos = new ArrayList(buckets.size()); - for(Integer bucketId : buckets) { - BucketRegion userBucket = userRegion.getDataStore().getLocalBucketById(bucketId); - if(userBucket == null) { - throw new BucketNotFoundException("User bucket was not found for region " + region + "bucket id " + bucketId); - } else { - repos.add(getRepository(userBucket.getId())); - } - } - - return repos; - } - - public abstract IndexRepository createOneIndexRepository(final Integer bucketId, - LuceneSerializer serializer, - LuceneIndexImpl index, PartitionedRegion userRegion) throws IOException; - - /** - * Return the repository for a given user bucket - */ - protected IndexRepository getRepository(Integer bucketId) throws BucketNotFoundException { - IndexRepository repo = indexRepositories.get(bucketId); - if(repo != null && !repo.isClosed()) { - return repo; - } - - repo = indexRepositories.compute(bucketId, (key, oldRepository) -> { - if(oldRepository != null && !oldRepository.isClosed()) { - return oldRepository; - } - if(oldRepository != null) { - oldRepository.cleanup(); - } - - try { - return createOneIndexRepository(bucketId, serializer, index, userRegion); - } catch(IOException e) { - throw new InternalGemFireError("Unable to create index repository", e); - } - - }); - - if(repo == null) { - throw new BucketNotFoundException("Colocated index buckets not found for bucket id " + bucketId); - } - - return repo; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListener.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListener.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListener.java deleted file mode 100644 index c9c03a5..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.cache.lucene.LuceneIndex; -import org.apache.lucene.analysis.Analyzer; - -import java.util.Map; - -public interface IndexListener { - - public void beforeIndexCreated(final String indexName, String regionPath, - final Analyzer analyzer, final Map fieldAnalyzers, - final String... fields); - - public void afterIndexCreated(LuceneIndex index); - - public void beforeIndexDestroyed(LuceneIndex index); - - public void afterIndexDestroyed(LuceneIndex index); -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListenerAdapter.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListenerAdapter.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListenerAdapter.java deleted file mode 100644 index dd916ac..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexListenerAdapter.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.cache.lucene.LuceneIndex; -import org.apache.lucene.analysis.Analyzer; - -import java.util.Map; - -public class IndexListenerAdapter implements IndexListener { - @Override - public void beforeIndexCreated(String indexName, String regionPath, Analyzer analyzer, - Map fieldAnalyzers, String... fields) { - } - - @Override - public void afterIndexCreated(LuceneIndex index) { - } - - @Override - public void beforeIndexDestroyed(LuceneIndex index) { - } - - @Override - public void afterIndexDestroyed(LuceneIndex index) { - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexRepositoryFactory.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexRepositoryFactory.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexRepositoryFactory.java deleted file mode 100644 index e6f01b0..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/IndexRepositoryFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene.internal; - -import java.io.IOException; - -import com.gemstone.gemfire.cache.lucene.internal.directory.RegionDirectory; -import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository; -import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepositoryImpl; -import com.gemstone.gemfire.cache.lucene.internal.repository.serializer.LuceneSerializer; -import com.gemstone.gemfire.internal.cache.BucketNotFoundException; -import com.gemstone.gemfire.internal.cache.BucketRegion; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; - -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; - -public class IndexRepositoryFactory { - - public IndexRepositoryFactory() { - } - - public IndexRepository createIndexRepository(final Integer bucketId, - LuceneSerializer serializer, - LuceneIndexImpl index, PartitionedRegion userRegion) - throws IOException - { - final IndexRepository repo; - LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion)index; - BucketRegion fileBucket = getMatchingBucket(indexForPR.getFileRegion(), bucketId); - BucketRegion chunkBucket = getMatchingBucket(indexForPR.getChunkRegion(), bucketId); - BucketRegion dataBucket = getMatchingBucket(userRegion, bucketId); - if(fileBucket == null || chunkBucket == null) { - return null; - } - RegionDirectory dir = new RegionDirectory(fileBucket, chunkBucket, indexForPR.getFileSystemStats()); - IndexWriterConfig config = new IndexWriterConfig(indexForPR.getAnalyzer()); - IndexWriter writer = new IndexWriter(dir, config); - repo = new IndexRepositoryImpl(fileBucket, writer, serializer, indexForPR.getIndexStats(), dataBucket); - return repo; - } - - /** - * Find the bucket in region2 that matches the bucket id from region1. - */ - protected BucketRegion getMatchingBucket(PartitionedRegion region, Integer bucketId) { - //Force the bucket to be created if it is not already - region.getOrCreateNodeForBucketWrite(bucketId, null); - - return region.getDataStore().getLocalBucketById(bucketId); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java deleted file mode 100644 index 27b4820..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneIndex.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.cache.lucene.LuceneIndex; -import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager; - -public interface InternalLuceneIndex extends LuceneIndex { - - public RepositoryManager getRepositoryManager(); - - /** - * Dump the files for this index to the given directory. - */ - public void dumpFiles(String directory); - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java deleted file mode 100644 index 403853e..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/InternalLuceneService.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.lucene.LuceneService; -import com.gemstone.gemfire.internal.cache.CacheService; -import com.gemstone.gemfire.internal.cache.extension.Extension; - -public interface InternalLuceneService extends LuceneService, Extension, CacheService { - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java deleted file mode 100644 index 29fb159..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene.internal; - -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.logging.log4j.Logger; - -import com.gemstone.gemfire.InternalGemFireError; -import com.gemstone.gemfire.cache.Operation; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionDestroyedException; -import com.gemstone.gemfire.cache.asyncqueue.AsyncEvent; -import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener; -import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager; -import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository; -import com.gemstone.gemfire.cache.query.internal.DefaultQuery; -import com.gemstone.gemfire.internal.cache.BucketNotFoundException; -import com.gemstone.gemfire.internal.cache.CacheObserverHolder; -import com.gemstone.gemfire.internal.cache.PrimaryBucketException; -import com.gemstone.gemfire.internal.cache.partitioned.Bucket; -import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientProxy.TestHook; -import com.gemstone.gemfire.internal.logging.LogService; - -/** - * An Async event queue listener that writes all of the - * events in batches to Lucene - */ -public class LuceneEventListener implements AsyncEventListener { - Logger logger = LogService.getLogger(); - - private final RepositoryManager repositoryManager; - - public LuceneEventListener(RepositoryManager repositoryManager) { - this.repositoryManager = repositoryManager; - } - - @Override - public void close() { - } - - @Override - public boolean processEvents(List events) { - // Try to get a PDX instance if possible, rather than a deserialized object - DefaultQuery.setPdxReadSerialized(true); - - Set affectedRepos = new HashSet(); - - try { - for (AsyncEvent event : events) { - Region region = event.getRegion(); - Object key = event.getKey(); - Object callbackArgument = event.getCallbackArgument(); - - IndexRepository repository = repositoryManager.getRepository(region, key, callbackArgument); - - Operation op = event.getOperation(); - - if (op.isCreate()) { - repository.update(key, event.getDeserializedValue()); - } else if (op.isUpdate()) { - repository.update(key, event.getDeserializedValue()); - } else if (op.isDestroy()) { - repository.delete(key); - } else if (op.isInvalidate()) { - repository.delete(key); - } else { - throw new InternalGemFireError("Unhandled operation " + op + " on " + event.getRegion()); - } - affectedRepos.add(repository); - } - - for(IndexRepository repo : affectedRepos) { - repo.commit(); - } - return true; - } catch(BucketNotFoundException | RegionDestroyedException | PrimaryBucketException e) { - logger.debug("Bucket not found while saving to lucene index: " + e.getMessage()); - return false; - } catch(IOException e) { - logger.error("Unable to save to lucene index", e); - return false; - } finally { - DefaultQuery.setPdxReadSerialized(false); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationProfile.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationProfile.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationProfile.java deleted file mode 100644 index de331ea..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexCreationProfile.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.DataSerializable; -import com.gemstone.gemfire.DataSerializer; -import com.gemstone.gemfire.internal.Version; -import com.gemstone.gemfire.internal.cache.CacheServiceProfile; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.standard.StandardAnalyzer; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.*; - -public class LuceneIndexCreationProfile implements CacheServiceProfile, DataSerializable { - - private String indexName; - - private String[] fieldNames; - - private String analyzerClass; - - private Map fieldAnalyzers; - - private String regionPath; - - /* Used by DataSerializer */ - public LuceneIndexCreationProfile() {} - - public LuceneIndexCreationProfile(String indexName, String regionPath, String[] fieldNames, Analyzer analyzer, - Map fieldAnalyzers) { - this.indexName = indexName; - this.regionPath = regionPath; - this.fieldNames = fieldNames; - this.analyzerClass = analyzer.getClass().getSimpleName(); - initializeFieldAnalyzers(fieldAnalyzers); - } - - public String getIndexName() { - return this.indexName; - } - - public String[] getFieldNames() { - return this.fieldNames; - } - - public String getAnalyzerClass() { - return this.analyzerClass; - } - - public Map getFieldAnalyzers() { - return this.fieldAnalyzers; - } - - protected void initializeFieldAnalyzers(Map fieldAnalyzers) { - this.fieldAnalyzers = new HashMap<>(); - for (String field : fieldNames) { - if(fieldAnalyzers != null && !fieldAnalyzers.isEmpty()) { - this.fieldAnalyzers.put(field, fieldAnalyzers.get(field) == null ? StandardAnalyzer.class.getSimpleName() : fieldAnalyzers.get(field).getClass().getSimpleName()); - } else { - this.fieldAnalyzers.put(field, StandardAnalyzer.class.getSimpleName()); - } - } - } - - @Override - public String getId() { - return "lucene_"+LuceneServiceImpl.getUniqueIndexName(indexName, regionPath); - } - - @Override - public String checkCompatibility(String regionPath, CacheServiceProfile profile) { - String result = null; - LuceneIndexCreationProfile remoteProfile = (LuceneIndexCreationProfile) profile; - if (remoteProfile == null) { - // TODO This can occur if one member defines no indexes but another one does. Currently this is caught by the async event id checks. - } else { - // Verify fields are the same - if (!Arrays.equals(remoteProfile.getFieldNames(), getFieldNames())) { - return LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_FIELDS_2_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_FIELDS_3 - .toString(getIndexName(), regionPath, Arrays.toString(getFieldNames()), Arrays.toString(remoteProfile.getFieldNames())); - } - - // Verify the analyzer class is the same - // Note: This test will currently only fail if per-field analyzers are used in one member but not another, - // This condition will be caught in the tests below so this test is commented out. If we ever allow the user - // to configure a single analyzer for all fields, then this test will be useful again. - /* - if (!remoteLuceneIndexProfile.getAnalyzerClass().isInstance(getAnalyzer())) { - result = LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_ANALYZER_2_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_ANALYZER_3 - .toString(indexName, regionPath, remoteLuceneIndexProfile.getAnalyzerClass().getName(), analyzer.getClass().getName()); - } - */ - - // Iterate the existing analyzers and compare them to the input analyzers - // Note: This is currently destructive to the input field analyzers map which should be ok since its a transient object. - if (!getFieldAnalyzers().equals(remoteProfile.getFieldAnalyzers())) { - if (getFieldAnalyzers().size() != remoteProfile.getFieldAnalyzers().size()) { - return LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_FIELDS_2_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_FIELDS_3 - .toString(getIndexName(), regionPath, - Arrays.toString(getFieldAnalyzers().keySet().toArray()), - Arrays.toString(remoteProfile.getFieldAnalyzers().keySet().toArray())); - } - // now the 2 maps should have the same size - for (String field:getFieldAnalyzers().keySet()) { - if (!remoteProfile.getFieldAnalyzers().get(field).equals(getFieldAnalyzers().get(field))) { - return LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_ANALYZER_2_ON_FIELD_3_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_ANALYZER_4_ON_THAT_FIELD - .toString(getIndexName(), regionPath, - getFieldAnalyzers().get(field), field, - remoteProfile.getFieldAnalyzers().get(field)); - } - } - } - } - return result; - } - - @Override - public void toData(DataOutput out) throws IOException { - DataSerializer.writeString(this.indexName, out); - DataSerializer.writeString(this.regionPath, out); - DataSerializer.writeStringArray(this.fieldNames, out); - DataSerializer.writeString(this.analyzerClass, out); - DataSerializer.writeHashMap(this.fieldAnalyzers, out); - } - - @Override - public void fromData(DataInput in) throws IOException, ClassNotFoundException { - this.indexName = DataSerializer.readString(in); - this.regionPath = DataSerializer.readString(in); - this.fieldNames = DataSerializer.readStringArray(in); - this.analyzerClass = DataSerializer.readString(in); - this.fieldAnalyzers = DataSerializer.readHashMap(in); - } - - public String toString() { - return new StringBuilder() - .append(getClass().getSimpleName()) - .append("[") - .append("indexName=") - .append(this.indexName) - .append("; fieldNames=") - .append(Arrays.toString(this.fieldNames)) - .append("; analyzerClass=") - .append(this.analyzerClass) - .append("; fieldAnalyzers=") - .append(this.fieldAnalyzers) - .append("]") - .toString(); - } - - public String getRegionPath() { - return this.regionPath; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexFactory.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexFactory.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexFactory.java deleted file mode 100755 index b6ac867..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; - -public class LuceneIndexFactory { - public LuceneIndexFactory() { - } - - public LuceneIndexImpl create(String indexName, String regionPath, GemFireCacheImpl cache) { - return new LuceneIndexForPartitionedRegion(indexName, regionPath, cache); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java deleted file mode 100644 index b64e026..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene.internal; - -import com.gemstone.gemfire.cache.AttributesFactory; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.PartitionAttributes; -import com.gemstone.gemfire.cache.PartitionAttributesFactory; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.RegionShortcut; -import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue; -import com.gemstone.gemfire.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl; -import com.gemstone.gemfire.cache.execute.FunctionService; -import com.gemstone.gemfire.cache.execute.ResultCollector; -import com.gemstone.gemfire.cache.lucene.internal.directory.DumpDirectoryFiles; -import com.gemstone.gemfire.cache.lucene.internal.filesystem.ChunkKey; -import com.gemstone.gemfire.cache.lucene.internal.filesystem.File; -import com.gemstone.gemfire.cache.lucene.internal.filesystem.FileSystemStats; -import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager; -import com.gemstone.gemfire.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; - -/* wrapper of IndexWriter */ -public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl { - protected Region fileRegion; - protected Region chunkRegion; - protected final FileSystemStats fileSystemStats; - - public LuceneIndexForPartitionedRegion(String indexName, String regionPath, Cache cache) { - super(indexName, regionPath, cache); - - final String statsName = indexName + "-" + regionPath; - this.fileSystemStats = new FileSystemStats(cache.getDistributedSystem(), statsName); - } - - protected RepositoryManager createRepositoryManager() { - RegionShortcut regionShortCut; - final boolean withPersistence = withPersistence(); - RegionAttributes regionAttributes = dataRegion.getAttributes(); - final boolean withStorage = regionAttributes.getPartitionAttributes().getLocalMaxMemory()>0; - - // TODO: 1) dataRegion should be withStorage - // 2) Persistence to Persistence - // 3) Replicate to Replicate, Partition To Partition - // 4) Offheap to Offheap - if (!withStorage) { - throw new IllegalStateException("The data region to create lucene index should be with storage"); - } - if (withPersistence) { - // TODO: add PartitionedRegionAttributes instead - regionShortCut = RegionShortcut.PARTITION_PERSISTENT; - } else { - regionShortCut = RegionShortcut.PARTITION; - } - - // create PR fileRegion, but not to create its buckets for now - final String fileRegionName = createFileRegionName(); - PartitionAttributes partitionAttributes = dataRegion.getPartitionAttributes(); - if (!fileRegionExists(fileRegionName)) { - fileRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes, regionAttributes); - } - - // create PR chunkRegion, but not to create its buckets for now - final String chunkRegionName = createChunkRegionName(); - if (!chunkRegionExists(chunkRegionName)) { - chunkRegion = createChunkRegion(regionShortCut, fileRegionName, partitionAttributes, chunkRegionName, regionAttributes); - } - fileSystemStats.setFileSupplier(() -> (int) getFileRegion().getLocalSize()); - fileSystemStats.setChunkSupplier(() -> (int) getChunkRegion().getLocalSize()); - fileSystemStats.setBytesSupplier(() -> getChunkRegion().getPrStats().getDataStoreBytesInUse()); - - // we will create RegionDirectories on the fly when data comes in - HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer(getFieldNames()); - return new PartitionedRepositoryManager(this, mapper); - } - - public PartitionedRegion getFileRegion() { - return (PartitionedRegion) fileRegion; - } - - public PartitionedRegion getChunkRegion() { - return (PartitionedRegion) chunkRegion; - } - - public FileSystemStats getFileSystemStats() { - return fileSystemStats; - } - - boolean fileRegionExists(String fileRegionName) { - return cache. getRegion(fileRegionName) != null; - } - - Region createFileRegion(final RegionShortcut regionShortCut, - final String fileRegionName, - final PartitionAttributes partitionAttributes, - final RegionAttributes regionAttributes) { - return createRegion(fileRegionName, regionShortCut, this.regionPath, partitionAttributes, regionAttributes); - } - - public String createFileRegionName() { - return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath)+".files"; - } - - boolean chunkRegionExists(String chunkRegionName) { - return cache. getRegion(chunkRegionName) != null; - } - - Region createChunkRegion(final RegionShortcut regionShortCut, - final String fileRegionName, - final PartitionAttributes partitionAttributes, final String chunkRegionName, final RegionAttributes regionAttributes) { - return createRegion(chunkRegionName, regionShortCut, fileRegionName, partitionAttributes, regionAttributes); - } - - public String createChunkRegionName() { - return LuceneServiceImpl.getUniqueIndexName(indexName, regionPath) + ".chunks"; - } - - private PartitionAttributesFactory configureLuceneRegionAttributesFactory(PartitionAttributesFactory attributesFactory, PartitionAttributes dataRegionAttributes) { - attributesFactory.setTotalNumBuckets(dataRegionAttributes.getTotalNumBuckets()); - attributesFactory.setRedundantCopies(dataRegionAttributes.getRedundantCopies()); - return attributesFactory; - } - - protected Region createRegion(final String regionName, - final RegionShortcut regionShortCut, - final String colocatedWithRegionName, - final PartitionAttributes partitionAttributes, - final RegionAttributes regionAttributes) - { - PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory(); - partitionAttributesFactory.setColocatedWith(colocatedWithRegionName); - configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes); - - // Create AttributesFactory based on input RegionShortcut - RegionAttributes baseAttributes = this.cache.getRegionAttributes(regionShortCut.toString()); - AttributesFactory factory = new AttributesFactory(baseAttributes); - factory.setPartitionAttributes(partitionAttributesFactory.create()); - factory.setDiskStoreName(regionAttributes.getDiskStoreName()); - RegionAttributes attributes = factory.create(); - - return createRegion(regionName, attributes); - } - - public void close() { - // TODO Auto-generated method stub - - } - - @Override - public void dumpFiles(final String directory) { - ResultCollector results = FunctionService.onRegion(getDataRegion()) - .withArgs(new String[] {directory, indexName}) - .execute(DumpDirectoryFiles.ID); - results.getResult(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/05e6d966/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java deleted file mode 100644 index 67461a9..0000000 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexImpl.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.gemstone.gemfire.cache.lucene.internal; - -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.apache.logging.log4j.Logger; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.standard.StandardAnalyzer; - -import com.gemstone.gemfire.InternalGemFireError; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.DataPolicy; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; -import com.gemstone.gemfire.cache.asyncqueue.AsyncEventQueue; -import com.gemstone.gemfire.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl; -import com.gemstone.gemfire.cache.lucene.internal.filesystem.ChunkKey; -import com.gemstone.gemfire.cache.lucene.internal.filesystem.File; -import com.gemstone.gemfire.cache.lucene.internal.filesystem.FileSystemStats; -import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager; -import com.gemstone.gemfire.cache.lucene.internal.xml.LuceneIndexCreation; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.InternalRegionArguments; -import com.gemstone.gemfire.internal.cache.LocalRegion; -import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import com.gemstone.gemfire.internal.logging.LogService; - -public abstract class LuceneIndexImpl implements InternalLuceneIndex { - protected static final Logger logger = LogService.getLogger(); - - protected final String indexName; - protected final String regionPath; - protected final Cache cache; - protected final LuceneIndexStats indexStats; - - protected boolean hasInitialized = false; - protected Map fieldAnalyzers; - protected String[] searchableFieldNames; - protected RepositoryManager repositoryManager; - protected Analyzer analyzer; - protected LocalRegion dataRegion; - - protected LuceneIndexImpl(String indexName, String regionPath, Cache cache) { - this.indexName = indexName; - this.regionPath = regionPath; - this.cache = cache; - - final String statsName = indexName + "-" + regionPath; - this.indexStats = new LuceneIndexStats(cache.getDistributedSystem(), statsName); - } - - @Override - public String getName() { - return this.indexName; - } - - @Override - public String getRegionPath() { - return this.regionPath; - } - - protected LocalRegion getDataRegion() { - return (LocalRegion)cache.getRegion(regionPath); - } - - protected boolean withPersistence() { - RegionAttributes ra = dataRegion.getAttributes(); - DataPolicy dp = ra.getDataPolicy(); - final boolean withPersistence = dp.withPersistence(); - return withPersistence; - } - - protected void setSearchableFields(String[] fields) { - searchableFieldNames = fields; - } - - @Override - public boolean waitUntilFlushed(int maxWaitInMillisecond) { - String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath); - AsyncEventQueue queue = (AsyncEventQueue)cache.getAsyncEventQueue(aeqId); - boolean flushed = false; - if (queue != null) { - long start = System.nanoTime(); - while (System.nanoTime() - start < TimeUnit.MILLISECONDS.toNanos(maxWaitInMillisecond)) { - if (0 == queue.size()) { - flushed = true; - break; - } else { - try { - Thread.sleep(200); - } catch (InterruptedException e) { - } - } - } - } else { - throw new IllegalArgumentException("The AEQ does not exist for the index "+indexName+" region "+regionPath); - } - - return flushed; - } - - @Override - public String[] getFieldNames() { - return searchableFieldNames; - } - - @Override - public Map getFieldAnalyzers() { - return this.fieldAnalyzers; - } - - public RepositoryManager getRepositoryManager() { - return this.repositoryManager; - } - - public void setAnalyzer(Analyzer analyzer) { - if (analyzer == null) { - this.analyzer = new StandardAnalyzer(); - } else { - this.analyzer = analyzer; - } - } - - public Analyzer getAnalyzer() { - return this.analyzer; - } - - public Cache getCache() { - return this.cache; - } - - public void setFieldAnalyzers(Map fieldAnalyzers) { - this.fieldAnalyzers = fieldAnalyzers == null ? null : Collections.unmodifiableMap(fieldAnalyzers); - } - - public LuceneIndexStats getIndexStats() { - return indexStats; - } - - protected void initialize() { - if (!hasInitialized) { - /* create index region */ - dataRegion = getDataRegion(); - //assert dataRegion != null; - - repositoryManager = createRepositoryManager(); - - // create AEQ, AEQ listener and specify the listener to repositoryManager - createAEQ(dataRegion); - - addExtension(dataRegion); - hasInitialized = true; - } - } - - protected abstract RepositoryManager createRepositoryManager(); - - protected AsyncEventQueue createAEQ(Region dataRegion) { - return createAEQ(createAEQFactory(dataRegion)); - } - - private AsyncEventQueueFactoryImpl createAEQFactory(final Region dataRegion) { - AsyncEventQueueFactoryImpl factory = (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory(); - if (dataRegion instanceof PartitionedRegion) { - factory.setParallel(true); // parallel AEQ for PR - } else { - factory.setParallel(false); // TODO: not sure if serial AEQ working or not - } - factory.setMaximumQueueMemory(1000); - factory.setDispatcherThreads(10); - factory.setIsMetaQueue(true); - if (dataRegion.getAttributes().getDataPolicy().withPersistence()) { - factory.setPersistent(true); - } - factory.setDiskStoreName(dataRegion.getAttributes().getDiskStoreName()); - factory.setDiskSynchronous(dataRegion.getAttributes().isDiskSynchronous()); - factory.setForwardExpirationDestroy(true); - return factory; - } - - private AsyncEventQueue createAEQ(AsyncEventQueueFactoryImpl factory) { - LuceneEventListener listener = new LuceneEventListener(repositoryManager); - String aeqId = LuceneServiceImpl.getUniqueIndexName(getName(), regionPath); - AsyncEventQueue indexQueue = factory.create(aeqId, listener); - return indexQueue; - } - -/** - * Register an extension with the region - * so that xml will be generated for this index. - */ - protected void addExtension(LocalRegion dataRegion) { - LuceneIndexCreation creation = new LuceneIndexCreation(); - creation.setName(this.getName()); - creation.addFieldNames(this.getFieldNames()); - creation.setRegion(dataRegion); - creation.setFieldAnalyzers(this.getFieldAnalyzers()); - dataRegion.getExtensionPoint().addExtension(creation); - } - - protected Region createRegion(final String regionName, final RegionAttributes attributes) { - // Create InternalRegionArguments to set isUsedForMetaRegion true to suppress xml generation (among other things) - InternalRegionArguments ira = new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false) - .setSnapshotInputStream(null).setImageTarget(null).setIsUsedForMetaRegion(true); - - // Create the region - try { - return ((GemFireCacheImpl)this.cache).createVMRegion(regionName, attributes, ira); - } catch (Exception e) { - InternalGemFireError ige = new InternalGemFireError(LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString()); - ige.initCause(e); - throw ige; - } - } -}