use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.
the class StartInstanceInAnotherJvm method main.
public static void main(String[] args) {
File dir = new File(args[0]);
GraphDatabaseAPI newSlave = (GraphDatabaseAPI) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(dir).setConfig(Args.parse(args).asMap()).newGraphDatabase();
}
use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.
the class LabelScanStoreHaIT method setUp.
@Before
public void setUp() {
KernelExtensionFactory<?> testExtension = labelScanStoreExtension(monitor);
TestHighlyAvailableGraphDatabaseFactory factory = new TestHighlyAvailableGraphDatabaseFactory();
factory.removeKernelExtensions(extension -> extension.getClass().getName().contains("LabelScan"));
factory.addKernelExtension(testExtension);
ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("root")).withDbFactory(factory).withSharedSetting(GraphDatabaseSettings.label_index, labelIndexSettingName()).withStoreDirInitializer((serverId, storeDir) -> {
if (serverId == 1) {
GraphDatabaseService db = new TestGraphDatabaseFactory().addKernelExtension(testExtension).newEmbeddedDatabaseBuilder(storeDir.getAbsoluteFile()).setConfig(GraphDatabaseSettings.label_index, labelIndexSettingName()).newGraphDatabase();
try {
createSomeLabeledNodes(db, new Label[] { Labels.First }, new Label[] { Labels.First, Labels.Second }, new Label[] { Labels.Second });
} finally {
db.shutdown();
}
}
}).build();
life.add(clusterManager);
life.start();
cluster = clusterManager.getCluster();
cluster.await(allSeesAllAsAvailable());
cluster.await(allAvailabilityGuardsReleased());
}
use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.
the class SlaveUpgradeTest method haShouldFailToStartWithOldStore.
@Test
public void haShouldFailToStartWithOldStore() throws Exception {
try {
File dir = testDirectory.directory("haShouldFailToStartWithOldStore");
MigrationTestUtils.find20FormatStoreDirectory(dir);
new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(dir).setConfig(ClusterSettings.server_id, "1").setConfig(ClusterSettings.initial_hosts, "localhost:9999").newGraphDatabase();
fail("Should exit abnormally");
} catch (Exception e) {
Throwable rootCause = Exceptions.rootCause(e);
assertThat(rootCause, instanceOf(UpgradeNotAllowedByConfigurationException.class));
}
}
use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.
the class ConflictingServerIdIT method testConflictingIdDoesNotSilentlyFail.
@Test
public void testConflictingIdDoesNotSilentlyFail() throws Exception {
HighlyAvailableGraphDatabase master = null, dbWithId21 = null, dbWithId22 = null;
try {
GraphDatabaseBuilder masterBuilder = new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(path(1)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5002").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + (5001 + 1)).setConfig(ClusterSettings.server_id, "" + 1).setConfig(HaSettings.ha_server, ":" + (8001 + 1)).setConfig(HaSettings.tx_push_factor, "0");
master = (HighlyAvailableGraphDatabase) masterBuilder.newGraphDatabase();
GraphDatabaseBuilder db21Builder = new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(path(2)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5002,127.0.0.1:5003").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + (5001 + 2)).setConfig(ClusterSettings.server_id, "" + 2).setConfig(HaSettings.ha_server, ":" + (8001 + 2)).setConfig(HaSettings.tx_push_factor, "0");
dbWithId21 = (HighlyAvailableGraphDatabase) db21Builder.newGraphDatabase();
GraphDatabaseBuilder db22Builder = new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(path(3)).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5002").setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + (5001 + 3)).setConfig(ClusterSettings.server_id, // Conflicting with the above
"" + 2).setConfig(HaSettings.ha_server, ":" + (8001 + 3)).setConfig(HaSettings.tx_push_factor, "0");
try {
dbWithId22 = (HighlyAvailableGraphDatabase) db22Builder.newGraphDatabase();
fail("Should not be able to startup when a cluster already has my id");
} catch (Exception e) {
// awesome
}
assertTrue(master.isMaster());
assertTrue(!dbWithId21.isMaster());
try (Transaction transaction = dbWithId21.beginTx()) {
transaction.success();
}
} finally {
if (dbWithId21 != null) {
dbWithId21.shutdown();
}
if (dbWithId22 != null) {
dbWithId22.shutdown();
}
if (master != null) {
master.shutdown();
}
}
}
use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.
the class RollingUpgradeIT method rollOver.
private void rollOver(LegacyDatabase legacyDb, int i, int masterServerId, int authorativeSlaveId) throws Exception {
String storeDir = legacyDb.getStoreDir();
if (i == 0) {
storeDir += "new";
}
stop(i);
File storeDirFile = new File(storeDir);
debug("Starting " + i + " as current version");
switch(authorativeSlaveId) {
case -1:
break;
case -2:
debug("At last master starting, deleting store so that it fetches from the new master");
FileUtils.deleteRecursively(storeDirFile);
break;
default:
debug("Consecutive slave starting, making it so that I will copy store from " + authorativeSlaveId);
FileUtils.deleteRecursively(storeDirFile);
storeDirFile.mkdirs();
backup(authorativeSlaveId, storeDirFile);
break;
}
startStandaloneDbToRunUpgrade(storeDirFile, i);
// start that db up in this JVM
newDbs[i] = (GraphDatabaseAPI) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDirFile).setConfig(config(i)).newGraphDatabase();
debug("Started " + i + " as current version");
legacyDbs[i] = null;
// issue transaction and see that it propagates
if (i != masterServerId) {
// if the instance is not the old master, create on the old master
legacyDbs[masterServerId].doComplexLoad(centralNode);
debug("Node created on " + i);
} else {
doComplexLoad(newDbs[1], centralNode);
}
for (int j = 0; j < legacyDbs.length; j++) {
if (legacyDbs[j] != null) {
legacyDbs[j].verifyComplexLoad(centralNode);
debug("Verified on legacy db " + j);
}
}
for (int j = 0; j < newDbs.length; j++) {
if (newDbs[j] != null) {
assertTrue("Rolled over database " + j + " not available within 1 minute", newDbs[i].isAvailable(MINUTES.toMillis(1)));
verifyComplexLoad(newDbs[j], centralNode);
debug("Verified on new db " + j);
}
}
}
Aggregations