Commit 4925ec35 by Sarath Subramanian

ATLAS-3070: Create patch framework to persist typedef patches applied to atlas

parent 2e1c5634
{
"patches": [
{
"id": "TYPEDEF_PATCH_0000_001",
"description": "Add 'replicatedFrom' and 'replicatedTo' attributes to Referenceable",
"action": "ADD_ATTRIBUTE",
"typeName": "Referenceable",
"applyToVersion": "1.0",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_0000_002",
"description": "Set serviceType 'atlas_core' to Referenceable",
"action": "SET_SERVICE_TYPE",
"typeName": "Referenceable",
"applyToVersion": "1.0",
"updateToVersion": "1.1",
"applyToVersion": "1.1",
"updateToVersion": "1.2",
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_003",
"description": "Set serviceType 'atlas_core' to __internal",
"action": "SET_SERVICE_TYPE",
"typeName": "__internal",
"applyToVersion": "1.0",
......@@ -15,6 +19,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_004",
"description": "Set serviceType 'atlas_core' to Asset",
"action": "SET_SERVICE_TYPE",
"typeName": "Asset",
"applyToVersion": "1.1",
......@@ -22,6 +28,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_005",
"description": "Set serviceType 'atlas_core' to DataSet",
"action": "SET_SERVICE_TYPE",
"typeName": "DataSet",
"applyToVersion": "1.1",
......@@ -29,6 +37,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_006",
"description": "Set serviceType 'atlas_core' to Infrastructure",
"action": "SET_SERVICE_TYPE",
"typeName": "Infrastructure",
"applyToVersion": "1.1",
......@@ -36,6 +46,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_007",
"description": "Set serviceType 'atlas_core' to Process",
"action": "SET_SERVICE_TYPE",
"typeName": "Process",
"applyToVersion": "1.1",
......@@ -43,6 +55,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_008",
"description": "Set serviceType 'atlas_core' to AtlasServer",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasServer",
"applyToVersion": "1.0",
......@@ -50,6 +64,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_009",
"description": "Set serviceType 'atlas_core' to __AtlasUserProfile",
"action": "SET_SERVICE_TYPE",
"typeName": "__AtlasUserProfile",
"applyToVersion": "1.0",
......@@ -57,6 +73,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_010",
"description": "Set serviceType 'atlas_core' to __AtlasUserSavedSearch",
"action": "SET_SERVICE_TYPE",
"typeName": "__AtlasUserSavedSearch",
"applyToVersion": "1.0",
......@@ -64,6 +82,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_011",
"description": "Set serviceType 'atlas_core' to __ExportImportAuditEntry",
"action": "SET_SERVICE_TYPE",
"typeName": "__ExportImportAuditEntry",
"applyToVersion": "1.0",
......@@ -71,6 +91,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_012",
"description": "Set serviceType 'atlas_core' to dataset_process_inputs",
"action": "SET_SERVICE_TYPE",
"typeName": "dataset_process_inputs",
"applyToVersion": "1.0",
......@@ -78,6 +100,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_013",
"description": "Set serviceType 'atlas_core' to process_dataset_outputs",
"action": "SET_SERVICE_TYPE",
"typeName": "process_dataset_outputs",
"applyToVersion": "1.0",
......@@ -85,6 +109,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_014",
"description": "Set serviceType 'atlas_core' to __AtlasUserProfile_savedsearches",
"action": "SET_SERVICE_TYPE",
"typeName": "__AtlasUserProfile_savedsearches",
"applyToVersion": "1.0",
......@@ -92,6 +118,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_015",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryTermRelationshipStatus",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryTermRelationshipStatus",
"applyToVersion": "1.0",
......@@ -99,6 +127,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_016",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryTermAssignmentStatus",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryTermAssignmentStatus",
"applyToVersion": "1.0",
......@@ -106,6 +136,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_017",
"description": "Set serviceType 'atlas_core' to AtlasGlossary",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossary",
"applyToVersion": "1.0",
......@@ -113,6 +145,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_018",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryTerm",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryTerm",
"applyToVersion": "1.0",
......@@ -120,6 +154,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_019",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryCategory",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryCategory",
"applyToVersion": "1.0",
......@@ -127,6 +163,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_020",
"description": "Set serviceType 'atlas_core' to AtlasGlossarySemanticAssignment",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossarySemanticAssignment",
"applyToVersion": "1.0",
......@@ -134,6 +172,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_021",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryTermAnchor",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryTermAnchor",
"applyToVersion": "1.0",
......@@ -141,6 +181,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_022",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryTermCategorization",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryTermCategorization",
"applyToVersion": "1.0",
......@@ -148,6 +190,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_023",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryCategoryAnchor",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryCategoryAnchor",
"applyToVersion": "1.0",
......@@ -155,6 +199,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_024",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryCategoryHierarchyLink",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryCategoryHierarchyLink",
"applyToVersion": "1.0",
......@@ -162,6 +208,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_025",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryRelatedTerm",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryRelatedTerm",
"applyToVersion": "1.0",
......@@ -169,6 +217,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_026",
"description": "Set serviceType 'atlas_core' to AtlasGlossarySynonym",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossarySynonym",
"applyToVersion": "1.0",
......@@ -176,6 +226,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_027",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryAntonym",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryAntonym",
"applyToVersion": "1.0",
......@@ -183,6 +235,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_028",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryPreferredTerm",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryPreferredTerm",
"applyToVersion": "1.0",
......@@ -190,6 +244,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_029",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryReplacementTerm",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryReplacementTerm",
"applyToVersion": "1.0",
......@@ -197,6 +253,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_030",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryTranslation",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryTranslation",
"applyToVersion": "1.0",
......@@ -204,6 +262,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_031",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryIsARelationship",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryIsARelationship",
"applyToVersion": "1.0",
......@@ -211,6 +271,8 @@
"serviceType": "atlas_core"
},
{
"id": "TYPEDEF_PATCH_0000_032",
"description": "Set serviceType 'atlas_core' to AtlasGlossaryValidValue",
"action": "SET_SERVICE_TYPE",
"typeName": "AtlasGlossaryValidValue",
"applyToVersion": "1.0",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_033",
"description": "Add 'position' attribute to hive_column",
"action": "ADD_ATTRIBUTE",
"typeName": "hive_column",
"applyToVersion": "1.0",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_034",
"description": "Add 'schemaAttributes' typeDefOptions to hive_column",
"action": "UPDATE_TYPEDEF_OPTIONS",
"typeName": "hive_column",
"applyToVersion": "1.1",
......@@ -10,6 +12,8 @@
}
},
{
"id": "TYPEDEF_PATCH_1000_035",
"description": "Add 'schemaElementsAttribute' typeDefOptions to hive_table",
"action": "UPDATE_TYPEDEF_OPTIONS",
"typeName": "hive_table",
"applyToVersion": "1.0",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_036",
"description": "Update 'table' attribute in hive_column",
"action": "UPDATE_ATTRIBUTE",
"typeName": "hive_column",
"applyToVersion": "1.2",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_037",
"description": "Add 'parameters', 'createTime' and 'modifiedTime' attributes to hbase_table",
"action": "ADD_ATTRIBUTE",
"typeName": "hbase_table",
"applyToVersion": "1.1",
......@@ -34,6 +36,8 @@
]
},
{
"id": "TYPEDEF_PATCH_1000_038",
"description": "Add 'createTime' and 'modifiedTime' attributes to hbase_column_family",
"action": "ADD_ATTRIBUTE",
"typeName": "hbase_column_family",
"applyToVersion": "1.0",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_039",
"description": "Add attributes to hbase_table",
"action": "ADD_ATTRIBUTE",
"typeName": "hbase_table",
"applyToVersion": "1.2",
......@@ -59,6 +61,8 @@
]
},
{
"id": "TYPEDEF_PATCH_1000_040",
"description": "Add attributes to hbase_column_family",
"action": "ADD_ATTRIBUTE",
"typeName": "hbase_column_family",
"applyToVersion": "1.1",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_041",
"description": "Add 'partitionCount' attribute to kafka_topic",
"action": "ADD_ATTRIBUTE",
"typeName": "kafka_topic",
"applyToVersion": "1.0",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_042",
"description": "Set serviceType 'file_system' to file_action",
"action": "SET_SERVICE_TYPE",
"typeName": "file_action",
"applyToVersion": "1.0",
......@@ -8,6 +10,8 @@
"serviceType": "file_system"
},
{
"id": "TYPEDEF_PATCH_1000_043",
"description": "Set serviceType 'file_system' to fs_permissions",
"action": "SET_SERVICE_TYPE",
"typeName": "fs_permissions",
"applyToVersion": "1.0",
......@@ -15,6 +19,8 @@
"serviceType": "file_system"
},
{
"id": "TYPEDEF_PATCH_1000_044",
"description": "Set serviceType 'file_system' to fs_path",
"action": "SET_SERVICE_TYPE",
"typeName": "fs_path",
"applyToVersion": "1.0",
......@@ -22,6 +28,8 @@
"serviceType": "file_system"
},
{
"id": "TYPEDEF_PATCH_1000_045",
"description": "Set serviceType 'file_system' to hdfs_path",
"action": "SET_SERVICE_TYPE",
"typeName": "hdfs_path",
"applyToVersion": "1.1",
......@@ -29,6 +37,8 @@
"serviceType": "file_system"
},
{
"id": "TYPEDEF_PATCH_1000_046",
"description": "Set serviceType 'hive' to hive_principal_type",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_principal_type",
"applyToVersion": "1.0",
......@@ -36,6 +46,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_047",
"description": "Set serviceType 'hive' to hive_order",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_order",
"applyToVersion": "1.0",
......@@ -43,6 +55,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_048",
"description": "Set serviceType 'hive' to hive_serde",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_serde",
"applyToVersion": "1.0",
......@@ -50,6 +64,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_049",
"description": "Set serviceType 'hive' to hive_process",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_process",
"applyToVersion": "1.0",
......@@ -57,6 +73,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_050",
"description": "Set serviceType 'hive' to hive_table",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_table",
"applyToVersion": "1.1",
......@@ -64,6 +82,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_051",
"description": "Set serviceType 'hive' to hive_storagedesc",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_storagedesc",
"applyToVersion": "1.0",
......@@ -71,6 +91,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_052",
"description": "Set serviceType 'hive' to hive_db",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_db",
"applyToVersion": "1.1",
......@@ -78,6 +100,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_053",
"description": "Set serviceType 'hive' to hive_column",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_column",
"applyToVersion": "1.3",
......@@ -85,6 +109,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_054",
"description": "Set serviceType 'hive' to hive_column_lineage",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_column_lineage",
"applyToVersion": "1.0",
......@@ -92,6 +118,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_055",
"description": "Set serviceType 'hive' to hive_table_db",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_table_db",
"applyToVersion": "1.0",
......@@ -99,6 +127,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_056",
"description": "Set serviceType 'hive' to hive_table_columns",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_table_columns",
"applyToVersion": "1.0",
......@@ -106,6 +136,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_057",
"description": "Set serviceType 'hive' to hive_table_partitionkeys",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_table_partitionkeys",
"applyToVersion": "1.0",
......@@ -113,6 +145,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_058",
"description": "Set serviceType 'hive' to hive_table_storagedesc",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_table_storagedesc",
"applyToVersion": "1.0",
......@@ -120,6 +154,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_059",
"description": "Set serviceType 'hive' to hive_process_column_lineage",
"action": "SET_SERVICE_TYPE",
"typeName": "hive_process_column_lineage",
"applyToVersion": "1.0",
......@@ -127,6 +163,8 @@
"serviceType": "hive"
},
{
"id": "TYPEDEF_PATCH_1000_060",
"description": "Set serviceType 'sqoop' to sqoop_process",
"action": "SET_SERVICE_TYPE",
"typeName": "sqoop_process",
"applyToVersion": "1.0",
......@@ -134,6 +172,8 @@
"serviceType": "sqoop"
},
{
"id": "TYPEDEF_PATCH_1000_061",
"description": "Set serviceType 'sqoop' to sqoop_dbdatastore",
"action": "SET_SERVICE_TYPE",
"typeName": "sqoop_dbdatastore",
"applyToVersion": "1.0",
......@@ -141,6 +181,8 @@
"serviceType": "sqoop"
},
{
"id": "TYPEDEF_PATCH_1000_062",
"description": "Set serviceType 'falcon' to falcon_feed_replication",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_feed_replication",
"applyToVersion": "1.0",
......@@ -148,6 +190,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_063",
"description": "Set serviceType 'falcon' to falcon_cluster",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_cluster",
"applyToVersion": "1.0",
......@@ -155,6 +199,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_064",
"description": "Set serviceType 'falcon' to falcon_feed",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_feed",
"applyToVersion": "1.0",
......@@ -162,6 +208,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_065",
"description": "Set serviceType 'falcon' to falcon_process",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_process",
"applyToVersion": "1.0",
......@@ -169,6 +217,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_066",
"description": "Set serviceType 'falcon' to falcon_feed_creation",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_feed_creation",
"applyToVersion": "1.0",
......@@ -176,6 +226,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_067",
"description": "Set serviceType 'falcon' to falcon_feed_cluster",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_feed_cluster",
"applyToVersion": "1.0",
......@@ -183,6 +235,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_068",
"description": "Set serviceType 'falcon' to falcon_cluster_process",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_cluster_process",
"applyToVersion": "1.0",
......@@ -190,6 +244,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_069",
"description": "Set serviceType 'falcon' to falcon_cluster_feed_creation",
"action": "SET_SERVICE_TYPE",
"typeName": "falcon_cluster_feed_creation",
"applyToVersion": "1.0",
......@@ -197,6 +253,8 @@
"serviceType": "falcon"
},
{
"id": "TYPEDEF_PATCH_1000_070",
"description": "Set serviceType 'hbase' to hbase_namespace",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_namespace",
"applyToVersion": "1.0",
......@@ -204,6 +262,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_071",
"description": "Set serviceType 'hbase' to hbase_table",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_table",
"applyToVersion": "1.3",
......@@ -211,6 +271,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_072",
"description": "Set serviceType 'hbase' to hbase_column_family",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_column_family",
"applyToVersion": "1.2",
......@@ -218,6 +280,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_073",
"description": "Set serviceType 'hbase' to hbase_column",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_column",
"applyToVersion": "1.0",
......@@ -225,6 +289,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_074",
"description": "Set serviceType 'hbase' to hbase_table_namespace",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_table_namespace",
"applyToVersion": "1.0",
......@@ -232,6 +298,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_075",
"description": "Set serviceType 'hbase' to hbase_table_column_families",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_table_column_families",
"applyToVersion": "1.0",
......@@ -239,6 +307,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_076",
"description": "Set serviceType 'hbase' to hbase_column_family_columns",
"action": "SET_SERVICE_TYPE",
"typeName": "hbase_column_family_columns",
"applyToVersion": "1.0",
......@@ -246,6 +316,8 @@
"serviceType": "hbase"
},
{
"id": "TYPEDEF_PATCH_1000_077",
"description": "Set serviceType 'avro' to avro_type",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_type",
"applyToVersion": "1.0",
......@@ -253,6 +325,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_078",
"description": "Set serviceType 'avro' to avro_field",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_field",
"applyToVersion": "1.0",
......@@ -260,6 +334,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_079",
"description": "Set serviceType 'avro' to avro_record",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_record",
"applyToVersion": "1.0",
......@@ -267,6 +343,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_080",
"description": "Set serviceType 'avro' to avro_schema",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_schema",
"applyToVersion": "1.0",
......@@ -274,6 +352,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_081",
"description": "Set serviceType 'avro' to avro_primitive",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_primitive",
"applyToVersion": "1.0",
......@@ -281,6 +361,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_082",
"description": "Set serviceType 'avro' to avro_fixed",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_fixed",
"applyToVersion": "1.0",
......@@ -288,6 +370,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_083",
"description": "Set serviceType 'avro' to avro_enum",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_enum",
"applyToVersion": "1.0",
......@@ -295,6 +379,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_084",
"description": "Set serviceType 'avro' to avro_collection",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_collection",
"applyToVersion": "1.0",
......@@ -302,6 +388,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_085",
"description": "Set serviceType 'avro' to avro_schema_associatedEntities",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_schema_associatedEntities",
"applyToVersion": "1.0",
......@@ -309,6 +397,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_086",
"description": "Set serviceType 'avro' to avro_record_fields",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_record_fields",
"applyToVersion": "1.0",
......@@ -316,6 +406,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_087",
"description": "Set serviceType 'avro' to avro_field_types",
"action": "SET_SERVICE_TYPE",
"typeName": "avro_field_types",
"applyToVersion": "1.0",
......@@ -323,6 +415,8 @@
"serviceType": "avro"
},
{
"id": "TYPEDEF_PATCH_1000_088",
"description": "Set serviceType 'kafka' to kafka_topic",
"action": "SET_SERVICE_TYPE",
"typeName": "kafka_topic",
"applyToVersion": "1.1",
......@@ -330,6 +424,8 @@
"serviceType": "kafka"
},
{
"id": "TYPEDEF_PATCH_1000_089",
"description": "Set serviceType 'kafka' to jms_topic",
"action": "SET_SERVICE_TYPE",
"typeName": "jms_topic",
"applyToVersion": "1.0",
......@@ -337,6 +433,8 @@
"serviceType": "kafka"
},
{
"id": "TYPEDEF_PATCH_1000_090",
"description": "Set serviceType 'kafka' to kafka_topic_avroSchema",
"action": "SET_SERVICE_TYPE",
"typeName": "kafka_topic_avroSchema",
"applyToVersion": "1.0",
......@@ -344,6 +442,8 @@
"serviceType": "kafka"
},
{
"id": "TYPEDEF_PATCH_1000_091",
"description": "Set serviceType 'storm' to storm_topology",
"action": "SET_SERVICE_TYPE",
"typeName": "storm_topology",
"applyToVersion": "1.0",
......@@ -351,6 +451,8 @@
"serviceType": "storm"
},
{
"id": "TYPEDEF_PATCH_1000_092",
"description": "Set serviceType 'storm' to storm_node",
"action": "SET_SERVICE_TYPE",
"typeName": "storm_node",
"applyToVersion": "1.0",
......@@ -358,6 +460,8 @@
"serviceType": "storm"
},
{
"id": "TYPEDEF_PATCH_1000_093",
"description": "Set serviceType 'storm' to storm_spout",
"action": "SET_SERVICE_TYPE",
"typeName": "storm_spout",
"applyToVersion": "1.0",
......@@ -365,6 +469,8 @@
"serviceType": "storm"
},
{
"id": "TYPEDEF_PATCH_1000_094",
"description": "Set serviceType 'storm' to storm_bolt",
"action": "SET_SERVICE_TYPE",
"typeName": "storm_bolt",
"applyToVersion": "1.0",
......@@ -372,6 +478,8 @@
"serviceType": "storm"
},
{
"id": "TYPEDEF_PATCH_1000_095",
"description": "Set serviceType 'storm' to storm_topology_nodes",
"action": "SET_SERVICE_TYPE",
"typeName": "storm_topology_nodes",
"applyToVersion": "1.0",
......@@ -379,4 +487,4 @@
"serviceType": "storm"
}
]
}
}
\ No newline at end of file
{
"patches": [
{
"id": "TYPEDEF_PATCH_1000_096",
"description": "Remove legacy reference attribute 'db' from hive_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "hive_table_db",
"applyToVersion": "1.1",
......@@ -10,6 +12,8 @@
}
},
{
"id": "TYPEDEF_PATCH_1000_097",
"description": "Remove legacy reference attribute 'columns' from hive_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "hive_table_columns",
"applyToVersion": "1.1",
......@@ -19,6 +23,8 @@
}
},
{
"id": "TYPEDEF_PATCH_1000_098",
"description": "Remove legacy reference attribute 'partitionkeys' from hive_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "hive_table_partitionkeys",
"applyToVersion": "1.1",
......@@ -28,6 +34,8 @@
}
},
{
"id": "TYPEDEF_PATCH_1000_099",
"description": "Remove legacy reference attribute 'sd' from hive_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "hive_table_storagedesc",
"applyToVersion": "1.1",
......@@ -37,6 +45,8 @@
}
},
{
"id": "TYPEDEF_PATCH_1000_100",
"description": "Remove legacy reference attribute 'query' from hive_column_lineage",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "hive_process_column_lineage",
"applyToVersion": "1.1",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_2000_101",
"description": "Add 'schemaAttributes' typeDefOptions to rdbms_column",
"action": "UPDATE_TYPEDEF_OPTIONS",
"typeName": "rdbms_column",
"applyToVersion": "1.1",
......@@ -10,6 +12,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_102",
"description": "Add 'schemaElementsAttribute' typeDefOptions to rdbms_table",
"action": "UPDATE_TYPEDEF_OPTIONS",
"typeName": "rdbms_table",
"applyToVersion": "1.1",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_2000_103",
"description": "Set serviceType 'rdbms' to rdbms_instance",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_instance",
"applyToVersion": "1.1",
......@@ -8,6 +10,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_104",
"description": "Set serviceType 'rdbms' to rdbms_db",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_db",
"applyToVersion": "1.1",
......@@ -15,6 +19,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_105",
"description": "Set serviceType 'rdbms' to rdbms_table",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_table",
"applyToVersion": "1.2",
......@@ -22,6 +28,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_106",
"description": "Set serviceType 'rdbms' to rdbms_column",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_column",
"applyToVersion": "1.2",
......@@ -29,6 +37,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_107",
"description": "Set serviceType 'rdbms' to rdbms_index",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_index",
"applyToVersion": "1.1",
......@@ -36,6 +46,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_108",
"description": "Set serviceType 'rdbms' to rdbms_foreign_key",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_foreign_key",
"applyToVersion": "1.1",
......@@ -43,6 +55,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_109",
"description": "Set serviceType 'rdbms' to rdbms_instance_databases",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_instance_databases",
"applyToVersion": "1.0",
......@@ -50,6 +64,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_110",
"description": "Set serviceType 'rdbms' to rdbms_db_tables",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_db_tables",
"applyToVersion": "1.0",
......@@ -57,6 +73,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_111",
"description": "Set serviceType 'rdbms' to rdbms_table_columns",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_table_columns",
"applyToVersion": "1.0",
......@@ -64,6 +82,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_112",
"description": "Set serviceType 'rdbms' to rdbms_table_indexes",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_table_indexes",
"applyToVersion": "1.0",
......@@ -71,6 +91,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_113",
"description": "Set serviceType 'rdbms' to rdbms_index_columns",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_index_columns",
"applyToVersion": "1.0",
......@@ -78,6 +100,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_114",
"description": "Set serviceType 'rdbms' to rdbms_table_foreign_key",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_table_foreign_key",
"applyToVersion": "1.0",
......@@ -85,6 +109,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_115",
"description": "Set serviceType 'rdbms' to rdbms_foreign_key_key_columns",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_foreign_key_key_columns",
"applyToVersion": "1.0",
......@@ -92,6 +118,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_116",
"description": "Set serviceType 'rdbms' to rdbms_foreign_key_table_references",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_foreign_key_table_references",
"applyToVersion": "1.0",
......@@ -99,6 +127,8 @@
"serviceType": "rdbms"
},
{
"id": "TYPEDEF_PATCH_2000_117",
"description": "Set serviceType 'rdbms' to rdbms_foreign_key_column_references",
"action": "SET_SERVICE_TYPE",
"typeName": "rdbms_foreign_key_column_references",
"applyToVersion": "1.0",
......@@ -106,4 +136,4 @@
"serviceType": "rdbms"
}
]
}
}
\ No newline at end of file
{
"patches": [
{
"id": "TYPEDEF_PATCH_2000_118",
"description": "Remove legacy reference attribute 'databases' from rdbms_instance",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_instance_databases",
"applyToVersion": "1.1",
......@@ -11,6 +13,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_119",
"description": "Remove legacy reference attribute 'tables' from rdbms_db",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_db_tables",
"applyToVersion": "1.1",
......@@ -21,6 +25,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_120",
"description": "Remove legacy reference attribute 'columns' from rdbms_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_table_columns",
"applyToVersion": "1.1",
......@@ -31,6 +37,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_121",
"description": "Remove legacy reference attribute 'indexes' from rdbms_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_table_indexes",
"applyToVersion": "1.1",
......@@ -41,6 +49,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_122",
"description": "Remove legacy reference attribute 'foreign_keys' from rdbms_table",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_table_foreign_key",
"applyToVersion": "1.1",
......@@ -51,6 +61,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_123",
"description": "Remove legacy reference attribute 'columns' from rdbms_index",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_index_columns",
"applyToVersion": "1.1",
......@@ -60,6 +72,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_124",
"description": "Remove legacy reference attribute 'key_columns' from rdbms_foreign_key",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_foreign_key_key_columns",
"applyToVersion": "1.1",
......@@ -69,6 +83,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_125",
"description": "Remove legacy reference attribute 'references_table' from rdbms_foreign_key",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_foreign_key_table_references",
"applyToVersion": "1.1",
......@@ -78,6 +94,8 @@
}
},
{
"id": "TYPEDEF_PATCH_2000_126",
"description": "Remove legacy reference attribute 'references_columns' from rdbms_foreign_key",
"action": "REMOVE_LEGACY_REF_ATTRIBUTES",
"typeName": "rdbms_foreign_key_column_references",
"applyToVersion": "1.1",
......
{
"patches": [
{
"id": "TYPEDEF_PATCH_3000_127",
"description": "Set serviceType 'aws' to aws_tag",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_tag",
"applyToVersion": "1.0",
......@@ -8,6 +10,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_128",
"description": "Set serviceType 'aws' to aws_cloud_watch_metric",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_cloud_watch_metric",
"applyToVersion": "1.0",
......@@ -15,6 +19,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_129",
"description": "Set serviceType 'aws' to aws_s3_bucket_lifeCycleRule",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_bucket_lifeCycleRule",
"applyToVersion": "1.0",
......@@ -22,6 +28,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_130",
"description": "Set serviceType 'aws' to aws_s3_access_policy",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_access_policy",
"applyToVersion": "1.0",
......@@ -29,6 +37,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_131",
"description": "Set serviceType 'aws' to aws_s3_object",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_object",
"applyToVersion": "1.0",
......@@ -36,6 +46,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_132",
"description": "Set serviceType 'aws' to aws_s3_pseudo_dir",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_pseudo_dir",
"applyToVersion": "1.0",
......@@ -43,6 +55,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_133",
"description": "Set serviceType 'aws' to aws_s3_bucket",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_bucket",
"applyToVersion": "1.0",
......@@ -50,6 +64,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_134",
"description": "Set serviceType 'aws' to aws_s3_bucket_aws_s3_pseudo_dirs",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_bucket_aws_s3_pseudo_dirs",
"applyToVersion": "1.0",
......@@ -57,6 +73,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_135",
"description": "Set serviceType 'aws' to aws_s3_pseudo_dir_aws_objects",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_pseudo_dir_aws_objects",
"applyToVersion": "1.0",
......@@ -64,6 +82,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_136",
"description": "Set serviceType 'aws' to aws_s3_object_avro_schema",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_object_avro_schema",
"applyToVersion": "1.0",
......@@ -71,6 +91,8 @@
"serviceType": "aws"
},
{
"id": "TYPEDEF_PATCH_3000_137",
"description": "Set serviceType 'aws' to aws_s3_pseudo_dir_avro_schema",
"action": "SET_SERVICE_TYPE",
"typeName": "aws_s3_pseudo_dir_avro_schema",
"applyToVersion": "1.0",
......
......@@ -86,6 +86,15 @@ public final class Constants {
public static final String MODIFIED_BY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "modifiedBy");
/**
* Patch vertices property keys.
*/
public static final String PATCH_ID_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.id");
public static final String PATCH_DESCRIPTION_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.description");
public static final String PATCH_TYPE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.type");
public static final String PATCH_ACTION_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.action");
public static final String PATCH_STATE_PROPERTY_KEY = encodePropertyKey(INTERNAL_PROPERTY_KEY_PREFIX + "patch.state");
/**
* The homeId field is used when saving into Atlas a copy of an object that is being imported from another
* repository. The homeId will be set to a String that identifies the other repository. The specific format
* of repository identifiers is domain dependent. Where it is set by Open Metadata Repository Services it will
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.model.patches;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Display all atlas patches.
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasPatch implements Serializable {
private String id;
private String description;
private String type;
private String action;
private String updatedBy;
private String createdBy;
private long createdTime;
private long updatedTime;
private PatchStatus status;
public enum PatchStatus { APPLIED, SKIPPED, FAILED, UNKNOWN }
public AtlasPatch() { }
public AtlasPatch(String id, String patchName, String type, String action, PatchStatus status, String updatedBy,
String createdBy, long createdTime, long updatedTime) {
this.id = id;
this.description = patchName;
this.type = type;
this.action = action;
this.status = status;
this.updatedBy = updatedBy;
this.createdBy = createdBy;
this.createdTime = createdTime;
this.updatedTime = updatedTime;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public PatchStatus getStatus() {
return status;
}
public void setStatus(PatchStatus status) {
this.status = status;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public long getCreatedTime() {
return createdTime;
}
public void setCreatedTime(long createdTime) {
this.createdTime = createdTime;
}
public long getUpdatedTime() {
return updatedTime;
}
public void setUpdatedTime(long updatedTime) {
this.updatedTime = updatedTime;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AtlasPatch that = (AtlasPatch) o;
return createdTime == that.createdTime &&
updatedTime == that.updatedTime &&
Objects.equals(id, that.id) &&
Objects.equals(description, that.description) &&
Objects.equals(type, that.type) &&
Objects.equals(action, that.action) &&
Objects.equals(updatedBy, that.updatedBy) &&
Objects.equals(createdBy, that.createdBy) &&
status == that.status;
}
@Override
public int hashCode() {
return Objects.hash(id, description, type, action, updatedBy, createdBy, createdTime, updatedTime, status);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("AtlasPatch{");
sb.append("id=").append(id);
sb.append(", description='").append(description).append('\'');
sb.append(", type='").append(type).append('\'');
sb.append(", action='").append(action).append('\'');
sb.append(", updatedBy='").append(updatedBy).append('\'');
sb.append(", createdBy='").append(createdBy).append('\'');
sb.append(", createdTime=").append(createdTime);
sb.append(", updatedTime=").append(updatedTime);
sb.append(", status=").append(status);
sb.append('}');
return sb.toString();
}
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class AtlasPatches implements Serializable {
private List<AtlasPatch> patches;
public AtlasPatches(List<AtlasPatch> patches) {
this.patches = patches;
}
public AtlasPatches() {
}
public List<AtlasPatch> getPatches() {
return patches;
}
public void setPatches(List<AtlasPatch> patches) {
this.patches = patches;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AtlasPatches that = (AtlasPatches) o;
return Objects.equals(patches, that.patches);
}
@Override
public int hashCode() {
return Objects.hash(patches);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("AtlasPatches{");
sb.append("patches=").append(patches);
sb.append('}');
return sb.toString();
}
}
}
\ No newline at end of file
......@@ -332,6 +332,8 @@ public class AtlasTypeUtil {
if (typeDef != null) {
if (typeDef.getClass().equals(AtlasEntityDef.class)) {
ret.getEntityDefs().add((AtlasEntityDef) typeDef);
} else if (typeDef.getClass().equals(AtlasRelationshipDef.class)) {
ret.getRelationshipDefs().add((AtlasRelationshipDef) typeDef);
} else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
ret.getClassificationDefs().add((AtlasClassificationDef) typeDef);
} else if (typeDef.getClass().equals(AtlasStructDef.class)) {
......
......@@ -280,6 +280,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
createVertexIndex(management, TRAIT_NAMES_PROPERTY_KEY, UniqueKind.NONE, String.class, SET, true, true);
createVertexIndex(management, PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, UniqueKind.NONE, String.class, LIST, true, true);
createVertexIndex(management, PATCH_ID_PROPERTY_KEY, UniqueKind.GLOBAL_UNIQUE, String.class, SINGLE, true, false);
createVertexIndex(management, PATCH_DESCRIPTION_PROPERTY_KEY, UniqueKind.NONE, String.class, SINGLE, true, false);
createVertexIndex(management, PATCH_TYPE_PROPERTY_KEY, UniqueKind.NONE, String.class, SINGLE, true, false);
createVertexIndex(management, PATCH_ACTION_PROPERTY_KEY, UniqueKind.NONE, String.class, SINGLE, true, false);
createVertexIndex(management, PATCH_STATE_PROPERTY_KEY, UniqueKind.NONE, String.class, SINGLE, true, false);
// create vertex-centric index
createVertexCentricIndex(management, CLASSIFICATION_LABEL, AtlasEdgeDirection.BOTH, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class, SINGLE);
createVertexCentricIndex(management, CLASSIFICATION_LABEL, AtlasEdgeDirection.BOTH, CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, Boolean.class, SINGLE);
......
......@@ -29,6 +29,7 @@ import org.apache.atlas.authorize.AtlasAuthorizerFactory;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.ha.HAConfiguration;
import org.apache.atlas.listener.ActiveStateChangeHandler;
import org.apache.atlas.model.patches.AtlasPatch.PatchStatus;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
......@@ -40,6 +41,10 @@ import org.apache.atlas.model.typedef.AtlasRelationshipEndDef;
import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v2.AtlasTypeDefGraphStoreV2;
import org.apache.atlas.store.AtlasTypeDefStore;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
......@@ -71,27 +76,46 @@ import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
import static org.apache.atlas.model.patches.AtlasPatch.PatchStatus.APPLIED;
import static org.apache.atlas.model.patches.AtlasPatch.PatchStatus.FAILED;
import static org.apache.atlas.model.patches.AtlasPatch.PatchStatus.SKIPPED;
import static org.apache.atlas.model.patches.AtlasPatch.PatchStatus.UNKNOWN;
import static org.apache.atlas.repository.Constants.CREATED_BY_KEY;
import static org.apache.atlas.repository.Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.MODIFIED_BY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_ACTION_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_ID_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_DESCRIPTION_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_STATE_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_TYPE_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.TIMESTAMP_PROPERTY_KEY;
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.findByPatchId;
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.initPatchesRegistry;
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.setEncodedProperty;
/**
* Class that handles initial loading of models and patches into typedef store
*/
@Service
public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefStoreInitializer.class);
public static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefStoreInitializer.class);
public static final String PATCHES_FOLDER_NAME = "patches";
public static final String RELATIONSHIP_LABEL = "relationshipLabel";
public static final String RELATIONSHIP_CATEGORY = "relationshipCategory";
public static final String RELATIONSHIP_SWAP_ENDS = "swapEnds";
public static final String TYPEDEF_PATCH_TYPE = "TYPEDEF_PATCH";
private final AtlasTypeDefStore atlasTypeDefStore;
private final AtlasTypeRegistry atlasTypeRegistry;
private final AtlasGraph atlasGraph;
private final Configuration conf;
@Inject
public AtlasTypeDefStoreInitializer(AtlasTypeDefStore atlasTypeDefStore, AtlasTypeRegistry atlasTypeRegistry, Configuration conf) {
public AtlasTypeDefStoreInitializer(AtlasTypeDefStore atlasTypeDefStore, AtlasTypeRegistry atlasTypeRegistry,
AtlasGraph atlasGraph, Configuration conf) {
this.atlasTypeDefStore = atlasTypeDefStore;
this.atlasTypeRegistry = atlasTypeRegistry;
this.atlasGraph = atlasGraph;
this.conf = conf;
}
......@@ -134,6 +158,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
// look for folders we need to load models from
File topModeltypesDir = new File(modelsDirName);
File[] modelsDirContents = topModeltypesDir.exists() ? topModeltypesDir.listFiles() : null;
Map<String, PatchStatus> patchesRegistry = initPatchesRegistry();
if (modelsDirContents != null && modelsDirContents.length > 0) {
Arrays.sort(modelsDirContents);
......@@ -144,13 +169,13 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
continue;
} else if (!folder.getName().equals(PATCHES_FOLDER_NAME)){
// load the models alphabetically in the subfolders apart from patches
loadModelsInFolder(folder);
loadModelsInFolder(folder, patchesRegistry);
}
}
}
// load any files in the top models folder and any associated patches.
loadModelsInFolder(topModeltypesDir);
loadModelsInFolder(topModeltypesDir, patchesRegistry);
}
LOG.info("<== AtlasTypeDefStoreInitializer.loadBootstrapTypeDefs()");
}
......@@ -158,8 +183,9 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
/**
* Load all the model files in the supplied folder followed by the contents of the patches folder.
* @param typesDir
* @param patchesRegistry
*/
private void loadModelsInFolder(File typesDir) {
private void loadModelsInFolder(File typesDir, Map<String, PatchStatus> patchesRegistry) {
LOG.info("==> AtlasTypeDefStoreInitializer({})", typesDir);
String typesDirName = typesDir.getName();
......@@ -201,7 +227,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
}
applyTypePatches(typesDir.getPath());
applyTypePatches(typesDir.getPath(), patchesRegistry);
}
LOG.info("<== AtlasTypeDefStoreInitializer({})", typesDir);
}
......@@ -399,7 +425,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
return ret;
}
private void applyTypePatches(String typesDirName) {
private void applyTypePatches(String typesDirName, Map<String, PatchStatus> patchesRegistry) {
String typePatchesDirName = typesDirName + File.separator + PATCHES_FOLDER_NAME;
File typePatchesDir = new File(typePatchesDirName);
File[] typePatchFiles = typePatchesDir.exists() ? typePatchesDir.listFiles() : null;
......@@ -430,43 +456,99 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
for (File typePatchFile : typePatchFiles) {
if (typePatchFile.isFile()) {
String patchFile = typePatchFile.getAbsolutePath();
LOG.info("Applying patches in file {}", typePatchFile.getAbsolutePath());
LOG.info("Applying patches in file {}", patchFile);
try {
String jsonStr = new String(Files.readAllBytes(typePatchFile.toPath()), StandardCharsets.UTF_8);
String jsonStr = new String(Files.readAllBytes(typePatchFile.toPath()), StandardCharsets.UTF_8);
TypeDefPatches patches = AtlasType.fromJson(jsonStr, TypeDefPatches.class);
if (patches == null || CollectionUtils.isEmpty(patches.getPatches())) {
LOG.info("No patches in file {}", typePatchFile.getAbsolutePath());
LOG.info("No patches in file {}", patchFile);
continue;
}
int patchIndex = 0;
for (TypeDefPatch patch : patches.getPatches()) {
PatchHandler patchHandler = patchHandlerRegistry.get(patch.getAction());
if (patchHandler == null) {
LOG.error("Unknown patch action {} in file {}. Ignored",
patch.getAction(), typePatchFile.getAbsolutePath());
LOG.error("Unknown patch action {} in file {}. Ignored", patch.getAction(), patchFile);
continue;
}
try {
patchHandler.applyPatch(patch);
} catch (AtlasBaseException excp) {
LOG.error("Failed to apply {} patch in file {}. Ignored", patch.getAction(), typePatchFile.getAbsolutePath(), excp);
String patchId = patch.getId();
if (StringUtils.isEmpty(patchId)) {
patchId = typePatchFile.getName() + "_" + patchIndex;
patch.setId(patchId);
}
if (isPatchApplicable(patchId, patchesRegistry)) {
PatchStatus status;
try {
status = patchHandler.applyPatch(patch);
} catch (AtlasBaseException ex) {
status = FAILED;
LOG.error("Failed to apply {} (status: {}; action: {}) in file: {}. Ignored.",
patchId, status.toString(), patch.getAction(), patchFile);
}
createOrUpdatePatchVertex(patch, status, patchesRegistry);
LOG.info("{} (status: {}; action: {}) in file: {}", patchId, status.toString(), patch.getAction(), patchFile);
} else {
LOG.info("{} in file: {} already {}. Ignoring.", patchId, patchFile, patchesRegistry.get(patchId).toString());
}
patchIndex++;
}
} catch (Throwable t) {
LOG.error("Failed to apply patches in file {}. Ignored", typePatchFile.getAbsolutePath(), t);
LOG.error("Failed to apply patches in file {}. Ignored", patchFile, t);
}
}
}
}
}
private boolean isPatchApplicable(String patchId, Map<String, PatchStatus> patchesRegistry) {
if (MapUtils.isEmpty(patchesRegistry) || !patchesRegistry.containsKey(patchId)) {
return true;
}
PatchStatus status = patchesRegistry.get(patchId);
if (status == FAILED || status == UNKNOWN) {
return true;
}
return false;
}
private void createOrUpdatePatchVertex(TypeDefPatch patch, PatchStatus patchStatus, Map<String, PatchStatus> patchesRegistry) {
String patchId = patch.getId();
boolean isPatchRegistered = MapUtils.isNotEmpty(patchesRegistry) && patchesRegistry.containsKey(patchId);
AtlasVertex patchVertex = isPatchRegistered ? findByPatchId(patchId) : atlasGraph.addVertex();
setEncodedProperty(patchVertex, PATCH_ID_PROPERTY_KEY, patchId);
setEncodedProperty(patchVertex, PATCH_DESCRIPTION_PROPERTY_KEY, patch.getDescription());
setEncodedProperty(patchVertex, PATCH_TYPE_PROPERTY_KEY, TYPEDEF_PATCH_TYPE);
setEncodedProperty(patchVertex, PATCH_ACTION_PROPERTY_KEY, patch.getAction());
setEncodedProperty(patchVertex, PATCH_STATE_PROPERTY_KEY, patchStatus.toString());
setEncodedProperty(patchVertex, TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
setEncodedProperty(patchVertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContext.get().getRequestTime());
setEncodedProperty(patchVertex, CREATED_BY_KEY, AtlasTypeDefGraphStoreV2.getCurrentUser());
setEncodedProperty(patchVertex, MODIFIED_BY_KEY, AtlasTypeDefGraphStoreV2.getCurrentUser());
AtlasGraphProvider.getGraphInstance().commit();
}
/**
* typedef patch details
*/
......@@ -476,6 +558,8 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
static class TypeDefPatch {
private String id;
private String description;
private String action;
private String typeName;
private String applyToVersion;
......@@ -485,6 +569,22 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
private Map<String, String> typeDefOptions;
private String serviceType;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAction() {
return action;
}
......@@ -583,7 +683,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
public String[] getSupportedActions() { return supportedActions; }
public abstract void applyPatch(TypeDefPatch patch) throws AtlasBaseException;
public abstract PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException;
protected boolean isPatchApplicable(TypeDefPatch patch, AtlasBaseTypeDef currentTypeDef) {
String currentVersion = currentTypeDef.getTypeVersion();
......@@ -601,9 +701,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
@Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
PatchStatus ret;
if (typeDef == null) {
throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
......@@ -616,35 +717,48 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
for (AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
updatedDef.addAttribute(attributeDef);
}
updatedDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateEntityDefByName(typeName, updatedDef);
ret = APPLIED;
} else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
AtlasClassificationDef updatedDef = new AtlasClassificationDef((AtlasClassificationDef)typeDef);
for (AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
updatedDef.addAttribute(attributeDef);
}
updatedDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateClassificationDefByName(typeName, updatedDef);
ret = APPLIED;
} else if (typeDef.getClass().equals(AtlasStructDef.class)) {
AtlasStructDef updatedDef = new AtlasStructDef((AtlasStructDef)typeDef);
for (AtlasAttributeDef attributeDef : patch.getAttributeDefs()) {
updatedDef.addAttribute(attributeDef);
}
updatedDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateStructDefByName(typeName, updatedDef);
ret = APPLIED;
} else {
throw new AtlasBaseException(AtlasErrorCode.PATCH_NOT_APPLICABLE_FOR_TYPE,
patch.getAction(), typeDef.getClass().getSimpleName());
throw new AtlasBaseException(AtlasErrorCode.PATCH_NOT_APPLICABLE_FOR_TYPE, patch.getAction(), typeDef.getClass().getSimpleName());
}
} else {
LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}",
patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion());
patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion());
ret = SKIPPED;
}
return ret;
}
}
......@@ -654,9 +768,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
@Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
PatchStatus ret;
if (typeDef == null) {
throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
......@@ -671,6 +786,8 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
updatedDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateEntityDefByName(typeName, updatedDef);
ret = APPLIED;
} else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
AtlasClassificationDef updatedDef = new AtlasClassificationDef((AtlasClassificationDef)typeDef);
......@@ -679,6 +796,8 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
updatedDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateClassificationDefByName(typeName, updatedDef);
ret = APPLIED;
} else if (typeDef.getClass().equals(AtlasStructDef.class)) {
AtlasStructDef updatedDef = new AtlasStructDef((AtlasStructDef)typeDef);
......@@ -688,14 +807,18 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
typeDefStore.updateStructDefByName(typeName, updatedDef);
ret = APPLIED;
} else {
throw new AtlasBaseException(AtlasErrorCode.PATCH_NOT_APPLICABLE_FOR_TYPE,
patch.getAction(), typeDef.getClass().getSimpleName());
throw new AtlasBaseException(AtlasErrorCode.PATCH_NOT_APPLICABLE_FOR_TYPE, patch.getAction(), typeDef.getClass().getSimpleName());
}
} else {
LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}",
patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion());
ret = SKIPPED;
}
return ret;
}
private void addOrUpdateAttributes(AtlasStructDef structDef, List<AtlasAttributeDef> attributesToUpdate) {
......@@ -717,9 +840,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
@Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
PatchStatus ret = null;
if (typeDef == null) {
throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
......@@ -810,6 +934,8 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
RequestContext.get().setInTypePatching(true); // to allow removal of attributes
typeDefStore.updateTypesDef(typesDef);
ret = APPLIED;
} finally {
RequestContext.get().setInTypePatching(false);
}
......@@ -817,7 +943,11 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
} else {
LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}",
patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion());
ret = SKIPPED;
}
return ret;
}
}
......@@ -827,9 +957,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
@Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
PatchStatus ret;
if (typeDef == null) {
throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
......@@ -848,10 +979,16 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
typeDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateTypesDef(AtlasTypeUtil.getTypesDef(typeDef));
ret = APPLIED;
} else {
LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}",
patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion());
ret = SKIPPED;
}
return ret;
}
}
......@@ -861,9 +998,10 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
@Override
public void applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException {
String typeName = patch.getTypeName();
AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName);
PatchStatus ret;
if (typeDef == null) {
throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName);
......@@ -874,10 +1012,16 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
typeDef.setTypeVersion(patch.getUpdateToVersion());
typeDefStore.updateTypesDef(AtlasTypeUtil.getTypesDef(typeDef));
ret = APPLIED;
} else {
LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}",
patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion());
LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}", patch.getTypeName(),
patch.getApplyToVersion(), patch.getUpdateToVersion());
ret = SKIPPED;
}
return ret;
}
}
}
......@@ -23,10 +23,14 @@ import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.GraphTransactionInterceptor;
import org.apache.atlas.RequestContext;
import org.apache.atlas.SortOrder;
import org.apache.atlas.annotation.GraphTransaction;
import org.apache.atlas.discovery.SearchProcessor;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.patches.AtlasPatch;
import org.apache.atlas.model.patches.AtlasPatch.AtlasPatches;
import org.apache.atlas.model.patches.AtlasPatch.PatchStatus;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graph.AtlasGraphProvider;
......@@ -35,12 +39,14 @@ import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasElement;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
import org.apache.atlas.repository.graphdb.AtlasIndexQuery.Result;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.utils.AtlasPerfMetrics.MetricRecorder;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
......@@ -51,13 +57,25 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.apache.atlas.model.patches.AtlasPatch.PatchStatus.UNKNOWN;
import static org.apache.atlas.repository.Constants.CREATED_BY_KEY;
import static org.apache.atlas.repository.Constants.INDEX_SEARCH_VERTEX_PREFIX_DEFAULT;
import static org.apache.atlas.repository.Constants.INDEX_SEARCH_VERTEX_PREFIX_PROPERTY;
import static org.apache.atlas.repository.Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.MODIFIED_BY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_ACTION_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_ID_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_DESCRIPTION_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_STATE_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.PATCH_TYPE_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.TIMESTAMP_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.VERTEX_INDEX;
import static org.apache.atlas.repository.graphdb.AtlasGraphQuery.SortOrder.*;
/**
......@@ -320,6 +338,22 @@ public class AtlasGraphUtilsV2 {
return vertex;
}
public static AtlasVertex findByPatchId(String patchId) {
AtlasVertex ret = null;
String indexQuery = getIndexSearchPrefix() + "\"" + PATCH_ID_PROPERTY_KEY + "\" : ("+ patchId +")";
Iterator<Result<Object, Object>> results = AtlasGraphProvider.getGraphInstance().indexQuery(VERTEX_INDEX, indexQuery).vertices();
while (results != null && results.hasNext()) {
ret = results.next().getVertex();
if (ret != null) {
break;
}
}
return ret;
}
public static AtlasVertex findByGuid(String guid) {
AtlasVertex ret = GraphTransactionInterceptor.getVertexFromCache(guid);
......@@ -433,6 +467,64 @@ public class AtlasGraphUtilsV2 {
return vertex;
}
public static Map<String, PatchStatus> initPatchesRegistry() {
Map<String, PatchStatus> ret = new HashMap<>();
AtlasPatches patches = getPatches();
for (AtlasPatch patch : patches.getPatches()) {
String patchId = patch.getId();
PatchStatus patchStatus = patch.getStatus();
if (patchId != null && patchStatus != null) {
ret.put(patchId, patchStatus);
}
}
return ret;
}
public static AtlasPatches getPatches() {
List<AtlasPatch> patches = new ArrayList<>();
String indexQuery = getIndexSearchPrefix() + "\"" + PATCH_ID_PROPERTY_KEY + "\" : (*)";
Iterator<Result<Object, Object>> results = AtlasGraphProvider.getGraphInstance().indexQuery(VERTEX_INDEX, indexQuery).vertices();
while (results != null && results.hasNext()) {
AtlasVertex patchVertex = results.next().getVertex();
AtlasPatch patch = toAtlasPatch(patchVertex);
patches.add(patch);
}
// Sort the patches based on patch id
if (CollectionUtils.isNotEmpty(patches)) {
Collections.sort(patches, (p1, p2) -> p1.getId().compareTo(p2.getId()));
}
return new AtlasPatches(patches);
}
private static AtlasPatch toAtlasPatch(AtlasVertex vertex) {
AtlasPatch ret = new AtlasPatch();
ret.setId(getEncodedProperty(vertex, PATCH_ID_PROPERTY_KEY, String.class));
ret.setDescription(getEncodedProperty(vertex, PATCH_DESCRIPTION_PROPERTY_KEY, String.class));
ret.setType(getEncodedProperty(vertex, PATCH_TYPE_PROPERTY_KEY, String.class));
ret.setAction(getEncodedProperty(vertex, PATCH_ACTION_PROPERTY_KEY, String.class));
ret.setCreatedBy(getEncodedProperty(vertex, CREATED_BY_KEY, String.class));
ret.setUpdatedBy(getEncodedProperty(vertex, MODIFIED_BY_KEY, String.class));
ret.setCreatedTime(getEncodedProperty(vertex, TIMESTAMP_PROPERTY_KEY, Long.class));
ret.setUpdatedTime(getEncodedProperty(vertex, MODIFICATION_TIMESTAMP_PROPERTY_KEY, Long.class));
ret.setStatus(getPatchStatus(vertex));
return ret;
}
private static PatchStatus getPatchStatus(AtlasVertex vertex) {
String patchStatus = AtlasGraphUtilsV2.getEncodedProperty(vertex, PATCH_STATE_PROPERTY_KEY, String.class);
return patchStatus != null ? PatchStatus.valueOf(patchStatus) : UNKNOWN;
}
public static List<String> findEntityGUIDsByType(String typename, SortOrder sortOrder) {
AtlasGraphQuery query = AtlasGraphProvider.getGraphInstance().query()
.has(Constants.ENTITY_TYPE_PROPERTY_KEY, typename);
......@@ -555,9 +647,9 @@ public class AtlasGraphUtilsV2 {
String propertyName = attribute.getVertexPropertyName();
AtlasIndexQuery query = getIndexQuery(entityType, propertyName, attrVal.toString());
for (Iterator<AtlasIndexQuery.Result> iter = query.vertices(); iter.hasNext(); ) {
AtlasIndexQuery.Result result = iter.next();
AtlasVertex vertex = result.getVertex();
for (Iterator<Result> iter = query.vertices(); iter.hasNext(); ) {
Result result = iter.next();
AtlasVertex vertex = result.getVertex();
// skip non-entity vertices, if any got returned
if (vertex == null || !vertex.getPropertyKeys().contains(Constants.GUID_PROPERTY_KEY)) {
......
......@@ -534,7 +534,7 @@ public class AtlasTypeDefGraphStoreV2 extends AtlasTypeDefGraphStore {
vertex.setProperty(Constants.VERSION_PROPERTY_KEY, newVersion);
}
private String getCurrentUser() {
public static String getCurrentUser() {
String ret = RequestContext.getCurrentUser();
if (StringUtils.isBlank(ret)) {
......
......@@ -28,7 +28,6 @@ import org.apache.atlas.authorize.AtlasPrivilege;
import org.apache.atlas.authorize.AtlasAuthorizationUtils;
import org.apache.atlas.discovery.SearchContext;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.discovery.AtlasSearchResult;
import org.apache.atlas.model.impexp.AtlasServer;
import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.impexp.AtlasExportResult;
......@@ -39,6 +38,7 @@ import org.apache.atlas.model.impexp.MigrationStatus;
import org.apache.atlas.model.instance.AtlasCheckStateRequest;
import org.apache.atlas.model.instance.AtlasCheckStateResult;
import org.apache.atlas.model.metrics.AtlasMetrics;
import org.apache.atlas.model.patches.AtlasPatch.AtlasPatches;
import org.apache.atlas.repository.impexp.AtlasServerService;
import org.apache.atlas.repository.impexp.ExportImportAuditService;
import org.apache.atlas.repository.impexp.ExportService;
......@@ -47,6 +47,7 @@ import org.apache.atlas.repository.impexp.MigrationProgressService;
import org.apache.atlas.repository.impexp.ZipSink;
import org.apache.atlas.repository.impexp.ZipSource;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.services.MetricsService;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
......@@ -555,6 +556,23 @@ public class AdminResource {
}
}
@GET
@Path("patches")
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasPatches getAtlasPatches() {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AdminResource.getAtlasPatches()");
}
AtlasPatches ret = AtlasGraphUtilsV2.getPatches();
if (LOG.isDebugEnabled()) {
LOG.debug("<== AdminResource.getAtlasPatches()");
}
return ret;
}
private String getEditableEntityTypes(Configuration config) {
String ret = DEFAULT_EDITABLE_ENTITY_TYPES;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment