use of org.neo4j.kernel.ha.MasterClient in project graphdb by neo4j-attic.
the class AbstractZooKeeperManager method invalidateMaster.
private void invalidateMaster() {
if (cachedMaster != null) {
MasterClient client = (MasterClient) cachedMaster.first();
if (client != null) {
client.shutdown();
}
cachedMaster = Pair.<Master, Machine>of(null, Machine.NO_MACHINE);
}
}
use of org.neo4j.kernel.ha.MasterClient 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.ha.MasterClient in project graphdb by neo4j-attic.
the class SingleJvmWithNettyTest method makeSlaveBroker.
@Override
protected Broker makeSlaveBroker(MasterImpl master, int masterId, int id, GraphDatabaseService graphDb) {
final Machine masterMachine = new //
Machine(//
masterId, //
-1, //
1, "localhost:" + Protocol.PORT);
final Master client = new MasterClient(masterMachine, graphDb);
return new AbstractBroker(id, graphDb) {
public boolean iAmMaster() {
return false;
}
public Pair<Master, Machine> getMasterReally() {
return getMaster();
}
public Pair<Master, Machine> getMaster() {
return Pair.of(client, masterMachine);
}
public Object instantiateMasterServer(GraphDatabaseService graphDb) {
throw new UnsupportedOperationException("cannot instantiate master server on slave");
}
};
}
use of org.neo4j.kernel.ha.MasterClient in project graphdb by neo4j-attic.
the class AbstractZooKeeperManager method getMasterFromZooKeeper.
protected Pair<Master, Machine> getMasterFromZooKeeper(boolean wait) {
Machine master = getMasterBasedOn(getAllMachines(wait).values());
MasterClient masterClient = null;
if (cachedMaster.other().getMachineId() != master.getMachineId()) {
invalidateMaster();
if (master != Machine.NO_MACHINE && master.getMachineId() != getMyMachineId()) {
masterClient = new MasterClient(master, graphDb);
}
cachedMaster = Pair.<Master, Machine>of(masterClient, master);
}
return cachedMaster;
}
Aggregations