50
50
import org .apache .atlas .repository .patches .SuperTypesUpdatePatch ;
51
51
import org .apache .atlas .repository .patches .AtlasPatchManager ;
52
52
import org .apache .atlas .repository .patches .AtlasPatchRegistry ;
53
+ import org .apache .atlas .service .redis .RedisService ;
53
54
import org .apache .atlas .store .AtlasTypeDefStore ;
54
55
import org .apache .atlas .type .AtlasEntityType ;
55
56
import org .apache .atlas .type .AtlasStructType .AtlasAttribute ;
@@ -101,15 +102,23 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
101
102
private final Configuration conf ;
102
103
private final AtlasGraph graph ;
103
104
private final AtlasPatchManager patchManager ;
105
+ private final RedisService redisService ;
106
+ private static long CURRENT_ENUM_TYPEDEF_INTERNAL_VERSION ;
107
+ private static long CURRENT_BUSINESS_METADATA_TYPEDEF_INTERNAL_VERSION ;
108
+ private static long CURRENT_CLASSIFICATION_TYPEDEF_INTERNAL_VERSION ;
109
+ private static long CURRENT_STRUCT_TYPEDEF_INTERNAL_VERSION ;
110
+ private static long CURRENT_ENTITY_TYPEDEF_INTERNAL_VERSION ;
111
+ private static long CURRENT_RELATIONSHIP_TYPEDEF_INTERNAL_VERSION ;
104
112
105
113
@ Inject
106
114
public AtlasTypeDefStoreInitializer (AtlasTypeDefStore typeDefStore , AtlasTypeRegistry typeRegistry ,
107
- AtlasGraph graph , Configuration conf , AtlasPatchManager patchManager ) throws AtlasBaseException {
115
+ AtlasGraph graph , Configuration conf , AtlasPatchManager patchManager , RedisService redisService ) throws AtlasBaseException {
108
116
this .typeDefStore = typeDefStore ;
109
117
this .typeRegistry = typeRegistry ;
110
118
this .conf = conf ;
111
119
this .graph = graph ;
112
120
this .patchManager = patchManager ;
121
+ this .redisService = redisService ;
113
122
}
114
123
115
124
@ PostConstruct
@@ -118,6 +127,12 @@ public void init() {
118
127
119
128
if (!HAConfiguration .isHAEnabled (conf )) {
120
129
startInternal ();
130
+ CURRENT_ENUM_TYPEDEF_INTERNAL_VERSION = Long .parseLong (redisService .getValue (Constants .TYPEDEF_ENUM_CACHE_LATEST_VERSION , "1" ));
131
+ CURRENT_BUSINESS_METADATA_TYPEDEF_INTERNAL_VERSION = Long .parseLong (redisService .getValue (Constants .TYPEDEF_BUSINESS_METADATA_CACHE_LATEST_VERSION , "1" ));
132
+ CURRENT_CLASSIFICATION_TYPEDEF_INTERNAL_VERSION = Long .parseLong (redisService .getValue (Constants .TYPEDEF_CLASSIFICATION_METADATA_CACHE_LATEST_VERSION , "1" ));
133
+ CURRENT_STRUCT_TYPEDEF_INTERNAL_VERSION = Long .parseLong (redisService .getValue (Constants .TYPEDEF_STRUCT_CACHE_LATEST_VERSION , "1" ));
134
+ CURRENT_ENTITY_TYPEDEF_INTERNAL_VERSION = Long .parseLong (redisService .getValue (Constants .TYPEDEF_ENTITY_CACHE_LATEST_VERSION , "1" ));
135
+ CURRENT_RELATIONSHIP_TYPEDEF_INTERNAL_VERSION = Long .parseLong (redisService .getValue (Constants .TYPEDEF_RELATIONSHIP_CACHE_LATEST_VERSION , "1" ));
121
136
} else {
122
137
LOG .info ("AtlasTypeDefStoreInitializer.init(): deferring type loading until instance activation" );
123
138
}
@@ -407,6 +422,54 @@ public int getHandlerOrder() {
407
422
return HandlerOrder .TYPEDEF_STORE_INITIALIZER .getOrder ();
408
423
}
409
424
425
+ public static long getCurrentEnumTypedefInternalVersion () {
426
+ return CURRENT_ENUM_TYPEDEF_INTERNAL_VERSION ;
427
+ }
428
+
429
+ public static void setCurrentEnumTypedefInternalVersion (long version ) {
430
+ CURRENT_ENUM_TYPEDEF_INTERNAL_VERSION = version ;
431
+ }
432
+
433
+ public static long getCurrentBMTypedefInternalVersion () {
434
+ return CURRENT_BUSINESS_METADATA_TYPEDEF_INTERNAL_VERSION ;
435
+ }
436
+
437
+ public static void setCurrentBMTypedefInternalVersion (long version ) {
438
+ CURRENT_BUSINESS_METADATA_TYPEDEF_INTERNAL_VERSION = version ;
439
+ }
440
+
441
+ public static long getCurrentClassificationTypedefInternalVersion () {
442
+ return CURRENT_CLASSIFICATION_TYPEDEF_INTERNAL_VERSION ;
443
+ }
444
+
445
+ public static void setCurrentClassificationTypedefInternalVersion (long version ) {
446
+ CURRENT_CLASSIFICATION_TYPEDEF_INTERNAL_VERSION = version ;
447
+ }
448
+
449
+ public static long getCurrentStructTypedefInternalVersion () {
450
+ return CURRENT_STRUCT_TYPEDEF_INTERNAL_VERSION ;
451
+ }
452
+
453
+ public static void setCurrentStructTypedefInternalVersion (long version ) {
454
+ CURRENT_STRUCT_TYPEDEF_INTERNAL_VERSION = version ;
455
+ }
456
+
457
+ public static long getCurrentEntityTypedefInternalVersion () {
458
+ return CURRENT_ENTITY_TYPEDEF_INTERNAL_VERSION ;
459
+ }
460
+
461
+ public static void setCurrentEntityTypedefInternalVersion (long version ) {
462
+ CURRENT_ENTITY_TYPEDEF_INTERNAL_VERSION = version ;
463
+ }
464
+
465
+ public static long getCurrentRelationshipTypedefInternalVersion () {
466
+ return CURRENT_RELATIONSHIP_TYPEDEF_INTERNAL_VERSION ;
467
+ }
468
+
469
+ public static void setCurrentRelationshipTypedefInternalVersion (long version ) {
470
+ CURRENT_RELATIONSHIP_TYPEDEF_INTERNAL_VERSION = version ;
471
+ }
472
+
410
473
private static boolean updateTypeAttributes (AtlasStructDef oldStructDef , AtlasStructDef newStructDef , boolean checkTypeVersion ) {
411
474
boolean ret = isTypeUpdateApplicable (oldStructDef , newStructDef , checkTypeVersion );
412
475
0 commit comments