Search in sources :

Example 1 with ToFileStoreWriter

use of org.neo4j.com.ToFileStoreWriter in project graphdb by neo4j-attic.

the class OnlineBackup method full.

public OnlineBackup full(String targetDirectory) {
    if (directoryContainsDb(targetDirectory)) {
        throw new RuntimeException(targetDirectory + " already contains a database");
    }
    //                                                     TODO OMG this is ugly
    BackupClient client = new BackupClient(hostNameOrIp, port, new NotYetExistingGraphDatabase(targetDirectory));
    try {
        Response<Void> response = client.fullBackup(new ToFileStoreWriter(targetDirectory));
        GraphDatabaseService targetDb = startTemporaryDb(targetDirectory);
        try {
            unpackResponse(response, targetDb, MasterUtil.txHandlerForFullCopy());
        } finally {
            targetDb.shutdown();
        }
    } finally {
        client.shutdown();
        // TODO This is also ugly
        StringLogger.close(targetDirectory);
    }
    return this;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) ToFileStoreWriter(org.neo4j.com.ToFileStoreWriter)

Example 2 with ToFileStoreWriter

use of org.neo4j.com.ToFileStoreWriter 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)

Aggregations

ToFileStoreWriter (org.neo4j.com.ToFileStoreWriter)2 SlaveContext (org.neo4j.com.SlaveContext)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Pair (org.neo4j.helpers.Pair)1