@@ -123,135 +123,17 @@ public void init() throws AtlasBaseException {
123
123
}
124
124
125
125
@ Override
126
- public void reloadEnumTypeDefs () throws AtlasBaseException {
127
- LOG .info ("==> AtlasTypeDefGraphStore.reloadEnumTypeDefs()" );
128
- AtlasTransientTypeRegistry ttr = null ;
129
- boolean commitUpdates = false ;
130
-
131
- try {
132
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
133
- List <AtlasEnumDef > enumDefs = getEnumDefStore (ttr ).getAll ();
134
- for (AtlasBaseTypeDef atlasBaseTypeDef : ttr .getAllEnumDefs ()) {
135
- if (atlasBaseTypeDef instanceof AtlasEnumDef ) {
136
- ttr .removeTypeByName (atlasBaseTypeDef .getName ());
137
- }
138
- }
139
- ttr .addTypes (enumDefs );
140
- commitUpdates = true ;
141
- } finally {
142
- typeRegistry .releaseTypeRegistryForUpdate (ttr , commitUpdates );
143
- LOG .info ("<== AtlasTypeDefGraphStore.reloadEnumTypeDefs()" );
144
- }
145
- }
146
-
147
- @ Override
148
- public void reloadStructTypeDefs () throws AtlasBaseException {
149
- LOG .info ("==> AtlasTypeDefGraphStore.reloadStructTypeDefs()" );
150
- AtlasTransientTypeRegistry ttr = null ;
151
- boolean commitUpdates = false ;
152
-
153
- try {
154
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
155
- List <AtlasStructDef > structDefs = getStructDefStore (ttr ).getAll ();
156
- for (AtlasBaseTypeDef atlasBaseTypeDef : ttr .getAllStructDefs ()) {
157
- if (atlasBaseTypeDef instanceof AtlasStructDef ) {
158
- ttr .removeTypeByName (atlasBaseTypeDef .getName ());
159
- }
160
- }
161
- ttr .addTypes (structDefs );
162
- commitUpdates = true ;
163
- } finally {
164
- typeRegistry .releaseTypeRegistryForUpdate (ttr , commitUpdates );
165
- LOG .info ("<== AtlasTypeDefGraphStore.reloadStructTypeDefs()" );
166
- }
167
- }
168
-
169
- @ Override
170
- public void reloadEntityTypeDefs () throws AtlasBaseException {
171
- LOG .info ("==> AtlasTypeDefGraphStore.reloadEntityTypeDefs()" );
172
- AtlasTransientTypeRegistry ttr = null ;
173
- boolean commitUpdates = false ;
174
-
175
- try {
176
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
177
- List <AtlasEntityDef > entityDefs = getEntityDefStore (ttr ).getAll ();
178
- for (AtlasBaseTypeDef atlasBaseTypeDef : ttr .getAllEntityDefs ()) {
179
- if (atlasBaseTypeDef instanceof AtlasEntityDef ) {
180
- ttr .removeTypeByName (atlasBaseTypeDef .getName ());
181
- }
182
- }
183
- ttr .addTypes (entityDefs );
184
- commitUpdates = true ;
185
- } finally {
186
- typeRegistry .releaseTypeRegistryForUpdate (ttr , commitUpdates );
187
- LOG .info ("<== AtlasTypeDefGraphStore.reloadEntityTypeDefs()" );
188
- }
189
- }
190
-
191
- @ Override
192
- public void reloadRelationshipTypeDefs () throws AtlasBaseException {
193
- LOG .info ("==> AtlasTypeDefGraphStore.reloadRelationshipTypeDefs()" );
194
- AtlasTransientTypeRegistry ttr = null ;
195
- boolean commitUpdates = false ;
196
-
197
- try {
198
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
199
- List <AtlasRelationshipDef > relationshipDefs = getRelationshipDefStore (ttr ).getAll ();
200
- for (AtlasBaseTypeDef atlasBaseTypeDef : ttr .getAllRelationshipDefs ()) {
201
- if (atlasBaseTypeDef instanceof AtlasRelationshipDef ) {
202
- ttr .removeTypeByName (atlasBaseTypeDef .getName ());
203
- }
204
- }
205
- ttr .addTypes (relationshipDefs );
206
- commitUpdates = true ;
207
- } finally {
208
- typeRegistry .releaseTypeRegistryForUpdate (ttr , commitUpdates );
209
- LOG .info ("<== AtlasTypeDefGraphStore.reloadRelationshipTypeDefs()" );
210
- }
211
- }
212
-
213
- @ Override
214
- public void reloadBusinessMetadataTypeDefs () throws AtlasBaseException {
215
- LOG .info ("==> AtlasTypeDefGraphStore.reloadBusinessMetadataTypeDefs()" );
216
- AtlasTransientTypeRegistry ttr = null ;
217
- boolean commitUpdates = false ;
218
-
219
- try {
220
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
221
- List <AtlasBusinessMetadataDef > businessMetadataDefs = getBusinessMetadataDefStore (ttr ).getAll ();
222
- for (AtlasBaseTypeDef atlasBaseTypeDef : ttr .getAllBusinessMetadataDefs ()) {
223
- if (atlasBaseTypeDef instanceof AtlasBusinessMetadataDef ) {
224
- ttr .removeTypeByName (atlasBaseTypeDef .getName ());
225
- }
226
- }
227
- ttr .addTypes (businessMetadataDefs );
228
- commitUpdates = true ;
229
- } finally {
230
- typeRegistry .releaseTypeRegistryForUpdate (ttr , commitUpdates );
231
- LOG .info ("<== AtlasTypeDefGraphStore.reloadBusinessMetadataTypeDefs()" );
232
- }
233
- }
234
-
235
- @ Override
236
- public void reloadClassificationMetadataTypeDefs () throws AtlasBaseException {
237
- LOG .info ("==> AtlasTypeDefGraphStore.reloadClassificationMetadataTypeDefs()" );
238
- AtlasTransientTypeRegistry ttr = null ;
239
- boolean commitUpdates = false ;
240
-
241
- try {
242
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
243
- List <AtlasClassificationDef > classificationDefs = getClassificationDefStore (ttr ).getAll ();
244
- for (AtlasBaseTypeDef atlasBaseTypeDef : ttr .getAllClassificationDefs ()) {
245
- if (atlasBaseTypeDef instanceof AtlasClassificationDef ) {
246
- ttr .removeTypeByName (atlasBaseTypeDef .getName ());
247
- }
248
- }
249
- ttr .addTypes (classificationDefs );
250
- commitUpdates = true ;
251
- } finally {
252
- typeRegistry .releaseTypeRegistryForUpdate (ttr , commitUpdates );
253
- LOG .info ("<== AtlasTypeDefGraphStore.reloadClassificationMetadataTypeDefs()" );
254
- }
126
+ public void initWithoutLock () throws AtlasBaseException {
127
+ // need even better approach than this
128
+ AtlasTypesDef typesDef = new AtlasTypesDef (getEnumDefStore (typeRegistry ).getAll (),
129
+ getStructDefStore (typeRegistry ).getAll (),
130
+ getClassificationDefStore (typeRegistry ).getAll (),
131
+ getEntityDefStore (typeRegistry ).getAll (),
132
+ getRelationshipDefStore (typeRegistry ).getAll (),
133
+ getBusinessMetadataDefStore (typeRegistry ).getAll ());
134
+
135
+ rectifyTypeErrorsIfAny (typesDef );
136
+ typeRegistry .addTypes (typesDef );
255
137
}
256
138
257
139
@ Override
@@ -831,7 +713,7 @@ public void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
831
713
832
714
@ Override
833
715
@ GraphTransaction
834
- public AtlasBaseTypeDef deleteTypeByName (String typeName ) throws AtlasBaseException {
716
+ public void deleteTypeByName (String typeName ) throws AtlasBaseException {
835
717
AtlasType atlasType = typeRegistry .getType (typeName );
836
718
if (atlasType == null ) {
837
719
throw new AtlasBaseException (AtlasErrorCode .INVALID_PARAMETERS .TYPE_NAME_NOT_FOUND , typeName );
@@ -855,58 +737,52 @@ public AtlasBaseTypeDef deleteTypeByName(String typeName) throws AtlasBaseExcept
855
737
}
856
738
857
739
deleteTypesDef (typesDef );
858
- return baseTypeDef ;
859
740
}
860
741
861
742
@ Override
862
743
public AtlasTypesDef searchTypesDef (SearchFilter searchFilter ) throws AtlasBaseException {
863
744
final AtlasTypesDef typesDef = new AtlasTypesDef ();
864
745
Predicate searchPredicates = FilterUtil .getPredicateFromSearchFilter (searchFilter );
865
- AtlasTransientTypeRegistry ttr = null ;
866
- try {
867
- ttr = typeRegistry .lockTypeRegistryForUpdate (5 );
868
- for (AtlasEnumType enumType : ttr .getAllEnumTypes ()) {
869
- if (searchPredicates .evaluate (enumType )) {
870
- typesDef .getEnumDefs ().add (enumType .getEnumDef ());
871
- }
746
+
747
+ for (AtlasEnumType enumType : typeRegistry .getAllEnumTypes ()) {
748
+ if (searchPredicates .evaluate (enumType )) {
749
+ typesDef .getEnumDefs ().add (enumType .getEnumDef ());
872
750
}
751
+ }
873
752
874
- for (AtlasStructType structType : ttr .getAllStructTypes ()) {
875
- if (searchPredicates .evaluate (structType )) {
876
- typesDef .getStructDefs ().add (structType .getStructDef ());
877
- }
753
+ for (AtlasStructType structType : typeRegistry .getAllStructTypes ()) {
754
+ if (searchPredicates .evaluate (structType )) {
755
+ typesDef .getStructDefs ().add (structType .getStructDef ());
878
756
}
757
+ }
879
758
880
- for (AtlasClassificationType classificationType : ttr .getAllClassificationTypes ()) {
881
- if (searchPredicates .evaluate (classificationType )) {
882
- typesDef .getClassificationDefs ().add (classificationType .getClassificationDef ());
883
- }
759
+ for (AtlasClassificationType classificationType : typeRegistry .getAllClassificationTypes ()) {
760
+ if (searchPredicates .evaluate (classificationType )) {
761
+ typesDef .getClassificationDefs ().add (classificationType .getClassificationDef ());
884
762
}
763
+ }
885
764
886
- for (AtlasEntityType entityType : ttr .getAllEntityTypes ()) {
887
- if (searchPredicates .evaluate (entityType )) {
888
- typesDef .getEntityDefs ().add (entityType .getEntityDef ());
889
- }
765
+ for (AtlasEntityType entityType : typeRegistry .getAllEntityTypes ()) {
766
+ if (searchPredicates .evaluate (entityType )) {
767
+ typesDef .getEntityDefs ().add (entityType .getEntityDef ());
890
768
}
769
+ }
891
770
892
- for (AtlasRelationshipType relationshipType : ttr .getAllRelationshipTypes ()) {
893
- if (searchPredicates .evaluate (relationshipType )) {
894
- typesDef .getRelationshipDefs ().add (relationshipType .getRelationshipDef ());
895
- }
771
+ for (AtlasRelationshipType relationshipType : typeRegistry .getAllRelationshipTypes ()) {
772
+ if (searchPredicates .evaluate (relationshipType )) {
773
+ typesDef .getRelationshipDefs ().add (relationshipType .getRelationshipDef ());
896
774
}
775
+ }
897
776
898
- for (AtlasBusinessMetadataType businessMetadataType : ttr .getAllBusinessMetadataTypes ()) {
899
- if (searchPredicates .evaluate (businessMetadataType )) {
900
- typesDef .getBusinessMetadataDefs ().add (businessMetadataType .getBusinessMetadataDef ());
901
- }
777
+ for (AtlasBusinessMetadataType businessMetadataType : typeRegistry .getAllBusinessMetadataTypes ()) {
778
+ if (searchPredicates .evaluate (businessMetadataType )) {
779
+ typesDef .getBusinessMetadataDefs ().add (businessMetadataType .getBusinessMetadataDef ());
902
780
}
781
+ }
903
782
904
- AtlasAuthorizationUtils .filterTypesDef (new AtlasTypesDefFilterRequest (typesDef ));
783
+ AtlasAuthorizationUtils .filterTypesDef (new AtlasTypesDefFilterRequest (typesDef ));
905
784
906
- return typesDef ;
907
- } finally {
908
- typeRegistry .releaseTypeRegistryForUpdate (ttr , false );
909
- }
785
+ return typesDef ;
910
786
}
911
787
912
788
@ Override
0 commit comments