Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow async initialization of Node and Client #29

Closed
nithril opened this issue Oct 7, 2013 · 7 comments
Closed

Allow async initialization of Node and Client #29

nithril opened this issue Oct 7, 2013 · 7 comments
Assignees
Labels
Milestone

Comments

@nithril
Copy link
Contributor

nithril commented Oct 7, 2013

Node and client can take times to initialize. An async mode can be especialy usefull for unit test where speed matter

@dadoonet
Copy link
Owner

Hi @nithril,

Thanks for your pull request. Really useful.
Could you do some changes?

Then squash all commits, push that again to your branch and ping me back.

Thanks for your help!

@nithril
Copy link
Contributor Author

nithril commented Oct 23, 2013

Hello David,

I will do these changes next week.

Nicolas

@ghost ghost assigned dadoonet Nov 18, 2013
@dadoonet
Copy link
Owner

Hi @nithril

I'm working on updating the project to elasticsearch 2.0.

The latest blocker I have is related to your PR.

Previously, in elasticsearch, Node was an interface: https://github.com/elastic/elasticsearch/blob/1.7/src/main/java/org/elasticsearch/node/Node.java
But now, it's a Class: https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/node/Node.java#L109

So this code:

proxyfiedNode = (Node) Proxy.newProxyInstance(Node.class.getClassLoader(),
    new Class[]{Node.class}, new GenericInvocationHandler(nodeFuture));

Can't work anymore:

17:56:06,825 WARN  [o.s.c.s.ClassPathXmlApplicationContext] Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testNode': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.elasticsearch.node.Node is not an interface
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:743) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) [spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) [spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) [spring-context-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at fr.pilato.spring.elasticsearch.xml.AbstractXmlContextModel.startContext(AbstractXmlContextModel.java:58) [test-classes/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60]
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) [junit-4.12.jar:4.12]
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12]
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.junit.runners.Suite.runChild(Suite.java:128) [junit-4.12.jar:4.12]
    at org.junit.runners.Suite.runChild(Suite.java:27) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137) [junit-4.12.jar:4.12]
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) [junit-rt.jar:?]
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) [junit-rt.jar:?]
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) [junit-rt.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) [idea_rt.jar:?]
Caused by: java.lang.IllegalArgumentException: org.elasticsearch.node.Node is not an interface
    at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:623) ~[?:1.7.0_60]
    at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:591) ~[?:1.7.0_60]
    at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244) ~[?:1.7.0_60]
    at java.lang.reflect.WeakCache.get(WeakCache.java:141) ~[?:1.7.0_60]
    at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:454) ~[?:1.7.0_60]
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:736) ~[?:1.7.0_60]
    at fr.pilato.spring.elasticsearch.ElasticsearchNodeFactoryBean.afterPropertiesSet(ElasticsearchNodeFactoryBean.java:67) ~[classes/:?]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) ~[spring-beans-4.1.4.RELEASE.jar:4.1.4.RELEASE]
    ... 47 more

Thoughts?

@nithril
Copy link
Contributor Author

nithril commented Oct 12, 2015

Hi David,

Is it possible to push your code to a branch that I can have a look ?

Thanks!

dadoonet added a commit that referenced this issue Oct 12, 2015
@dadoonet
Copy link
Owner

@nithril
Copy link
Contributor Author

nithril commented Oct 13, 2015

Hi,

The proxy cannot be created anymore using JDK proxy. It should be created using cglib. I can fix this issue at the end of the day.

@dadoonet
Copy link
Owner

Cool! Thanks!

dadoonet added a commit that referenced this issue Oct 15, 2015
Tests fail see: #29 (comment)

Closes #73.

(cherry picked from commit af88902)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants