Search in sources :

Example 1 with Pair

use of org.neo4j.helpers.Pair in project neo4j-mobile-android by neo4j-contrib.

the class OrderedByTypeExpander method doExpand.

@Override
Iterator<Relationship> doExpand(final Node start) {
    return new NestingIterator<Relationship, Pair<RelationshipType, Direction>>(orderedTypes.iterator()) {

        @Override
        protected Iterator<Relationship> createNestedIterator(Pair<RelationshipType, Direction> entry) {
            RelationshipType type = entry.first();
            Direction dir = entry.other();
            return ((dir == Direction.BOTH) ? start.getRelationships(type) : start.getRelationships(type, dir)).iterator();
        }
    };
}
Also used : Relationship(org.neo4j.graphdb.Relationship) NestingIterator(org.neo4j.helpers.collection.NestingIterator) RelationshipType(org.neo4j.graphdb.RelationshipType) Direction(org.neo4j.graphdb.Direction) Pair(org.neo4j.helpers.Pair)

Example 2 with Pair

use of org.neo4j.helpers.Pair in project graphdb by neo4j-attic.

the class HighlyAvailableGraphDatabase method getSlaveContext.

@Override
public SlaveContext getSlaveContext(int eventIdentifier) {
    XaDataSourceManager localDataSourceManager = getConfig().getTxModule().getXaDataSourceManager();
    Collection<XaDataSource> dataSources = localDataSourceManager.getAllRegisteredDataSources();
    @SuppressWarnings("unchecked") Pair<String, Long>[] txs = new Pair[dataSources.size()];
    int i = 0;
    for (XaDataSource dataSource : dataSources) {
        txs[i++] = Pair.of(dataSource.getName(), dataSource.getLastCommittedTxId());
    }
    return new SlaveContext(machineId, eventIdentifier, txs);
}
Also used : SlaveContext(org.neo4j.com.SlaveContext) XaDataSourceManager(org.neo4j.kernel.impl.transaction.XaDataSourceManager) XaDataSource(org.neo4j.kernel.impl.transaction.xaframework.XaDataSource) Pair(org.neo4j.helpers.Pair)

Example 3 with Pair

use of org.neo4j.helpers.Pair in project graphdb by neo4j-attic.

the class HighlyAvailableGraphDatabase method copyStoreFromMaster.

private void copyStoreFromMaster(Pair<Master, Machine> master) throws Exception {
    msgLog.logMessage("Copying store from master");
    Response<Void> response = master.first().copyStore(new SlaveContext(machineId, 0, new Pair[0]), new ToFileStoreWriter(storeDir));
    EmbeddedGraphDatabase tempDb = new EmbeddedGraphDatabase(storeDir);
    try {
        MasterUtil.applyReceivedTransactions(response, tempDb, MasterUtil.txHandlerForFullCopy());
    } finally {
        tempDb.shutdown();
    }
    msgLog.logMessage("Done copying store from master");
}
Also used : SlaveContext(org.neo4j.com.SlaveContext) Pair(org.neo4j.helpers.Pair) ToFileStoreWriter(org.neo4j.com.ToFileStoreWriter)

Example 4 with Pair

use of org.neo4j.helpers.Pair in project graphdb by neo4j-attic.

the class OnlineBackup method slaveContextOf.

@SuppressWarnings("unchecked")
private SlaveContext slaveContextOf(GraphDatabaseService graphDb) {
    XaDataSourceManager dsManager = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
    List<Pair<String, Long>> txs = new ArrayList<Pair<String, Long>>();
    for (XaDataSource ds : dsManager.getAllRegisteredDataSources()) {
        txs.add(Pair.of(ds.getName(), ds.getLastCommittedTxId()));
    }
    return new SlaveContext(0, 0, txs.toArray(new Pair[0]));
}
Also used : SlaveContext(org.neo4j.com.SlaveContext) XaDataSourceManager(org.neo4j.kernel.impl.transaction.XaDataSourceManager) ArrayList(java.util.ArrayList) AbstractGraphDatabase(org.neo4j.kernel.AbstractGraphDatabase) XaDataSource(org.neo4j.kernel.impl.transaction.xaframework.XaDataSource) Pair(org.neo4j.helpers.Pair)

Example 5 with Pair

use of org.neo4j.helpers.Pair in project graphdb by neo4j-attic.

the class TestChangingOfLogFormat method inabilityToStartFromOldFormatFromNonCleanShutdown.

@Test
public void inabilityToStartFromOldFormatFromNonCleanShutdown() throws Exception {
    String storeDir = "target/var/oldlog";
    deleteFileOrDirectory(storeDir);
    GraphDatabaseService db = new EmbeddedGraphDatabase(storeDir);
    Transaction tx = db.beginTx();
    db.createNode();
    tx.success();
    tx.finish();
    Pair<Pair<File, File>, Pair<File, File>> copy = copyLogicalLog(storeDir);
    decrementLogFormat(copy.other().other());
    db.shutdown();
    renameCopiedLogicalLog(storeDir);
    try {
        db = new EmbeddedGraphDatabase(storeDir);
        fail("Shouldn't be able to do recovery (and upgrade log format version) on non-clean shutdown");
    } catch (Exception e) {
        // Good
        e.printStackTrace();
    }
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) IOException(java.io.IOException) Pair(org.neo4j.helpers.Pair) Test(org.junit.Test)

Aggregations

Pair (org.neo4j.helpers.Pair)9 SlaveContext (org.neo4j.com.SlaveContext)4 XaDataSource (org.neo4j.kernel.impl.transaction.xaframework.XaDataSource)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 XaDataSourceManager (org.neo4j.kernel.impl.transaction.XaDataSourceManager)3 File (java.io.File)2 AbstractGraphDatabase (org.neo4j.kernel.AbstractGraphDatabase)2 NeoStoreXaDataSource (org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource)2 FileInputStream (java.io.FileInputStream)1 BufferUnderflowException (java.nio.BufferUnderflowException)1 ByteBuffer (java.nio.ByteBuffer)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IndexCommit (org.apache.lucene.index.IndexCommit)1 SnapshotDeletionPolicy (org.apache.lucene.index.SnapshotDeletionPolicy)1 KeeperException (org.apache.zookeeper.KeeperException)1 Test (org.junit.Test)1 ToFileStoreWriter (org.neo4j.com.ToFileStoreWriter)1