Search in sources :

Example 26 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class GBPTreePartialCreateFuzzIT method main.

static void main(String[] args) throws Exception {
    // Just start and immediately close. The process spawning this subprocess will kill it in the middle of all this
    Path file = Path.of(args[0]);
    try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
        JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
        SingleFilePageSwapperFactory swapper = new SingleFilePageSwapperFactory(fs);
        try (PageCache pageCache = new MuninnPageCache(swapper, jobScheduler, config(10))) {
            fs.deleteFile(file);
            new GBPTreeBuilder<>(pageCache, file, longLayout().build()).build().close();
        }
    }
}
Also used : Path(java.nio.file.Path) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) JobScheduler(org.neo4j.scheduler.JobScheduler) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) PageCache(org.neo4j.io.pagecache.PageCache) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache)

Example 27 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class LoadCommandTest method shouldRespectTheDatabaseLock.

@Test
void shouldRespectTheDatabaseLock() throws IOException {
    Path databaseDirectory = homeDir.resolve("data/databases/foo");
    Files.createDirectories(databaseDirectory);
    DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
        Locker locker = new DatabaseLocker(fileSystem, databaseLayout)) {
        locker.checkLock();
        CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> executeForce("foo"));
        assertEquals("The database is in use. Stop database 'foo' and try again.", commandFailed.getMessage());
    }
}
Also used : Path(java.nio.file.Path) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) DatabaseLocker(org.neo4j.kernel.internal.locker.DatabaseLocker) Locker(org.neo4j.kernel.internal.locker.Locker) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DatabaseLocker(org.neo4j.kernel.internal.locker.DatabaseLocker) CommandFailedException(org.neo4j.cli.CommandFailedException) Test(org.junit.jupiter.api.Test)

Example 28 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class TokenScanWriteMonitor method main.

/**
 * Dumps a token scan write log as plain text. Arguments:
 * <ul>
 *     <li>{@value #ARG_TOFILE}: dumps to a .txt file next to the writelog</li>
 *     <li>{@value #ARG_TXFILTER}: filter for which tx ids to include in the dump.
 *     <p>
 *     Consists of one or more groups separated by comma.
 *     <p>
 *     Each group is either a txId, or a txId range, e.g. 123-456
 *     </li>
 * </ul>
 * <p>
 * How to interpret the dump, e.g:
 * <pre>
 * === ..../neostore.labelscanstore.db.writelog ===
 * [1,1]+tx:6,entity:0,token:0
 * [1,1]+tx:3,entity:20,token:0
 * [1,1]+tx:4,entity:40,token:0
 * [1,1]+tx:5,entity:60,token:0
 * [2,1]+tx:8,entity:80,token:1
 * [3,1]+tx:10,entity:41,token:1
 * [4,1]+tx:9,entity:21,token:1
 * [4,1]+tx:11,entity:61,token:1
 * [4,1]+range:0,tokenId:1
 *  [00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000]
 *  [00100000 00000000 00000000 00000000 00000000 00100000 00000000 00000000]
 * [5,1]+tx:12,entity:81,token:1
 * [5,1]+range:1,tokenId:1
 *  [00000000 00000000 00000000 00000000 00000000 00000001 00000000 00000000]
 *  [00000000 00000000 00000000 00000000 00000000 00000010 00000000 00000000]
 * [6,1]+tx:13,entity:1,token:1
 * [6,1]+range:0,tokenId:1
 *  [00100000 00000000 00000010 00000000 00000000 00100000 00000000 00000000]
 *  [00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000010]
 * [7,1]+tx:14,entity:62,token:1
 * [7,1]+range:0,tokenId:1
 * </pre>
 * How to interpret a message like:
 * <pre>
 * [1,1]+tx:6,entity:0,token:0
 *  ▲ ▲ ▲   ▲        ▲       ▲
 *  │ │ │   │        │       └── token id of the change
 *  │ │ │   │        └────────── entity id of the change
 *  │ │ │   └─────────────────── id of transaction making this particular change
 *  │ │ └─────────────────────── addition, a minus means removal
 *  │ └───────────────────────── flush, local to each write session, incremented when a batch of changes is flushed internally in a writer session
 *  └─────────────────────────── write session, incremented for each token index writer
 * </pre>
 * How to interpret a message like:
 * <pre>
 * [4,1]+range:0,tokenId:1
 *  [00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000]
 *  [00100000 00000000 00000000 00000000 00000000 00100000 00000000 00000000]
 * </pre>
 * First the first line (parts within bracket same as above):
 * <pre>
 * [4,1]+range:0,tokenId:1
 *             ▲         ▲
 *             │         └── token id of the changed bitset to apply
 *             └──────────── range, i.e. which bitset to apply this change for
 * </pre>
 * Then the bitsets are printed
 * <pre>
 *  [00000000 00000000 00000010 00000000 00000000 00000000 00000000 00000000] : state of the bitset for this token id before the change
 *  [00100000 00000000 00000000 00000000 00000000 00100000 00000000 00000000] : bits that applied to this bitset
 *                                                                              for addition the 1-bits denotes bits to be added
 *                                                                              for removal the 1-bits denotes bits to be removed
 * </pre>
 */
