use of org.neo4j.shell.impl.RmiLocation in project neo4j by neo4j.
the class LegacyDatabaseImpl method start.
public static Future<LegacyDatabase> start(String classpath, File storeDir, Map<String, String> config) throws Exception {
List<String> args = new ArrayList<String>();
args.add(storeDir.getAbsolutePath());
int rmiPort = 7000 + parseInt(config.get("ha.server_id"));
args.add("" + rmiPort);
args.addAll(asList(new Args(config).asArgs()));
final Process process = execJava(appendNecessaryTestClasses(classpath), LegacyDatabaseImpl.class.getName(), args.toArray(new String[0]));
new ProcessStreamHandler(process, false).launch();
final RmiLocation rmiLocation = rmiLocation(rmiPort);
ExecutorService executor = newSingleThreadExecutor();
Future<LegacyDatabase> future = executor.submit(new Callable<LegacyDatabase>() {
@Override
public LegacyDatabase call() throws Exception {
long endTime = currentTimeMillis() + SECONDS.toMillis(10000);
while (currentTimeMillis() < endTime) {
try {
return (LegacyDatabase) rmiLocation.getBoundObject();
} catch (RemoteException e) {
// OK
sleep(100);
}
}
process.destroy();
throw new IllegalStateException("Couldn't get remote to legacy database");
}
});
executor.shutdown();
return future;
}
Aggregations