idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
900
public static Titan1Edge createEdge ( Titan1Graph graph , Edge source ) { if ( source == null ) { return null ; } return new Titan1Edge ( graph , source ) ; }
Creates a Titan1Edge that corresponds to the given Gremlin Edge .
901
public static Titan1Vertex createVertex ( Titan1Graph graph , Vertex source ) { if ( source == null ) { return null ; } return new Titan1Vertex ( graph , source ) ; }
Creates a Titan1Vertex that corresponds to the given Gremlin Vertex .
902
public String getAdminStatus ( ) throws AtlasServiceException { String result = AtlasBaseClient . UNKNOWN_STATUS ; WebResource resource = getResource ( service , STATUS . getPath ( ) ) ; JSONObject response = callAPIWithResource ( STATUS , resource , null , JSONObject . class ) ; try { result = response . getString ( "Status" ) ; } catch ( JSONException e ) { LOG . error ( "Exception while parsing admin status response. Returned response {}" , response . toString ( ) , e ) ; } return result ; }
Return status of the service instance the client is pointing to .
903
private WebResource getResource ( WebResource service , APIInfo api , String ... pathParams ) { WebResource resource = service . path ( api . getPath ( ) ) ; resource = appendPathParams ( resource , pathParams ) ; return resource ; }
Modify URL to include the path params
904
private ObjectNode objectNodeFromElement ( final AtlasElement element ) { final boolean isEdge = element instanceof AtlasEdge ; final boolean showTypes = mode == AtlasGraphSONMode . EXTENDED ; final List < String > propertyKeys = isEdge ? this . edgePropertyKeys : this . vertexPropertyKeys ; final ElementPropertiesRule elementPropertyConfig = isEdge ? this . edgePropertiesRule : this . vertexPropertiesRule ; final ObjectNode jsonElement = createJSONMap ( createPropertyMap ( element , propertyKeys , elementPropertyConfig , normalized ) , propertyKeys , showTypes ) ; if ( ( isEdge && this . includeReservedEdgeId ) || ( ! isEdge && this . includeReservedVertexId ) ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_ID , element . getId ( ) ) ; } if ( element instanceof AtlasEdge ) { final AtlasEdge edge = ( AtlasEdge ) element ; if ( this . includeReservedEdgeId ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_ID , element . getId ( ) ) ; } if ( this . includeReservedEdgeType ) { jsonElement . put ( AtlasGraphSONTokens . INTERNAL_TYPE , AtlasGraphSONTokens . EDGE ) ; } if ( this . includeReservedEdgeOutV ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_OUT_V , edge . getOutVertex ( ) . getId ( ) ) ; } if ( this . includeReservedEdgeInV ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_IN_V , edge . getInVertex ( ) . getId ( ) ) ; } if ( this . includeReservedEdgeLabel ) { jsonElement . put ( AtlasGraphSONTokens . INTERNAL_LABEL , edge . getLabel ( ) ) ; } } else if ( element instanceof AtlasVertex ) { if ( this . includeReservedVertexId ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_ID , element . getId ( ) ) ; } if ( this . includeReservedVertexType ) { jsonElement . put ( AtlasGraphSONTokens . INTERNAL_TYPE , AtlasGraphSONTokens . VERTEX ) ; } } return jsonElement ; }
Creates GraphSON for a single graph element .
905
public static JSONObject jsonFromElement ( final AtlasElement element , final Set < String > propertyKeys , final AtlasGraphSONMode mode ) throws JSONException { final AtlasGraphSONUtility graphson = element instanceof AtlasEdge ? new AtlasGraphSONUtility ( mode , null , propertyKeys ) : new AtlasGraphSONUtility ( mode , propertyKeys , null ) ; return graphson . jsonFromElement ( element ) ; }
Creates a Jettison JSONObject from a graph element .
906
private static char [ ] getPassword ( TextDevice textDevice , String key ) { boolean noMatch ; char [ ] cred = new char [ 0 ] ; char [ ] passwd1 ; char [ ] passwd2 ; do { passwd1 = textDevice . readPassword ( "Please enter the password value for %s:" , key ) ; passwd2 = textDevice . readPassword ( "Please enter the password value for %s again:" , key ) ; noMatch = ! Arrays . equals ( passwd1 , passwd2 ) ; if ( noMatch ) { if ( passwd1 != null ) { Arrays . fill ( passwd1 , ' ' ) ; } textDevice . printf ( "Password entries don't match. Please try again.\n" ) ; } else { if ( passwd1 . length == 0 ) { textDevice . printf ( "An empty password is not valid. Please try again.\n" ) ; noMatch = true ; } else { cred = passwd1 ; } } if ( passwd2 != null ) { Arrays . fill ( passwd2 , ' ' ) ; } } while ( noMatch ) ; return cred ; }
Retrieves a password from the command line .
907
private static CredentialProvider getCredentialProvider ( TextDevice textDevice ) throws IOException { String providerPath = textDevice . readLine ( "Please enter the full path to the credential provider:" ) ; if ( providerPath != null ) { Configuration conf = new Configuration ( false ) ; conf . set ( CredentialProviderFactory . CREDENTIAL_PROVIDER_PATH , providerPath ) ; return CredentialProviderFactory . getProviders ( conf ) . get ( 0 ) ; } return null ; }
\ Returns a credential provider for the entered JKS path .
908
public void start ( ) throws AtlasException { if ( ! HAConfiguration . isHAEnabled ( configuration ) ) { LOG . info ( "HA is not enabled, no need to start leader election service" ) ; return ; } cacheActiveStateChangeHandlers ( ) ; serverId = AtlasServerIdSelector . selectServerId ( configuration ) ; joinElection ( ) ; }
Join leader election on starting up .
909
public void stop ( ) { if ( ! HAConfiguration . isHAEnabled ( configuration ) ) { LOG . info ( "HA is not enabled, no need to stop leader election service" ) ; return ; } try { leaderLatch . close ( ) ; curatorFactory . close ( ) ; } catch ( IOException e ) { LOG . error ( "Error closing leader latch" , e ) ; } }
Leave leader election process and clean up resources on shutting down .
910
public void addInstance ( IReferenceableInstance instance ) throws AtlasException { ClassType classType = typeSystem . getDataType ( ClassType . class , instance . getTypeName ( ) ) ; ITypedReferenceableInstance newInstance = classType . convert ( instance , Multiplicity . REQUIRED ) ; findReferencedInstancesToPreLoad ( newInstance ) ; Id id = instance . getId ( ) ; if ( mapper . lookupVertex ( id ) == null ) { if ( id . isAssigned ( ) ) { guidsToLookup . add ( id ) ; } else { addToClassMap ( classType , instance ) ; } } }
Adds an instance to be loaded .
911
public static boolean isHAEnabled ( Configuration configuration ) { boolean ret = false ; if ( configuration . containsKey ( HAConfiguration . ATLAS_SERVER_HA_ENABLED_KEY ) ) { ret = configuration . getBoolean ( ATLAS_SERVER_HA_ENABLED_KEY ) ; } else { String [ ] ids = configuration . getStringArray ( HAConfiguration . ATLAS_SERVER_IDS ) ; ret = ids != null && ids . length > 1 ; } return ret ; }
Return whether HA is enabled or not .
912
public static String getBoundAddressForId ( Configuration configuration , String serverId ) { String hostPort = configuration . getString ( ATLAS_SERVER_ADDRESS_PREFIX + serverId ) ; boolean isSecure = configuration . getBoolean ( SecurityProperties . TLS_ENABLED ) ; String protocol = ( isSecure ) ? "https://" : "http://" ; return protocol + hostPort ; }
Get the web server address that a server instance with the passed ID is bound to .
913
protected org . apache . commons . configuration . Configuration getApplicationConfiguration ( ) { try { return ApplicationProperties . get ( ) ; } catch ( AtlasException e ) { LOG . warn ( "Error reading application configuration" , e ) ; } return null ; }
Returns the metadata application configuration .
914
public static String getUserFromRequest ( HttpServletRequest httpRequest ) { String user = httpRequest . getRemoteUser ( ) ; if ( ! StringUtils . isEmpty ( user ) ) { return user ; } user = httpRequest . getParameter ( "user.name" ) ; if ( ! StringUtils . isEmpty ( user ) ) { return user ; } user = httpRequest . getHeader ( "Remote-User" ) ; if ( ! StringUtils . isEmpty ( user ) ) { return user ; } user = getDoAsUser ( httpRequest ) ; if ( ! StringUtils . isEmpty ( user ) ) { return user ; } return null ; }
Returns the user of the given request .
915
public static String getRequestURI ( HttpServletRequest httpRequest ) { final StringBuilder url = new StringBuilder ( 100 ) . append ( httpRequest . getRequestURI ( ) ) ; if ( httpRequest . getQueryString ( ) != null ) { url . append ( '?' ) . append ( httpRequest . getQueryString ( ) ) ; } return url . toString ( ) ; }
Returns the URI of the given request .
916
public void update ( String serverId ) throws AtlasBaseException { try { CuratorFramework client = curatorFactory . clientInstance ( ) ; HAConfiguration . ZookeeperProperties zookeeperProperties = HAConfiguration . getZookeeperProperties ( configuration ) ; String atlasServerAddress = HAConfiguration . getBoundAddressForId ( configuration , serverId ) ; List < ACL > acls = Arrays . asList ( new ACL [ ] { AtlasZookeeperSecurityProperties . parseAcl ( zookeeperProperties . getAcl ( ) , ZooDefs . Ids . OPEN_ACL_UNSAFE . get ( 0 ) ) } ) ; Stat serverInfo = client . checkExists ( ) . forPath ( getZnodePath ( zookeeperProperties ) ) ; if ( serverInfo == null ) { client . create ( ) . withMode ( CreateMode . EPHEMERAL ) . withACL ( acls ) . forPath ( getZnodePath ( zookeeperProperties ) ) ; } client . setData ( ) . forPath ( getZnodePath ( zookeeperProperties ) , atlasServerAddress . getBytes ( Charset . forName ( "UTF-8" ) ) ) ; } catch ( Exception e ) { throw new AtlasBaseException ( AtlasErrorCode . CURATOR_FRAMEWORK_UPDATE , e , "forPath: getZnodePath" ) ; } }
Update state of the active server instance .
917
public String getActiveServerAddress ( ) { CuratorFramework client = curatorFactory . clientInstance ( ) ; String serverAddress = null ; try { HAConfiguration . ZookeeperProperties zookeeperProperties = HAConfiguration . getZookeeperProperties ( configuration ) ; byte [ ] bytes = client . getData ( ) . forPath ( getZnodePath ( zookeeperProperties ) ) ; serverAddress = new String ( bytes , Charset . forName ( "UTF-8" ) ) ; } catch ( Exception e ) { LOG . error ( "Error getting active server address" , e ) ; } return serverAddress ; }
Retrieve state of the active server instance .
918
@ Path ( "/guid/{guid}" ) @ Consumes ( { Servlets . JSON_MEDIA_TYPE , MediaType . APPLICATION_JSON } ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public EntityMutationResponse deleteByGuid ( @ PathParam ( "guid" ) final String guid ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.deleteByGuid(" + guid + ")" ) ; } return entitiesStore . deleteById ( guid ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Delete an entity identified by its GUID .
919
@ Path ( "/guid/{guid}/classification/{classificationName}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasClassification getClassification ( @ PathParam ( "guid" ) String guid , @ PathParam ( "classificationName" ) final String classificationName ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.getClassification(" + guid + "," + classificationName + ")" ) ; } if ( StringUtils . isEmpty ( guid ) ) { throw new AtlasBaseException ( AtlasErrorCode . INSTANCE_GUID_NOT_FOUND , guid ) ; } ensureClassificationType ( classificationName ) ; return entitiesStore . getClassification ( guid , classificationName ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Gets the list of classifications for a given entity represented by a guid .
920
@ Path ( "/guid/{guid}/classifications" ) @ Consumes ( { Servlets . JSON_MEDIA_TYPE , MediaType . APPLICATION_JSON } ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public void addClassifications ( @ PathParam ( "guid" ) final String guid , List < AtlasClassification > classifications ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.addClassifications(" + guid + ")" ) ; } if ( StringUtils . isEmpty ( guid ) ) { throw new AtlasBaseException ( AtlasErrorCode . INSTANCE_GUID_NOT_FOUND , guid ) ; } entitiesStore . addClassifications ( guid , classifications ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Adds classifications to an existing entity represented by a guid .
921
@ Path ( "/guid/{guid}/classifications" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public void updateClassification ( @ PathParam ( "guid" ) final String guid , List < AtlasClassification > classifications ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.updateClassification(" + guid + ")" ) ; } if ( StringUtils . isEmpty ( guid ) ) { throw new AtlasBaseException ( AtlasErrorCode . INSTANCE_GUID_NOT_FOUND , guid ) ; } entitiesStore . updateClassifications ( guid , classifications ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Updates classifications to an existing entity represented by a guid .
922
@ Path ( "/guid/{guid}/classification/{classificationName}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public void deleteClassification ( @ PathParam ( "guid" ) String guid , @ PathParam ( "classificationName" ) final String classificationName ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.deleteClassification(" + guid + "," + classificationName + ")" ) ; } if ( StringUtils . isEmpty ( guid ) ) { throw new AtlasBaseException ( AtlasErrorCode . INSTANCE_GUID_NOT_FOUND , guid ) ; } ensureClassificationType ( classificationName ) ; entitiesStore . deleteClassifications ( guid , new ArrayList < String > ( ) { { add ( classificationName ) ; } } ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Deletes a given classification from an existing entity represented by a guid .
923
@ Path ( "/bulk" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasEntitiesWithExtInfo getByGuids ( @ QueryParam ( "guid" ) List < String > guids ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.getByGuids(" + guids + ")" ) ; } if ( CollectionUtils . isEmpty ( guids ) ) { throw new AtlasBaseException ( AtlasErrorCode . INSTANCE_GUID_NOT_FOUND , guids ) ; } return entitiesStore . getByIds ( guids ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Bulk API to retrieve list of entities identified by its GUIDs .
924
@ Path ( "/bulk" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public EntityMutationResponse deleteByGuids ( @ QueryParam ( "guid" ) final List < String > guids ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.deleteByGuids(" + guids + ")" ) ; } return entitiesStore . deleteByIds ( guids ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Bulk API to delete list of entities identified by its GUIDs
925
@ Path ( "/bulk/classification" ) @ Consumes ( { Servlets . JSON_MEDIA_TYPE , MediaType . APPLICATION_JSON } ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public void addClassification ( ClassificationAssociateRequest request ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityREST.addClassification(" + request + ")" ) ; } AtlasClassification classification = request == null ? null : request . getClassification ( ) ; List < String > entityGuids = request == null ? null : request . getEntityGuids ( ) ; if ( classification == null || StringUtils . isEmpty ( classification . getTypeName ( ) ) ) { throw new AtlasBaseException ( AtlasErrorCode . INVALID_PARAMETERS , "no classification" ) ; } if ( CollectionUtils . isEmpty ( entityGuids ) ) { throw new AtlasBaseException ( AtlasErrorCode . INVALID_PARAMETERS , "empty guid list" ) ; } entitiesStore . addClassification ( entityGuids , classification ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Bulk API to associate a tag to multiple entities
926
private void validateUniqueAttribute ( AtlasEntityType entityType , Map < String , Object > attributes ) throws AtlasBaseException { if ( MapUtils . isEmpty ( attributes ) ) { throw new AtlasBaseException ( AtlasErrorCode . ATTRIBUTE_UNIQUE_INVALID , entityType . getTypeName ( ) , "" ) ; } for ( String attributeName : attributes . keySet ( ) ) { AtlasAttributeDef attribute = entityType . getAttributeDef ( attributeName ) ; if ( attribute == null || ! attribute . getIsUnique ( ) ) { throw new AtlasBaseException ( AtlasErrorCode . ATTRIBUTE_UNIQUE_INVALID , entityType . getTypeName ( ) , attributeName ) ; } } }
Validate that each attribute given is an unique attribute
927
public static < T > T notNull ( T obj , String name ) { if ( obj == null ) { throw new IllegalArgumentException ( name + " cannot be null" ) ; } return obj ; }
Check that a value is not null . If null throws an IllegalArgumentException .
928
public static < T > Collection < T > notEmpty ( Collection < T > list , String name ) { notNull ( list , name ) ; if ( list . isEmpty ( ) ) { throw new IllegalArgumentException ( String . format ( "Collection %s is empty" , name ) ) ; } return list ; }
Check that a list is not null and not empty .
929
public static void lessThan ( long value , long maxValue , String name ) { if ( value <= 0 ) { throw new IllegalArgumentException ( name + " should be > 0, current value " + value ) ; } if ( value > maxValue ) { throw new IllegalArgumentException ( name + " should be <= " + maxValue + ", current value " + value ) ; } }
Checks that the given value is < = max value .
930
@ Path ( "/typedef/name/{name}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasBaseTypeDef getTypeDefByName ( @ PathParam ( "name" ) String name ) throws AtlasBaseException { AtlasBaseTypeDef ret = typeDefStore . getByName ( name ) ; return ret ; }
Get type definition by it s name
931
@ Path ( "/enumdef/guid/{guid}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasEnumDef getEnumDefByGuid ( @ PathParam ( "guid" ) String guid ) throws AtlasBaseException { AtlasEnumDef ret = typeDefStore . getEnumDefByGuid ( guid ) ; return ret ; }
Get the enum definition for the given guid
932
@ Path ( "/structdef/guid/{guid}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasStructDef getStructDefByGuid ( @ PathParam ( "guid" ) String guid ) throws AtlasBaseException { AtlasStructDef ret = typeDefStore . getStructDefByGuid ( guid ) ; return ret ; }
Get the struct definition for the given guid
933
@ Path ( "/classificationdef/guid/{guid}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasClassificationDef getClassificationDefByGuid ( @ PathParam ( "guid" ) String guid ) throws AtlasBaseException { AtlasClassificationDef ret = typeDefStore . getClassificationDefByGuid ( guid ) ; return ret ; }
Get the classification definition for the given guid
934
@ Path ( "/entitydef/guid/{guid}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasEntityDef getEntityDefByGuid ( @ PathParam ( "guid" ) String guid ) throws AtlasBaseException { AtlasEntityDef ret = typeDefStore . getEntityDefByGuid ( guid ) ; return ret ; }
Get the Entity definition for the given guid
935
@ Path ( "/relationshipdef/guid/{guid}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasRelationshipDef getRelationshipDefByGuid ( @ PathParam ( "guid" ) String guid ) throws AtlasBaseException { AtlasRelationshipDef ret = typeDefStore . getRelationshipDefByGuid ( guid ) ; return ret ; }
Get the relationship definition for the given guid
936
private SearchFilter getSearchFilter ( HttpServletRequest httpServletRequest ) { SearchFilter ret = new SearchFilter ( ) ; Set < String > keySet = httpServletRequest . getParameterMap ( ) . keySet ( ) ; for ( String key : keySet ) { ret . setParam ( String . valueOf ( key ) , String . valueOf ( httpServletRequest . getParameter ( key ) ) ) ; } return ret ; }
Populate a SearchFilter on the basis of the Query Parameters
937
public boolean equalsContents ( Object o ) { if ( this == o ) { return true ; } if ( o == null ) { return false ; } if ( o . getClass ( ) != getClass ( ) ) { return false ; } if ( ! super . equalsContents ( o ) ) { return false ; } Referenceable obj = ( Referenceable ) o ; if ( ! traitNames . equals ( obj . getTraits ( ) ) ) { return false ; } return true ; }
Matches traits values associated with this Referenceable and skips the id match
938
private void validateEntityAssociations ( String guid , List < AtlasClassification > classifications ) throws AtlasBaseException { List < String > entityClassifications = getClassificationNames ( guid ) ; for ( AtlasClassification classification : classifications ) { String newClassification = classification . getTypeName ( ) ; if ( CollectionUtils . isNotEmpty ( entityClassifications ) && entityClassifications . contains ( newClassification ) ) { throw new AtlasBaseException ( AtlasErrorCode . INVALID_PARAMETERS , "entity: " + guid + ", already associated with classification: " + newClassification ) ; } } }
Validate if classification is not already associated with the entities
939
public static AtlasElementPropertyConfig includeProperties ( final Set < String > vertexPropertyKeys , final Set < String > edgePropertyKeys ) { return new AtlasElementPropertyConfig ( vertexPropertyKeys , edgePropertyKeys , ElementPropertiesRule . INCLUDE , ElementPropertiesRule . INCLUDE ) ; }
Construct a configuration that includes the specified properties from both vertices and edges .
940
public static AtlasElementPropertyConfig excludeProperties ( final Set < String > vertexPropertyKeys , final Set < String > edgePropertyKeys ) { return new AtlasElementPropertyConfig ( vertexPropertyKeys , edgePropertyKeys , ElementPropertiesRule . EXCLUDE , ElementPropertiesRule . EXCLUDE ) ; }
Construct a configuration that excludes the specified properties from both vertices and edges .
941
@ Path ( "/dsl" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasSearchResult searchUsingDSL ( @ QueryParam ( "query" ) String query , @ QueryParam ( "typeName" ) String typeName , @ QueryParam ( "classification" ) String classification , @ QueryParam ( "limit" ) int limit , @ QueryParam ( "offset" ) int offset ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "DiscoveryREST.searchUsingDSL(" + query + "," + typeName + "," + classification + "," + limit + "," + offset + ")" ) ; } String queryStr = query == null ? "" : query ; if ( StringUtils . isNoneEmpty ( typeName ) ) { queryStr = escapeTypeName ( typeName ) + " " + queryStr ; } if ( StringUtils . isNoneEmpty ( classification ) ) { if ( StringUtils . isEmpty ( query ) ) { queryStr += ( " isa " + classification ) ; } } return atlasDiscoveryService . searchUsingDslQuery ( queryStr , limit , offset ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Retrieve data for the specified DSL
942
@ Path ( "/attribute" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public AtlasSearchResult searchUsingAttribute ( @ QueryParam ( "attrName" ) String attrName , @ QueryParam ( "attrValuePrefix" ) String attrValuePrefix , @ QueryParam ( "typeName" ) String typeName , @ QueryParam ( "limit" ) int limit , @ QueryParam ( "offset" ) int offset ) throws AtlasBaseException { AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "DiscoveryREST.searchUsingAttribute(" + attrName + "," + attrValuePrefix + "," + typeName + "," + limit + "," + offset + ")" ) ; } if ( StringUtils . isEmpty ( attrName ) && StringUtils . isEmpty ( attrValuePrefix ) ) { throw new AtlasBaseException ( AtlasErrorCode . INVALID_PARAMETERS , String . format ( "attrName : {0}, attrValue: {1} for attribute search." , attrName , attrValuePrefix ) ) ; } return atlasDiscoveryService . searchUsingBasicQuery ( null , typeName , null , attrName , attrValuePrefix , true , limit , offset ) ; } finally { AtlasPerfTracer . log ( perf ) ; } }
Retrieve data for the specified attribute search query
943
@ Path ( "{guid}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response getEntityDefinition ( @ PathParam ( "guid" ) String guid ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> EntityResource.getEntityDefinition({})" , guid ) ; } AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityResource.getEntityDefinition(" + guid + ")" ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching entity definition for guid={} " , guid ) ; } guid = ParamChecker . notEmpty ( guid , "guid cannot be null" ) ; final String entityDefinition = metadataService . getEntityDefinitionJson ( guid ) ; JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; Response . Status status = Response . Status . NOT_FOUND ; if ( entityDefinition != null ) { response . put ( AtlasClient . DEFINITION , new JSONObject ( entityDefinition ) ) ; status = Response . Status . OK ; } else { response . put ( AtlasClient . ERROR , Servlets . escapeJsonString ( String . format ( "An entity with GUID={%s} does not exist" , guid ) ) ) ; } return Response . status ( status ) . entity ( response ) . build ( ) ; } catch ( EntityNotFoundException e ) { LOG . error ( "An entity with GUID={} does not exist " , guid , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . NOT_FOUND ) ) ; } catch ( AtlasException | IllegalArgumentException e ) { LOG . error ( "Bad GUID={} " , guid , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get instance definition for GUID {}" , guid , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get instance definition for GUID {}" , guid , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== EntityResource.getEntityDefinition({})" , guid ) ; } } }
Fetch the complete definition of an entity given its GUID .
944
public Response getEntityListByType ( String entityType ) { try { Preconditions . checkNotNull ( entityType , "Entity type cannot be null" ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching entity list for type={} " , entityType ) ; } final List < String > entityList = metadataService . getEntityList ( entityType ) ; JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; response . put ( AtlasClient . TYPENAME , entityType ) ; response . put ( AtlasClient . RESULTS , new JSONArray ( entityList ) ) ; response . put ( AtlasClient . COUNT , entityList . size ( ) ) ; return Response . ok ( response ) . build ( ) ; } catch ( NullPointerException e ) { LOG . error ( "Entity type cannot be null" , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( AtlasException | IllegalArgumentException e ) { LOG . error ( "Unable to get entity list for type {}" , entityType , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get entity list for type {}" , entityType , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get entity list for type {}" , entityType , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } }
Gets the list of entities for a given entity type .
945
public Response getEntityDefinitionByAttribute ( String entityType , String attribute , String value ) { try { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching entity definition for type={}, qualified name={}" , entityType , value ) ; } entityType = ParamChecker . notEmpty ( entityType , "Entity type cannot be null" ) ; attribute = ParamChecker . notEmpty ( attribute , "attribute name cannot be null" ) ; value = ParamChecker . notEmpty ( value , "attribute value cannot be null" ) ; Map < String , Object > attributes = new HashMap < > ( ) ; attributes . put ( attribute , value ) ; AtlasEntityWithExtInfo entityInfo ; try { entityInfo = entitiesStore . getByUniqueAttributes ( getEntityType ( entityType ) , attributes ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Cannot find entity with type: {}, attribute: {} and value: {}" , entityType , attribute , value ) ; throw toWebApplicationException ( e ) ; } String entityDefinition = null ; if ( entityInfo != null ) { AtlasEntity entity = entityInfo . getEntity ( ) ; final ITypedReferenceableInstance instance = restAdapters . getITypedReferenceable ( entity ) ; entityDefinition = InstanceSerialization . toJson ( instance , true ) ; } JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; Response . Status status = Response . Status . NOT_FOUND ; if ( entityDefinition != null ) { response . put ( AtlasClient . DEFINITION , new JSONObject ( entityDefinition ) ) ; status = Response . Status . OK ; } else { response . put ( AtlasClient . ERROR , Servlets . escapeJsonString ( String . format ( "An entity with type={%s}, " + "qualifiedName={%s} does not exist" , entityType , value ) ) ) ; } return Response . status ( status ) . entity ( response ) . build ( ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Unable to get instance definition for type={}, qualifiedName={}" , entityType , value , e ) ; throw toWebApplicationException ( e ) ; } catch ( IllegalArgumentException e ) { LOG . error ( "Bad type={}, qualifiedName={}" , entityType , value , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get instance definition for type={}, qualifiedName={}" , entityType , value , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get instance definition for type={}, qualifiedName={}" , entityType , value , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } }
Fetch the complete definition of an entity given its qualified name .
946
@ Path ( "{guid}/traitDefinitions" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response getTraitDefinitionsForEntity ( @ PathParam ( "guid" ) String guid ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> EntityResource.getTraitDefinitionsForEntity({})" , guid ) ; } AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityResource.getTraitDefinitionsForEntity(" + guid + ")" ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching all trait definitions for entity={}" , guid ) ; } final List < AtlasClassification > classifications = entitiesStore . getClassifications ( guid ) ; JSONArray traits = new JSONArray ( ) ; for ( AtlasClassification classification : classifications ) { IStruct trait = restAdapters . getTrait ( classification ) ; traits . put ( new JSONObject ( InstanceSerialization . toJson ( trait , true ) ) ) ; } JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; response . put ( AtlasClient . RESULTS , traits ) ; response . put ( AtlasClient . COUNT , traits . length ( ) ) ; return Response . ok ( response ) . build ( ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Unable to get trait definition for entity {}" , guid , e ) ; throw toWebApplicationException ( e ) ; } catch ( IllegalArgumentException e ) { LOG . error ( "Unable to get trait definition for entity {}" , guid , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get trait definitions for entity {}" , guid , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get trait definitions for entity {}" , guid , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== EntityResource.getTraitDefinitionsForEntity({})" , guid ) ; } } }
Fetches the trait definitions of all the traits associated to the given entity
947
@ Path ( "{guid}/traitDefinitions/{traitName}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response getTraitDefinitionForEntity ( @ PathParam ( "guid" ) String guid , @ PathParam ( "traitName" ) String traitName ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> EntityResource.getTraitDefinitionForEntity({}, {})" , guid , traitName ) ; } AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityResource.getTraitDefinitionForEntity(" + guid + ", " + traitName + ")" ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching trait definition for entity {} and trait name {}" , guid , traitName ) ; } final AtlasClassification classification = entitiesStore . getClassification ( guid , traitName ) ; IStruct traitDefinition = restAdapters . getTrait ( classification ) ; JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; response . put ( AtlasClient . RESULTS , new JSONObject ( InstanceSerialization . toJson ( traitDefinition , true ) ) ) ; return Response . ok ( response ) . build ( ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw toWebApplicationException ( e ) ; } catch ( IllegalArgumentException e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== EntityResource.getTraitDefinitionForEntity({}, {})" , guid , traitName ) ; } } }
Fetches the trait definition for an entity given its guid and trait name
948
@ Path ( "{guid}/audit" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response getAuditEvents ( @ PathParam ( "guid" ) String guid , @ QueryParam ( "startKey" ) String startKey , @ QueryParam ( "count" ) @ DefaultValue ( "100" ) short count ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> EntityResource.getAuditEvents({}, {}, {})" , guid , startKey , count ) ; } AtlasPerfTracer perf = null ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Audit events request for entity {}, start key {}, number of results required {}" , guid , startKey , count ) ; } try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityResource.getAuditEvents(" + guid + ", " + startKey + ", " + count + ")" ) ; } List < EntityAuditEvent > events = metadataService . getAuditEvents ( guid , startKey , count ) ; JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; response . put ( AtlasClient . EVENTS , getJSONArray ( events ) ) ; return Response . ok ( response ) . build ( ) ; } catch ( AtlasException | IllegalArgumentException e ) { LOG . error ( "Unable to get audit events for entity guid={} startKey={}" , guid , startKey , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get audit events for entity guid={} startKey={}" , guid , startKey , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get audit events for entity guid={} startKey={}" , guid , startKey , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== EntityResource.getAuditEvents({}, {}, {})" , guid , startKey , count ) ; } } }
Returns the entity audit events for a given entity id . The events are returned in the decreasing order of timestamp .
949
public boolean isOrderExpression ( GroovyExpression expr ) { if ( expr instanceof FunctionCallExpression ) { FunctionCallExpression functionCallExpression = ( FunctionCallExpression ) expr ; if ( functionCallExpression . getFunctionName ( ) . equals ( ORDER_METHOD ) ) { return true ; } } return false ; }
Determines if specified expression is an order method call
950
public GroovyExpression generateUnaryHasExpression ( GroovyExpression parent , String fieldName ) { return new FunctionCallExpression ( TraversalStepType . FILTER , parent , HAS_METHOD , new LiteralExpression ( fieldName ) ) ; }
Generates an expression which checks whether the vertices in the query have a field with the given name .
951
protected GroovyExpression generateLoopEmitExpression ( GraphPersistenceStrategies s , IDataType dataType ) { return typeTestExpression ( s , dataType . getName ( ) , getCurrentObjectExpression ( ) ) ; }
Generates the emit expression used in loop expressions .
952
public GroovyExpression generateAliasExpression ( GroovyExpression parent , String alias ) { return new FunctionCallExpression ( TraversalStepType . SIDE_EFFECT , parent , AS_METHOD , new LiteralExpression ( alias ) ) ; }
Generates an alias expression
953
public GroovyExpression generateAdjacentVerticesExpression ( GroovyExpression parent , AtlasEdgeDirection dir ) { return new FunctionCallExpression ( TraversalStepType . FLAT_MAP_TO_ELEMENTS , parent , getGremlinFunctionName ( dir ) ) ; }
Generates an expression that gets the vertices adjacent to the vertex in parent in the specified direction .
954
public GroovyExpression generateAdjacentVerticesExpression ( GroovyExpression parent , AtlasEdgeDirection dir , String label ) { return new FunctionCallExpression ( TraversalStepType . FLAT_MAP_TO_ELEMENTS , parent , getGremlinFunctionName ( dir ) , new LiteralExpression ( label ) ) ; }
Generates an expression that gets the vertices adjacent to the vertex in parent in the specified direction following only edges with the given label .
955
public GroovyExpression generateCountExpression ( GroovyExpression itExpr ) { GroovyExpression collectionExpr = new CastExpression ( itExpr , "Collection" ) ; return new FunctionCallExpression ( collectionExpr , "size" ) ; }
assumes cast already performed
956
public String getAliasNameIfRelevant ( GroovyExpression expr ) { if ( ! ( expr instanceof FunctionCallExpression ) ) { return null ; } FunctionCallExpression fc = ( FunctionCallExpression ) expr ; if ( ! fc . getFunctionName ( ) . equals ( AS_METHOD ) ) { return null ; } LiteralExpression aliasName = ( LiteralExpression ) fc . getArguments ( ) . get ( 0 ) ; return aliasName . getValue ( ) . toString ( ) ; }
Checks if the given expression is an alias expression and if so returns the alias from the expression . Otherwise null is returned .
957
@ Path ( "stack" ) @ Produces ( MediaType . TEXT_PLAIN ) public String getThreadDump ( ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> AdminResource.getThreadDump()" ) ; } ThreadGroup topThreadGroup = Thread . currentThread ( ) . getThreadGroup ( ) ; while ( topThreadGroup . getParent ( ) != null ) { topThreadGroup = topThreadGroup . getParent ( ) ; } Thread [ ] threads = new Thread [ topThreadGroup . activeCount ( ) ] ; int nr = topThreadGroup . enumerate ( threads ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < nr ; i ++ ) { builder . append ( threads [ i ] . getName ( ) ) . append ( "\nState: " ) . append ( threads [ i ] . getState ( ) ) . append ( "\n" ) ; String stackTrace = StringUtils . join ( threads [ i ] . getStackTrace ( ) , "\n" ) ; builder . append ( stackTrace ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== AdminResource.getThreadDump()" ) ; } return builder . toString ( ) ; }
Fetches the thread stack dump for this application .
958
@ Path ( "version" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response getVersion ( ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> AdminResource.getVersion()" ) ; } if ( version == null ) { try { PropertiesConfiguration configProperties = new PropertiesConfiguration ( "atlas-buildinfo.properties" ) ; JSONObject response = new JSONObject ( ) ; response . put ( "Version" , configProperties . getString ( "build.version" , "UNKNOWN" ) ) ; response . put ( "Name" , configProperties . getString ( "project.name" , "apache-atlas" ) ) ; response . put ( "Description" , configProperties . getString ( "project.description" , "Metadata Management and Data Governance Platform over Hadoop" ) ) ; version = Response . ok ( response ) . build ( ) ; } catch ( JSONException | ConfigurationException e ) { throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== AdminResource.getVersion()" ) ; } return version ; }
Fetches the version for this application .
959
private Referenceable registerDatabase ( String databaseName ) throws Exception { Referenceable dbRef = getDatabaseReference ( clusterName , databaseName ) ; Database db = hiveClient . getDatabase ( databaseName ) ; if ( db != null ) { if ( dbRef == null ) { dbRef = createDBInstance ( db ) ; dbRef = registerInstance ( dbRef ) ; } else { LOG . info ( "Database {} is already registered with id {}. Updating it." , databaseName , dbRef . getId ( ) . id ) ; dbRef = createOrUpdateDBInstance ( db , dbRef ) ; updateInstance ( dbRef ) ; } } return dbRef ; }
Checks if db is already registered else creates and registers db entity
960
private Referenceable registerInstance ( Referenceable referenceable ) throws Exception { String typeName = referenceable . getTypeName ( ) ; LOG . debug ( "creating instance of type {}" , typeName ) ; String entityJSON = InstanceSerialization . toJson ( referenceable , true ) ; LOG . debug ( "Submitting new entity {} = {}" , referenceable . getTypeName ( ) , entityJSON ) ; List < String > guids = getAtlasClient ( ) . createEntity ( entityJSON ) ; LOG . debug ( "created instance for type {}, guid: {}" , typeName , guids ) ; return new Referenceable ( guids . get ( guids . size ( ) - 1 ) , referenceable . getTypeName ( ) , null ) ; }
Registers an entity in atlas
961
private Referenceable getDatabaseReference ( String clusterName , String databaseName ) throws Exception { LOG . debug ( "Getting reference for database {}" , databaseName ) ; String typeName = HiveDataTypes . HIVE_DB . getName ( ) ; return getEntityReference ( typeName , getDBQualifiedName ( clusterName , databaseName ) ) ; }
Gets reference to the atlas entity for the database
962
public static String getDBQualifiedName ( String clusterName , String dbName ) { return String . format ( "%s@%s" , dbName . toLowerCase ( ) , clusterName ) ; }
Construct the qualified name used to uniquely identify a Database instance in Atlas .
963
private int importTables ( Referenceable databaseReferenceable , String databaseName , final boolean failOnError ) throws Exception { int tablesImported = 0 ; List < String > hiveTables = hiveClient . getAllTables ( databaseName ) ; LOG . info ( "Importing tables {} for db {}" , hiveTables . toString ( ) , databaseName ) ; for ( String tableName : hiveTables ) { int imported = importTable ( databaseReferenceable , databaseName , tableName , failOnError ) ; tablesImported += imported ; } if ( tablesImported == hiveTables . size ( ) ) { LOG . info ( "Successfully imported all {} tables from {} " , tablesImported , databaseName ) ; } else { LOG . error ( "Able to import {} tables out of {} tables from {}. Please check logs for import errors" , tablesImported , hiveTables . size ( ) , databaseName ) ; } return tablesImported ; }
Imports all tables for the given db
964
private Referenceable getTableReference ( Table hiveTable ) throws Exception { LOG . debug ( "Getting reference for table {}.{}" , hiveTable . getDbName ( ) , hiveTable . getTableName ( ) ) ; String typeName = HiveDataTypes . HIVE_TABLE . getName ( ) ; String tblQualifiedName = getTableQualifiedName ( getClusterName ( ) , hiveTable . getDbName ( ) , hiveTable . getTableName ( ) ) ; return getEntityReference ( typeName , tblQualifiedName ) ; }
Gets reference for the table
965
public Referenceable createTableInstance ( Referenceable dbReference , Table hiveTable ) throws AtlasHookException { return createOrUpdateTableInstance ( dbReference , null , hiveTable ) ; }
Create a new table instance in Atlas
966
public GroovyExpression apply ( GroovyExpression expr , OptimizationContext context ) { FunctionCallExpression exprAsFunction = ( FunctionCallExpression ) expr ; GroovyExpression result = exprAsFunction . getCaller ( ) ; List < GroovyExpression > nonExtractableArguments = new ArrayList < > ( ) ; for ( GroovyExpression argument : exprAsFunction . getArguments ( ) ) { if ( GremlinQueryOptimizer . isExtractable ( argument ) ) { result = GremlinQueryOptimizer . copyWithNewLeafNode ( ( AbstractFunctionExpression ) argument , result ) ; } else { logger_ . warn ( "Found non-extractable argument '{}' in the 'and' expression '{}'" , argument . toString ( ) , expr . toString ( ) ) ; nonExtractableArguments . add ( argument ) ; } } if ( ! nonExtractableArguments . isEmpty ( ) ) { result = factory . generateLogicalExpression ( result , "and" , nonExtractableArguments ) ; } return result ; }
Expands the given and expression . There is no need to recursively expand the children here . This method is called recursively by GremlinQueryOptimier on the children .
967
private void updateCurrentFunction ( AbstractFunctionExpression parentExpr ) { GroovyExpression expr = parentExpr . getCaller ( ) ; if ( expr instanceof AbstractFunctionExpression ) { AbstractFunctionExpression exprAsFunction = ( AbstractFunctionExpression ) expr ; GroovyExpression exprCaller = exprAsFunction . getCaller ( ) ; parentExpr . setCaller ( exprCaller ) ; updateCurrentFunctionDefintion ( exprAsFunction ) ; } }
Adds the caller of parentExpr to the current body of the last function that was created .
968
private boolean creatingFunctionShortensGremlin ( GroovyExpression headExpr ) { int tailLength = getTailLength ( ) ; int length = headExpr . toString ( ) . length ( ) - tailLength ; int overhead = 0 ; if ( nextFunctionBodyStart instanceof AbstractFunctionExpression ) { overhead = functionDefLength ; } else { overhead = INITIAL_FUNCTION_DEF_LENGTH ; } overhead += FUNCTION_CALL_OVERHEAD * scaleFactor ; return length * scaleFactor > overhead + length ; }
the overall length of the Groovy script .
969
private AtlasEdge createInverseReference ( AtlasAttribute inverseAttribute , AtlasStructType inverseAttributeType , AtlasVertex inverseVertex , AtlasVertex vertex ) throws AtlasBaseException { String propertyName = AtlasGraphUtilsV1 . getQualifiedAttributePropertyKey ( inverseAttributeType , inverseAttribute . getName ( ) ) ; String inverseEdgeLabel = AtlasGraphUtilsV1 . getEdgeLabel ( propertyName ) ; AtlasEdge ret ; try { ret = graphHelper . getOrCreateEdge ( inverseVertex , vertex , inverseEdgeLabel ) ; } catch ( RepositoryException e ) { throw new AtlasBaseException ( AtlasErrorCode . INTERNAL_ERROR , e ) ; } return ret ; }
legacy method to create edges for inverse reference
970
private String getRootLoggerDirectory ( ) { String rootLoggerDirectory = null ; org . apache . log4j . Logger rootLogger = org . apache . log4j . Logger . getRootLogger ( ) ; Enumeration allAppenders = rootLogger . getAllAppenders ( ) ; if ( allAppenders != null ) { while ( allAppenders . hasMoreElements ( ) ) { Appender appender = ( Appender ) allAppenders . nextElement ( ) ; if ( appender instanceof FileAppender ) { FileAppender fileAppender = ( FileAppender ) appender ; String rootLoggerFile = fileAppender . getFile ( ) ; rootLoggerDirectory = new File ( rootLoggerFile ) . getParent ( ) ; break ; } } } return rootLoggerDirectory ; }
Get the root logger file location under which the failed log messages will be written .
971
int assignPosition ( Id id ) throws RepositoryException { int pos = - 1 ; if ( ! freePositions . isEmpty ( ) ) { pos = freePositions . remove ( 0 ) ; } else { pos = nextPos ++ ; ensureCapacity ( pos ) ; } idPosMap . put ( id , pos ) ; for ( HierarchicalTypeStore s : superTypeStores ) { s . assignPosition ( id ) ; } return pos ; }
Assign a storage position to an Id . - try to assign from freePositions - ensure storage capacity . - add entry in idPosMap .
972
void releaseId ( Id id ) { Integer pos = idPosMap . get ( id ) ; if ( pos != null ) { idPosMap . remove ( id ) ; freePositions . add ( pos ) ; for ( HierarchicalTypeStore s : superTypeStores ) { s . releaseId ( id ) ; } } }
- remove from idPosMap - add to freePositions .
973
void store ( ReferenceableInstance i ) throws RepositoryException { int pos = idPosMap . get ( i . getId ( ) ) ; typeNameList . set ( pos , i . getTypeName ( ) ) ; storeFields ( pos , i ) ; for ( HierarchicalTypeStore s : superTypeStores ) { s . store ( i ) ; } }
- store the typeName - store the immediate attributes in the respective IAttributeStore - call store on each SuperType .
974
void load ( ReferenceableInstance i ) throws RepositoryException { int pos = idPosMap . get ( i . getId ( ) ) ; loadFields ( pos , i ) ; for ( HierarchicalTypeStore s : superTypeStores ) { s . load ( i ) ; } }
- copy over the immediate attribute values from the respective IAttributeStore - call load on each SuperType .
975
public static String getMessageJson ( Object message ) { VersionedMessage < ? > versionedMessage = new VersionedMessage < > ( CURRENT_MESSAGE_VERSION , message ) ; return GSON . toJson ( versionedMessage ) ; }
Get the notification message JSON from the given object .
976
public synchronized List < EntityAuditEvent > listEvents ( String entityId , String startKey , short maxResults ) throws AtlasException { List < EntityAuditEvent > events = new ArrayList < > ( ) ; String myStartKey = startKey ; if ( myStartKey == null ) { myStartKey = entityId ; } SortedMap < String , EntityAuditEvent > subMap = auditEvents . tailMap ( myStartKey ) ; for ( EntityAuditEvent event : subMap . values ( ) ) { if ( events . size ( ) < maxResults && event . getEntityId ( ) . equals ( entityId ) ) { events . add ( event ) ; } } return events ; }
while we are iterating through the map
977
public static void validateUpdate ( FieldMapping oldFieldMapping , FieldMapping newFieldMapping ) throws TypeUpdateException { Map < String , AttributeInfo > newFields = newFieldMapping . fields ; for ( AttributeInfo attribute : oldFieldMapping . fields . values ( ) ) { if ( newFields . containsKey ( attribute . name ) ) { AttributeInfo newAttribute = newFields . get ( attribute . name ) ; if ( ! newAttribute . equals ( attribute ) ) { if ( attribute . multiplicity == Multiplicity . REQUIRED && newAttribute . multiplicity == Multiplicity . OPTIONAL ) { continue ; } else { throw new TypeUpdateException ( "Attribute " + attribute . name + " can't be updated" ) ; } } } else { throw new TypeUpdateException ( "Old Attribute " + attribute . name + " is missing" ) ; } } Set < String > newAttributes = new HashSet < > ( ImmutableList . copyOf ( newFields . keySet ( ) ) ) ; newAttributes . removeAll ( oldFieldMapping . fields . keySet ( ) ) ; for ( String attributeName : newAttributes ) { AttributeInfo newAttribute = newFields . get ( attributeName ) ; if ( newAttribute . multiplicity == Multiplicity . REQUIRED ) { throw new TypeUpdateException ( "Can't add required attribute " + attributeName ) ; } } }
Validates that the old field mapping can be replaced with new field mapping
978
public static Direction createDirection ( AtlasEdgeDirection dir ) { switch ( dir ) { case IN : return Direction . IN ; case OUT : return Direction . OUT ; case BOTH : return Direction . BOTH ; default : throw new RuntimeException ( "Unrecognized direction: " + dir ) ; } }
Retrieves the titan direction corresponding to the given AtlasEdgeDirection .
979
public StructType defineQueryResultType ( String name , Map < String , IDataType > tempTypes , AttributeDefinition ... attrDefs ) throws AtlasException { AttributeInfo [ ] infos = new AttributeInfo [ attrDefs . length ] ; for ( int i = 0 ; i < attrDefs . length ; i ++ ) { infos [ i ] = new AttributeInfo ( this , attrDefs [ i ] , tempTypes ) ; } return new StructType ( this , name , null , infos ) ; }
construct a temporary StructType for a Query Result . This is not registered in the typeSystem . The attributes in the typeDefinition can only reference permanent types .
980
@ Path ( "search" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response search ( @ QueryParam ( "query" ) String query , @ DefaultValue ( LIMIT_OFFSET_DEFAULT ) @ QueryParam ( "limit" ) int limit , @ DefaultValue ( LIMIT_OFFSET_DEFAULT ) @ QueryParam ( "offset" ) int offset ) { boolean dslQueryFailed = false ; Response response = null ; try { response = searchUsingQueryDSL ( query , limit , offset ) ; if ( response . getStatus ( ) != Response . Status . OK . getStatusCode ( ) ) { dslQueryFailed = true ; } } catch ( Exception e ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Error while running DSL. Switching to fulltext for query {}" , query , e ) ; } dslQueryFailed = true ; } if ( dslQueryFailed ) { response = searchUsingFullText ( query , limit , offset ) ; } return response ; }
Search using a given query .
981
@ Path ( "search/dsl" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response searchUsingQueryDSL ( @ QueryParam ( "query" ) String dslQuery , @ DefaultValue ( LIMIT_OFFSET_DEFAULT ) @ QueryParam ( "limit" ) int limit , @ DefaultValue ( LIMIT_OFFSET_DEFAULT ) @ QueryParam ( "offset" ) int offset ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> MetadataDiscoveryResource.searchUsingQueryDSL({}, {}, {})" , dslQuery , limit , offset ) ; } AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "MetadataDiscoveryResource.searchUsingQueryDSL(" + dslQuery + ", " + limit + ", " + offset + ")" ) ; } dslQuery = ParamChecker . notEmpty ( dslQuery , "dslQuery cannot be null" ) ; QueryParams queryParams = validateQueryParams ( limit , offset ) ; final String jsonResultStr = discoveryService . searchByDSL ( dslQuery , queryParams ) ; JSONObject response = new DSLJSONResponseBuilder ( ) . results ( jsonResultStr ) . query ( dslQuery ) . build ( ) ; return Response . ok ( response ) . build ( ) ; } catch ( DiscoveryException | IllegalArgumentException e ) { LOG . error ( "Unable to get entity list for dslQuery {}" , dslQuery , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get entity list for dslQuery {}" , dslQuery , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get entity list for dslQuery {}" , dslQuery , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== MetadataDiscoveryResource.searchUsingQueryDSL({}, {}, {})" , dslQuery , limit , offset ) ; } } }
Search using query DSL format .
982
@ Path ( "search/gremlin" ) @ Consumes ( Servlets . JSON_MEDIA_TYPE ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response searchUsingGremlinQuery ( @ QueryParam ( "query" ) String gremlinQuery ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> MetadataDiscoveryResource.searchUsingGremlinQuery({})" , gremlinQuery ) ; } AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "MetadataDiscoveryResource.searchUsingGremlinQuery(" + gremlinQuery + ")" ) ; } gremlinQuery = ParamChecker . notEmpty ( gremlinQuery , "gremlinQuery cannot be null or empty" ) ; final List < Map < String , String > > results = discoveryService . searchByGremlin ( gremlinQuery ) ; JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; response . put ( AtlasClient . QUERY , gremlinQuery ) ; response . put ( AtlasClient . QUERY_TYPE , QUERY_TYPE_GREMLIN ) ; JSONArray list = new JSONArray ( ) ; for ( Map < String , String > result : results ) { list . put ( new JSONObject ( result ) ) ; } response . put ( AtlasClient . RESULTS , list ) ; response . put ( AtlasClient . COUNT , list . length ( ) ) ; return Response . ok ( response ) . build ( ) ; } catch ( DiscoveryException | IllegalArgumentException e ) { LOG . error ( "Unable to get entity list for gremlinQuery {}" , gremlinQuery , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get entity list for gremlinQuery {}" , gremlinQuery , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get entity list for gremlinQuery {}" , gremlinQuery , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== MetadataDiscoveryResource.searchUsingGremlinQuery({})" , gremlinQuery ) ; } } }
Search using raw gremlin query format .
983
public AndCondition copy ( ) { AndCondition builder = new AndCondition ( ) ; builder . children . addAll ( children ) ; return builder ; }
Makes a copy of this AndExpr .
984
public < V , E > NativeTitanGraphQuery < V , E > create ( NativeTitanQueryFactory < V , E > factory ) { NativeTitanGraphQuery < V , E > query = factory . createNativeTitanQuery ( ) ; for ( QueryPredicate predicate : children ) { predicate . addTo ( query ) ; } return query ; }
Creates a NativeTitanGraphQuery that can be used to evaluate this condition .
985
public void cache ( AtlasEntityWithExtInfo entity ) { if ( entity != null && entity . getEntity ( ) != null && entity . getEntity ( ) . getGuid ( ) != null ) { entityCacheV2 . put ( entity . getEntity ( ) . getGuid ( ) , entity ) ; } }
Adds the specified instance to the cache
986
public List < Map < String , String > > searchByGremlin ( String gremlinQuery ) throws DiscoveryException { LOG . debug ( "Executing gremlin query={}" , gremlinQuery ) ; try { Object o = graph . executeGremlinScript ( gremlinQuery , false ) ; return extractResult ( o ) ; } catch ( AtlasBaseException e ) { throw new DiscoveryException ( e ) ; } }
Assumes the User is familiar with the persistence structure of the Repository . The given query is run uninterpreted against the underlying Graph Store . The results are returned as a List of Rows . each row is a Map of Key Value pairs .
987
private static void addSolr5Index ( ) { try { Field field = StandardIndexProvider . class . getDeclaredField ( "ALL_MANAGER_CLASSES" ) ; field . setAccessible ( true ) ; Field modifiersField = Field . class . getDeclaredField ( "modifiers" ) ; modifiersField . setAccessible ( true ) ; modifiersField . setInt ( field , field . getModifiers ( ) & ~ Modifier . FINAL ) ; Map < String , String > customMap = new HashMap < > ( StandardIndexProvider . getAllProviderClasses ( ) ) ; customMap . put ( "solr" , Solr5Index . class . getName ( ) ) ; customMap . put ( "solr5" , Solr5Index . class . getName ( ) ) ; ImmutableMap < String , String > immap = ImmutableMap . copyOf ( customMap ) ; field . set ( null , immap ) ; LOG . debug ( "Injected solr5 index - {}" , Solr5Index . class . getName ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Titan loads index backend name to implementation using StandardIndexProvider . ALL_MANAGER_CLASSES But StandardIndexProvider . ALL_MANAGER_CLASSES is a private static final ImmutableMap Only way to inject Solr5Index is to modify this field . So using hacky reflection to add Sol5Index
988
private String getPassword ( org . apache . commons . configuration . Configuration config , String key ) throws IOException { String password ; String provider = config . getString ( CERT_STORES_CREDENTIAL_PROVIDER_PATH ) ; if ( provider != null ) { LOG . info ( "Attempting to retrieve password from configured credential provider path" ) ; Configuration c = new Configuration ( ) ; c . set ( CredentialProviderFactory . CREDENTIAL_PROVIDER_PATH , provider ) ; CredentialProvider credentialProvider = CredentialProviderFactory . getProviders ( c ) . get ( 0 ) ; CredentialProvider . CredentialEntry entry = credentialProvider . getCredentialEntry ( key ) ; if ( entry == null ) { throw new IOException ( String . format ( "No credential entry found for %s. " + "Please create an entry in the configured credential provider" , key ) ) ; } else { password = String . valueOf ( entry . getCredential ( ) ) ; } } else { throw new IOException ( "No credential provider path configured for storage of certificate store passwords" ) ; } return password ; }
Retrieves a password from a configured credential provider or prompts for the password and stores it in the configured credential provider .
989
protected org . apache . commons . configuration . Configuration getConfiguration ( ) { try { return ApplicationProperties . get ( ) ; } catch ( AtlasException e ) { throw new RuntimeException ( "Unable to load configuration: " + ApplicationProperties . APPLICATION_PROPERTIES ) ; } }
Returns the application configuration .
990
public void andWith ( OrCondition other ) { List < AndCondition > expandedExpressionChildren = new ArrayList < > ( ) ; for ( AndCondition otherExprTerm : other . getAndTerms ( ) ) { for ( AndCondition currentExpr : children ) { AndCondition currentAndConditionCopy = currentExpr . copy ( ) ; currentAndConditionCopy . andWith ( otherExprTerm . getTerms ( ) ) ; expandedExpressionChildren . add ( currentAndConditionCopy ) ; } } children = expandedExpressionChildren ; }
Updates this OrCondition in place so that it matches vertices that satisfy the current OrCondition AND that satisfy the provided OrCondition .
991
public static boolean validate ( final String date ) { Matcher matcher = PATTERN . matcher ( date ) ; if ( matcher . matches ( ) ) { matcher . reset ( ) ; if ( matcher . find ( ) ) { int year = Integer . parseInt ( matcher . group ( 1 ) ) ; String month = matcher . group ( 2 ) ; String day = matcher . group ( 3 ) ; if ( day . equals ( "31" ) && ( month . equals ( "4" ) || month . equals ( "6" ) || month . equals ( "9" ) || month . equals ( "11" ) || month . equals ( "04" ) || month . equals ( "06" ) || month . equals ( "09" ) ) ) { return false ; } else if ( month . equals ( "2" ) || month . equals ( "02" ) ) { if ( year % 4 == 0 ) { return ! ( day . equals ( "30" ) || day . equals ( "31" ) ) ; } else { return ! ( day . equals ( "29" ) || day . equals ( "30" ) || day . equals ( "31" ) ) ; } } else { return true ; } } else { return false ; } } else { return false ; } }
Validate date format with regular expression .
992
private List < GroovyExpression > expandOrs ( GroovyExpression expr , OptimizationContext context ) { if ( GremlinQueryOptimizer . isOrExpression ( expr ) ) { return expandOrFunction ( expr , context ) ; } return processOtherExpression ( expr , context ) ; }
Recursively traverses the given expression expanding or expressions wherever they are found .
993
private List < GroovyExpression > expandOrFunction ( GroovyExpression expr , OptimizationContext context ) { FunctionCallExpression functionCall = ( FunctionCallExpression ) expr ; GroovyExpression caller = functionCall . getCaller ( ) ; List < GroovyExpression > updatedCallers = null ; if ( caller != null ) { updatedCallers = expandOrs ( caller , context ) ; } else { updatedCallers = Collections . singletonList ( null ) ; } UpdatedExpressions newArguments = getUpdatedChildren ( functionCall . getArguments ( ) , context ) ; List < GroovyExpression > allUpdatedArguments = new ArrayList < > ( ) ; for ( List < GroovyExpression > exprs : newArguments . getUpdatedChildren ( ) ) { allUpdatedArguments . addAll ( exprs ) ; } List < AbstractFunctionExpression > extractableArguments = new ArrayList < > ( ) ; List < GroovyExpression > nonExtractableArguments = new ArrayList < > ( ) ; for ( GroovyExpression argument : allUpdatedArguments ) { if ( GremlinQueryOptimizer . isExtractable ( argument ) ) { extractableArguments . add ( ( AbstractFunctionExpression ) argument ) ; } else { logger_ . warn ( "Found non-extractable argument '{}; in the 'or' expression '{}'" , argument . toString ( ) , expr . toString ( ) ) ; nonExtractableArguments . add ( argument ) ; } } List < GroovyExpression > result = new ArrayList < > ( ) ; for ( GroovyExpression updatedCaller : updatedCallers ) { for ( AbstractFunctionExpression arg : extractableArguments ) { GroovyExpression updated = GremlinQueryOptimizer . copyWithNewLeafNode ( arg , updatedCaller ) ; result . add ( updated ) ; } if ( ! nonExtractableArguments . isEmpty ( ) ) { result . add ( factory . generateLogicalExpression ( updatedCaller , "or" , nonExtractableArguments ) ) ; } } return result ; }
This method takes an or expression and expands it into multiple expressions .
994
private List < GroovyExpression > processOtherExpression ( GroovyExpression source , OptimizationContext context ) { UpdatedExpressions updatedChildren = getUpdatedChildren ( source , context ) ; if ( ! updatedChildren . hasChanges ( ) ) { return Collections . singletonList ( source ) ; } List < GroovyExpression > result = new ArrayList < GroovyExpression > ( ) ; List < List < GroovyExpression > > updateChildLists = Lists . cartesianProduct ( updatedChildren . getUpdatedChildren ( ) ) ; for ( List < GroovyExpression > updatedChildList : updateChildLists ) { result . add ( source . copy ( updatedChildList ) ) ; } return result ; }
This is called when we encounter an expression that is not an or for example an and expressio . For these expressions we process the children and create copies with the cartesian product of the updated arguments .
995
protected List < GrantedAuthority > getAuthorities ( String username ) { final List < GrantedAuthority > grantedAuths = new ArrayList < > ( ) ; grantedAuths . add ( new SimpleGrantedAuthority ( "DATA_SCIENTIST" ) ) ; return grantedAuths ; }
This method will be modified when actual roles are introduced .
996
protected void checkVersion ( VersionedMessage < T > versionedMessage , String messageJson ) { int comp = versionedMessage . compareVersion ( expectedVersion ) ; if ( comp > 0 ) { String msg = String . format ( VERSION_MISMATCH_MSG , expectedVersion , versionedMessage . getVersion ( ) , messageJson ) ; notificationLogger . error ( msg ) ; throw new IncompatibleVersionException ( msg ) ; } if ( comp < 0 ) { notificationLogger . info ( String . format ( VERSION_MISMATCH_MSG , expectedVersion , versionedMessage . getVersion ( ) , messageJson ) ) ; } }
Check the message version against the expected version .
997
public String getOutputsGraph ( String datasetName ) throws AtlasException { LOG . info ( "Fetching lineage outputs graph for datasetName={}" , datasetName ) ; datasetName = ParamChecker . notEmpty ( datasetName , "dataset name" ) ; TypeUtils . Pair < String , String > typeIdPair = validateDatasetNameExists ( datasetName ) ; return getOutputsGraphForId ( typeIdPair . right ) ; }
Return the lineage outputs graph for the given datasetName .
998
public String getInputsGraph ( String tableName ) throws AtlasException { LOG . info ( "Fetching lineage inputs graph for tableName={}" , tableName ) ; tableName = ParamChecker . notEmpty ( tableName , "table name" ) ; TypeUtils . Pair < String , String > typeIdPair = validateDatasetNameExists ( tableName ) ; return getInputsGraphForId ( typeIdPair . right ) ; }
Return the lineage inputs graph for the given tableName .
999
public String getSchema ( String datasetName ) throws AtlasException { datasetName = ParamChecker . notEmpty ( datasetName , "table name" ) ; LOG . info ( "Fetching schema for tableName={}" , datasetName ) ; TypeUtils . Pair < String , String > typeIdPair = validateDatasetNameExists ( datasetName ) ; return getSchemaForId ( typeIdPair . left , typeIdPair . right ) ; }
Return the schema for the given tableName .