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);
}
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);
}
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);
}
}
Aggregations