-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEOMESA-3436 NiFi - Fix FSDS path cache classpath (#3258)
* Use Caffeine 2.x-compatible API calls
- Loading branch information
1 parent
713b902
commit 601ffb9
Showing
2 changed files
with
103 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ommon/src/test/scala/org/locationtech/geomesa/fs/storage/common/utils/PathCacheTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*********************************************************************** | ||
* Copyright (c) 2013-2025 Commonwealth Computer Research, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Apache License, Version 2.0 | ||
* which accompanies this distribution and is available at | ||
* http://www.opensource.org/licenses/apache2.0.php. | ||
***********************************************************************/ | ||
|
||
package org.locationtech.geomesa.fs.storage.common.utils | ||
|
||
import org.apache.hadoop.conf.Configuration | ||
import org.apache.hadoop.fs.{FileSystem, Path} | ||
import org.junit.runner.RunWith | ||
import org.specs2.mutable.Specification | ||
import org.specs2.runner.JUnitRunner | ||
|
||
import java.nio.file.Files | ||
import scala.concurrent.duration.DurationInt | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class PathCacheTest extends Specification { | ||
|
||
"PathCache" should { | ||
"update list cache when registering a new file" >> { | ||
val root = new Path(Files.createTempDirectory("geomesa").toFile.getPath) | ||
val fs = FileSystem.get(root.toUri, new Configuration()) | ||
try { | ||
val file = new Path(root, "test") | ||
PathCache.exists(fs, file) must beFalse | ||
PathCache.list(fs, root) must beEmpty | ||
// create the file | ||
fs.create(file).close() | ||
fs.exists(file) must beTrue | ||
// verify cache has not been updated | ||
PathCache.exists(fs, file) must beFalse | ||
PathCache.list(fs, root) must beEmpty | ||
// register the file | ||
PathCache.register(fs, file) | ||
// verify cached values have been updated | ||
PathCache.exists(fs, file) must beTrue | ||
eventually(10, 100.millis)(PathCache.list(fs, root).toList must haveLength(1)) | ||
// note: it's hard to verify this is a cached value, since it doesn't cache if a file doesn't exist... | ||
PathCache.status(fs, file) must not(beNull) | ||
} finally { | ||
fs.delete(root, true) | ||
} | ||
} | ||
} | ||
} |