Search in sources :

Example 1 with HighlyAvailableGraphDatabase

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);
}
Also used : Broker(org.neo4j.kernel.ha.Broker) FakeMasterBroker(org.neo4j.kernel.ha.FakeMasterBroker) FakeSlaveBroker(org.neo4j.kernel.ha.FakeSlaveBroker) HashMap(java.util.HashMap) HighlyAvailableGraphDatabase(org.neo4j.kernel.HighlyAvailableGraphDatabase) ArrayList(java.util.ArrayList) File(java.io.File)

Example 2 with HighlyAvailableGraphDatabase

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();
        }
    });
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) HighlyAvailableGraphDatabase(org.neo4j.kernel.HighlyAvailableGraphDatabase)

Example 3 with HighlyAvailableGraphDatabase

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));
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) HighlyAvailableGraphDatabase(org.neo4j.kernel.HighlyAvailableGraphDatabase) File(java.io.File) Before(org.junit.Before)

Example 4 with HighlyAvailableGraphDatabase

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;
}
Also used : Broker(org.neo4j.kernel.ha.Broker) FakeMasterBroker(org.neo4j.kernel.ha.FakeMasterBroker) FakeSlaveBroker(org.neo4j.kernel.ha.FakeSlaveBroker) HighlyAvailableGraphDatabase(org.neo4j.kernel.HighlyAvailableGraphDatabase) MasterClient(org.neo4j.kernel.ha.MasterClient) FakeSlaveBroker(org.neo4j.kernel.ha.FakeSlaveBroker) FakeMasterBroker(org.neo4j.kernel.ha.FakeMasterBroker) PlaceHolderGraphDatabaseService(slavetest.PlaceHolderGraphDatabaseService)

Example 5 with HighlyAvailableGraphDatabase

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);
}
Also used : Broker(org.neo4j.kernel.ha.Broker) FakeMasterBroker(org.neo4j.kernel.ha.FakeMasterBroker) FakeSlaveBroker(org.neo4j.kernel.ha.FakeSlaveBroker) MasterImpl(org.neo4j.kernel.ha.MasterImpl) HighlyAvailableGraphDatabase(org.neo4j.kernel.HighlyAvailableGraphDatabase)

Aggregations

HighlyAvailableGraphDatabase (org.neo4j.kernel.HighlyAvailableGraphDatabase)5 Broker (org.neo4j.kernel.ha.Broker)3 FakeMasterBroker (org.neo4j.kernel.ha.FakeMasterBroker)3 FakeSlaveBroker (org.neo4j.kernel.ha.FakeSlaveBroker)3 File (java.io.File)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 MasterClient (org.neo4j.kernel.ha.MasterClient)1 MasterImpl (org.neo4j.kernel.ha.MasterImpl)1 PlaceHolderGraphDatabaseService (slavetest.PlaceHolderGraphDatabaseService)1