or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mddatabase-management.mdevents.mdgraph-database.mdgraph-model.mdindex.mdprocedures.mdquery-execution.mdschema.mdspatial.mdtraversal.md

configuration.mddocs/

0

# Configuration

1

2

Type-safe configuration system with validation, default values, and property file loading for customizing database behavior, performance, and security settings with comprehensive setting management.

3

4

## Capabilities

5

6

### Setting Interface

7

8

Interface representing a configuration setting with type safety, validation, and metadata.

9

10

```java { .api }

11

/**

12

* Represents a configuration setting

13

*/

14

public interface Setting<T> {

15

16

/**

17

* Get the name of this setting

18

* @return Setting name

19

*/

20

String name();

21

22

/**

23

* Get the default value for this setting

24

* @return Default value

25

*/

26

T defaultValue();

27

28

/**

29

* Get the description of this setting

30

* @return Setting description

31

*/

32

String description();

33

34

/**

35

* Parse a string value into the setting's type

36

* @param value String value to parse

37

* @return Parsed value

38

* @throws IllegalArgumentException if value cannot be parsed

39

*/

40

T parse(String value);

41

42

/**

43

* Validate a value for this setting

44

* @param value Value to validate

45

* @throws IllegalArgumentException if value is invalid

46

*/

47

void validate(T value);

48

49

/**

50

* Get the setting's value type

51

* @return Class representing the value type

52

*/

53

Class<T> getType();

54

55

/**

56

* Check if this setting is deprecated

57

* @return true if deprecated

58

*/

59

boolean deprecated();

60

61

/**

62

* Get replacement setting if this one is deprecated

63

* @return Replacement setting, or null if none

64

*/

65

Setting<T> replacement();

66

}

67

```

68

69

### Graph Database Settings

70

71

Central configuration settings class containing all standard Neo4j configuration options.

72

73

```java { .api }

74

/**

75

* Central configuration settings for Neo4j

76

*/

77

public final class GraphDatabaseSettings {

78

79

// Database directories and files

80

public static final Setting<Path> data_directory =

81

setting("server.directories.data", PATH, Paths.get("data"));

82

83

public static final Setting<Path> logs_directory =

84

setting("server.directories.logs", PATH, Paths.get("logs"));

85

86

public static final Setting<Path> plugins_directory =

87

setting("server.directories.plugins", PATH, Paths.get("plugins"));

88

89

// Memory settings

90

public static final Setting<Long> heap_initial_size =

91

setting("server.memory.heap.initial_size", BYTES, null);

92

93

public static final Setting<Long> heap_max_size =

94

setting("server.memory.heap.max_size", BYTES, null);

95

96

public static final Setting<Long> pagecache_memory =

97

setting("server.memory.pagecache.size", BYTES, null);

98

99

// Transaction settings

100

public static final Setting<Duration> transaction_timeout =

101

setting("db.transaction.timeout", DURATION, Duration.ofSeconds(0));

102

103

public static final Setting<Integer> transaction_concurrent_maximum =

104

setting("db.transaction.concurrent.maximum", INT, 1000);

105

106

public static final Setting<Duration> transaction_bookmark_ready_timeout =

107

setting("db.transaction.bookmark_ready_timeout", DURATION, Duration.ofSeconds(30));

108

109

// Query settings

110

public static final Setting<Duration> cypher_query_cache_size =

111

setting("db.cypher.query_cache_size", DURATION, Duration.ofSeconds(0));

112

113

public static final Setting<Boolean> cypher_hints_error =

114

setting("db.cypher.hints_error", BOOLEAN, false);

115

116

public static final Setting<Long> cypher_min_replan_interval =

117

setting("db.cypher.min_replan_interval", LONG, 10000L);

118

119

// Security settings

120

public static final Setting<Boolean> auth_enabled =

121

setting("dbms.security.auth_enabled", BOOLEAN, true);

122

123

public static final Setting<Duration> auth_lock_time =

124

setting("dbms.security.auth_lock_time", DURATION, Duration.ofSeconds(5));

125

126

public static final Setting<Integer> auth_max_failed_attempts =

127

setting("dbms.security.auth_max_failed_attempts", INT, 3);

128

129

// Network settings

130

public static final Setting<SocketAddress> default_listen_address =

131

setting("server.default_listen_address", SOCKET_ADDRESS,

132

new SocketAddress("localhost", 7687));

133

134

public static final Setting<AdvertisedSocketAddress> default_advertised_address =

135

setting("server.default_advertised_address", ADVERTISED_SOCKET_ADDRESS, null);

136

137

// Logging settings

138

public static final Setting<Level> log_level =

139

setting("server.logs.debug.level", LOG_LEVEL, Level.INFO);

140

141

public static final Setting<Boolean> log_queries =

142

setting("db.logs.query.enabled", BOOLEAN, false);

143

144

public static final Setting<Duration> log_queries_threshold =

145

setting("db.logs.query.threshold", DURATION, Duration.ofSeconds(0));

146

147

// Backup and import settings

148

public static final Setting<Boolean> allow_file_urls =

149

setting("db.security.allow_csv_import_from_file_urls", BOOLEAN, true);

150

151

public static final Setting<Path> import_directory =

152

setting("server.directories.import", PATH, Paths.get("import"));

153

154

// Performance settings

155

public static final Setting<Boolean> read_only =

156

setting("db.read_only", BOOLEAN, false);

157

158

public static final Setting<Integer> relationship_grouping_threshold =

159

setting("db.relationship_grouping_threshold", INT, 50);

160

161

public static final Setting<Boolean> dense_node_threshold =

162

setting("db.dense_node_threshold", BOOLEAN, true);

163

}

164

```

