23
23
import com .dqops .core .filesystem .virtual .FileNameSanitizer ;
24
24
import com .dqops .core .filesystem .virtual .HomeFilePath ;
25
25
import com .dqops .core .filesystem .virtual .HomeFolderPath ;
26
+ import com .dqops .core .principal .DqoUserPrincipal ;
27
+ import com .dqops .core .principal .DqoUserPrincipalProvider ;
28
+ import com .dqops .core .principal .UserDomainIdentity ;
26
29
import com .dqops .core .similarity .TableSimilarityRefreshService ;
27
30
import com .dqops .core .similarity .TableSimilarityRefreshServiceProvider ;
28
31
import com .dqops .data .checkresults .statuscache .DomainConnectionTableKey ;
@@ -79,7 +82,7 @@ public class LocalFileSystemCacheImpl implements LocalFileSystemCache, Disposabl
79
82
private final TableLineageCacheProvider tableLineageCacheProvider ;
80
83
private final TableSimilarityRefreshServiceProvider tableSimilarityRefreshServiceProvider ;
81
84
private final HomeLocationFindService homeLocationFindService ;
82
- private final Path userHomeRootPath ;
85
+ private Path userHomeRootPath ;
83
86
private Instant nextFileChangeDetectionAt = Instant .now ().minus (100L , ChronoUnit .MILLIS );
84
87
private boolean wasRecentlyInvalidated ;
85
88
@@ -105,17 +108,6 @@ public LocalFileSystemCacheImpl(DqoCacheConfigurationProperties dqoCacheConfigur
105
108
this .tableLineageCacheProvider = tableLineageCacheProvider ;
106
109
this .tableSimilarityRefreshServiceProvider = tableSimilarityRefreshServiceProvider ;
107
110
this .homeLocationFindService = homeLocationFindService ;
108
- this .userHomeRootPath = homeLocationFindService .getUserHomePath () != null ? Path .of (homeLocationFindService .getUserHomePath ()) : Path .of ("." );
109
-
110
- WatchService newWatchService = null ;
111
- if (dqoCacheConfigurationProperties .isEnable () && dqoCacheConfigurationProperties .isWatchFileSystemChanges ()) {
112
- try {
113
- newWatchService = FileSystems .getDefault ().newWatchService ();
114
- } catch (IOException ioe ) {
115
- throw new DqoRuntimeException ("Cannot create a watch service." );
116
- }
117
- }
118
- this .watchService = newWatchService ;
119
111
120
112
this .folderListsCache = Caffeine .newBuilder ()
121
113
.maximumSize (dqoCacheConfigurationProperties .getYamlFilesLimit ())
@@ -140,6 +132,25 @@ public LocalFileSystemCacheImpl(DqoCacheConfigurationProperties dqoCacheConfigur
140
132
.build ();
141
133
}
142
134
135
+ /**
136
+ * Starts a local file system cache.
137
+ */
138
+ @ Override
139
+ public void start () {
140
+ this .userHomeRootPath = homeLocationFindService .getRootUserHomePath () != null ?
141
+ Path .of (homeLocationFindService .getRootUserHomePath ()) : Path .of ("." );
142
+
143
+ WatchService newWatchService = null ;
144
+ if (dqoCacheConfigurationProperties .isEnable () && dqoCacheConfigurationProperties .isWatchFileSystemChanges ()) {
145
+ try {
146
+ newWatchService = FileSystems .getDefault ().newWatchService ();
147
+ } catch (IOException ioe ) {
148
+ throw new DqoRuntimeException ("Cannot create a watch service." );
149
+ }
150
+ }
151
+ this .watchService = newWatchService ;
152
+ }
153
+
143
154
/**
144
155
* Called when the object is destroyed. Stops the watcher.
145
156
* @throws Exception
@@ -157,7 +168,7 @@ public void destroy() throws Exception {
157
168
* @param folderPath Folder path.
158
169
*/
159
170
public void startFolderWatcher (Path folderPath ) {
160
- if (folderPath == null ) {
171
+ if (folderPath == null || this . watchService == null ) {
161
172
return ;
162
173
}
163
174
@@ -481,6 +492,10 @@ public void invalidateFile(Path filePath) {
481
492
* and it is not a real invalidation, but just a notification that a file was just cached.
482
493
*/
483
494
public void invalidateTableCaches (Path filePath , boolean replacingCachedFile ) {
495
+ if (this .userHomeRootPath == null ) {
496
+ return ; // not initialized
497
+ }
498
+
484
499
if (!filePath .startsWith (this .userHomeRootPath )) {
485
500
return ;
486
501
}
0 commit comments