Showing posts with label neo4j. Show all posts
Showing posts with label neo4j. Show all posts

Friday, September 7, 2018

how to disable log in spring data neo4j

Leave a Comment

I am getting unwanted query log from spring neo4j like following

25-08-2018 23:47:07.597 [restartedMain] INFO  o.n.o.d.bolt.request.BoltRequest.executeRequest -  Request: MATCH (n:`OntoCategory`) WHERE n.`name` = { `name_0` } WITH n RETURN n,[ [ (n)-[r_h1:`HasSynonym`]->(o1:`OntoSynonyms`) | [ r_h1, o1 ] ] ], ID(n) with params {name_0=Breakfast Items} 25-08-2018 23:47:07.610 [restartedMain] INFO  o.n.o.d.bolt.request.BoltRequest.executeRequest - 

I am using following logging properties in my application.properties

Is there anything I've missed to add. I'm using spring boot version 2.0.3

logging.level.root=info logging.path=path logging.file=${logging.path}/log.log logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %n%highlight%msg%n 

Following two log properties are added from following post which doesn't change anything

log4j.category.org.springframework.data.neo4j=DEBUG log4j.category.org.springframework.data.neo4j.support.query=DEBUG` 

3 Answers

Answers 1

Since you have this configuration :

logging.level.root=info 

The root log level will be info, but if another level is different, it will override it for this log.

So, to have the following behaviour :

  • Neo4j log will be displayed if its level is WARN or higher (so, no request log)
  • Every other log in your app will be displayed if its level is INFO or higher

What you want is to do this :

logging.level.root=info log4j.category.org.springframework.data.neo4j=WARN log4j.category.org.springframework.data.neo4j.support.query=WARN 

Answers 2

If you set the log4j log level to DEBUG, then all log messages at DEBUG level and above (which includes INFO) will be logged.

To prevent INFO level messages from being logged, you should set the log level to WARN (or an even higher level).

Answers 3

log4j.category.org.springframework.data.neo4j.support.query=DEBUG

This entry in the log configuration, logs the query. To avoid logging query to the log files remove this entry.

Read More

Sunday, November 5, 2017

Neo4j: Which internal module responsible for verifying WHERE conditions from cypher?

Leave a Comment

My goal is to add to neo4j engine additional filtering, which will verify every node and relationship for property. This will give ability to break graph to subsets and perform random queries in different "layers" on demand.

According to this answer:

Cypher is build on the Traversal API

Though I tried to set breakpoints in PathExpanders.scala and StandardExpander.scala and it seems they aren't triggered while executing cypher MATCH query. Also modifying PathEvaluator in Evaluators.java didn't affected results for cypher queries.

I also inspected ast.rewriters which are triggered during cypher parsing, though it seems that I need to embed global filtering on later steps - when engine selects data from store.

In which place verification of node/relationship properties happens for cypher queries?

0 Answers

Read More

Sunday, April 10, 2016

How to Dynamically reload Spring Data Neo4j graph database service with different databases

Leave a Comment

I already configured my project to use one graph database and this is in embedded mode. Here is my configuration class.

@Configuration @EnableNeo4jRepositories(basePackages = "com.comp") @EnableTransactionManagement static class ApplicationConfig {      @Value("${application.neo4j.db.path}")     private String dbPath;      public ApplicationConfig() {     }      @Configuration     static class Neo4jMoreConfig extends Neo4jConfiguration {         Neo4jMoreConfig() {             setBasePackage("com.comp");         }      }      @Bean     public GraphDatabaseService graphDatabaseService() {         return new GraphDatabaseFactory().newEmbeddedDatabase(new File(dbPath));     }  } 

When the application is deploying its creating the database based on the name that I configured in application.yml. But I have a requirement to create multiple databases for different scenarios. For that I need to reload/refresh my graphDatabaseService to include new db path. How can I do this ?

1 Answers

Answers 1

Configuring Spring Data Neo4j 4.1 in an HA Environment

Transaction Binding in HA Mode

A typical Neo4j HA cluster will consist of a master node and a couple of slave nodes for providing failover capability and optionally for handling reads. (Although it is possible to write to slaves, this is uncommon because it requires additional effort to synchronise a slave with the master node) enter image description here

Typical HA Cluster

When operating in HA mode, Neo4j does not make open transactions available across all nodes in the cluster. This means we must bind every request within a specific transaction to the same node in the cluster, or the commit will fail with 404 Not Found.

Read-only Transactions

As of version 4, Spring Data Neo4j does not distinguish between WRITE transactions and READ-ONLY transactions. We cannot therefore bind read-only transactions to slaves and write transactions to master. A future version will address this deficiency, but in the meantime the only way to ensure that everything works as expected is to direct every transaction to master. There are a couple of ways to to achieve this.

Static Binding to a Designated Master

Example cluster:

  1. master: 192.168.0.55
  2. slave1: 192.168.0.56
  3. slave2: 192.168.0.67

SDN4 Binding to master IP address

Components.driver().setURI("http://192.168.0.55:7474"); 

We don’t really recommend this approach, except for testing purposes and non-critical deployments. Firstly, it will only work if you always bring up the designated master first, and secondly, if the master goes down all subsequent transactions will fail until it is restarted. In HA mode, the cluster is able to elect a new master when this happens, but as of version 4 of Spring Data Neo4j, there is no mechanism for querying the cluster to identify the current master. The solution in this case is to use a load balancer such as HAProxy that can do this for us. This is described in the next section.

Dynamic Binding via a Load Balancer

In the Neo4j HA architecture, a cluster is typically fronted by a load balancer. The following example shows how to configure your application and set up HAProxy as a load balancer to route all requests to whichever machine in the cluster is currently identified as the master. Since only one machine can ever be the elected master, this should work exactly as we would like. Furthermore, should the elected master fail, a new server will be elected from the cluster as master and HAProxy will automatically route transactions to this server.

Example cluster fronted by HAProxy

  1. haproxy: 10.0.2.200
  2. neo4j-server1: 10.0.1.10
  3. neo4j-server2: 10.0.1.11
  4. neo4j-server3: 10.0.1.12

Spring Data Neo4j 4 Binding via HAProxy

Components.driver().setURI("http://10.0.2.200"); 

Sample haproxy.cfg

global     daemon     maxconn 256  defaults     mode http     timeout connect 5000ms     timeout client 50000ms     timeout server 50000ms  frontend http-in     bind *:80     default_backend neo4j  backend neo4j     option httpchk GET /db/manage/server/ha/master     server s1 10.0.1.10:7474 maxconn 32     server s2 10.0.1.11:7474 maxconn 32     server s3 10.0.1.12:7474 maxconn 32  listen admin     bind *:8080     stats enable 

Resource Link:

  1. Good Relationships: The Spring Data Neo4j Guide Book

For a full tutorial using java, link is here.

Read More

Friday, April 1, 2016

Hibernate OGM Neo4j (5.0 ) Wildfly 10 Error. Provider org.hibernate.ogm.service.impl.OgmIntegrator not a subtype

Leave a Comment

I am getting this error while deployment of ear .

org.jboss.msc.service.StartException in service jboss.persistenceunit."test.ear/server.war#graphdb": java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.ogm.service.impl.OgmIntegrator not a subtype at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) at org.jboss.threads.JBossThread.run(JBossThread.java:320)   Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.ogm.service.impl.OgmIntegrator not a subtype at java.util.ServiceLoader.fail(ServiceLoader.java:239) at java.util.ServiceLoader.access$300(ServiceLoader.java:185) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:324) at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:40) at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:213) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:288) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:161) at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:160) at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135) at org.hibernate.ogm.jpa.HibernateOgmPersistence.createContainerEntityManagerFactory(HibernateOgmPersistence.java:96) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) ... 7 more 

And my persistence xml is

<persistence-unit name="graphdb" transaction-type="JTA">     <!-- Use Hibernate OGM provider: configuration will be transparent -->     <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>     <class>com.healthpray.persistence.entities.User</class>     <properties>         <property name="hibernate.transaction.jta.platform"             value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" />         <property name="hibernate.ogm.datastore.provider" value="neo4j_embedded" />         <property name="hibernate.ogm.neo4j.database_path" value="/home/manju/testdb" />     </properties> </persistence-unit> 

Can any one please whats the issue ? . I tried removing the JTA provider also.

Wildfly - 10.0 JPA -2.1 Java - 8 Hibernate - 5.0.0.Beta1

1 Answers

Answers 1

It was not working because Wildfly trying to load different version of hibernate. So binary conflict.

I disabled JPA subsystem in standalone.xml. Now its working fine.

Read More