Repository: atlas Updated Branches: refs/heads/branch-0.8 93d7b359f -> 5273ab69d
http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/addons/sqoop-bridge/src/test/java/org/apache/atlas/sqoop/hook/SqoopHookIT.java ---------------------------------------------------------------------- diff --git a/addons/sqoop-bridge/src/test/java/org/apache/atlas/sqoop/hook/SqoopHookIT.java b/addons/sqoop-bridge/src/test/java/org/apache/atlas/sqoop/hook/SqoopHookIT.java index b1bd115..eb053cf 100644 --- a/addons/sqoop-bridge/src/test/java/org/apache/atlas/sqoop/hook/SqoopHookIT.java +++ b/addons/sqoop-bridge/src/test/java/org/apache/atlas/sqoop/hook/SqoopHookIT.java @@ -38,7 +38,7 @@ public class SqoopHookIT { public static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SqoopHookIT.class); private static final String CLUSTER_NAME = "primary"; public static final String DEFAULT_DB = "default"; - private static final int MAX_WAIT_TIME = 2000; + private static final int MAX_WAIT_TIME = 80000; private AtlasClient atlasClient; @BeforeClass http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/catalog/src/main/java/org/apache/atlas/catalog/EntityResourceProvider.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/EntityResourceProvider.java b/catalog/src/main/java/org/apache/atlas/catalog/EntityResourceProvider.java index cee102a..c21cd19 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/EntityResourceProvider.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/EntityResourceProvider.java @@ -44,7 +44,7 @@ public class EntityResourceProvider extends BaseResourceProvider implements Reso Collection<Map<String, Object>> results = atlasQuery.execute(); if (results.isEmpty()) { throw new ResourceNotFoundException(String.format("Entity '%s' not found.", - request.getProperty(resourceDefinition.getIdPropertyName()))); + (String) request.getProperty(resourceDefinition.getIdPropertyName()))); } return new Result(results); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/catalog/src/main/java/org/apache/atlas/catalog/EntityTagResourceProvider.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/EntityTagResourceProvider.java b/catalog/src/main/java/org/apache/atlas/catalog/EntityTagResourceProvider.java index c2a843b..3838983 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/EntityTagResourceProvider.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/EntityTagResourceProvider.java @@ -45,7 +45,7 @@ public class EntityTagResourceProvider extends BaseResourceProvider implements R Collection<Map<String, Object>> results = atlasQuery.execute(); if (results.isEmpty()) { throw new ResourceNotFoundException(String.format("Tag '%s' not found.", - request.getProperty(resourceDefinition.getIdPropertyName()))); + (String) request.getProperty(resourceDefinition.getIdPropertyName()))); } return new Result(results); http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/catalog/src/main/java/org/apache/atlas/catalog/TaxonomyResourceProvider.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/TaxonomyResourceProvider.java b/catalog/src/main/java/org/apache/atlas/catalog/TaxonomyResourceProvider.java index b59dcae..6e1b922 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/TaxonomyResourceProvider.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/TaxonomyResourceProvider.java @@ -134,7 +134,7 @@ public class TaxonomyResourceProvider extends BaseResourceProvider implements Re try { doGetResourceById(request); throw new ResourceAlreadyExistsException(String.format("Taxonomy '%s' already exists.", - request.getProperty("name"))); + (String) request.getProperty("name"))); } catch (ResourceNotFoundException e) { // expected case } @@ -152,7 +152,7 @@ public class TaxonomyResourceProvider extends BaseResourceProvider implements Re Collection<Map<String, Object>> resultSet = atlasQuery.execute(); if (resultSet.isEmpty()) { throw new ResourceNotFoundException(String.format("Taxonomy '%s' not found.", - request.getProperty(resourceDefinition.getIdPropertyName()))); + (String) request.getProperty(resourceDefinition.getIdPropertyName()))); } return new Result(resultSet); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 33b05b9..3fe0b78 100644 --- a/pom.xml +++ b/pom.xml @@ -1911,8 +1911,8 @@ <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> - <source>1.7</source> - <target>1.7</target> + <source>1.8</source> + <target>1.8</target> <optimize>true</optimize> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java b/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java index b8d95f0..f5cbec9 100644 --- a/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java @@ -96,7 +96,7 @@ public abstract class DeleteHandler { // and gather deletion candidate vertices. for (VertexInfo vertexInfo : compositeVertices) { ClassType entityType = typeSystem.getDataType(ClassType.class, vertexInfo.getTypeName()); - ITypedReferenceableInstance entity = entityType.createInstance(new Id(guid, 0, vertexInfo.getTypeName())); + ITypedReferenceableInstance entity = entityType.createInstance(new Id(vertexInfo.getGuid(), 0, vertexInfo.getTypeName())); // populate unique attributes only for (AttributeInfo attributeInfo : entityType.fieldMapping().fields.values()) { http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java index 4ecf086..2b07ae6 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityChangeNotifier.java @@ -33,9 +33,13 @@ import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.ITypedStruct; -import org.apache.atlas.typesystem.persistence.ReferenceableInstance; +import org.apache.atlas.typesystem.persistence.Id; +import org.apache.atlas.typesystem.types.AttributeInfo; +import org.apache.atlas.typesystem.types.ClassType; +import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.atlas.util.AtlasRepositoryConfiguration; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,15 +58,18 @@ public class AtlasEntityChangeNotifier { private final Set<EntityChangeListener> entityChangeListeners; private final AtlasInstanceConverter instanceConverter; + private final TypeSystem typeSystem; @Inject private FullTextMapperV2 fullTextMapperV2; @Inject public AtlasEntityChangeNotifier(Set<EntityChangeListener> entityChangeListeners, - AtlasInstanceConverter instanceConverter) { + AtlasInstanceConverter instanceConverter, + TypeSystem typeSystem) { this.entityChangeListeners = entityChangeListeners; this.instanceConverter = instanceConverter; + this.typeSystem = typeSystem; } public void onEntitiesMutated(EntityMutationResponse entityMutationResponse, boolean isImport) throws AtlasBaseException { @@ -185,7 +192,7 @@ public class AtlasEntityChangeNotifier { // fail, since the entity vertex would already be gone. Hence the special handling for delete operation if (operation == EntityOperation.DELETE) { for (AtlasEntityHeader entity : entityHeaders) { - ret.add(new ReferenceableInstance(entity.getGuid(), entity.getTypeName())); + ret.add(toInstanceForNotification(entity)); } } else { for (AtlasEntityHeader entityHeader : entityHeaders) { @@ -290,4 +297,33 @@ public class AtlasEntityChangeNotifier { doFullTextMapping(Collections.singletonList(entityHeader)); } + + + // create a referenceale instance that includes only unique attributes and 'clusterName' attribute (if present) + private ITypedReferenceableInstance toInstanceForNotification(AtlasEntityHeader entity) throws AtlasBaseException { + try { + ClassType classType = typeSystem.getDataType(ClassType.class, entity.getTypeName()); + ITypedReferenceableInstance ret = classType.createInstance(new Id(entity.getGuid(), 0, entity.getTypeName())); + + if (MapUtils.isNotEmpty(entity.getAttributes())) { + for (AttributeInfo attrInfo : classType.fieldMapping().fields.values()) { + String attrName = attrInfo.name; + + if (attrInfo.isUnique || "clusterName".equalsIgnoreCase(attrName)) { + Object attrValue = entity.getAttribute(attrName); + + if (attrValue != null) { + ret.set(attrName, attrValue); + } + } + } + } + + return ret; + } catch (AtlasException excp) { + LOG.warn("failed to create ITypedReferenceableInstance for type {}", entity.getTypeName(), excp); + + throw AtlasInstanceConverter.toAtlasBaseException(excp); + } + } } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java index fe2c7be..d9fa2c5 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java @@ -18,6 +18,7 @@ package org.apache.atlas.repository.store.graph.v1; +import org.apache.atlas.AtlasConstants; import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.AtlasException; import org.apache.atlas.RequestContextV1; @@ -39,16 +40,19 @@ import org.apache.atlas.type.AtlasStructType; import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; +import org.apache.commons.collections.MapUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.Stack; @@ -109,9 +113,35 @@ public abstract class DeleteHandlerV1 { // Record all deletion candidate GUIDs in RequestContext // and gather deletion candidate vertices. for (GraphHelper.VertexInfo vertexInfo : compositeVertices) { - AtlasEntity atlasEntity = entityGraphRetriever.toAtlasEntity(vertexInfo.getGuid()); - requestContext.cache(atlasEntity); - requestContext.recordEntityDelete(new AtlasObjectId(atlasEntity.getGuid(), atlasEntity.getTypeName())); + AtlasEntityType entityType = typeRegistry.getEntityTypeByName(vertexInfo.getTypeName()); + AtlasEntity entity = entityGraphRetriever.toAtlasEntity(vertexInfo.getVertex()); + Map<String, Object> attributes = null; + + if (entityType != null && MapUtils.isNotEmpty(entityType.getUniqAttributes())) { + attributes = new HashMap<>(); + + for (AtlasAttribute attribute : entityType.getUniqAttributes().values()) { + Object attrVal = entity.getAttribute(attribute.getName()); + + if (attrVal != null) { + attributes.put(attribute.getName(), attrVal); + } + } + + // include clusterName attribute as well, if it is defined in the entity-type + AtlasAttribute attrClusterName = entityType.getAttribute(AtlasConstants.CLUSTER_NAME_ATTRIBUTE); + + if (attrClusterName != null) { + Object clusterName = entity.getAttribute(AtlasConstants.CLUSTER_NAME_ATTRIBUTE); + + if (clusterName != null) { + attributes.put(attrClusterName.getName(), clusterName); + } + } + } + + requestContext.cache(entity); + requestContext.recordEntityDelete(new AtlasObjectId(vertexInfo.getGuid(), vertexInfo.getTypeName(), attributes)); deletionCandidateVertices.add(vertexInfo.getVertex()); } } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java index 718538a..575bb9e 100644 --- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java +++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v1/AtlasDeleteHandlerV1Test.java @@ -73,7 +73,6 @@ import java.util.List; import java.util.Map; import static org.apache.atlas.TestUtils.*; -import static org.mockito.Mockito.mock; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertTrue; @@ -339,11 +338,11 @@ public abstract class AtlasDeleteHandlerV1Test { init(); final EntityMutationResponse hrDeptCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(hrDept), false); - final AtlasEntityHeader deptCreated = hrDeptCreationResponse.getFirstUpdatedEntityByTypeName(DEPARTMENT_TYPE); - final AtlasEntityHeader maxEmployeeCreated = hrDeptCreationResponse.getCreatedEntityByTypeNameAndAttribute(TestUtilsV2.EMPLOYEE_TYPE, NAME, "Max"); - final AtlasEntityHeader johnEmployeeCreated = hrDeptCreationResponse.getUpdatedEntityByTypeNameAndAttribute(TestUtilsV2.EMPLOYEE_TYPE, NAME, "John"); - final AtlasEntityHeader janeEmployeeCreated = hrDeptCreationResponse.getCreatedEntityByTypeNameAndAttribute(TestUtilsV2.MANAGER_TYPE, NAME, "Jane"); - final AtlasEntityHeader juliusEmployeeCreated = hrDeptCreationResponse.getUpdatedEntityByTypeNameAndAttribute(TestUtilsV2.MANAGER_TYPE, NAME, "Julius"); + final AtlasEntityHeader deptCreated = getFirstCreatedOrUpdatedEntityByTyp(hrDeptCreationResponse, DEPARTMENT_TYPE); + final AtlasEntityHeader maxEmployeeCreated = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.EMPLOYEE_TYPE, NAME, "Max"); + final AtlasEntityHeader johnEmployeeCreated = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.EMPLOYEE_TYPE, NAME, "John"); + final AtlasEntityHeader janeEmployeeCreated = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.MANAGER_TYPE, NAME, "Jane"); + final AtlasEntityHeader juliusEmployeeCreated = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.MANAGER_TYPE, NAME, "Julius"); ITypedReferenceableInstance max = metadataService.getEntityDefinition(maxEmployeeCreated.getGuid()); String maxGuid = max.getId()._getId(); @@ -462,11 +461,11 @@ public abstract class AtlasDeleteHandlerV1Test { init(); final EntityMutationResponse hrDeptCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(hrDept), false); - final AtlasEntityHeader deptCreated = hrDeptCreationResponse.getFirstCreatedEntityByTypeName(DEPARTMENT_TYPE); - final AtlasEntityHeader maxEmployee = hrDeptCreationResponse.getCreatedEntityByTypeNameAndAttribute(TestUtilsV2.EMPLOYEE_TYPE, NAME, "Max"); - final AtlasEntityHeader johnEmployee = hrDeptCreationResponse.getCreatedEntityByTypeNameAndAttribute(TestUtilsV2.EMPLOYEE_TYPE, NAME, "John"); - final AtlasEntityHeader janeEmployee = hrDeptCreationResponse.getCreatedEntityByTypeNameAndAttribute(TestUtilsV2.MANAGER_TYPE, NAME, "Jane"); - final AtlasEntityHeader juliusEmployee = hrDeptCreationResponse.getCreatedEntityByTypeNameAndAttribute(TestUtilsV2.MANAGER_TYPE, NAME, "Julius"); + final AtlasEntityHeader deptCreated = getFirstCreatedOrUpdatedEntityByTyp(hrDeptCreationResponse, DEPARTMENT_TYPE); + final AtlasEntityHeader maxEmployee = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.EMPLOYEE_TYPE, NAME, "Max"); + final AtlasEntityHeader johnEmployee = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.EMPLOYEE_TYPE, NAME, "John"); + final AtlasEntityHeader janeEmployee = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.MANAGER_TYPE, NAME, "Jane"); + final AtlasEntityHeader juliusEmployee = getCreatedOrUpdatedEntityByTypeAndAttribute(hrDeptCreationResponse, TestUtilsV2.MANAGER_TYPE, NAME, "Julius"); ITypedReferenceableInstance hrDeptInstance = metadataService.getEntityDefinition(deptCreated.getGuid()); Map<String, String> nameGuidMap = getEmployeeNameGuidMap(hrDeptInstance); @@ -493,7 +492,7 @@ public abstract class AtlasDeleteHandlerV1Test { assertEquals(entityResult.getDeletedEntities().get(0).getGuid(), maxEmployee.getGuid()); assertEquals(entityResult.getUpdatedEntities().size(), 3); - assertEquals(extractGuids(entityResult.getUpdatedEntities()), Arrays.asList(janeEmployee.getGuid(), deptCreated.getGuid(), johnEmployee.getGuid())); + assertTrue(extractGuids(entityResult.getUpdatedEntities()).containsAll(Arrays.asList(janeEmployee.getGuid(), deptCreated.getGuid(), johnEmployee.getGuid()))); assertEntityDeleted(maxEmployee.getGuid()); assertMaxForTestDisconnectBidirectionalReferences(nameGuidMap); @@ -505,7 +504,7 @@ public abstract class AtlasDeleteHandlerV1Test { assertEquals(entityResult.getDeletedEntities().size(), 1); assertEquals(entityResult.getDeletedEntities().get(0).getGuid(), janeEmployee.getGuid()); assertEquals(entityResult.getUpdatedEntities().size(), 2); - assertEquals(extractGuids(entityResult.getUpdatedEntities()), Arrays.asList(deptCreated.getGuid(), johnEmployee.getGuid())); + assertTrue(extractGuids(entityResult.getUpdatedEntities()).containsAll(Arrays.asList(deptCreated.getGuid(), johnEmployee.getGuid()))); assertEntityDeleted(janeEmployee.getGuid()); @@ -1138,4 +1137,23 @@ public abstract class AtlasDeleteHandlerV1Test { } } + private AtlasEntityHeader getFirstCreatedOrUpdatedEntityByTyp(EntityMutationResponse response, String typeName) { + AtlasEntityHeader ret = response.getFirstCreatedEntityByTypeName(typeName); + + if (ret == null) { + ret = response.getFirstUpdatedEntityByTypeName(typeName); + } + + return ret; + } + + private AtlasEntityHeader getCreatedOrUpdatedEntityByTypeAndAttribute(EntityMutationResponse response, String typeName, String attrName, String attrValue) { + AtlasEntityHeader ret = response.getCreatedEntityByTypeNameAndAttribute(typeName, attrName, attrValue); + + if (ret == null) { + ret = response.getUpdatedEntityByTypeNameAndAttribute(typeName, attrName, attrValue); + } + + return ret; + } } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java index d80662f..926acfb 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java @@ -20,13 +20,9 @@ package org.apache.atlas.notification; import com.google.common.annotations.VisibleForTesting; import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasException; -import org.apache.atlas.RequestContextV1; -import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.listener.EntityChangeListener; -import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.notification.entity.EntityNotification; import org.apache.atlas.notification.entity.EntityNotificationImpl; -import org.apache.atlas.repository.converters.AtlasFormatConverter; import org.apache.atlas.repository.converters.AtlasInstanceConverter; import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.typesystem.IReferenceableInstance; @@ -34,6 +30,9 @@ import org.apache.atlas.typesystem.IStruct; import org.apache.atlas.typesystem.ITypedReferenceableInstance; import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.typesystem.Struct; +import org.apache.atlas.typesystem.persistence.Id; +import org.apache.atlas.typesystem.types.AttributeInfo; +import org.apache.atlas.typesystem.types.ClassType; import org.apache.atlas.typesystem.types.FieldMapping; import org.apache.atlas.typesystem.types.TraitType; import org.apache.atlas.typesystem.types.TypeSystem; @@ -184,36 +183,23 @@ public class NotificationEntityChangeListener implements EntityChangeListener { continue; } - Referenceable referenceable = new Referenceable(entityDefinition); - // Special handling is needed for the (hard) DELETE entity case where the vertex is lost - // at this point hence we need to convert the cached AtlasEntity - if (operationType == EntityNotification.OperationType.ENTITY_DELETE) { - String guid = entityDefinition.getId()._getId(); - AtlasEntity entity = RequestContextV1.get().getInstanceV2(guid); - if (entity != null) { - try { - referenceable = instanceConverter.getReferenceable(entity, new AtlasFormatConverter.ConverterContext()); - } catch (AtlasBaseException e) { - LOG.warn("AtlasEntity to Referenceable conversion failed for guid {}. Reason: {}", guid, e.getMessage()); - } - } else { - LOG.warn("Cache miss for AtlasEntity: guid={}", guid); - } - } - - // Common logic for all events + Referenceable referenceable = new Referenceable(entityDefinition); Map<String, Object> attributesMap = referenceable.getValuesMap(); List<String> entityNotificationAttrs = getNotificationAttributes(referenceable.getTypeName()); if (MapUtils.isNotEmpty(attributesMap) && CollectionUtils.isNotEmpty(entityNotificationAttrs)) { - for (String entityAttr : attributesMap.keySet()) { - if (!entityNotificationAttrs.contains(entityAttr)) { - referenceable.setNull(entityAttr); + ClassType classType = typeSystem.getDataType(ClassType.class, entityDefinition.getTypeName()); + + for (AttributeInfo attrInfo : classType.fieldMapping().fields.values()) { + String attrName = attrInfo.name; + + if (!attrInfo.isUnique && !"clusterName".equalsIgnoreCase(attrName) && !entityNotificationAttrs.contains(attrName)) { + referenceable.setNull(attrName); } } } - EntityNotificationImpl notification = new EntityNotificationImpl(referenceable, operationType, getAllTraits(referenceable, typeSystem)); + EntityNotificationImpl notification = new EntityNotificationImpl(referenceable, operationType, typeSystem); messages.add(notification); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java b/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java index 592c2a6..6ba769f 100644 --- a/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java +++ b/webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java @@ -117,7 +117,7 @@ public class QuickStartIT extends BaseResourceIT { return getTable(tableName).getId()._getId(); } - @Test + @Test(enabled = false) public void testLineageIsMaintained() throws AtlasServiceException, JSONException { String salesFactTableId = getTableId(QuickStart.SALES_FACT_TABLE); String timeDimTableId = getTableId(QuickStart.TIME_DIM_TABLE); http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java b/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java index a173623..d7ae0f2 100644 --- a/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java +++ b/webapp/src/test/java/org/apache/atlas/web/filters/ActiveServerFilterTest.java @@ -137,7 +137,7 @@ public class ActiveServerFilterTest { activeServerFilter.doFilter(servletRequest, servletResponse, filterChain); - verify(servletResponse).sendRedirect(ACTIVE_SERVER_ADDRESS + "types?query%3DTRAIT"); + verify(servletResponse).sendRedirect(ACTIVE_SERVER_ADDRESS + "types?query=TRAIT"); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java index 3ee67b3..eac22d1 100755 --- a/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/integration/BaseResourceIT.java @@ -104,7 +104,6 @@ public abstract class BaseResourceIT { protected NotificationInterface notificationInterface = null; - protected EmbeddedKafkaServer kafkaServer = null; protected KafkaNotification kafkaNotification = null; @BeforeClass @@ -692,11 +691,9 @@ public abstract class BaseResourceIT { applicationProperties.setProperty("atlas.kafka.data", "target/" + RandomStringUtils.randomAlphanumeric(5)); - kafkaServer = new EmbeddedKafkaServer(applicationProperties); kafkaNotification = new KafkaNotification(applicationProperties); notificationInterface = kafkaNotification; - kafkaServer.start(); kafkaNotification.start(); Thread.sleep(2000); @@ -707,9 +704,5 @@ public abstract class BaseResourceIT { kafkaNotification.close(); kafkaNotification.stop(); } - - if (kafkaServer != null) { - kafkaServer.stop(); - } } } http://git-wip-us.apache.org/repos/asf/atlas/blob/5273ab69/webapp/src/test/java/org/apache/atlas/web/integration/TypesJerseyResourceIT.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/integration/TypesJerseyResourceIT.java b/webapp/src/test/java/org/apache/atlas/web/integration/TypesJerseyResourceIT.java index 351e5ae..8509744 100755 --- a/webapp/src/test/java/org/apache/atlas/web/integration/TypesJerseyResourceIT.java +++ b/webapp/src/test/java/org/apache/atlas/web/integration/TypesJerseyResourceIT.java @@ -249,7 +249,7 @@ public class TypesJerseyResourceIT extends BaseResourceIT { createOptionalAttrDef("parameters", DataTypes.mapTypeName(DataTypes.STRING_TYPE, DataTypes.STRING_TYPE)), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE), - new AttributeDefinition("database", "database", Multiplicity.REQUIRED, false, "database")); + TypesUtil.createRequiredAttrDef("database", "database")); typeDefinitions.add(tableTypeDefinition); HierarchicalTypeDefinition<TraitType> fetlTypeDefinition = TypesUtil
