use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TransactionThroughMasterSwitchStressIT method reelectTheSameMasterMakingItGoToPendingAndBack.
private void reelectTheSameMasterMakingItGoToPendingAndBack(ManagedCluster cluster) throws Throwable {
HighlyAvailableGraphDatabase master = cluster.getMaster();
// Fail master and wait for master to go to pending, since it detects it's partitioned away
RepairKit masterRepair = cluster.fail(master, false, NetworkFlag.IN, NetworkFlag.OUT);
cluster.await(memberThinksItIsRole(master, UNKNOWN));
// Then Immediately repair
masterRepair.repair();
// Wait for this instance to go to master again, since the other instances are slave only
cluster.await(memberThinksItIsRole(master, MASTER));
cluster.await(ClusterManager.masterAvailable());
assertEquals(master, cluster.getMaster());
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class ClusterManager method allSeesAllAsAvailable.
public static Predicate<ManagedCluster> allSeesAllAsAvailable() {
return new Predicate<ManagedCluster>() {
@Override
public boolean test(ManagedCluster cluster) {
if (!allSeesAllAsJoined().test(cluster)) {
return false;
}
int clusterMembersChecked = 0;
for (HighlyAvailableGraphDatabase database : cluster.getAllMembers()) {
clusterMembersChecked++;
ClusterMembers members = database.getDependencyResolver().resolveDependency(ClusterMembers.class);
for (ClusterMember clusterMember : members.getMembers()) {
if (!cluster.isAvailable(clusterMember)) {
return false;
}
}
}
if (clusterMembersChecked == 0) {
return false;
}
// Everyone sees everyone else as available!
for (HighlyAvailableGraphDatabase database : cluster.getAllMembers()) {
Log log = database.getDependencyResolver().resolveDependency(LogService.class).getInternalLog(getClass());
log.debug(this.toString());
}
return true;
}
@Override
public String toString() {
return "All instances should see all others as available";
}
};
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class ClusterManager method stateToString.
public static String stateToString(ManagedCluster cluster) {
StringBuilder buf = new StringBuilder("\n");
for (HighlyAvailableGraphDatabase database : cluster.getAllMembers()) {
ClusterClient client = database.getDependencyResolver().resolveDependency(ClusterClient.class);
buf.append("Instance ").append(client.getServerId()).append(":State ").append(database.getInstanceState()).append(" (").append(client.getClusterServer()).append("):").append("\n");
ClusterMembers members = database.getDependencyResolver().resolveDependency(ClusterMembers.class);
buf.append(members);
}
return buf.toString();
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class ClusterManager method instanceEvicted.
public static Predicate<ClusterManager.ManagedCluster> instanceEvicted(final HighlyAvailableGraphDatabase instance) {
return new Predicate<ClusterManager.ManagedCluster>() {
@Override
public boolean test(ClusterManager.ManagedCluster managedCluster) {
InstanceId instanceId = managedCluster.getServerId(instance);
Iterable<HighlyAvailableGraphDatabase> members = managedCluster.getAllMembers();
for (HighlyAvailableGraphDatabase member : members) {
if (instanceId.equals(managedCluster.getServerId(member))) {
if (member.role().equals("UNKNOWN")) {
return true;
}
}
}
return false;
}
};
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TerminationOfSlavesDuringPullUpdatesTest method slavesDontTerminateAndReadConsistentDataWhenApplyingBatchSmallerThanSafeZone.
@Test
public void slavesDontTerminateAndReadConsistentDataWhenApplyingBatchSmallerThanSafeZone() throws Throwable {
long safeZone = TimeUnit.MINUTES.toMillis(1);
clusterRule.withSharedSetting(HaSettings.id_reuse_safe_zone_time, String.valueOf(safeZone));
// given
final ClusterManager.ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
// when
// ... slaves and master has node with long string property
long entityId = action.createInitialEntity(master);
cluster.sync();
// ... and property is removed on master
action.removeProperties(master, entityId);
// ... and maintenance is called to make sure "safe" ids are freed to be reused
forceMaintenance(master);
// ... and a new property is created on master that
action.setNewProperties(master, entityId);
final HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
Race race = new Race();
final AtomicBoolean end = new AtomicBoolean(false);
for (int i = 0; i < READER_CONTESTANTS; i++) {
race.addContestant(readContestant(action, entityId, slave, end));
}
race.addContestant(pullUpdatesContestant(slave, end));
race.go();
}
Aggregations