Search in sources :

Example 1 with UnableToCopyStoreFromOldMasterException

use of org.neo4j.kernel.ha.store.UnableToCopyStoreFromOldMasterException in project neo4j by neo4j.

the class SwitchToSlave method copyStoreFromMasterIfNeeded.

private void copyStoreFromMasterIfNeeded(URI masterUri, URI me, CancellationRequest cancellationRequest) throws Throwable {
    if (!isStorePresent(pageCache, storeDir)) {
        boolean success = false;
        monitor.storeCopyStarted();
        LifeSupport copyLife = new LifeSupport();
        try {
            MasterClient masterClient = newMasterClient(masterUri, me, null, copyLife);
            copyLife.start();
            boolean masterIsOld = MasterClient.CURRENT.compareTo(masterClient.getProtocolVersion()) > 0;
            if (masterIsOld) {
                throw new UnableToCopyStoreFromOldMasterException(MasterClient.CURRENT.getApplicationProtocol(), masterClient.getProtocolVersion().getApplicationProtocol());
            } else {
                copyStoreFromMaster(masterClient, cancellationRequest, MoveAfterCopy.moveReplaceExisting());
                success = true;
            }
        } finally {
            monitor.storeCopyCompleted(success);
            copyLife.shutdown();
        }
    }
}
Also used : UnableToCopyStoreFromOldMasterException(org.neo4j.kernel.ha.store.UnableToCopyStoreFromOldMasterException) MasterClient(org.neo4j.kernel.ha.com.slave.MasterClient) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport)

Example 2 with UnableToCopyStoreFromOldMasterException

use of org.neo4j.kernel.ha.store.UnableToCopyStoreFromOldMasterException in project neo4j by neo4j.

the class SwitchToSlaveCopyThenBranch method copyStore.

private void copyStore(URI masterUri, URI me, CancellationRequest cancellationRequest, MoveAfterCopy moveAfterCopy) throws Throwable {
    boolean success = false;
    monitor.storeCopyStarted();
    LifeSupport copyLife = new LifeSupport();
    try {
        MasterClient masterClient = newMasterClient(masterUri, me, null, copyLife);
        copyLife.start();
        boolean masterIsOld = MasterClient.CURRENT.compareTo(masterClient.getProtocolVersion()) > 0;
        if (masterIsOld) {
            throw new UnableToCopyStoreFromOldMasterException(MasterClient.CURRENT.getApplicationProtocol(), masterClient.getProtocolVersion().getApplicationProtocol());
        } else {
            copyStoreFromMaster(masterClient, cancellationRequest, moveAfterCopy);
            success = true;
        }
    } finally {
        monitor.storeCopyCompleted(success);
        copyLife.shutdown();
    }
}
Also used : UnableToCopyStoreFromOldMasterException(org.neo4j.kernel.ha.store.UnableToCopyStoreFromOldMasterException) MasterClient(org.neo4j.kernel.ha.com.slave.MasterClient) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport)

Aggregations

MasterClient (org.neo4j.kernel.ha.com.slave.MasterClient)2 UnableToCopyStoreFromOldMasterException (org.neo4j.kernel.ha.store.UnableToCopyStoreFromOldMasterException)2 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)2