Skip to content

Commit a3374c7

Browse files
sarathsubramanianmneethiraj
authored andcommitted
ATLAS-2456: Implement tag propagation using relationships
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
1 parent 9c58d30 commit a3374c7

File tree

42 files changed

+2637
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2637
-343
lines changed

addons/models/0000-Area0/0010-base_model.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
"cardinality": "SET",
214214
"isLegacyAttribute": true
215215
},
216-
"propagateTags": "NONE"
216+
"propagateTags": "ONE_TO_TWO"
217217
},
218218
{
219219
"name": "process_dataset_outputs",
@@ -232,7 +232,7 @@
232232
"isContainer": false,
233233
"cardinality": "SET"
234234
},
235-
"propagateTags": "NONE"
235+
"propagateTags": "ONE_TO_TWO"
236236
}
237237
]
238238
}

addons/models/1000-Hadoop/1030-hive_model.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@
539539
"cardinality": "SINGLE",
540540
"isLegacyAttribute": true
541541
},
542-
"propagateTags": "ONE_TO_TWO"
542+
"propagateTags": "NONE"
543543
},
544544
{
545545
"name": "hive_table_columns",
@@ -559,7 +559,7 @@
559559
"cardinality": "SINGLE",
560560
"isLegacyAttribute": true
561561
},
562-
"propagateTags": "ONE_TO_TWO"
562+
"propagateTags": "NONE"
563563
},
564564
{
565565
"name": "hive_table_partitionkeys",
@@ -579,7 +579,7 @@
579579
"cardinality": "SINGLE",
580580
"isLegacyAttribute": true
581581
},
582-
"propagateTags": "ONE_TO_TWO"
582+
"propagateTags": "NONE"
583583
},
584584
{
585585
"name": "hive_table_storagedesc",
@@ -599,7 +599,7 @@
599599
"cardinality": "SINGLE",
600600
"isLegacyAttribute": true
601601
},
602-
"propagateTags": "ONE_TO_TWO"
602+
"propagateTags": "NONE"
603603
},
604604
{
605605
"name": "hive_process_column_lineage",

addons/models/1000-Hadoop/1060-hbase_model.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
"cardinality": "SINGLE",
158158
"isLegacyAttribute": true
159159
},
160-
"propagateTags": "ONE_TO_TWO"
160+
"propagateTags": "NONE"
161161
},
162162
{
163163
"name": "hbase_column_family_columns",
@@ -177,7 +177,7 @@
177177
"cardinality": "SINGLE",
178178
"isLegacyAttribute": true
179179
},
180-
"propagateTags": "ONE_TO_TWO"
180+
"propagateTags": "NONE"
181181
}
182182
]
183-
}
183+
}

