use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class ConfigurableStandalonePageCacheFactoryTest method mustAutomaticallyStartEvictionThread.
@Test(timeout = 10000)
public void mustAutomaticallyStartEvictionThread() throws IOException {
try (FileSystemAbstraction fs = new DelegateFileSystemAbstraction(Jimfs.newFileSystem(jimConfig()))) {
File file = new File("/a").getCanonicalFile();
fs.create(file).close();
try (PageCache cache = ConfigurableStandalonePageCacheFactory.createPageCache(fs);
PagedFile pf = cache.map(file, 4096);
PageCursor cursor = pf.io(0, PagedFile.PF_SHARED_WRITE_LOCK)) {
// If the eviction thread has not been started, then this test will block forever.
for (int i = 0; i < 10_000; i++) {
assertTrue(cursor.next());
cursor.putInt(42);
}
}
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class LuceneSchemaIndexProviderFactory method newInstance.
@Override
public LuceneSchemaIndexProvider newInstance(KernelContext context, Dependencies dependencies) throws Throwable {
Config config = dependencies.getConfig();
LogProvider logging = dependencies.getLogging().getInternalLogProvider();
boolean ephemeral = config.get(GraphDatabaseFacadeFactory.Configuration.ephemeral);
FileSystemAbstraction fileSystem = dependencies.fileSystem();
DirectoryFactory directoryFactory = directoryFactory(ephemeral, fileSystem);
return new LuceneSchemaIndexProvider(fileSystem, directoryFactory, context.storeDir(), logging, config, context.databaseInfo().operationalMode);
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class QueryLoggerKernelExtension method newInstance.
@Override
public Lifecycle newInstance(@SuppressWarnings("unused") KernelContext context, final Dependencies dependencies) throws Throwable {
final Config config = dependencies.config();
boolean queryLogEnabled = config.get(GraphDatabaseSettings.log_queries);
final File queryLogFile = config.get(GraphDatabaseSettings.log_queries_filename);
final FileSystemAbstraction fileSystem = dependencies.fileSystem();
final JobScheduler jobScheduler = dependencies.jobScheduler();
final Monitors monitoring = dependencies.monitoring();
if (!queryLogEnabled) {
return createEmptyAdapter();
}
return new LifecycleAdapter() {
Closeable closable;
@Override
public void init() throws Throwable {
Long thresholdMillis = config.get(GraphDatabaseSettings.log_queries_threshold);
Long rotationThreshold = config.get(GraphDatabaseSettings.log_queries_rotation_threshold);
int maxArchives = config.get(GraphDatabaseSettings.log_queries_max_archives);
boolean logQueryParameters = config.get(GraphDatabaseSettings.log_queries_parameter_logging_enabled);
FormattedLog.Builder logBuilder = FormattedLog.withUTCTimeZone();
Log log;
if (rotationThreshold == 0) {
OutputStream logOutputStream = createOrOpenAsOuputStream(fileSystem, queryLogFile, true);
log = logBuilder.toOutputStream(logOutputStream);
closable = logOutputStream;
} else {
RotatingFileOutputStreamSupplier rotatingSupplier = new RotatingFileOutputStreamSupplier(fileSystem, queryLogFile, rotationThreshold, 0, maxArchives, jobScheduler.executor(JobScheduler.Groups.queryLogRotation));
log = logBuilder.toOutputStream(rotatingSupplier);
closable = rotatingSupplier;
}
QueryLogger logger = new QueryLogger(Clocks.systemClock(), log, thresholdMillis, logQueryParameters);
monitoring.addMonitorListener(logger);
}
@Override
public void shutdown() throws Throwable {
closable.close();
}
};
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class StoreMigratorTestUtil method buildClusterWithMasterDirIn.
public static ClusterManager.ManagedCluster buildClusterWithMasterDirIn(FileSystemAbstraction fs, final File legacyStoreDir, LifeSupport life, final Map<String, String> sharedConfig) throws Throwable {
File haRootDir = new File(legacyStoreDir.getParentFile(), "ha-migration");
fs.deleteRecursively(haRootDir);
ClusterManager clusterManager = new ClusterManager.Builder(haRootDir).withStoreDirInitializer((serverId, storeDir) -> {
if (// Initialize dir only for master, others will copy store from it
serverId == 1) {
FileUtils.copyRecursively(legacyStoreDir, storeDir);
}
}).withCluster(clusterOfSize(3)).withSharedConfig(sharedConfig).build();
life.add(clusterManager);
life.start();
return clusterManager.getCluster();
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class StoreMigrationIT method data.
@Parameterized.Parameters(name = "Migrate: {0}->{1}")
public static Iterable<Object[]> data() throws IOException {
FileSystemAbstraction fs = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fs);
File dir = TestDirectory.testDirectory(StoreMigrationIT.class).prepareDirectoryForTest("migration");
StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache);
LegacyStoreVersionCheck legacyStoreVersionCheck = new LegacyStoreVersionCheck(fs);
List<Object[]> data = new ArrayList<>();
ArrayList<RecordFormats> recordFormatses = new ArrayList<>();
RecordFormatSelector.allFormats().forEach((f) -> addIfNotThere(f, recordFormatses));
for (RecordFormats toFormat : recordFormatses) {
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, storeVersionCheck, legacyStoreVersionCheck, toFormat);
for (RecordFormats fromFormat : recordFormatses) {
File db = new File(dir, baseDirName(toFormat, fromFormat));
try {
createDb(fromFormat, db);
if (!upgradableDatabase.hasCurrentVersion(db)) {
upgradableDatabase.checkUpgradeable(db);
data.add(new Object[] { fromFormat, toFormat });
}
} catch (Exception e) {
//This means that the combination is not migratable.
}
fs.deleteRecursively(db);
}
}
return data;
}
Aggregations