Search in sources :

Example 1 with SettingImpl

use of org.neo4j.configuration.SettingImpl in project neo4j-documentation by neo4j.

the class ConfigDocsGenerator method document.

public String document(Predicate<SettingImpl<Object>> filter, String id, String title, String idPrefix) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    out = new PrintStream(baos);
    settingDescriptions = config.getDeclaredSettings().values().stream().map(setting -> (SettingImpl<Object>) setting).filter(filter).sorted(Comparator.comparing(SettingImpl::name)).map(setting -> new DocsConfigValue(idFromName(idPrefix, setting.name()), setting.name(), description(setting), setting.deprecated(), setting.toString(), valueAsString(setting), setting.internal(), // Should be in the description if deprecated
    Optional.empty(), setting.dynamic())).collect(Collectors.toList());
    out.print(documentSummary(id, title, settingDescriptions));
    settingDescriptions.forEach(this::documentForAllOutputs);
    out.flush();
    return baos.toString();
}
Also used : PrintStream(java.io.PrintStream) SecuritySettings(com.neo4j.configuration.SecuritySettings) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) SettingImpl(org.neo4j.configuration.SettingImpl) Predicate(java.util.function.Predicate) Config(org.neo4j.configuration.Config) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) List(java.util.List) Matcher(java.util.regex.Matcher) FabricEnterpriseSettings(com.neo4j.configuration.FabricEnterpriseSettings) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Comparator(java.util.Comparator) PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SettingImpl(org.neo4j.configuration.SettingImpl)

Example 2 with SettingImpl

use of org.neo4j.configuration.SettingImpl in project neo4j-documentation by neo4j.

the class ConfigDocsTool method main.

public static void main(String[] args) throws IOException {
    Args arguments = Args.parse(args);
    printUsage();
    List<String> orphans = arguments.orphans();
    Path outFile = orphans.size() == 1 ? Paths.get(orphans.get(0)) : null;
    String id = arguments.has("id") || warnMissingOption("ID", "--id=my-id", DEFAULT_ID) ? arguments.get("id") : DEFAULT_ID;
    String title = arguments.has("title") || warnMissingOption("title", "--title=my-title", DEFAULT_TITLE) ? arguments.get("title") : DEFAULT_TITLE;
    String idPrefix = arguments.has("id-prefix") || warnMissingOption("ID prefix", "--id-prefix=my-id-prefix", DEFAULT_ID_PREFIX) ? arguments.get("id-prefix") : DEFAULT_ID_PREFIX;
    Predicate<SettingImpl<Object>> filter = filters(arguments);
    System.out.printf("[+++] id=%s  title=%s  idPrefix=%s%n", id, title, idPrefix);
    try {
        String doc = new ConfigDocsGenerator().document(filter, id, title, idPrefix);
        if (null != outFile) {
            Path parentDir = outFile.getParent();
            if (!Files.exists(parentDir)) {
                Files.createDirectories(parentDir);
            }
            System.out.println("Saving docs in '" + outFile.toFile().getAbsolutePath() + "'.");
            Files.write(outFile, doc.getBytes());
        } else {
            System.out.println(doc);
        }
    } catch (NoSuchElementException | NoSuchFileException e) {
        e.printStackTrace();
        throw e;
    }
}
Also used : Path(java.nio.file.Path) Args(org.neo4j.internal.helpers.Args) NoSuchFileException(java.nio.file.NoSuchFileException) SettingImpl(org.neo4j.configuration.SettingImpl) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with SettingImpl

use of org.neo4j.configuration.SettingImpl in project neo4j by neo4j.

the class MemoryRecommendationsCommandTest method bytesToStringMustBeParseableBySettings.

@Test
void bytesToStringMustBeParseableBySettings() {
    SettingImpl<Long> setting = (SettingImpl<Long>) SettingImpl.newBuilder("arg", BYTES, null).build();
    for (int i = 1; i < 10_000; i++) {
        int mebibytes = 75 * i;
        long expectedBytes = mebiBytes(mebibytes);
        String bytesToString = bytesToString(expectedBytes);
        long actualBytes = setting.parse(bytesToString);
        long tenPercent = (long) (expectedBytes * 0.1);
        assertThat(actualBytes).as(mebibytes + "m").isBetween(expectedBytes - tenPercent, expectedBytes + tenPercent);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) SettingImpl(org.neo4j.configuration.SettingImpl) MemoryRecommendationsCommand.bytesToString(org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString) Test(org.junit.jupiter.api.Test)

Aggregations

SettingImpl (org.neo4j.configuration.SettingImpl)3 FabricEnterpriseSettings (com.neo4j.configuration.FabricEnterpriseSettings)1 SecuritySettings (com.neo4j.configuration.SecuritySettings)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 Path (java.nio.file.Path)1 Comparator (java.util.Comparator)1 List (java.util.List)1 NoSuchElementException (java.util.NoSuchElementException)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 Test (org.junit.jupiter.api.Test)1 MemoryRecommendationsCommand.bytesToString (org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString)1 Config (org.neo4j.configuration.Config)1