Search in sources :

Example 1 with FakeMasterBroker

use of org.neo4j.kernel.ha.FakeMasterBroker 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)

Aggregations

HighlyAvailableGraphDatabase (org.neo4j.kernel.HighlyAvailableGraphDatabase)1 Broker (org.neo4j.kernel.ha.Broker)1 FakeMasterBroker (org.neo4j.kernel.ha.FakeMasterBroker)1 FakeSlaveBroker (org.neo4j.kernel.ha.FakeSlaveBroker)1 MasterClient (org.neo4j.kernel.ha.MasterClient)1 PlaceHolderGraphDatabaseService (slavetest.PlaceHolderGraphDatabaseService)1