You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@atlas.apache.org by "David Kantor (JIRA)" <ji...@apache.org> on 2016/09/15 02:11:20 UTC

[jira] [Resolved] (ATLAS-1035) In some scenarios, creation of 2 instances with references between them in one call fails

     [ https://issues.apache.org/jira/browse/ATLAS-1035?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Kantor resolved ATLAS-1035.
---------------------------------
    Resolution: Not A Bug
      Assignee: David Kantor

I have debugged this issue, and Atlas is working as designed. In Atlas, the value of a non-composite reference is the referenced object's ID.  The target of a non-composite reference is not implicitly created by Atlas if it does not already exist. When setting a non-composite reference, either the target object must already exist, or, the target must be created in the same Atlas entity operation as the referencing object by either:

* being specified as one of the "root" entities when calling the Atlas operation, or
* being the target of a composite reference from some other entity that is being created

If neither of these is true, and the target of a non-composite reference does not exist, then the Atlas entity operation will fail with exception you encountered, because Atlas is saying: "This is a non-composite reference, but the target object has no existing vertex in the graph, and is not being created in this operation, so I don't know what ID to use for setting the reference". To avoid the "EntityNotFoundException: Could not find vertex for Class Reference" error, ensure that both entities are explicitly specified when calling the Atlas entities operation. The other option is changing the model, such that the reference is defined as composite. Note that this option has other ramifications, as it means the fully inflated target object will be returned whenever the source object is queried, and, the target object will be automatically deleted when the source object is deleted. Feel free to ping me if you'd like to discuss this further.

> In some scenarios, creation of 2 instances with references between them in one call fails
> -----------------------------------------------------------------------------------------
>
>                 Key: ATLAS-1035
>                 URL: https://issues.apache.org/jira/browse/ATLAS-1035
>             Project: Atlas
>          Issue Type: Bug
>            Reporter: Prasad  S Madugundu
>            Assignee: David Kantor
>
> If I create 2 instances that have references between them in one call, it fails with the following exception:
> SEVERE: org.apache.atlas.typesystem.exception.EntityNotFoundException: Could not find vertex for Class Reference (type: ConnectorDirectoryModel_OMRSConnectorDirectory, id: <unassigned>)
> Caused by: org.apache.atlas.repository.RepositoryException: org.apache.atlas.typesystem.exception.EntityNotFoundException: Could not find vertex for Class Reference (type: ConnectorDirectoryModel_OMRSConnectorDirectory, id: <unassigned>)
> 	at org.apache.atlas.repository.graph.GraphBackedMetadataRepository.createEntities(GraphBackedMetadataRepository.java:137)
> 	at org.apache.atlas.GraphTransactionInterceptor.invoke(GraphTransactionInterceptor.java:42)
> 	at org.apache.atlas.services.DefaultMetadataService.createEntities(DefaultMetadataService.java:337)
> 	at org.apache.atlas.services.DefaultMetadataService.createEntities(DefaultMetadataService.java:333)
> 	at org.apache.atlas.web.resources.EntityResource.submit(EntityResource.java:125)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
> 	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
> 	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
> 	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
> 	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
> 	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
> 	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
> 	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
> 	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
> 	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
> 	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
> 	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)
> 	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)
> 	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
> 	at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:287)
> 	at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:277)
> 	at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:182)
> 	at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
> 	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
> 	at org.apache.atlas.web.filters.AuditFilter.doFilter(AuditFilter.java:71)
> 	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
> 	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:119)
> 	at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:133)
> 	at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:130)
> 	at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:203)
> 	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:130)
> 	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
> 	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
> 	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
> 	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
> 	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
> 	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
> 	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
> 	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
> 	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
> 	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
> 	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
> 	at org.eclipse.jetty.server.Server.handle(Server.java:499)
> 	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
> 	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
> 	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
> 	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
> 	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: org.apache.atlas.typesystem.exception.EntityNotFoundException: Could not find vertex for Class Reference (type: ConnectorDirectoryModel_OMRSConnectorDirectory, id: <unassigned>)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.addOrUpdateClassVertex(TypedInstanceToGraphMapper.java:583)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.addOrUpdateReference(TypedInstanceToGraphMapper.java:513)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.mapAttributeToVertex(TypedInstanceToGraphMapper.java:217)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.mapInstanceToVertex(TypedInstanceToGraphMapper.java:186)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.addOrUpdateAttributesAndTraits(TypedInstanceToGraphMapper.java:168)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.addOrUpdateAttributesAndTraits(TypedInstanceToGraphMapper.java:144)
> 	at org.apache.atlas.repository.graph.TypedInstanceToGraphMapper.mapTypedInstanceToGraph(TypedInstanceToGraphMapper.java:102)
> 	at org.apache.atlas.repository.graph.GraphBackedMetadataRepository.createEntities(GraphBackedMetadataRepository.java:132)
> 	... 53 more
> Example:
> I have the types as follows (Catalog has reference called connectorDirectory to ConnectoryDirectory class):
> {
>     "typeName": "CatalogModel_OMRSCatalog",
>     "definition": {
>         "classTypes": [
>             {
>                 "hierarchicalMetaTypeName": "org.apache.atlas.typesystem.types.ClassType",
>                 "typeName": "CatalogModel_OMRSCatalog",
>                 "typeDescription": "",
>                 "attributeDefinitions": [
>                     {
>                         "name": "connectorDirectory",
>                         "dataTypeName": "ConnectorDirectoryModel_OMRSConnectorDirectory",
>                         "multiplicity": "required",
>                         "isComposite": false,
>                         "isUnique": false,
>                         "isIndexable": false,
>                         "reverseAttributeName": null
>                     }
>                 ]
>             }
>         ]
>     },
> }
> If I create ConnectorDirectory first and then create Catalog, it works (note that while creating Catalog, the ConnectorDirectory has ID):
> [
>     {
>         "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
>         "id": {
>             "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
>             "id": "-1468998004536470000",
>             "version": 0,
>             "typeName": "ConnectorDirectory"
>         },
>         "typeName": "ConnectorDirectory",
>         "values": {
>             "name": "DefaultConnectorDirectory",
>         },
>     }
> ]
> [
>     {
>         "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
>         "id": {
>             "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
>             "id": "-1468998006314995000",
>             "version": 0,
>             "typeName": "Catalog"
>         },
>         "typeName": "Catalog",
>         "values": {
>             "connectorDirectory": {
>                 "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
>                 "id": {
>                     "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
>                     "id": "6b7f8949-f5ad-453b-bc57-e8929cc9dd2c",
>                     "version": 0,
>                     "typeName": "ConnectorDirectory"
>                 },
>                 "typeName": "ConnectorDirectory",
>                 "values": {
>                     "name": "DefaultConnectorDirectory",
>                 },
>             },
>             "name": "DefaultCatalog",
>         },
>     }
> ]
> But, If I create both Catalog and ConnectorDirectory in one call, it fails (in this case the connectorDirectory does not have ID):
> [
>     {
>         "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
>         "id": {
>             "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
>             "id": "-1468998163729034000",
>             "version": 0,
>             "typeName": "Catalog"
>         },
>         "typeName": "Catalog",
>         "values": {
>             "connectorDirectory": {
>                 "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
>                 "id": {
>                     "jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
>                     "id": "-1468998163731032000",
>                     "version": 0,
>                     "typeName": "ConnectorDirectory"
>                 },
>                 "typeName": "ConnectorDirectory",
>                 "values": {
>                     "name": "DefaultConnectorDirectory",
>                 },
>             },
>             "name": "DefaultCatalog",
>         },
>     }
> ]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)