165

166

**Usage Examples:**

167

168

```java

169

import org.neo4j.configuration.GraphDatabaseSettings;

170

import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;

171

import java.time.Duration;

172

import java.nio.file.Paths;

173

174

// Basic configuration

175

DatabaseManagementService service = new DatabaseManagementServiceBuilder(dbPath)

176

.setConfig(GraphDatabaseSettings.transaction_timeout, Duration.ofMinutes(5))

177

.setConfig(GraphDatabaseSettings.heap_max_size, 2L * 1024 * 1024 * 1024) // 2GB

178

.setConfig(GraphDatabaseSettings.logs_directory, Paths.get("/custom/logs"))

179

.build();

180

181

// Performance tuning configuration

182

DatabaseManagementService service = new DatabaseManagementServiceBuilder(dbPath)

183

.setConfig(GraphDatabaseSettings.pagecache_memory, 4L * 1024 * 1024 * 1024) // 4GB

184

.setConfig(GraphDatabaseSettings.transaction_concurrent_maximum, 2000)

185

.setConfig(GraphDatabaseSettings.relationship_grouping_threshold, 100)

186

.setConfig(GraphDatabaseSettings.cypher_min_replan_interval, 5000L)

187

.build();

188

189

// Security configuration

190

DatabaseManagementService service = new DatabaseManagementServiceBuilder(dbPath)

191

.setConfig(GraphDatabaseSettings.auth_enabled, true)

192

.setConfig(GraphDatabaseSettings.auth_max_failed_attempts, 5)

193

.setConfig(GraphDatabaseSettings.auth_lock_time, Duration.ofMinutes(10))

194

.build();

195

```

196

197

### Config Interface

198

199

Configuration container providing access to settings and configuration management.

200

201

```java { .api }

202

/**

203

* Configuration container

204

*/

205

public interface Config {

206

207

/**

208

* Get the value of a configuration setting

209

* @param setting Setting to get value for

210

* @return Current value of the setting

211

*/

212

<T> T get(Setting<T> setting);

213

214

/**

215

* Set the value of a configuration setting

216

* @param setting Setting to set value for

217

* @param value New value for the setting

218

*/

219

<T> void set(Setting<T> setting, T value);

220

221

/**

222

* Check if a setting has been explicitly configured

223

* @param setting Setting to check

224

* @return true if setting has been explicitly set

225

*/

226

boolean isExplicitlySet(Setting<?> setting);

227

228

/**

229

* Get all configured settings

230

* @return Map of settings to their values

231

*/

232

Map<Setting<?>, Object> getValues();

233

234

/**

235

* Get configuration as properties

236

* @return Properties object with configuration

237

*/

238

Properties asProperties();

239

240

/**

241

* Validate the current configuration

242

* @throws IllegalArgumentException if configuration is invalid

243

*/

244

void validate();

245

246

/**

247

* Get configuration augmented with additional settings

248

* @param additionalConfig Additional configuration

249

* @return New config with merged settings

250

*/

251

Config with(Map<Setting<?>, Object> additionalConfig);

252

}

253

```

254

255

### Setting Builder Methods

256

257

Factory methods for creating different types of settings.

258

259

