use of org.neo4j.kernel.api.exceptions.KernelException in project neo4j by neo4j.
the class GraphDbStructureGuide method showStructure.
private void showStructure(Statement statement, DbStructureVisitor visitor) {
ReadOperations read = statement.readOperations();
try {
showTokens(visitor, read);
showSchema(visitor, read);
showStatistics(visitor, read);
} catch (KernelException e) {
throw new IllegalStateException("Kernel exception when traversing database schema structure and statistics. This is not expected to happen.", e);
}
}
use of org.neo4j.kernel.api.exceptions.KernelException in project neo4j by neo4j.
the class RemoveOrphanConstraintIndexesOnStartup method perform.
public void perform() {
try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
Statement statement = transaction.acquireStatement()) {
for (NewIndexDescriptor index : loop(statement.readOperations().uniqueIndexesGetAll())) {
if (statement.readOperations().indexGetOwningUniquenessConstraintId(index) == null) {
log.info("Removing orphan constraint index: " + index);
statement.schemaWriteOperations().uniqueIndexDrop(index);
}
}
transaction.success();
} catch (KernelException e) {
log.error("Failed to execute orphan index checking transaction.", e);
}
}
use of org.neo4j.kernel.api.exceptions.KernelException in project neo4j by neo4j.
the class DataSourceModule method setupProcedures.
private Procedures setupProcedures(PlatformModule platform, EditionModule editionModule) {
File pluginDir = platform.config.get(GraphDatabaseSettings.plugin_dir);
Log internalLog = platform.logging.getInternalLog(Procedures.class);
Procedures procedures = new Procedures(new SpecialBuiltInProcedures(Version.getNeo4jVersion(), platform.databaseInfo.edition.toString()), pluginDir, internalLog, new ProcedureConfig(platform.config));
platform.life.add(procedures);
platform.dependencies.satisfyDependency(procedures);
procedures.registerType(Node.class, new SimpleConverter(NTNode, Node.class));
procedures.registerType(Relationship.class, new SimpleConverter(NTRelationship, Relationship.class));
procedures.registerType(Path.class, new SimpleConverter(NTPath, Path.class));
procedures.registerType(Geometry.class, new SimpleConverter(NTGeometry, Geometry.class));
procedures.registerType(Point.class, new SimpleConverter(NTPoint, Point.class));
// Register injected public API components
Log proceduresLog = platform.logging.getUserLog(Procedures.class);
procedures.registerComponent(Log.class, (ctx) -> proceduresLog, true);
Guard guard = platform.dependencies.resolveDependency(Guard.class);
procedures.registerComponent(ProcedureTransaction.class, new ProcedureTransactionProvider(), true);
procedures.registerComponent(TerminationGuard.class, new TerminationGuardProvider(guard), true);
// Below components are not public API, but are made available for internal
// procedures to call, and to provide temporary workarounds for the following
// patterns:
// - Batch-transaction imports (GDAPI, needs to be real and passed to background processing threads)
// - Group-transaction writes (same pattern as above, but rather than splitting large transactions,
// combine lots of small ones)
// - Bleeding-edge performance (KernelTransaction, to bypass overhead of working with Core API)
procedures.registerComponent(DependencyResolver.class, (ctx) -> platform.dependencies, false);
procedures.registerComponent(KernelTransaction.class, (ctx) -> ctx.get(KERNEL_TRANSACTION), false);
procedures.registerComponent(GraphDatabaseAPI.class, (ctx) -> platform.graphDatabaseFacade, false);
// Security procedures
procedures.registerComponent(SecurityContext.class, ctx -> ctx.get(SECURITY_CONTEXT), true);
// Edition procedures
try {
editionModule.registerProcedures(procedures);
} catch (KernelException e) {
internalLog.error("Failed to register built-in edition procedures at start up: " + e.getMessage());
}
return procedures;
}
use of org.neo4j.kernel.api.exceptions.KernelException in project neo4j by neo4j.
the class ProcedureJarLoader method loadProceduresFromDir.
public Callables loadProceduresFromDir(File root) throws IOException, KernelException {
if (!root.exists()) {
return Callables.empty();
}
Callables out = new Callables();
List<URL> list = Stream.of(root.listFiles((dir, name) -> name.endsWith(".jar"))).map(this::toURL).collect(toList());
URL[] jarFiles = list.toArray(new URL[list.size()]);
URLClassLoader loader = new URLClassLoader(jarFiles, this.getClass().getClassLoader());
for (URL jarFile : jarFiles) {
loadProcedures(jarFile, loader, out);
}
return out;
}
use of org.neo4j.kernel.api.exceptions.KernelException in project neo4j by neo4j.
the class ReflectiveProcedureCompiler method compileAggregationFunction.
List<CallableUserAggregationFunction> compileAggregationFunction(Class<?> fcnDefinition) throws KernelException {
try {
List<Method> methods = Arrays.stream(fcnDefinition.getDeclaredMethods()).filter(m -> m.isAnnotationPresent(UserAggregationFunction.class)).collect(Collectors.toList());
if (methods.isEmpty()) {
return emptyList();
}
MethodHandle constructor = constructor(fcnDefinition);
ArrayList<CallableUserAggregationFunction> out = new ArrayList<>(methods.size());
for (Method method : methods) {
String valueName = method.getAnnotation(UserAggregationFunction.class).value();
String definedName = method.getAnnotation(UserAggregationFunction.class).name();
QualifiedName funcName = extractName(fcnDefinition, method, valueName, definedName);
if (config.isWhitelisted(funcName.toString())) {
out.add(compileAggregationFunction(fcnDefinition, constructor, method, funcName));
} else {
log.warn(String.format("The function '%s' is not on the whitelist and won't be loaded.", funcName.toString()));
}
}
out.sort(Comparator.comparing(a -> a.signature().name().toString()));
return out;
} catch (KernelException e) {
throw e;
} catch (Exception e) {
throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, e, "Failed to compile function defined in `%s`: %s", fcnDefinition.getSimpleName(), e.getMessage());
}
}
Aggregations