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 ( "...
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...
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...
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 pas...
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 ( CredentialProvid...
\ 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 ...
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 ....
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:...
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 . getHea...
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 . getBoundAddressF...
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 ( getZno...
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 . ...
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...
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 { AtlasPer...
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 ( PER...
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 ( Atla...
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 ) ) { p...
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 ...
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 . isPerfT...
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 : ...
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 . get...
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 (...
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 . getTypeN...
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 lim...
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...
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 . isPerfTraceEnabl...
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 ( entit...
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...
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 (...
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({...
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.ge...
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 = ( LiteralExpressio...
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 ) { topThread...
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" ) ; ...
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 ( ...
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 {} ...
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...
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 ( ...
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 ...
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 . getCall...
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 =...
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 ...
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 ( ) ) { Append...
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 ) ; } ret...
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 ...
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 )...
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 , attrDe...
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 offs...
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 (...
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({})" , gremlin...
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 Dis...
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 , ...
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 credent...
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 . an...
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 ...
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 ) { updatedC...
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 > resu...
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 ) ; notificationLogg...
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 ( datasetNa...
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 ge...
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 getSchemaFo...
Return the schema for the given tableName .