use of org.neo4j.io.fs.DefaultFileSystemAbstraction 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.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class ConcurrentStressIT method readAndWrite.
private void readAndWrite(int nReaders, int time, TimeUnit unit) throws Throwable {
try (DefaultFileSystemAbstraction fsa = new DefaultFileSystemAbstraction()) {
T raftLog = createRaftLog(fsa, dir.directory());
try {
ExecutorService es = Executors.newCachedThreadPool();
Collection<Future<Long>> futures = new ArrayList<>();
futures.add(es.submit(new TimedTask(() -> {
write(raftLog);
}, time, unit)));
for (int i = 0; i < nReaders; i++) {
futures.add(es.submit(new TimedTask(() -> {
read(raftLog);
}, time, unit)));
}
for (Future<Long> f : futures) {
long iterations = f.get();
}
es.shutdown();
} finally {
//noinspection ThrowFromFinallyBlock
raftLog.shutdown();
}
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class ReplayRaftLog method main.
public static void main(String[] args) throws IOException {
Args arg = Args.parse(args);
String from = arg.get("from");
System.out.println("From is " + from);
String to = arg.get("to");
System.out.println("to is " + to);
File logDirectory = new File(from);
System.out.println("logDirectory = " + logDirectory);
Config config = Config.embeddedDefaults(stringMap());
try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(config.get(raft_log_pruning_strategy), logProvider).newInstance();
SegmentedRaftLog log = new SegmentedRaftLog(fileSystem, logDirectory, config.get(raft_log_rotation_size), new CoreReplicatedContentMarshal(), logProvider, config.get(raft_log_reader_pool_size), Clocks.systemClock(), new OnDemandJobScheduler(), pruningStrategy);
// Not really, but we need to have a way to pass in the commit index
long totalCommittedEntries = log.appendIndex();
for (int i = 0; i <= totalCommittedEntries; i++) {
ReplicatedContent content = readLogEntry(log, i).content();
if (content instanceof ReplicatedTransaction) {
ReplicatedTransaction tx = (ReplicatedTransaction) content;
ReplicatedTransactionFactory.extractTransactionRepresentation(tx, new byte[0]).accept(element -> {
System.out.println(element);
return false;
});
}
}
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction 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());
}
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class ConvertNonCausalClusteringStoreIT method shouldReplicateTransactionToCoreMembers.
@Test
public void shouldReplicateTransactionToCoreMembers() throws Throwable {
// given
File dbDir = clusterRule.testDirectory().cleanDirectory("classic-db");
int classicNodeCount = 1024;
File classicNeo4jStore = createNeoStore(dbDir, classicNodeCount);
Cluster cluster = this.clusterRule.withRecordFormat(recordFormat).createCluster();
try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
for (CoreClusterMember core : cluster.coreMembers()) {
fileSystem.copyRecursively(classicNeo4jStore, core.storeDir());
}
}
cluster.start();
// when
cluster.coreTx((coreDB, tx) -> {
Node node = coreDB.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
});
cluster.addReadReplicaWithIdAndRecordFormat(4, recordFormat).start();
// then
for (final CoreClusterMember server : cluster.coreMembers()) {
CoreGraphDatabase db = server.database();
try (Transaction tx = db.beginTx()) {
ThrowingSupplier<Long, Exception> nodeCount = () -> count(db.getAllNodes());
Config config = db.getDependencyResolver().resolveDependency(Config.class);
assertEventually("node to appear on core server " + config.get(raft_advertised_address), nodeCount, greaterThan((long) classicNodeCount), 15, SECONDS);
assertEquals(classicNodeCount + 1, count(db.getAllNodes()));
tx.success();
}
}
}
Aggregations