use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class StormAtlasHook method createBoltInstance.
private Referenceable createBoltInstance(String boltName, Bolt stormBolt) {
Referenceable boltReferenceable = new Referenceable(StormDataTypes.STORM_BOLT.getName());
boltReferenceable.set(AtlasClient.NAME, boltName);
Serializable instance = Utils.javaDeserialize(stormBolt.get_bolt_object().get_serialized_java(), Serializable.class);
boltReferenceable.set("driverClass", instance.getClass().getName());
Map<String, String> flatConfigMap = StormTopologyUtil.getFieldValues(instance, true, null);
boltReferenceable.set("conf", flatConfigMap);
return boltReferenceable;
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class StormAtlasHookIT method testAddEntities.
// TODO: Fix failing test
@Test(enabled = false)
public void testAddEntities() throws Exception {
StormTopology stormTopology = StormTestUtil.createTestTopology();
StormTestUtil.submitTopology(stormCluster, TOPOLOGY_NAME, stormTopology);
LOG.info("Submitted topology {}", TOPOLOGY_NAME);
// todo: test if topology metadata is registered in atlas
String guid = getTopologyGUID();
Assert.assertNotNull(guid);
LOG.info("GUID is {}", guid);
Referenceable topologyReferenceable = atlasClient.getEntity(guid);
Assert.assertNotNull(topologyReferenceable);
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class AtlasHook method notifyEntities.
protected void notifyEntities(String user, List<Referenceable> entities) {
List<HookNotification> hookNotifications = new ArrayList<>();
hookNotifications.add(new EntityCreateRequest(user, entities));
notifyEntities(hookNotifications);
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class EntityNotificationV1 method getAllTraits.
// ----- helper methods ----------------------------------------------------
private static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) {
List<Struct> ret = new LinkedList<>();
for (String traitName : entityDefinition.getTraitNames()) {
Struct trait = entityDefinition.getTrait(traitName);
AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName);
Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
ret.add(trait);
if (CollectionUtils.isNotEmpty(superTypeNames)) {
for (String superTypeName : superTypeNames) {
Struct superTypeTrait = new Struct(superTypeName);
if (MapUtils.isNotEmpty(trait.getValues())) {
AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName);
if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) {
Map<String, Object> superTypeTraitAttributes = new HashMap<>();
for (Map.Entry<String, Object> attrEntry : trait.getValues().entrySet()) {
String attrName = attrEntry.getKey();
if (superType.getAllAttributes().containsKey(attrName)) {
superTypeTraitAttributes.put(attrName, attrEntry.getValue());
}
}
superTypeTrait.setValues(superTypeTraitAttributes);
}
}
ret.add(superTypeTrait);
}
}
}
return ret;
}
use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.
the class EntityJerseyResourceIT method testUTF8.
@Test
public void testUTF8() throws Exception {
// Type names cannot be arbitrary UTF8 characters. See org.apache.atlas.type.AtlasTypeUtil#validateType()
String classType = randomString();
String attrName = random();
String attrValue = random();
ClassTypeDefinition classTypeDefinition = TypesUtil.createClassTypeDef(classType, null, Collections.<String>emptySet(), TypesUtil.createUniqueRequiredAttrDef(attrName, AtlasBaseTypeDef.ATLAS_TYPE_STRING));
TypesDef typesDef = new TypesDef(Collections.<EnumTypeDefinition>emptyList(), Collections.<StructTypeDefinition>emptyList(), Collections.<TraitTypeDefinition>emptyList(), Collections.singletonList(classTypeDefinition));
createType(typesDef);
Referenceable instance = new Referenceable(classType);
instance.set(attrName, attrValue);
Id guid = createInstance(instance);
ObjectNode response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API_V1.GET_ENTITY, null, guid._getId());
Referenceable getReferenceable = AtlasType.fromV1Json(AtlasType.toJson(response.get(AtlasClient.DEFINITION)), Referenceable.class);
Assert.assertEquals(getReferenceable.get(attrName), attrValue);
}
Aggregations