use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class DumpLogicalLog method main.
/**
* Usage: [--txfilter "regex"] [--ccfilter cc-report-file] [--tofile] storeDirOrFile1 storeDirOrFile2 ...
*
* --txfilter
* Will match regex against each {@link LogEntry} and if there is a match,
* include transaction containing the LogEntry in the dump.
* regex matching is done with {@link Pattern}
*
* --ccfilter
* Will look at an inconsistency report file from consistency checker and
* include transactions that are relevant to them
*
* --tofile
* Redirects output to dump-logical-log.txt in the store directory
*/
public static void main(String[] args) throws IOException {
Args arguments = Args.withFlags(TO_FILE).parse(args);
TimeZone timeZone = parseTimeZoneConfig(arguments);
Predicate<LogEntry[]> filter = parseFilter(arguments, timeZone);
Function<LogEntry, String> serializer = parseSerializer(filter, timeZone);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Printer printer = getPrinter(arguments)) {
for (String fileAsString : arguments.orphans()) {
new DumpLogicalLog(fileSystem).dump(fileAsString, printer.getFor(fileAsString), filter, serializer);
}
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class CheckTxLogsTest method writeContent.
private void writeContent(File log, ThrowingConsumer<TransactionLogWriter, IOException> consumer) throws IOException {
FileSystemAbstraction fs = ensureLogExists(log);
try (StoreChannel channel = fs.open(log, "rw");
LogVersionedStoreChannel versionedChannel = new PhysicalLogVersionedStoreChannel(channel, 0, (byte) 0);
PhysicalFlushableChannel writableLogChannel = new PhysicalFlushableChannel(versionedChannel)) {
long offset = channel.size();
channel.position(offset);
consumer.accept(new TransactionLogWriter(new LogEntryWriter(writableLogChannel)));
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class CheckTxLogs method main.
public static void main(String[] args) throws Exception {
PrintStream out = System.out;
Args arguments = Args.withFlags(HELP_FLAG, VALIDATE_CHECKPOINTS_FLAG).parse(args);
if (arguments.getBoolean(HELP_FLAG)) {
printUsageAndExit(out);
}
boolean validateCheckPoints = arguments.getBoolean(VALIDATE_CHECKPOINTS_FLAG);
CheckType<?, ?>[] checkTypes = parseChecks(arguments);
File dir = parseDir(out, arguments);
boolean success = false;
try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction()) {
PhysicalLogFiles logFiles = new PhysicalLogFiles(dir, fs);
int numberOfLogFilesFound = (int) (logFiles.getHighestLogVersion() - logFiles.getLowestLogVersion() + 1);
out.println("Found " + numberOfLogFilesFound + " log files to verify in " + dir.getCanonicalPath());
CheckTxLogs tool = new CheckTxLogs(out, fs);
PrintingInconsistenciesHandler handler = new PrintingInconsistenciesHandler(out);
success = tool.scan(logFiles, handler, checkTypes);
if (validateCheckPoints) {
success &= tool.validateCheckPoints(logFiles, handler);
}
}
if (!success) {
System.exit(1);
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class SegmentedRaftLogRotationTruncationPruneTest method createRaftLog.
private RaftLog createRaftLog() throws Exception {
File directory = new File(RAFT_LOG_DIRECTORY_NAME);
FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
fileSystem.mkdir(directory);
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("1 entries", logProvider).newInstance();
SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fileSystem, directory, 1, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
newRaftLog.start();
return newRaftLog;
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RestartIT method readReplicaTest.
@Test
public void readReplicaTest() throws Exception {
// given
Cluster cluster = clusterRule.withNumberOfCoreMembers(2).withNumberOfReadReplicas(1).startCluster();
// when
final GraphDatabaseService coreDB = cluster.awaitLeader(5, TimeUnit.SECONDS).database();
try (Transaction tx = coreDB.beginTx()) {
Node node = coreDB.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
}
cluster.addCoreMemberWithId(2).start();
cluster.shutdown();
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
for (CoreClusterMember core : cluster.coreMembers()) {
ConsistencyCheckService.Result result = new ConsistencyCheckService().runFullConsistencyCheck(core.storeDir(), Config.embeddedDefaults(), ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), fileSystem, false, new CheckConsistencyConfig(true, true, true, false));
assertTrue("Inconsistent: " + core, result.isSuccessful());
}
for (ReadReplica readReplica : cluster.readReplicas()) {
ConsistencyCheckService.Result result = new ConsistencyCheckService().runFullConsistencyCheck(readReplica.storeDir(), Config.embeddedDefaults(), ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), fileSystem, false, new CheckConsistencyConfig(true, true, true, false));
assertTrue("Inconsistent: " + readReplica, result.isSuccessful());
}
}
}
Aggregations