```java { .api }

260

/**

261

* Factory methods for creating settings

262

*/

263

public final class Settings {

264

265

/**

266

* Create a string setting

267

* @param name Setting name

268

* @param defaultValue Default value

269

* @param description Setting description

270

* @return String setting

271

*/

272

public static Setting<String> setting(String name, String defaultValue, String description);

273

274

/**

275

* Create an integer setting

276

* @param name Setting name

277

* @param defaultValue Default value

278

* @param description Setting description

279

* @return Integer setting

280

*/

281

public static Setting<Integer> setting(String name, Integer defaultValue, String description);

282

283

/**

284

* Create a boolean setting

285

* @param name Setting name

286

* @param defaultValue Default value

287

* @param description Setting description

288

* @return Boolean setting

289

*/

290

public static Setting<Boolean> setting(String name, Boolean defaultValue, String description);

291

292

/**

293

* Create a duration setting

294

* @param name Setting name

295

* @param defaultValue Default value

296

* @param description Setting description

297

* @return Duration setting

298

*/

299

public static Setting<Duration> setting(String name, Duration defaultValue, String description);

300

301

/**

302

* Create a path setting

303

* @param name Setting name

304

* @param defaultValue Default value

305

* @param description Setting description

306

* @return Path setting

307

*/

308

public static Setting<Path> setting(String name, Path defaultValue, String description);

309

310

/**

311

* Create an enum setting

312

* @param name Setting name

313

* @param enumClass Enum class

314

* @param defaultValue Default value

315

* @param description Setting description

316

* @return Enum setting

317

*/

318

public static <T extends Enum<T>> Setting<T> setting(String name, Class<T> enumClass,

319

T defaultValue, String description);

320

321

/**

322

* Create a list setting

323

* @param name Setting name

324

* @param itemType Type of list items

325

* @param defaultValue Default value

326

* @param description Setting description

327

* @return List setting

328

*/

329

public static <T> Setting<List<T>> listSetting(String name, Class<T> itemType,

330

List<T> defaultValue, String description);

331

}

332

```

333

334

**Advanced Configuration Examples:**

335

336

```java

337

import org.neo4j.configuration.Config;

338

import org.neo4j.configuration.GraphDatabaseSettings;

339

import java.util.Map;

340

import java.util.Properties;

341

342

// Load configuration from file

343

DatabaseManagementService service = new DatabaseManagementServiceBuilder(dbPath)

344

.loadPropertiesFromFile(Paths.get("/etc/neo4j/neo4j.conf"))

345

.build();

346

347

// Programmatic configuration with validation

348

Map<Setting<?>, Object> configMap = Map.of(

349

GraphDatabaseSettings.transaction_timeout, Duration.ofMinutes(10),

350

GraphDatabaseSettings.heap_max_size, 8L * 1024 * 1024 * 1024, // 8GB

351

GraphDatabaseSettings.auth_enabled, false,

352

GraphDatabaseSettings.log_queries, true,

353

GraphDatabaseSettings.log_queries_threshold, Duration.ofSeconds(1)

354

);

355

356

DatabaseManagementService service = new DatabaseManagementServiceBuilder(dbPath)

357

.setConfig(configMap)

358

.build();

359

360

// Runtime configuration access

361

GraphDatabaseService db = service.database("neo4j");

362

Config config = db.getConfig();

363

364

// Check current values

365

Duration timeout = config.get(GraphDatabaseSettings.transaction_timeout);

366

Boolean authEnabled = config.get(GraphDatabaseSettings.auth_enabled);

367

Path dataDir = config.get(GraphDatabaseSettings.data_directory);

368

369

System.out.println("Transaction timeout: " + timeout);

370

System.out.println("Auth enabled: " + authEnabled);

371

System.out.println("Data directory: " + dataDir);

372

373

// Check if settings were explicitly configured

374

if (config.isExplicitlySet(GraphDatabaseSettings.heap_max_size)) {

375

System.out.println("Heap size was explicitly configured");

376

}

377

378

// Get all configuration as properties

379

Properties props = config.asProperties();

380

props.forEach((key, value) -> System.out.println(key + " = " + value));

381

382

// Create custom settings

383

public class MyApplicationSettings {

384

public static final Setting<String> app_name =

385

Settings.setting("myapp.name", "MyNeo4jApp", "Application name");

386

387

public static final Setting<Integer> worker_threads =

388

Settings.setting("myapp.worker_threads", 10, "Number of worker threads");

389

390

public static final Setting<List<String>> allowed_hosts =

391

Settings.listSetting("myapp.allowed_hosts", String.class,

392

List.of("localhost"), "Allowed host names");

393

}

394

395

// Use custom settings

396

DatabaseManagementService service = new DatabaseManagementServiceBuilder(dbPath)

397

.setConfig(MyApplicationSettings.app_name, "ProductionApp")

398

.setConfig(MyApplicationSettings.worker_threads, 20)

399

.setConfig(MyApplicationSettings.allowed_hosts, List.of("app1.example.com", "app2.example.com"))

400

.build();

401

```