So I was reading https://apple.github.io/foundationdb/api-general.html#multi-version-client-api and have a few questions about how to do this.
Currently we are using the java bindings and are doing a System.load() on the fdb shared object library before opening a database instance with a cluster file.
We are planning to upgrade to 6.1.8 from 6.0.15 and are planning to make the clients be able to handle both versions so that the database can be upgraded similar to what I read here:
Upgrading FoundationDB
I tried a naive approach of loading both library versions with the following:
import com.apple.foundationdb.Database;
import com.apple.foundationdb.FDB;
import com.apple.foundationdb.tuple.Tuple;
import java.io.File;
public class Main {
public static void main(String[] args) {
File fdbLib6015 = new File("resources/libfdb_c_6.0.15.so");
File fdbLib618 = new File("resources/libfdb_c_6.1.8.so");
File clusterFile6015 = new File("resources/fdb_6015.cluster");
File clusterFile618 = new File("resources/fdb_618.cluster");
System.load(fdbLib6015.getAbsolutePath());
System.load(fdbLib618.getAbsolutePath());
FDB fdb = FDB.selectAPIVersion(600);
File[] fdb_cluster_files = {clusterFile6015, clusterFile618};
for (int i = 0; i < fdb_cluster_files.length; i++) {
System.out.println("Trying to connect with cluster file: " + fdb_cluster_files[i].toString());
try(Database db = fdb.open(fdb_cluster_files[i].getAbsolutePath())) {
// Run an operation on the database
db.run(tr -> {
tr.set(Tuple.from("hello").pack(), Tuple.from("world").pack());
return null;
});
// Get the value of 'hello' from the database
String hello = db.run(tr -> {
byte[] result = tr.get(Tuple.from("hello").pack()).join();
return Tuple.fromBytes(result).getString(0);
});
System.out.println("Hello " + hello);
}
System.out.println("Success!\n");
}
}
private Main() {}
}
But this hangs when trying to connect to the 6.1.8 cluster due to loading the 6.0.15 library first. I can reverse the order of the System.load() and the 6.1.8 will connect whereas the 6.0.15 will hang forever.
So I know that approach will not work. I then looked further through the javadoc https://apple.github.io/foundationdb/javadoc/index.html but did not see anything relevant to the EXTERNAL_CLIENT_DIRECTORY / EXTERNAL_CLIENT_LIBRARY network options that the docs say need to be set.
Looking here I can see that it definitely is a network option but I guess my question is how would I set this with the Java API bindings properly to be able to connect to both a 6.1.8 and a 6.0.15 cluster? And then with this set up properly, would that client be able to handle an upgrade of the 6.0.15 cluster going to 6.1.8 with minimal downtime?
Or am I approaching this all wrong?