use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestMigration method canReadAndUpgradeOldIndexStoreFormat.
@Test
public void canReadAndUpgradeOldIndexStoreFormat() throws Exception {
String path = "target/var/old-index-store";
Neo4jTestCase.deleteFileOrDirectory(new File(path));
GraphDatabaseService db = new EmbeddedGraphDatabase(path);
db.shutdown();
InputStream stream = getClass().getClassLoader().getResourceAsStream("old-index.db");
writeFile(stream, new File(path, "index.db"));
db = new EmbeddedGraphDatabase(path);
assertTrue(db.index().existsForNodes("indexOne"));
Index<Node> indexOne = db.index().forNodes("indexOne");
verifyConfiguration(db, indexOne, LuceneIndexImplementation.EXACT_CONFIG);
assertTrue(db.index().existsForNodes("indexTwo"));
Index<Node> indexTwo = db.index().forNodes("indexTwo");
verifyConfiguration(db, indexTwo, LuceneIndexImplementation.FULLTEXT_CONFIG);
assertTrue(db.index().existsForRelationships("indexThree"));
Index<Relationship> indexThree = db.index().forRelationships("indexThree");
verifyConfiguration(db, indexThree, LuceneIndexImplementation.EXACT_CONFIG);
db.shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class ServerProcess method startup.
@Override
public void startup(Pair<String, String> config) throws Throwable {
String storeDir = config.first();
String backupConfigValue = config.other();
if (backupConfigValue == null) {
this.db = new EmbeddedGraphDatabase(storeDir);
} else {
this.db = new EmbeddedGraphDatabase(storeDir, stringMap(ENABLE_ONLINE_BACKUP, backupConfigValue));
}
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestBigBatchStore method testHighIds.
private void testHighIds(long highMark, int minus, int requiredHeapMb) {
assumeTrue(machineIsOkToRunThisTest(testName.getMethodName(), requiredHeapMb));
long idBelow = highMark - minus;
setHighId(IdType.NODE, idBelow);
setHighId(IdType.RELATIONSHIP, idBelow);
setHighId(IdType.PROPERTY, idBelow);
setHighId(IdType.ARRAY_BLOCK, idBelow);
setHighId(IdType.STRING_BLOCK, idBelow);
String propertyKey = "name";
int intPropertyValue = 123;
String stringPropertyValue = "Long string, longer than would fit in shortstring";
long[] arrayPropertyValue = new long[] { 1021L, 321L, 343212L };
long nodeBelowTheLine = db.createNode(map(propertyKey, intPropertyValue));
assertEquals(idBelow, nodeBelowTheLine);
long nodeAboveTheLine = db.createNode(map(propertyKey, stringPropertyValue));
long relBelowTheLine = db.createRelationship(nodeBelowTheLine, nodeAboveTheLine, this, map(propertyKey, arrayPropertyValue));
assertEquals(idBelow, relBelowTheLine);
long relAboveTheLine = db.createRelationship(nodeAboveTheLine, nodeBelowTheLine, this, null);
assertEquals(highMark, relAboveTheLine);
assertEquals(highMark, nodeAboveTheLine);
assertEquals(intPropertyValue, db.getNodeProperties(nodeBelowTheLine).get(propertyKey));
assertEquals(stringPropertyValue, db.getNodeProperties(nodeAboveTheLine).get(propertyKey));
assertTrue(Arrays.equals(arrayPropertyValue, (long[]) db.getRelationshipProperties(relBelowTheLine).get(propertyKey)));
assertEquals(asSet(asList(relBelowTheLine, relAboveTheLine)), asIds(db.getRelationships(idBelow)));
db.shutdown();
db = new BatchInserterImpl(PATH);
assertEquals(asSet(asList(relBelowTheLine, relAboveTheLine)), asIds(db.getRelationships(idBelow)));
db.shutdown();
GraphDatabaseService edb = new EmbeddedGraphDatabase(PATH);
assertEquals(nodeAboveTheLine, edb.getNodeById(highMark).getId());
assertEquals(relBelowTheLine, edb.getNodeById(idBelow).getSingleRelationship(this, Direction.OUTGOING).getId());
assertEquals(relAboveTheLine, edb.getNodeById(idBelow).getSingleRelationship(this, Direction.INCOMING).getId());
assertEquals(asSet(asList(edb.getRelationshipById(relBelowTheLine), edb.getRelationshipById(relAboveTheLine))), asSet(asCollection(edb.getNodeById(idBelow).getRelationships())));
edb.shutdown();
db = new BatchInserterImpl(PATH);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestBigStore method testHighIds.
private void testHighIds(long highMark, int minus, int requiredHeapMb) {
if (!machineIsOkToRunThisTest(testName.getMethodName(), requiredHeapMb)) {
return;
}
long idBelow = highMark - minus;
setHighIds(idBelow);
String propertyKey = "name";
int intPropertyValue = 123;
String stringPropertyValue = "Long string, longer than would fit in shortstring";
long[] arrayPropertyValue = new long[] { 1021L, 321L, 343212L };
Transaction tx = db.beginTx();
Node nodeBelowTheLine = db.createNode();
nodeBelowTheLine.setProperty(propertyKey, intPropertyValue);
assertEquals(idBelow, nodeBelowTheLine.getId());
Node nodeAboveTheLine = db.createNode();
nodeAboveTheLine.setProperty(propertyKey, stringPropertyValue);
Relationship relBelowTheLine = nodeBelowTheLine.createRelationshipTo(nodeAboveTheLine, this);
relBelowTheLine.setProperty(propertyKey, arrayPropertyValue);
assertEquals(idBelow, relBelowTheLine.getId());
Relationship relAboveTheLine = nodeAboveTheLine.createRelationshipTo(nodeBelowTheLine, this);
assertEquals(highMark, relAboveTheLine.getId());
assertEquals(highMark, nodeAboveTheLine.getId());
assertEquals(intPropertyValue, nodeBelowTheLine.getProperty(propertyKey));
assertEquals(stringPropertyValue, nodeAboveTheLine.getProperty(propertyKey));
assertTrue(Arrays.equals(arrayPropertyValue, (long[]) relBelowTheLine.getProperty(propertyKey)));
tx.success();
tx.finish();
for (int i = 0; i < 2; i++) {
assertEquals(nodeAboveTheLine, db.getNodeById(highMark));
assertEquals(idBelow, nodeBelowTheLine.getId());
assertEquals(highMark, nodeAboveTheLine.getId());
assertEquals(idBelow, relBelowTheLine.getId());
assertEquals(highMark, relAboveTheLine.getId());
assertEquals(relBelowTheLine, db.getNodeById(idBelow).getSingleRelationship(this, Direction.OUTGOING));
assertEquals(relAboveTheLine, db.getNodeById(idBelow).getSingleRelationship(this, Direction.INCOMING));
assertEquals(idBelow, relBelowTheLine.getId());
assertEquals(highMark, relAboveTheLine.getId());
assertEquals(asSet(asList(relBelowTheLine, relAboveTheLine)), asSet(asCollection(db.getNodeById(idBelow).getRelationships())));
if (i == 0) {
db.shutdown();
db = new EmbeddedGraphDatabase(PATH);
}
}
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestNeo4j method testKeepLogsConfig.
@Test
public void testKeepLogsConfig() {
Map<String, String> config = new HashMap<String, String>();
config.put(Config.KEEP_LOGICAL_LOGS, "nioneodb");
String storeDir = "target/configdb";
deleteFileOrDirectory(storeDir);
EmbeddedGraphDatabase db = new EmbeddedGraphDatabase(storeDir, config);
XaDataSourceManager xaDsMgr = db.getConfig().getTxModule().getXaDataSourceManager();
XaDataSource xaDs = xaDsMgr.getXaDataSource("nioneodb");
assertTrue(xaDs.isLogicalLogKept());
db.shutdown();
config.remove(Config.KEEP_LOGICAL_LOGS);
db = new EmbeddedGraphDatabase(storeDir, config);
xaDsMgr = db.getConfig().getTxModule().getXaDataSourceManager();
xaDs = xaDsMgr.getXaDataSource("nioneodb");
assertTrue(!xaDs.isLogicalLogKept());
db.shutdown();
config.put(Config.KEEP_LOGICAL_LOGS, "true");
db = new EmbeddedGraphDatabase(storeDir, config);
xaDsMgr = db.getConfig().getTxModule().getXaDataSourceManager();
xaDs = xaDsMgr.getXaDataSource("nioneodb");
assertTrue(xaDs.isLogicalLogKept());
}
Aggregations