Java Code Examples for org.apache.atlas.model.instance.AtlasEntity#setRelationshipAttributes()
The following examples show how to use
org.apache.atlas.model.instance.AtlasEntity#setRelationshipAttributes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlterTableRename.java From atlas with Apache License 2.0 | 5 votes |
private void renameStorageDesc(AtlasEntityWithExtInfo oldEntityExtInfo, AtlasEntityWithExtInfo newEntityExtInfo, List<HookNotification> notifications) { AtlasEntity oldSd = getStorageDescEntity(oldEntityExtInfo); AtlasEntity newSd = new AtlasEntity(getStorageDescEntity(newEntityExtInfo)); // make a copy of newSd, since we will be setting relationshipAttributes to 'null' below // and we need relationship attributes later during entity full update if (oldSd != null && newSd != null) { AtlasObjectId oldSdId = new AtlasObjectId(oldSd.getTypeName(), ATTRIBUTE_QUALIFIED_NAME, oldSd.getAttribute(ATTRIBUTE_QUALIFIED_NAME)); newSd.removeAttribute(ATTRIBUTE_TABLE); newSd.setRelationshipAttributes(null); notifications.add(new EntityPartialUpdateRequestV2(getUserName(), oldSdId, new AtlasEntityWithExtInfo(newSd))); } }
Example 2
Source File: EntityAuditListenerV2.java From atlas with Apache License 2.0 | 4 votes |
private String getAuditEventDetail(AtlasEntity entity, EntityAuditActionV2 action) { Map<String, Object> prunedAttributes = pruneEntityAttributesForAudit(entity); String auditPrefix = getV2AuditPrefix(action); String auditString = auditPrefix + AtlasType.toJson(entity); byte[] auditBytes = auditString.getBytes(StandardCharsets.UTF_8); long auditSize = auditBytes != null ? auditBytes.length : 0; long auditMaxSize = auditRepository.repositoryMaxSize(); if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store attributes in audit LOG.warn("audit record too long: entityType={}, guid={}, size={}; maxSize={}. entity attribute values not stored in audit", entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize); Map<String, Object> attrValues = entity.getAttributes(); Map<String, Object> relAttrValues = entity.getRelationshipAttributes(); entity.setAttributes(null); entity.setRelationshipAttributes(null); auditString = auditPrefix + AtlasType.toJson(entity); auditBytes = auditString.getBytes(StandardCharsets.UTF_8); // recheck auditString size auditSize = auditBytes != null ? auditBytes.length : 0; if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store classifications and meanings as well LOG.warn("audit record still too long: entityType={}, guid={}, size={}; maxSize={}. audit will have only summary details", entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize); AtlasEntity shallowEntity = new AtlasEntity(); shallowEntity.setGuid(entity.getGuid()); shallowEntity.setTypeName(entity.getTypeName()); shallowEntity.setCreateTime(entity.getCreateTime()); shallowEntity.setUpdateTime(entity.getUpdateTime()); shallowEntity.setCreatedBy(entity.getCreatedBy()); shallowEntity.setUpdatedBy(entity.getUpdatedBy()); shallowEntity.setStatus(entity.getStatus()); shallowEntity.setVersion(entity.getVersion()); auditString = auditPrefix + AtlasType.toJson(shallowEntity); } entity.setAttributes(attrValues); entity.setRelationshipAttributes(relAttrValues); } restoreEntityAttributes(entity, prunedAttributes); return auditString; }
Example 3
Source File: AlterTableRename.java From atlas with Apache License 2.0 | 4 votes |
private void processTables(Table oldTable, Table newTable, List<HookNotification> ret) throws Exception { AtlasEntityWithExtInfo oldTableEntity = toTableEntity(oldTable); AtlasEntityWithExtInfo renamedTableEntity = toTableEntity(newTable); if (oldTableEntity == null || renamedTableEntity == null) { return; } // update qualifiedName for all columns, partitionKeys, storageDesc String renamedTableQualifiedName = (String) renamedTableEntity.getEntity().getAttribute(ATTRIBUTE_QUALIFIED_NAME); renameColumns((List<AtlasObjectId>) oldTableEntity.getEntity().getRelationshipAttribute(ATTRIBUTE_COLUMNS), oldTableEntity, renamedTableQualifiedName, ret); renameColumns((List<AtlasObjectId>) oldTableEntity.getEntity().getRelationshipAttribute(ATTRIBUTE_PARTITION_KEYS), oldTableEntity, renamedTableQualifiedName, ret); renameStorageDesc(oldTableEntity, renamedTableEntity, ret); // set previous name as the alias renamedTableEntity.getEntity().setAttribute(ATTRIBUTE_ALIASES, Collections.singletonList(oldTable.getTableName())); // make a copy of renamedTableEntity to send as partial-update with no relationship attributes AtlasEntity renamedTableEntityForPartialUpdate = new AtlasEntity(renamedTableEntity.getEntity()); renamedTableEntityForPartialUpdate.setRelationshipAttributes(null); String oldTableQualifiedName = (String) oldTableEntity.getEntity().getAttribute(ATTRIBUTE_QUALIFIED_NAME); AtlasObjectId oldTableId = new AtlasObjectId(oldTableEntity.getEntity().getTypeName(), ATTRIBUTE_QUALIFIED_NAME, oldTableQualifiedName); // update qualifiedName and other attributes (like params - which include lastModifiedTime, lastModifiedBy) of the table ret.add(new EntityPartialUpdateRequestV2(getUserName(), oldTableId, new AtlasEntityWithExtInfo(renamedTableEntityForPartialUpdate))); // to handle cases where Atlas didn't have the oldTable, send a full update ret.add(new EntityUpdateRequestV2(getUserName(), new AtlasEntitiesWithExtInfo(renamedTableEntity))); // partial update relationship attribute ddl if (!context.isMetastoreHook()) { AtlasEntity ddlEntity = createHiveDDLEntity(renamedTableEntity.getEntity(), true); if (ddlEntity != null) { ret.add(new HookNotification.EntityCreateRequestV2(getUserName(), new AtlasEntitiesWithExtInfo(ddlEntity))); } } context.removeFromKnownTable(oldTableQualifiedName); }