I am currently writing up a program to install FDB client/server packages, extracting their files, and then running fdbserver
and fdbcli
binaries to start up a server and create a database (trying to do this all programmatically because I am using it as the setup for my java test environment which requires foundationdb
).
I have currently successfully managed to download the binaries and have been able to successfully run both fdbserver
and fdbcli
binaries. However, there seems to be something wrong when I try to create a new database by running ./fdbcli --exec "configure new single memory"
. The error message I get specifically is: ERROR: Unknown command
configure new single memory’. Try help'?
I initially that maybe the issue was related to fdbcli
binary but I do not think this is the case because when I run ./fdbcli --exec "status"
, I get a correct response. Is there something I am doing wrong // is there some other way I can manage to create a new database programmatically?
This sounds like some escaping issue to me. Can you give us some more context on how you automate this? And can you post the relevant code that runs this command?
This is the code I am using to run the binaries:
final CommandLine status = new CommandLine(fdbCliBinary.getAbsolutePath());
status.addArgument("--exec");
status.addArgument("\"status\"");
executeCommand(status, true);
final CommandLine configureDatabase = new CommandLine(fdbCliBinary.getAbsolutePath());
configureDatabase.addArgument("--exec");
configureDatabase.addArgument("\"configure new single memory\"");
executeCommand(configureDatabase, true);
where executeCommand
is as follows:
private void executeCommand(final CommandLine command, final boolean shouldExecuteAsync) {
LOGGER.warn("Running async: {}", String.join(" ", command.toStrings()));
try {
final ExecuteWatchdog watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
final DefaultExecutor executor = new DefaultExecutor();
executor.setWatchdog(watchdog);
executor.setWorkingDirectory(foundationLocalDir);
watchdogs.add(watchdog);
LOGGER.warn("command: " + command.toString());
if (shouldExecuteAsync) {
// Using a result handler makes the command run async
executor.execute(command, new DefaultExecuteResultHandler());
} else {
// Only passing in command makes the command run sync
executor.execute(command);
}
} catch (Exception e) {
LOGGER.warn("FAILED EXECUTE: " + e.getStackTrace());
}
}
Running the first status
command returns a valid response but running the second configure new single memory
command fails.
Here are the log statements that get printed as well in case it helps:
Running async: /Users/kevinchan/Documents/Courses/cs5152/geowave/test/./target/temp/fdb/fdbcli --exec status
Running async: /Users/kevinchan/Documents/Courses/cs5152/geowave/test/./target/temp/fdb/fdbcli --exec "configure new single memory"
I just tried putting the command into a configure-db.sh
file as follows:
#!/bin/sh
/Users/kevinchan/Documents/Courses/cs5152/geowave/test/./target/temp/fdb/fdbcli --exec "configure new single memory"
and then changing my code to run configure-db.sh
instead and that seems to work so it seems like your hunch that it has to do with escaping characters seems to correct? Although I am not sure how I would fix my code.
I think this is wrong. Can you try the following?
configureDatabase.addArgument("configure new single memory");
This being said, escaping rules usually confuse me. I would assume that the addArgument
method does some automatic escaping for you and so your additional escaping is then carried over to fdbcli (and so fdbcli thinks that you want to have this as one token).
I tried changing it to that but I get the same error
Oh I figured it out! addArgument
as an optional field called handleQuoting
which defaults to true
. I just called:
configureDatabase.addArgument("configure new single memory", false);
and it worked! Thanks so much for the help!