-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "MET-5473: Upgrade to jdk 21 builder (#639)"
This reverts commit 0f9e8b4.
- Loading branch information
Showing
17 changed files
with
139 additions
and
123 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
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
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
114 changes: 52 additions & 62 deletions
114
...-common-mongo/src/main/java/eu/europeana/metis/mongo/embedded/EmbeddedLocalhostMongo.java
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 |
---|---|---|
@@ -1,85 +1,75 @@ | ||
package eu.europeana.metis.mongo.embedded; | ||
|
||
import de.flapdoodle.embed.mongo.commands.ImmutableMongodArguments; | ||
import de.flapdoodle.embed.mongo.commands.MongodArguments; | ||
import de.flapdoodle.embed.mongo.Command; | ||
import de.flapdoodle.embed.mongo.MongodExecutable; | ||
import de.flapdoodle.embed.mongo.MongodStarter; | ||
import de.flapdoodle.embed.mongo.config.Defaults; | ||
import de.flapdoodle.embed.mongo.config.MongodConfig; | ||
import de.flapdoodle.embed.mongo.config.Net; | ||
import de.flapdoodle.embed.mongo.distribution.Version; | ||
import de.flapdoodle.embed.mongo.transitions.ImmutableMongod; | ||
import de.flapdoodle.embed.mongo.transitions.Mongod; | ||
import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess; | ||
import de.flapdoodle.embed.process.io.ImmutableProcessOutput; | ||
import de.flapdoodle.embed.process.io.ProcessOutput; | ||
import de.flapdoodle.embed.process.io.Processors; | ||
import de.flapdoodle.embed.process.io.Slf4jLevel; | ||
import de.flapdoodle.reverse.TransitionWalker; | ||
import de.flapdoodle.reverse.transitions.Start; | ||
import de.flapdoodle.embed.process.config.RuntimeConfig; | ||
import de.flapdoodle.embed.process.config.io.ProcessOutput; | ||
import de.flapdoodle.embed.process.runtime.Network; | ||
import eu.europeana.metis.network.NetworkUtil; | ||
import java.io.IOException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Starts an in memory Mongo database. This class is to be used for unit testing on localhost. | ||
*/ | ||
public class EmbeddedLocalhostMongo { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedLocalhostMongo.class); | ||
|
||
private static final String DEFAULT_MONGO_HOST = "127.0.0.1"; | ||
private static final ImmutableProcessOutput processOutput = ProcessOutput.builder() | ||
.commands(Processors.logTo(LOGGER, Slf4jLevel.DEBUG)) | ||
.output(Processors.logTo(LOGGER, Slf4jLevel.INFO)) | ||
.error(Processors.logTo(LOGGER, Slf4jLevel.ERROR)) | ||
.build(); | ||
|
||
private static final ImmutableMongodArguments mongodArguments = MongodArguments.defaults() | ||
.withSyncDelay(0) | ||
.withStorageEngine("ephemeralForTest") | ||
.withUseNoJournal(true); | ||
private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedLocalhostMongo.class); | ||
|
||
private TransitionWalker.ReachedState<RunningMongodProcess> runningMongodProcessReachedState; | ||
private int mongoPort; | ||
private static final String DEFAULT_MONGO_HOST = "127.0.0.1"; | ||
private MongodExecutable mongodExecutable; | ||
private int mongoPort; | ||
|
||
/** | ||
* Constructor for default object for localhost mongo | ||
*/ | ||
public EmbeddedLocalhostMongo() { | ||
//Nothing to do | ||
} | ||
/** | ||
* Constructor for default object for localhost mongo | ||
*/ | ||
public EmbeddedLocalhostMongo() { | ||
//Nothing to do | ||
} | ||
|
||
/** | ||
* Starts a local host mongo. | ||
*/ | ||
public void start() { | ||
if (runningMongodProcessReachedState == null) { | ||
try { | ||
mongoPort = new NetworkUtil().getAvailableLocalPort(); | ||
ImmutableMongod mongod = Mongod.instance() | ||
.withNet(Start.to(Net.class).initializedWith(Net.builder().bindIp(DEFAULT_MONGO_HOST).port(mongoPort).isIpv6(true).build())) | ||
.withProcessOutput(Start.to(ProcessOutput.class).initializedWith(processOutput)) | ||
.withMongodArguments(Start.to(MongodArguments.class).initializedWith(mongodArguments)); | ||
/** | ||
* Starts a local host mongo. | ||
*/ | ||
public void start() { | ||
if (mongodExecutable == null) { | ||
try { | ||
mongoPort = new NetworkUtil().getAvailableLocalPort(); | ||
RuntimeConfig runtimeConfig = Defaults.runtimeConfigFor(Command.MongoD, LOGGER) | ||
.processOutput(ProcessOutput.getDefaultInstanceSilent()) | ||
.build(); | ||
|
||
runningMongodProcessReachedState = mongod.start(Version.Main.V4_4); | ||
MongodConfig mongodConfig = MongodConfig.builder() | ||
.version(Version.V4_0_12) | ||
.net(new Net(DEFAULT_MONGO_HOST, mongoPort, Network.localhostIsIPv6())) | ||
.build(); | ||
|
||
} catch (IOException e) { | ||
LOGGER.error("Exception when starting embedded mongo", e); | ||
} | ||
} | ||
MongodStarter runtime = MongodStarter.getInstance(runtimeConfig); | ||
mongodExecutable = runtime.prepare(mongodConfig); | ||
mongodExecutable.start(); | ||
} catch (IOException e) { | ||
LOGGER.error("Exception when starting embedded mongo", e); | ||
} | ||
} | ||
} | ||
|
||
public String getMongoHost() { | ||
return DEFAULT_MONGO_HOST; | ||
} | ||
public String getMongoHost() { | ||
return DEFAULT_MONGO_HOST; | ||
} | ||
|
||
public int getMongoPort() { | ||
return mongoPort; | ||
} | ||
public int getMongoPort() { | ||
return mongoPort; | ||
} | ||
|
||
/** | ||
* Stop a previously started local host mongo. | ||
*/ | ||
public void stop() { | ||
runningMongodProcessReachedState.close(); | ||
} | ||
/** | ||
* Stop a previously started local host mongo. | ||
*/ | ||
public void stop() { | ||
mongodExecutable.stop(); | ||
} | ||
} |
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
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
4 changes: 2 additions & 2 deletions
4
...st/src/main/java/eu/europeana/metis/core/rest/exception/RestResponseExceptionHandler.java
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
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
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
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
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
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
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
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
Oops, something went wrong.