ATLAS-3398: introduced consitency-lock configuration to avoid multiple entities with same unique attribute value
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
This commit is contained in:
parent
05eba3fdb9
commit
80efe92630
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue