use of org.neo4j.procedure.Admin in project neo4j by neo4j.
the class BuiltInDbmsProcedures method listConfig.
@Admin
@SystemProcedure
@Description("List the currently active config of Neo4j.")
@Procedure(name = "dbms.listConfig", mode = DBMS)
public Stream<ConfigResult> listConfig(@Name(value = "searchString", defaultValue = "") String searchString) {
String lowerCasedSearchString = searchString.toLowerCase();
List<ConfigResult> results = new ArrayList<>();
Config config = graph.getDependencyResolver().resolveDependency(Config.class);
config.getValues().forEach((setting, value) -> {
if (!setting.internal() && setting.name().toLowerCase().contains(lowerCasedSearchString)) {
results.add(new ConfigResult(setting, value));
}
});
return results.stream().sorted(Comparator.comparing(c -> c.name));
}
use of org.neo4j.procedure.Admin in project neo4j by neo4j.
the class BuiltInDbmsProcedures method clearAllQueryCaches.
@Admin
@SystemProcedure
@Description("Clears all query caches.")
@Procedure(name = "db.clearQueryCaches", mode = DBMS)
public Stream<StringResult> clearAllQueryCaches() {
QueryExecutionEngine queryExecutionEngine = graph.getDependencyResolver().resolveDependency(QueryExecutionEngine.class);
// this query itself does not count
long numberOfClearedQueries = queryExecutionEngine.clearQueryCaches() - 1;
String result = numberOfClearedQueries == 0 ? "Query cache already empty." : "Query caches successfully cleared of " + numberOfClearedQueries + " queries.";
log.info("Called db.clearQueryCaches(): " + result);
return Stream.of(new StringResult(result));
}
use of org.neo4j.procedure.Admin in project neo4j by neo4j.
the class BuiltInDbmsProcedures method upgrade.
@Admin
@SystemProcedure
@Description("Upgrade the system database schema if it is not the current schema.")
@Procedure(name = "dbms.upgrade", mode = WRITE)
public Stream<SystemGraphComponentUpgradeResult> upgrade() throws ProcedureException {
if (!callContext.isSystemDatabase()) {
throw new ProcedureException(ProcedureCallFailed, "This is an administration command and it should be executed against the system database: dbms.upgrade");
}
SystemGraphComponents versions = systemGraphComponents;
SystemGraphComponent.Status status = versions.detect(transaction);
// New components are not currently initialised in cluster deployment when new binaries are booted on top of an existing database.
// This is a known shortcoming of the lifecycle and a state transfer from UNINITIALIZED to CURRENT must be supported
// as a workaround until it is fixed.
var upgradableStatuses = List.of(REQUIRES_UPGRADE, UNINITIALIZED);
if (upgradableStatuses.contains(status)) {
ArrayList<String> failed = new ArrayList<>();
versions.forEach(component -> {
SystemGraphComponent.Status initialStatus = component.detect(transaction);
if (upgradableStatuses.contains(initialStatus)) {
try {
component.upgradeToCurrent(graph);
} catch (Exception e) {
failed.add(String.format("[%s] %s", component.componentName(), e.getMessage()));
}
}
});
String upgradeResult = failed.isEmpty() ? "Success" : "Failed: " + String.join(", ", failed);
return Stream.of(new SystemGraphComponentUpgradeResult(versions.detect(transaction).name(), upgradeResult));
} else {
return Stream.of(new SystemGraphComponentUpgradeResult(status.name(), status.resolution()));
}
}
Aggregations