common/src/main/java/org/apache/atlas/repository/Constants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public final class Constants {
6969
* Trait names property key and index name.
7070
*/
7171
public static final String TRAIT_NAMES_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "traitNames";
72+
public static final String PROPAGATED_TRAIT_NAMES_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "propagatedTraitNames";
7273

7374
public static final String VERSION_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "version";
7475
public static final String STATE_PROPERTY_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "state";
@@ -115,6 +116,9 @@ public final class Constants {
115116
public static final String ATTRIBUTE_NAME_VERSION = "version";
116117
public static final String TEMP_STRUCT_NAME_PREFIX = "__tempQueryResultStruct";
117118

119+
public static final String CLASSIFICATION_ENTITY_GUID = INTERNAL_PROPERTY_KEY_PREFIX + "entityGuid";
120+
public static final String CLASSIFICATION_PROPAGATE_KEY = INTERNAL_PROPERTY_KEY_PREFIX + "propagate";
121+
118122
private Constants() {
119123
}
120124

graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasElement.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.List;
2323
import java.util.Set;
2424

25-
import org.apache.atlas.AtlasException;
2625
import org.codehaus.jettison.json.JSONException;
2726
import org.codehaus.jettison.json.JSONObject;
2827

@@ -85,7 +84,7 @@ public interface AtlasElement {
8584
* is needed for this because special logic is required to handle this situation
8685
* in some implementations.
8786
*/
88-
void setListProperty(String propertyName, List<String> values) throws AtlasException;
87+
void setListProperty(String propertyName, List<String> values);
8988

9089

9190
/**

graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasVertex.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public interface AtlasVertex<V, E> extends AtlasElement {
5555
*/
5656
<T> void addProperty(String propertyName, T value);
5757

58+
/**
59+
* Adds a value to a multiplicity-many property.
60+
* If the property is already present, the value is added to it; if not, the propery is set with the given value
61+
*
62+
* @param propertyName
63+
* @param value
64+
*/
65+
<T> void addListProperty(String propertyName, T value);
5866

5967
/**
6068
* Creates a vertex query.

graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusVertex.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public <T> void addProperty(String propertyName, T value) {
5252
}
5353
}
5454

55+
@Override
56+
public <T> void addListProperty(String propertyName, T value) {
57+
try {
58+
getWrappedElement().property(VertexProperty.Cardinality.list, propertyName, value);
59+
} catch(SchemaViolationException e) {
60+
throw new AtlasSchemaViolationException(e);
61+
}
62+
}
5563

5664

5765
@Override

graphdb/titan0/src/main/java/org/apache/atlas/repository/graphdb/titan0/Titan0Vertex.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ public <T> void addProperty(String propertyName, T value) {
9999
}
100100
}
101101

102+
@Override
103+
public <T> void addListProperty(String propertyName, T value) {
104+
try {
105+
getAsTitanVertex().addProperty(propertyName, value);
106+
} catch (SchemaViolationException e) {
107+
if (getPropertyValues(propertyName, value.getClass()).contains(value)) {
108+
// follow java set semantics, don't throw an exception if
109+
// value is already there.
110+
return;
111+
}
112+
throw new AtlasSchemaViolationException(e);
113+
}
114+
}
115+
102116
@Override
103117
public <T> Collection<T> getPropertyValues(String key, Class<T> clazz) {
104118

intg/src/main/java/org/apache/atlas/AtlasErrorCode.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ public enum AtlasErrorCode {
122122
INVALID_DSL_HAS_PROPERTY(400, "ATLAS-400-00-068", "DSL Semantic Error - Property needs to be a primitive type: {0}"),
123123
RELATIONSHIP_UPDATE_END_CHANGE_NOT_ALLOWED(404, "ATLAS-400-00-069", "change of relationship end is not permitted. relationship-type={}, relationship-guid={}, end-guid={}, updated-end-guid={}"),
124124
RELATIONSHIP_UPDATE_TYPE_CHANGE_NOT_ALLOWED(404, "ATLAS-400-00-06A", "change of relationship type is not permitted. relationship-guid={}, current-type={}, new-type={}"),
125+
CLASSIFICATION_UPDATE_FROM_PROPAGATED_ENTITY(400, "ATLAS-400-00-06B", "Update to classification {0} is not allowed from propagated entity"),
126+
CLASSIFICATION_DELETE_FROM_PROPAGATED_ENTITY(400, "ATLAS-400-00-06C", "Delete of classification {0} is not allowed from propagated entity"),
127+
CLASSIFICATION_NOT_ASSOCIATED_WITH_ENTITY(400, "ATLAS-400-00-06D", "Classification {0} is not associated with entity"),
128+
125129
// All Not found enums go here
126130
TYPE_NAME_NOT_FOUND(404, "ATLAS-404-00-001", "Given typename {0} was invalid"),
127131
TYPE_GUID_NOT_FOUND(404, "ATLAS-404-00-002", "Given type guid {0} was invalid"),
@@ -137,6 +141,7 @@ public enum AtlasErrorCode {
137141
RELATIONSHIP_CRUD_INVALID_PARAMS(404, "ATLAS-404-00-00D", "Invalid relationship creation/updation parameters passed : {0}"),
138142
RELATIONSHIPDEF_END_TYPE_NAME_NOT_FOUND(404, "ATLAS-404-00-00E", "RelationshipDef {0} endDef typename {0} cannot be found"),
139143
RELATIONSHIP_ALREADY_DELETED(404, "ATLAS-404-00-00F", "Attempting to delete a relationship which is already deleted : {0}"),
144+
INVALID_ENTITY_GUID_FOR_CLASSIFICATION_UPDATE(404, "ATLAS-404-00-010", "Updating entityGuid of classification is not allowed."),
140145

141146
// All data conflict errors go here
142147
TYPE_ALREADY_EXISTS(409, "ATLAS-409-00-001", "Given type {0} already exists"),
@@ -157,17 +162,16 @@ public enum AtlasErrorCode {
157162
FAILED_TO_OBTAIN_GREMLIN_SCRIPT_ENGINE(500, "ATLAS-500-00-008", "Failed to obtain gremlin script engine: {0}"),
158163
JSON_ERROR_OBJECT_MAPPER_NULL_RETURNED(500, "ATLAS-500-00-009", "ObjectMapper.readValue returned NULL for class: {0}"),
159164
GREMLIN_SCRIPT_EXECUTION_FAILED(500, "ATLAS-500-00-00A", "Gremlin script execution failed: {0}"),
160-
161165
CURATOR_FRAMEWORK_UPDATE(500, "ATLAS-500-00-00B", "ActiveInstanceState.update resulted in exception."),
162166
QUICK_START(500, "ATLAS-500-00-00C", "Failed to run QuickStart: {0}"),
163167
EMBEDDED_SERVER_START(500, "ATLAS-500-00-00D", "EmbeddedServer.Start: failed!"),
164168
STORM_TOPOLOGY_UTIL(500, "ATLAS-500-00-00E", "StormToplogyUtil: {0}"),
165169
SQOOP_HOOK(500, "ATLAS-500-00-00F", "SqoopHook: {0}"),
166170
HIVE_HOOK(500, "ATLAS-500-00-010", "HiveHook: {0}"),
167171
HIVE_HOOK_METASTORE_BRIDGE(500, "ATLAS-500-00-011", "HiveHookMetaStoreBridge: {0}"),
168-
169-
DATA_ACCESS_SAVE_FAILED(500, "ATLAS-500-00-00B", "Save failed: {0}"),
170-
DATA_ACCESS_LOAD_FAILED(500, "ATLAS-500-00-00C", "Load failed: {0}");
172+
DATA_ACCESS_SAVE_FAILED(500, "ATLAS-500-00-012", "Save failed: {0}"),
173+
DATA_ACCESS_LOAD_FAILED(500, "ATLAS-500-00-013", "Load failed: {0}"),
174+
ENTITY_NOTIFICATION_FAILED(500, "ATLAS-500-00-014", "Notification failed for operation: {} : {}");
171175

172176
private String errorCode;
173177
private String errorMessage;
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.atlas.listener;
20+
21+
import org.apache.atlas.exception.AtlasBaseException;
22+
import org.apache.atlas.model.instance.AtlasClassification;
23+
import org.apache.atlas.model.instance.AtlasEntity;
24+
25+
import java.util.List;
26+
27+
/**
28+
* Entity change notification listener V2.
29+
*/
30+
public interface EntityChangeListenerV2 {
31+
/**
32+
* This is upon adding new entities to the repository.
33+
*
34+
* @param entities the created entities
35+
* @param isImport
36+
*/
37+
void onEntitiesAdded(List<AtlasEntity> entities, boolean isImport) throws AtlasBaseException;
38+
39+
/**
40+
* This is upon updating an entity.
41+
*
42+
* @param entities the updated entities
43+
* @param isImport
44+
*/
45+
void onEntitiesUpdated(List<AtlasEntity> entities, boolean isImport) throws AtlasBaseException;
46+
47+
/**
48+
* This is upon deleting entities from the repository.
49+
*
50+
* @param entities the deleted entities
51+
* @param isImport
52+
*/
53+
void onEntitiesDeleted(List<AtlasEntity> entities, boolean isImport) throws AtlasBaseException;
54+
55+
/**
56+
* This is upon adding new classifications to an entity.
57+
*
58+
* @param entity the entity
59+
* @param classifications classifications that needs to be added to an entity
60+
* @throws AtlasBaseException if the listener notification fails
61+
*/
62+
void onClassificationsAdded(AtlasEntity entity, List<AtlasClassification> classifications) throws AtlasBaseException;
63+
64+
/**
65+
* This is upon updating classifications to an entity.
66+
*
67+
* @param entity the entity
68+
* @param classifications classifications that needs to be updated for an entity
69+
* @throws AtlasBaseException if the listener notification fails
70+
*/
71+
void onClassificationsUpdated(AtlasEntity entity, List<AtlasClassification> classifications) throws AtlasBaseException;
72+
73+
/**
74+
* This is upon deleting classifications from an entity.
75+
*
76+
* @param entity the entity
77+
* @param classificationNames classifications names for the instance that needs to be deleted from entity
78+
* @throws AtlasBaseException if the listener notification fails
79+
*/
80+
void onClassificationsDeleted(AtlasEntity entity, List<String> classificationNames) throws AtlasBaseException;
81+
}

0 commit comments

Comments
 (0)