use of org.neo4j.kernel.HighlyAvailableGraphDatabase in project graphdb by neo4j-attic.
the class SingleJvmTest method addDb.
@Override
protected void addDb(Map<String, String> config) {
haDbs = haDbs != null ? haDbs : new ArrayList<GraphDatabaseService>();
int machineId = haDbs.size() + 1;
File slavePath = dbPath(machineId);
PlaceHolderGraphDatabaseService placeHolderDb = new PlaceHolderGraphDatabaseService(slavePath.getAbsolutePath());
Broker broker = makeSlaveBroker(master, 0, machineId, placeHolderDb);
Map<String, String> cfg = new HashMap<String, String>(config);
cfg.put(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_MACHINE_ID, Integer.toString(machineId));
cfg.put(Config.KEEP_LOGICAL_LOGS, "true");
HighlyAvailableGraphDatabase db = new HighlyAvailableGraphDatabase(slavePath.getAbsolutePath(), cfg, wrapBrokerAndSetPlaceHolderDb(placeHolderDb, broker));
placeHolderDb.setDb(db);
haDbs.add(db);
}
use of org.neo4j.kernel.HighlyAvailableGraphDatabase in project graphdb by neo4j-attic.
the class StartLocalHaDb method main.
public static void main(String[] args) {
String path = args[0];
String configFile = args[1];
Map<String, String> config = HighlyAvailableGraphDatabase.loadConfigurations(configFile);
final GraphDatabaseService graphDb = new HighlyAvailableGraphDatabase(path, config);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
graphDb.shutdown();
}
});
}
use of org.neo4j.kernel.HighlyAvailableGraphDatabase in project graphdb by neo4j-attic.
the class TestBackupToolHa method before.
@Before
public void before() throws Exception {
if (osIsWindows())
return;
FileUtils.deleteDirectory(new File(PATH));
FileUtils.deleteDirectory(new File(BACKUP_PATH));
zk = new LocalhostZooKeeperCluster(TestBackupToolHa.class, 2181, 2182, 2183);
instances = new ArrayList<GraphDatabaseService>();
for (int i = 0; i < 3; i++) {
String storeDir = new File(PATH, "" + i).getAbsolutePath();
Map<String, String> config = stringMap(CONFIG_KEY_HA_MACHINE_ID, "" + i, CONFIG_KEY_HA_SERVER, "localhost:" + (6666 + i), CONFIG_KEY_HA_ZOO_KEEPER_SERVERS, zk.getConnectionString(), ENABLE_ONLINE_BACKUP, "port=" + (4444 + i));
GraphDatabaseService instance = new HighlyAvailableGraphDatabase(storeDir, config);
instances.add(instance);
}
// Really doesn't matter which instance
representation = createSomeData(instances.get(1));
}
use of org.neo4j.kernel.HighlyAvailableGraphDatabase in project graphdb by neo4j-attic.
the class StandaloneDatabase method withFakeBroker.
public static StandaloneDatabase withFakeBroker(String testMethodName, final File path, int machineId, final int masterId, String[] extraArgs) {
StandaloneDatabase standalone = new StandaloneDatabase(testMethodName, new Bootstrap(path, machineId) {
@Override
HighlyAvailableGraphDatabase start(String storeDir, Map<String, String> config) {
final PlaceHolderGraphDatabaseService placeHolderGraphDb = new PlaceHolderGraphDatabaseService(path.getAbsolutePath());
final Broker broker;
if (machineId == masterId) {
broker = new FakeMasterBroker(machineId, placeHolderGraphDb);
} else {
broker = new FakeSlaveBroker(new MasterClient("localhost", Protocol.PORT, placeHolderGraphDb), masterId, machineId, placeHolderGraphDb);
}
HighlyAvailableGraphDatabase db = new HighlyAvailableGraphDatabase(storeDir, config, AbstractHaTest.wrapBrokerAndSetPlaceHolderDb(placeHolderGraphDb, broker));
placeHolderGraphDb.setDb(db);
System.out.println("Started HA db (w/o zoo keeper)");
return db;
}
});
standalone.awaitStarted();
return standalone;
}
use of org.neo4j.kernel.HighlyAvailableGraphDatabase in project graphdb by neo4j-attic.
the class SingleJvmTest method startUpMaster.
@Override
protected void startUpMaster(Map<String, String> extraConfig) throws Exception {
int masterId = 0;
Map<String, String> config = MapUtil.stringMap(extraConfig, HighlyAvailableGraphDatabase.CONFIG_KEY_HA_MACHINE_ID, String.valueOf(masterId));
String path = dbPath(0).getAbsolutePath();
PlaceHolderGraphDatabaseService placeHolderDb = new PlaceHolderGraphDatabaseService(path);
Broker broker = makeMasterBroker(master, masterId, placeHolderDb);
HighlyAvailableGraphDatabase db = new HighlyAvailableGraphDatabase(path, config, wrapBrokerAndSetPlaceHolderDb(placeHolderDb, broker));
placeHolderDb.setDb(db);
// db.newMaster( null, new Exception() );
master = new MasterImpl(db);
}
Aggregations