Commit 80efe926 by Damian Warszawski Committed by Madhan Neethiraj

ATLAS-3398: introduced consitency-lock configuration to avoid multiple entities…

ATLAS-3398: introduced consitency-lock configuration to avoid multiple entities with same unique attribute value Signed-off-by: 's avatarMadhan Neethiraj <madhan@apache.org>
parent 05eba3fd
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package org.apache.atlas.repository.graphdb.janus; package org.apache.atlas.repository.graphdb.janus;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import org.apache.atlas.AtlasConfiguration;
import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Element; import org.apache.tinkerpop.gremlin.structure.Element;
...@@ -46,6 +47,7 @@ import java.util.Set; ...@@ -46,6 +47,7 @@ import java.util.Set;
* Janus implementation of AtlasGraphManagement. * Janus implementation of AtlasGraphManagement.
*/ */
public class AtlasJanusGraphManagement implements 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 Parameter[] STRING_PARAMETER_ARRAY = new Parameter[]{Mapping.STRING.asParameter()};
private static final Logger LOG = LoggerFactory.getLogger(AtlasJanusGraphManagement.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasJanusGraphManagement.class);
...@@ -246,23 +248,16 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement { ...@@ -246,23 +248,16 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement {
@Override @Override
public void createVertexCompositeIndex(String propertyName, boolean isUnique, List<AtlasPropertyKey> propertyKeys) { public void createVertexCompositeIndex(String propertyName, boolean isUnique, List<AtlasPropertyKey> propertyKeys) {
IndexBuilder indexBuilder = management.buildIndex(propertyName, Vertex.class); createCompositeIndex(propertyName, isUnique, propertyKeys, Vertex.class);
for (AtlasPropertyKey key : propertyKeys) {
PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key);
indexBuilder.addKey(janusKey);
}
if (isUnique) {
indexBuilder.unique();
}
indexBuilder.buildCompositeIndex();
} }
@Override @Override
public void createEdgeCompositeIndex(String propertyName, boolean isUnique, List<AtlasPropertyKey> propertyKeys) { 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) { for (AtlasPropertyKey key : propertyKeys) {
PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key); PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(key);
...@@ -273,7 +268,11 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement { ...@@ -273,7 +268,11 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement {
indexBuilder.unique(); indexBuilder.unique();
} }
indexBuilder.buildCompositeIndex(); JanusGraphIndex index = indexBuilder.buildCompositeIndex();
if (lockEnabled && isUnique) {
management.setConsistency(index, ConsistencyModifier.LOCK);
}
} }
@Override @Override
......
...@@ -71,7 +71,8 @@ public enum AtlasConfiguration { ...@@ -71,7 +71,8 @@ public enum AtlasConfiguration {
MIGRATION_IMPORT_START_POSITION("atlas.migration.import.start.position", 0), MIGRATION_IMPORT_START_POSITION("atlas.migration.import.start.position", 0),
LINEAGE_USING_GREMLIN("atlas.lineage.query.use.gremlin", false), 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; private static final Configuration APPLICATION_PROPERTIES;
......
...@@ -57,7 +57,7 @@ public class FreeTextSearchProcessorTest extends BasicTestSetup { ...@@ -57,7 +57,7 @@ public class FreeTextSearchProcessorTest extends BasicTestSetup {
} }
@Test @Test
public void searchTablesByName() throws AtlasBaseException, InterruptedException { public void searchTablesByName() throws AtlasBaseException {
SearchParameters params = new SearchParameters(); SearchParameters params = new SearchParameters();
params.setTypeName("hive_table"); params.setTypeName("hive_table");
params.setQuery("sales"); params.setQuery("sales");
...@@ -73,7 +73,7 @@ public class FreeTextSearchProcessorTest extends BasicTestSetup { ...@@ -73,7 +73,7 @@ public class FreeTextSearchProcessorTest extends BasicTestSetup {
} }
@Test @Test
public void searchByNameSortBy() throws AtlasBaseException, InterruptedException { public void searchByNameSortBy() throws AtlasBaseException {
SearchParameters params = new SearchParameters(); SearchParameters params = new SearchParameters();
params.setTypeName("hive_table"); params.setTypeName("hive_table");
params.setQuery("sales"); params.setQuery("sales");
......
...@@ -434,7 +434,7 @@ ...@@ -434,7 +434,7 @@
--> -->
<lst name="defaults"> <lst name="defaults">
<str name="defType">edismax</str> <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> <str name="hl.fl">*</str>
<bool name="hl.requireFieldMatch">true</bool> <bool name="hl.requireFieldMatch">true</bool>
<bool name="lowercaseOperators">true</bool> <bool name="lowercaseOperators">true</bool>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment