use of org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME in project neo4j by neo4j.
the class NumberArrayTest method arrays.
public static Collection<NumberArrayTestData> arrays() {
PageCache pageCache = fixture.pageCache;
Path dir = fixture.directory;
NullLog log = NullLog.getInstance();
Collection<NumberArrayTestData> list = new ArrayList<>();
Map<String, NumberArrayFactory> factories = new HashMap<>();
factories.put("HEAP", NumberArrayFactories.HEAP);
factories.put("OFF_HEAP", NumberArrayFactories.OFF_HEAP);
factories.put("AUTO_WITHOUT_PAGECACHE", NumberArrayFactories.AUTO_WITHOUT_PAGECACHE);
factories.put("CHUNKED_FIXED_SIZE", NumberArrayFactories.CHUNKED_FIXED_SIZE);
factories.put("autoWithPageCacheFallback", NumberArrayFactories.auto(pageCache, NULL, dir, true, NO_MONITOR, log, DEFAULT_DATABASE_NAME));
factories.put("PageCachedNumberArrayFactory", new PageCachedNumberArrayFactory(pageCache, NULL, dir, log, DEFAULT_DATABASE_NAME));
for (Map.Entry<String, NumberArrayFactory> entry : factories.entrySet()) {
String name = entry.getKey() + " => ";
NumberArrayFactory factory = entry.getValue();
list.add(arrayData(name + "IntArray", factory.newIntArray(INDEXES, -1, INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.set(index, (Integer) value), IntArray::get));
list.add(arrayData(name + "DynamicIntArray", factory.newDynamicIntArray(CHUNK_SIZE, -1, INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.set(index, (Integer) value), IntArray::get));
list.add(arrayData(name + "LongArray", factory.newLongArray(INDEXES, -1, INSTANCE), random -> random.nextLong(1_000_000_000), (array, index, value) -> array.set(index, (Long) value), LongArray::get));
list.add(arrayData(name + "DynamicLongArray", factory.newDynamicLongArray(CHUNK_SIZE, -1, INSTANCE), random -> random.nextLong(1_000_000_000), (array, index, value) -> array.set(index, (Long) value), LongArray::get));
list.add(arrayData(name + "ByteArray5", factory.newByteArray(INDEXES, defaultByteArray(5), INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.setInt(index, 1, (Integer) value), (array, index) -> array.getInt(index, 1)));
list.add(arrayData(name + "DynamicByteArray5", factory.newDynamicByteArray(CHUNK_SIZE, defaultByteArray(5), INSTANCE), random -> random.nextInt(1_000_000_000), (array, index, value) -> array.setInt(index, 1, (Integer) value), (array, index) -> array.getInt(index, 1)));
Function<RandomRule, Object> valueGenerator = random -> new long[] { random.nextLong(), random.nextInt(), (short) random.nextInt(), (byte) random.nextInt() };
Writer<ByteArray> writer = (array, index, value) -> {
long[] values = (long[]) value;
array.setLong(index, 0, values[0]);
array.setInt(index, 8, (int) values[1]);
array.setShort(index, 12, (short) values[2]);
array.setByte(index, 14, (byte) values[3]);
};
Reader<ByteArray> reader = (array, index) -> new long[] { array.getLong(index, 0), array.getInt(index, 8), array.getShort(index, 12), array.getByte(index, 14) };
list.add(arrayData(name + "ByteArray15", factory.newByteArray(INDEXES, defaultByteArray(15), INSTANCE), valueGenerator, writer, reader));
list.add(arrayData(name + "DynamicByteArray15", factory.newDynamicByteArray(CHUNK_SIZE, defaultByteArray(15), INSTANCE), valueGenerator, writer, reader));
}
return list;
}
use of org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME in project neo4j by neo4j.
the class DatabaseFileListingTest method verifyLogFilesWithCustomPathListing.
private void verifyLogFilesWithCustomPathListing(Path path) throws IOException {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath("customDb")).setConfig(GraphDatabaseSettings.transaction_logs_root_path, path).build();
GraphDatabaseAPI graphDatabase = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
Database database = graphDatabase.getDependencyResolver().resolveDependency(Database.class);
LogFiles logFiles = graphDatabase.getDependencyResolver().resolveDependency(LogFiles.class);
assertTrue(database.listStoreFiles(true).stream().anyMatch(metadata -> metadata.isLogFile() && logFiles.isLogFile(metadata.path())));
assertEquals(path.getFileName().toString(), logFiles.logFilesDirectory().getParent().getFileName().toString());
managementService.shutdown();
}
use of org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME in project neo4j by neo4j.
the class TransactionEventsIT method shouldGetSpecifiedUsernameAndMetaDataInTXData.
@Test
void shouldGetSpecifiedUsernameAndMetaDataInTXData() {
final AtomicReference<String> usernameRef = new AtomicReference<>();
final AtomicReference<Map<String, Object>> metaDataRef = new AtomicReference<>();
dbms.registerTransactionEventListener(DEFAULT_DATABASE_NAME, getBeforeCommitListener(txData -> {
usernameRef.set(txData.username());
metaDataRef.set(txData.metaData());
}));
AuthSubject subject = mock(AuthSubject.class);
when(subject.username()).thenReturn("Christof");
LoginContext loginContext = new LoginContext(subject, EMBEDDED_CONNECTION) {
@Override
public SecurityContext authorize(IdLookup idLookup, String dbName, AbstractSecurityLog securityLog) {
return new SecurityContext(subject, AccessMode.Static.WRITE, EMBEDDED_CONNECTION, dbName);
}
};
Map<String, Object> metadata = genericMap("username", "joe");
runTransaction(loginContext, metadata);
assertThat(usernameRef.get()).as("Should have specified username").isEqualTo("Christof");
assertThat(metaDataRef.get()).as("Should have metadata with specified username").isEqualTo(metadata);
}
use of org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME in project neo4j by neo4j.
the class GBPTreeGenericCountsStoreTest method shouldNotStartWithoutFileIfReadOnly.
@Test
void shouldNotStartWithoutFileIfReadOnly() {
final Path file = directory.file("non-existing");
final IllegalStateException e = assertThrows(IllegalStateException.class, () -> new GBPTreeCountsStore(pageCache, file, fs, immediate(), CountsBuilder.EMPTY, readOnly(), PageCacheTracer.NULL, NO_MONITOR, DEFAULT_DATABASE_NAME, randomMaxCacheSize()));
assertTrue(Exceptions.contains(e, t -> t instanceof ReadOnlyDbException));
assertTrue(Exceptions.contains(e, t -> t instanceof TreeFileNotFoundException));
assertTrue(Exceptions.contains(e, t -> t instanceof IllegalStateException));
}
use of org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME in project neo4j by neo4j.
the class IndexedIdGeneratorTest method shouldNotStartWithoutFileIfReadOnly.
@Test
void shouldNotStartWithoutFileIfReadOnly() {
Path file = directory.file("non-existing");
final IllegalStateException e = assertThrows(IllegalStateException.class, () -> new IndexedIdGenerator(pageCache, file, immediate(), IdType.LABEL_TOKEN, false, () -> 0, MAX_ID, readOnly(), Config.defaults(), DEFAULT_DATABASE_NAME, NULL));
assertTrue(Exceptions.contains(e, t -> t instanceof ReadOnlyDbException));
assertTrue(Exceptions.contains(e, t -> t instanceof TreeFileNotFoundException));
assertTrue(Exceptions.contains(e, t -> t instanceof IllegalStateException));
}
Aggregations