Search in sources :

Example 6 with StoreCopyClient

use of org.neo4j.com.storecopy.StoreCopyClient in project neo4j by neo4j.

the class SwitchToSlaveBranchThenCopyTest method newSwitchToSlaveSpy.

private SwitchToSlaveBranchThenCopy newSwitchToSlaveSpy() throws Exception {
    PageCache pageCacheMock = mock(PageCache.class);
    PagedFile pagedFileMock = mock(PagedFile.class);
    when(pagedFileMock.getLastPageId()).thenReturn(1L);
    when(pageCacheMock.map(any(File.class), anyInt())).thenReturn(pagedFileMock);
    when(pageCacheMock.streamFilesRecursive(any(File.class))).thenReturn(Stream.empty());
    StoreCopyClient storeCopyClient = mock(StoreCopyClient.class);
    return newSwitchToSlaveSpy(pageCacheMock, storeCopyClient);
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) StoreCopyClient(org.neo4j.com.storecopy.StoreCopyClient) PagedFile(org.neo4j.io.pagecache.PagedFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache)

Example 7 with StoreCopyClient

use of org.neo4j.com.storecopy.StoreCopyClient in project neo4j by neo4j.

the class SwitchToSlaveCopyThenBranchTest method newSwitchToSlaveSpy.

private SwitchToSlaveCopyThenBranch newSwitchToSlaveSpy() throws Exception {
    PageCache pageCacheMock = mock(PageCache.class);
    PagedFile pagedFileMock = mock(PagedFile.class);
    when(pagedFileMock.getLastPageId()).thenReturn(1L);
    when(pageCacheMock.map(any(File.class), anyInt())).thenReturn(pagedFileMock);
    StoreCopyClient storeCopyClient = mock(StoreCopyClient.class);
    Stream mockStream = mock(Stream.class);
    when(mockStream.filter(any(Predicate.class))).thenReturn(mock(Stream.class));
    when(pageCacheMock.streamFilesRecursive(any(File.class))).thenReturn(mockStream);
    return newSwitchToSlaveSpy(pageCacheMock, storeCopyClient);
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) StoreCopyClient(org.neo4j.com.storecopy.StoreCopyClient) Stream(java.util.stream.Stream) PagedFile(org.neo4j.io.pagecache.PagedFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Predicate(java.util.function.Predicate)

Example 8 with StoreCopyClient

use of org.neo4j.com.storecopy.StoreCopyClient in project neo4j by neo4j.

the class BackupService method fullBackup.

private BackupOutcome fullBackup(FileSystemAbstraction fileSystem, String sourceHostNameOrIp, int sourcePort, File targetDirectory, ConsistencyCheck consistencyCheck, Config tuningConfiguration, long timeout, boolean forensics) {
    if (!directoryIsEmpty(fileSystem, targetDirectory)) {
        throw new RuntimeException("Can only perform a full backup into an empty directory but " + targetDirectory + " is not empty");
    }
    long timestamp = System.currentTimeMillis();
    long lastCommittedTx = -1;
    try (PageCache pageCache = createPageCache(fileSystem, tuningConfiguration)) {
        StoreCopyClient storeCopier = new StoreCopyClient(targetDirectory, tuningConfiguration, loadKernelExtensions(), logProvider, fileSystem, pageCache, monitors.newMonitor(StoreCopyClient.Monitor.class, getClass()), forensics);
        FullBackupStoreCopyRequester storeCopyRequester = new FullBackupStoreCopyRequester(sourceHostNameOrIp, sourcePort, timeout, forensics, monitors);
        storeCopier.copyStore(storeCopyRequester, CancellationRequest.NEVER_CANCELLED, MoveAfterCopy.moveReplaceExisting());
        bumpDebugDotLogFileVersion(targetDirectory, timestamp);
        boolean consistent = false;
        try {
            consistent = consistencyCheck.runFull(targetDirectory, tuningConfiguration, ProgressMonitorFactory.textual(System.err), logProvider, fileSystem, pageCache, false);
        } catch (ConsistencyCheckFailedException e) {
            log.error("Consistency check incomplete", e);
        }
        clearIdFiles(fileSystem, targetDirectory);
        return new BackupOutcome(lastCommittedTx, consistent);
    } catch (Exception e) {
        throw Exceptions.launderedException(e);
    }
}
Also used : RequestMonitor(org.neo4j.com.monitor.RequestMonitor) ByteCounterMonitor(org.neo4j.kernel.monitoring.ByteCounterMonitor) StoreCopyClient(org.neo4j.com.storecopy.StoreCopyClient) PageCache(org.neo4j.io.pagecache.PageCache) ExternallyManagedPageCache(org.neo4j.com.storecopy.ExternallyManagedPageCache) ConfigurableStandalonePageCacheFactory.createPageCache(org.neo4j.kernel.impl.pagecache.ConfigurableStandalonePageCacheFactory.createPageCache) UnexpectedStoreVersionException(org.neo4j.kernel.impl.store.UnexpectedStoreVersionException) MismatchingStoreIdException(org.neo4j.kernel.impl.store.MismatchingStoreIdException) MissingLogDataException(org.neo4j.kernel.impl.transaction.log.MissingLogDataException) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) ConnectException(java.net.ConnectException) IOException(java.io.IOException)

Aggregations

StoreCopyClient (org.neo4j.com.storecopy.StoreCopyClient)8 PageCache (org.neo4j.io.pagecache.PageCache)8 File (java.io.File)5 URI (java.net.URI)5 Test (org.junit.Test)5 MoveAfterCopy (org.neo4j.com.storecopy.MoveAfterCopy)5 CancellationRequest (org.neo4j.helpers.CancellationRequest)5 PagedFile (org.neo4j.io.pagecache.PagedFile)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 IOException (java.io.IOException)3 Stream (java.util.stream.Stream)3 InetSocketAddress (java.net.InetSocketAddress)2 URISyntaxException (java.net.URISyntaxException)2 TimeUnit (java.util.concurrent.TimeUnit)2 Predicate (java.util.function.Predicate)2 Assert.assertNull (org.junit.Assert.assertNull)2 Assert.fail (org.junit.Assert.fail)2 InOrder (org.mockito.InOrder)2 Matchers.any (org.mockito.Matchers.any)2 Matchers.anyInt (org.mockito.Matchers.anyInt)2