You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2018/03/13 22:59:09 UTC
[geode] branch feature/GEODE-3926_2 updated: Added
LuceneIndexCreationInProgressException.java
This is an automated email from the ASF dual-hosted git repository.
udo pushed a commit to branch feature/GEODE-3926_2
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-3926_2 by this push:
new 3f855ec Added LuceneIndexCreationInProgressException.java
3f855ec is described below
commit 3f855ec39037a12c83c06a8e625e90d0b71dbfdf
Author: Udo <uk...@pivotal.io>
AuthorDate: Tue Mar 13 15:59:00 2018 -0700
Added LuceneIndexCreationInProgressException.java
---
.../cache/lucene/internal/InternalLuceneIndex.java | 1 +
.../LuceneIndexCreationInProgressException.java | 9 +++++++++
.../internal/LuceneIndexForPartitionedRegion.java | 10 ++++++++++
.../internal/PartitionedRepositoryManager.java | 20 +++++++++++++++-----
4 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
index 74e4ac8..46243f7 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
@@ -39,4 +39,5 @@ public interface InternalLuceneIndex extends LuceneIndex {
void initialize();
+ boolean isIndexAvailable();
}
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationInProgressException.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationInProgressException.java
new file mode 100644
index 0000000..7077246
--- /dev/null
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationInProgressException.java
@@ -0,0 +1,9 @@
+package org.apache.geode.cache.lucene.internal;
+
+import org.apache.geode.GemFireException;
+
+public class LuceneIndexCreationInProgressException extends GemFireException {
+ public LuceneIndexCreationInProgressException(String message) {
+ super(message);
+ }
+}
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index bbc5a1c..9418801 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -229,6 +229,16 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
}
}
+ @Override
+ public boolean isIndexAvailable() {
+ PartitionedRegion fileAndChunkRegion = getFileAndChunkRegion();
+ if(fileAndChunkRegion != null)
+ {
+ return fileAndChunkRegion.get(IndexRepositoryFactory.APACHE_GEODE_INDEX_COMPLETE) != null;
+ }
+ return false;
+ }
+
private void destroyOnRemoteMembers() {
PartitionedRegion pr = (PartitionedRegion) getDataRegion();
DistributionManager dm = pr.getDistributionManager();
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java
index cef66bf..5d74ec0 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java
@@ -47,7 +47,9 @@ public class PartitionedRepositoryManager implements RepositoryManager {
protected final ConcurrentHashMap<Integer, IndexRepository> indexRepositories =
new ConcurrentHashMap<Integer, IndexRepository>();
- /** The user region for this index */
+ /**
+ * The user region for this index
+ */
protected PartitionedRegion userRegion = null;
protected final LuceneSerializer serializer;
protected final InternalLuceneIndex index;
@@ -76,7 +78,12 @@ public class PartitionedRepositoryManager implements RepositoryManager {
throw new BucketNotFoundException(
"User bucket was not found for region " + region + "bucket id " + bucketId);
} else {
- repos.add(getRepository(userBucket.getId()));
+ if (index.isIndexAvailable()) {
+ repos.add(getRepository(userBucket.getId()));
+ } else {
+ throw new LuceneIndexCreationInProgressException(
+ "Lucene Index creation still in progress for bucket: " + userBucket.getId());
+ }
}
}
@@ -114,14 +121,16 @@ public class PartitionedRepositoryManager implements RepositoryManager {
}
protected IndexRepository computeRepository(Integer bucketId, LuceneSerializer serializer,
- InternalLuceneIndex index, PartitionedRegion userRegion, IndexRepository oldRepository)
+ InternalLuceneIndex index,
+ PartitionedRegion userRegion,
+ IndexRepository oldRepository)
throws IOException {
return indexRepositoryFactory.computeIndexRepository(bucketId, serializer, index, userRegion,
oldRepository);
}
- private IndexRepository computeRepository(Integer bucketId) {
+ protected IndexRepository computeRepository(Integer bucketId) {
try {
isDataRegionReady.await();
} catch (InterruptedException e) {
@@ -155,7 +164,8 @@ public class PartitionedRepositoryManager implements RepositoryManager {
try {
computeRepository(bucketId);
} catch (LuceneIndexDestroyedException e) {
- /* expected exception */}
+ /* expected exception */
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
udo@apache.org.