This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new 80efe92 ATLAS-3398: introduced consitency-lock configuration to avoid
multiple entities with same unique attribute value
80efe92 is described below
commit 80efe92630a9198ed4b4c564f6e78c8079045930
Author: Damian Warszawski <[email protected]>
AuthorDate: Thu Jul 30 17:11:34 2020 -0700
ATLAS-3398: introduced consitency-lock configuration to avoid multiple
entities with same unique attribute value
Signed-off-by: Madhan Neethiraj <[email protected]>
---
.../graphdb/janus/AtlasJanusGraphManagement.java | 29 +++++++++++-----------
.../java/org/apache/atlas/AtlasConfiguration.java | 3 ++-
.../discovery/FreeTextSearchProcessorTest.java | 4 +--
.../resources/solr/core-template/solrconfig.xml | 2 +-
4 files changed, 19 insertions(+), 19 deletions(-)
diff --git
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java
index d0cda71..2a2ef92 100644
---
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java
+++
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java
@@ -18,6 +18,7 @@
package org.apache.atlas.repository.graphdb.janus;
import com.google.common.base.Preconditions;
+import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Element;
@@ -46,6 +47,7 @@ import java.util.Set;
* Janus implementation of AtlasGraphManagement.
*/
public class AtlasJanusGraphManagement implements AtlasGraphManagement {
+ private static final boolean lockEnabled =
AtlasConfiguration.STORAGE_CONSISTENCY_LOCK_ENABLED.getBoolean();
private static final Parameter[] STRING_PARAMETER_ARRAY = new
Parameter[]{Mapping.STRING.asParameter()};
private static final Logger LOG =
LoggerFactory.getLogger(AtlasJanusGraphManagement.class);
@@ -246,23 +248,16 @@ public class AtlasJanusGraphManagement implements
AtlasGraphManagement {
@Override
public void createVertexCompositeIndex(String propertyName, boolean
isUnique, List<AtlasPropertyKey> propertyKeys) {
- IndexBuilder indexBuilder = management.buildIndex(propertyName,
Vertex.class);
-
- for (AtlasPropertyKey key : propertyKeys) {
- PropertyKey janusKey =
AtlasJanusObjectFactory.createPropertyKey(key);
- indexBuilder.addKey(janusKey);
- }
-
- if (isUnique) {
- indexBuilder.unique();
- }
-
- indexBuilder.buildCompositeIndex();
+ createCompositeIndex(propertyName, isUnique, propertyKeys,
Vertex.class);
}
@Override
public void createEdgeCompositeIndex(String propertyName, boolean
isUnique, List<AtlasPropertyKey> propertyKeys) {
- IndexBuilder indexBuilder = management.buildIndex(propertyName,
Edge.class);
+ createCompositeIndex(propertyName, isUnique, propertyKeys, Edge.class);
+ }
+
+ private void createCompositeIndex(String propertyName, boolean isUnique,
List<AtlasPropertyKey> propertyKeys, Class<? extends Element> elementType) {
+ IndexBuilder indexBuilder = management.buildIndex(propertyName,
elementType);
for (AtlasPropertyKey key : propertyKeys) {
PropertyKey janusKey =
AtlasJanusObjectFactory.createPropertyKey(key);
@@ -273,7 +268,11 @@ public class AtlasJanusGraphManagement implements
AtlasGraphManagement {
indexBuilder.unique();
}
- indexBuilder.buildCompositeIndex();
+ JanusGraphIndex index = indexBuilder.buildCompositeIndex();
+
+ if (lockEnabled && isUnique) {
+ management.setConsistency(index, ConsistencyModifier.LOCK);
+ }
}
@Override
@@ -309,4 +308,4 @@ public class AtlasJanusGraphManagement implements
AtlasGraphManagement {
LOG.info("setConsistency: {}: {}: Done!",
elementType.getSimpleName(), count);
}
}
-}
\ No newline at end of file
+}
diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
index 2c007ca..a942b9f 100644
--- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
+++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
@@ -71,7 +71,8 @@ public enum AtlasConfiguration {
MIGRATION_IMPORT_START_POSITION("atlas.migration.import.start.position",
0),
LINEAGE_USING_GREMLIN("atlas.lineage.query.use.gremlin", false),
- HTTP_HEADER_SERVER_VALUE("atlas.http.header.server.value","Apache Atlas");
+ HTTP_HEADER_SERVER_VALUE("atlas.http.header.server.value","Apache Atlas"),
+
STORAGE_CONSISTENCY_LOCK_ENABLED("atlas.graph.storage.consistency-lock.enabled",
true);
private static final Configuration APPLICATION_PROPERTIES;
diff --git
a/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java
b/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java
index 464b281..2a38d87 100644
---
a/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java
+++
b/repository/src/test/java/org/apache/atlas/discovery/FreeTextSearchProcessorTest.java
@@ -57,7 +57,7 @@ public class FreeTextSearchProcessorTest extends
BasicTestSetup {
}
@Test
- public void searchTablesByName() throws AtlasBaseException,
InterruptedException {
+ public void searchTablesByName() throws AtlasBaseException {
SearchParameters params = new SearchParameters();
params.setTypeName("hive_table");
params.setQuery("sales");
@@ -73,7 +73,7 @@ public class FreeTextSearchProcessorTest extends
BasicTestSetup {
}
@Test
- public void searchByNameSortBy() throws AtlasBaseException,
InterruptedException {
+ public void searchByNameSortBy() throws AtlasBaseException {
SearchParameters params = new SearchParameters();
params.setTypeName("hive_table");
params.setQuery("sales");
diff --git a/test-tools/src/main/resources/solr/core-template/solrconfig.xml
b/test-tools/src/main/resources/solr/core-template/solrconfig.xml
index 39cc6ab..8ebbeff 100644
--- a/test-tools/src/main/resources/solr/core-template/solrconfig.xml
+++ b/test-tools/src/main/resources/solr/core-template/solrconfig.xml
@@ -434,7 +434,7 @@
-->
<lst name="defaults">
<str name="defType">edismax</str>
- <str name="qf">3eh1_t^3 yrp_t^10 m4l_t^10 kjp_t^10 iyt_t^10
cn9_t^1 x6t_t^3 hdx_t^3 3ksl_s^3 3qbp_s^3 3mdh_s^3 3oqt_s^3 3nyd_t^3 7uv9_t^3
7ldx_t^3</str>
+ <str name="qf">3hmt_t 35x_t f0l_t i6d_l 7f2d_t 7gn9_t 3oqt_s jr9_t
3rwl_t lc5_t mx1_t 7dhh_t iyt_l 3j7p_t 7klh_t 7hfp_t 7i85_t ohx_t 7bwl_l
7cp1_l</str>
<str name="hl.fl">*</str>
<bool name="hl.requireFieldMatch">true</bool>
<bool name="lowercaseOperators">true</bool>