public static void main(String[] args) throws IOException {
    Args arguments = Args.withFlags(ARG_TOFILE).parse(args);
    if (arguments.orphans().size() == 0) {
        System.err.println("Please supply database directory");
        return;
    }
    DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(Path.of(arguments.orphans().get(0)));
    FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
    TxFilter txFilter = parseTxFilter(arguments.get(ARG_TXFILTER, null));
    PrintStream out = System.out;
    boolean redirectsToFile = arguments.getBoolean(ARG_TOFILE);
    for (EntityType entityType : EntityType.values()) {
        if (redirectsToFile) {
            Path outFile = Path.of(writeLogBaseFile(databaseLayout, entityType).toAbsolutePath() + ".txt");
            System.out.println("Redirecting output to " + outFile);
            out = new PrintStream(new BufferedOutputStream(Files.newOutputStream(outFile)));
        }
        Dumper dumper = new PrintStreamDumper(out);
        dump(fs, databaseLayout, dumper, txFilter, entityType);
        if (redirectsToFile) {
            out.close();
        }
    }
}
Also used : EntityType(org.neo4j.common.EntityType) Path(java.nio.file.Path) PrintStream(java.io.PrintStream) Args(org.neo4j.internal.helpers.Args) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) BufferedOutputStream(java.io.BufferedOutputStream)

Example 29 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class DbmsDiagnosticsManagerTest method prepareDatabase.

private Database prepareDatabase(NamedDatabaseId databaseId) throws IOException {
    Database database = mock(Database.class);
    Dependencies databaseDependencies = new Dependencies();
    databaseDependencies.satisfyDependency(DbmsInfo.COMMUNITY);
    databaseDependencies.satisfyDependency(storageEngine);
    databaseDependencies.satisfyDependency(storageEngineFactory);
    databaseDependencies.satisfyDependency(new DefaultFileSystemAbstraction());
    databaseDependencies.satisfyDependency(logFilesBasedOnlyBuilder(directory.homePath(), directory.getFileSystem()).withLogEntryReader(mock(LogEntryReader.class)).build());
    when(database.getDependencyResolver()).thenReturn(databaseDependencies);
    when(database.getNamedDatabaseId()).thenReturn(databaseId);
    when(database.isStarted()).thenReturn(true);
    when(database.getDatabaseLayout()).thenReturn(DatabaseLayout.ofFlat(directory.homePath()));
    return database;
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Database(org.neo4j.kernel.database.Database) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) Dependencies(org.neo4j.collection.Dependencies)

Example 30 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class LogPruneStrategyFactoryTest method setUp.

@BeforeEach
void setUp() {
    fsa = new DefaultFileSystemAbstraction();
    clock = Clocks.nanoClock();
    logProvider = new AssertableLogProvider();
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)82 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)43 File (java.io.File)24 Path (java.nio.file.Path)21 PageCache (org.neo4j.io.pagecache.PageCache)21 Test (org.junit.Test)14 Test (org.junit.jupiter.api.Test)13 IOException (java.io.IOException)12 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)11 Config (org.neo4j.kernel.configuration.Config)11 Config (org.neo4j.configuration.Config)9 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)8 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)7 Transaction (org.neo4j.graphdb.Transaction)7 PrintStream (java.io.PrintStream)6 Before (org.junit.Before)6 CommandFailed (org.neo4j.commandline.admin.CommandFailed)6 Args (org.neo4j.helpers.Args)6 StandalonePageCacheFactory.createPageCache (org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache)6 JobScheduler (org.neo4j.scheduler.JobScheduler)6