Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-10-12 Thread ashishb888
static class ICCall implements IgniteCallable {
private static final long serialVersionUID = 
4278959731940740185L;

@IgniteInstanceResource
private Ignite ignite;
@SpringResource(resourceName = "testService")
private TestService ts;
@SpringApplicationContextResource
private ApplicationContext ac;

private int affKey;
private String cacheName;

ICCall(int affKey, String cacheName) {
this.affKey = affKey;
this.cacheName = cacheName;
}

@Override
public Long call() {
log.debug("affKey: " + affKey + ", cacheName: " + 
cacheName);
log.debug("beans: " + 
Arrays.toString(ac.getBeanDefinitionNames()));

return ts.call(affKey, cacheName);
}
}

I am not able to get ApplicationContext by using
@SpringApplicationContextResource. So getting null pointer exception. Did I
miss something? 
How one can use @SpringResource & @SpringApplicationContextResource in
IgniteCallable?

BR,
Ashish





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-10-15 Thread ashishb888
Please help



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-10-19 Thread Ilya Kazakov
Hello!

I am trying to reproduce your issue and in my example everything is ok. It
looks like you create your spring application without igniteSpringBean. Look
at my example, please.

/

public class Main {

public static void main(String[] srgs) throws Exception {
BeanFactory appCtx = new
ClassPathXmlApplicationContext("/spring-bean.xml");
Ignite ignite = (Ignite) appCtx.getBean("igniteSpringBean");
ignite.compute().call(C.getList(10));
}

static public class C implements IgniteCallable {
private static final long serialVersionUID = 4278959731940740185L;

@IgniteInstanceResource
private Ignite ignite;

@SpringApplicationContextResource
private ApplicationContext context;

@Override
public Integer call() throws Exception {
System.out.println("Ignite: " + ignite);
System.out.println("Context: " +
context.getBeanDefinitionNames());
System.out.println("---");
return 1;
}

public static List getList(int size){
return IntStream.range(0, size - 1).mapToObj(i -> new
C()).collect(Collectors.toList());
}
}
}
///
// spring-bean.xml


http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd";>
















   
127.0.0.1:47500..47509














--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-10-20 Thread ashishb888
Thank you Ilya for the response.

I have two application first one is the server and second one is client.
Here

  
you can find the sever application code and  here

  
you can find the client application code

BR,
Ashish



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-10-27 Thread Ilya Kazakov
Hello, Ashish!

But I see in your example only config and Main classes. Can you show,
please, some actions in your code?

--
Ilya Kazakov

вт, 20 окт. 2020 г. в 17:06, ashishb888 :

> Thank you Ilya for the response.
>
> I have two application first one is the server and second one is client.
> Here
> <
> https://github.com/ashishb888/ignite-2.8-poc/tree/master/ignite-spring-resource>
>
> you can find the sever application code and  here
> <
> https://github.com/ashishb888/ignite-2.8-poc/tree/master/ignite-spring-resource-compute-client>
>
> you can find the client application code
>
> BR,
> Ashish
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-10-27 Thread ashishb888
Hello Ilya,

All actions happens in service package e.g.
poc.ignite.service.ComputeService#main()

Starting server: ignite-spring-resource$ java -jar target/*.jar
Starting client: ignite-spring-resource-compute-client$ java -jar
target/*.jar

I have attached the logs

ignite-spring-resource.log

  
ignite-spring-resoure-compute-client.log

  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-02 Thread ashishb888
Awaiting response. If you anything else let me know

BR,
Ashish



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-02 Thread Ilya Kazakov
Hello, Ashish! But I can not find poc.ignite.service.ComputeService class
by your link. Maybe you sent the wrong link?

Check, please.

Ilya Kazakov

вт, 3 нояб. 2020 г. в 12:11, ashishb888 :

> Awaiting response. If you anything else let me know
>
> BR,
> Ashish
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-02 Thread ashishb888
Hi Ilya,

My bad I forgot to push the changes. Now I just pushed the changes so you
can find the required details.

BR,
Ashish



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-06 Thread Ilya Kazakov
Hello, Asish!

Try to clean your BeanConfig class. Write this class like (in the client
and in the server app):

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource({"classpath*:applicationContext.xml"})
public class BeansConfig { }


File applicationContext.xml should be placed in the resources folder.
And write the system configuration to this file in xml. For example:


http://www.springframework.org/schema/beans";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd";>











127.0.0.1:47500..47509












Pay attention! In igniteSpringBean we use IgniteSpringBean class (not
Ignite). This is a prerequisite if you want to use
@SpringApplicationContextResource in IgniteCallable on remote nodes.

Ilya Kazakov

вт, 3 нояб. 2020 г. в 14:25, ashishb888 :

> Hi Ilya,
>
> My bad I forgot to push the changes. Now I just pushed the changes so you
> can find the required details.
>
> BR,
> Ashish
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-09 Thread ashishb888
Thank you Ilya!

I did replace Ignite bean with IgniteSpringBean by using Java configuration
(and not the XML) as below,

@Slf4j
@Configuration
public class BeansConfig {

@Bean
public IgniteSpringBean igniteSpringBean() {
log.debug("igniteSpringBean service");

IgniteSpringBean igniteSpringBean = new IgniteSpringBean();
igniteSpringBean.setConfiguration(igniteConfiguration());

return igniteSpringBean;
}

private IgniteConfiguration igniteConfiguration() {
log.debug("igniteConfiguration service");

TcpDiscoverySpi spi = new TcpDiscoverySpi();

spi.setLocalPort(42500);
spi.setLocalPortRange(100);

TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

// 
ipFinder.setAddresses(Arrays.asList("172.17.104.233:42500..42700"));
ipFinder.setAddresses(Arrays.asList("localhost:42500..42700"));

spi.setIpFinder(ipFinder);
IgniteConfiguration igniteConfiguration = new 
IgniteConfiguration();

igniteConfiguration.setFailureDetectionTimeout(9);

TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
commSpi.setLocalPort(42100);

commSpi.setMessageQueueLimit(1024);
commSpi.setSocketWriteTimeout(1L);

igniteConfiguration.setCommunicationSpi(commSpi);

// All properties should be in YAML
igniteConfiguration.setDiscoverySpi(spi);
igniteConfiguration.setIncludeEventTypes();
igniteConfiguration.setPeerClassLoadingEnabled(true);
igniteConfiguration.setGridLogger(new Slf4jLogger());
igniteConfiguration.setWorkDirectory("/var/tmp/ignite/work");

return igniteConfiguration;
}
}


Anyone looking to make use @SpringResource &
@SpringApplicationContextResource please refer the below code,

Compute client

  

Compute server

  

BR,
Ashish



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-09 Thread Ilya Kazakov
Hello, Asish!

Does it work?

--
Ilya Kazakov

пн, 9 нояб. 2020 г. в 21:26, ashishb888 :

> Thank you Ilya!
>
> I did replace Ignite bean with IgniteSpringBean by using Java configuration
> (and not the XML) as below,
>
> @Slf4j
> @Configuration
> public class BeansConfig {
>
> @Bean
> public IgniteSpringBean igniteSpringBean() {
> log.debug("igniteSpringBean service");
>
> IgniteSpringBean igniteSpringBean = new IgniteSpringBean();
> igniteSpringBean.setConfiguration(igniteConfiguration());
>
> return igniteSpringBean;
> }
>
> private IgniteConfiguration igniteConfiguration() {
> log.debug("igniteConfiguration service");
>
> TcpDiscoverySpi spi = new TcpDiscoverySpi();
>
> spi.setLocalPort(42500);
> spi.setLocalPortRange(100);
>
> TcpDiscoveryVmIpFinder ipFinder = new
> TcpDiscoveryVmIpFinder();
>
> // ipFinder.setAddresses(Arrays.asList("
> 172.17.104.233:42500..42700"));
>
> ipFinder.setAddresses(Arrays.asList("localhost:42500..42700"));
>
> spi.setIpFinder(ipFinder);
> IgniteConfiguration igniteConfiguration = new
> IgniteConfiguration();
>
> igniteConfiguration.setFailureDetectionTimeout(9);
>
> TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
> commSpi.setLocalPort(42100);
>
> commSpi.setMessageQueueLimit(1024);
> commSpi.setSocketWriteTimeout(1L);
>
> igniteConfiguration.setCommunicationSpi(commSpi);
>
> // All properties should be in YAML
> igniteConfiguration.setDiscoverySpi(spi);
> igniteConfiguration.setIncludeEventTypes();
> igniteConfiguration.setPeerClassLoadingEnabled(true);
> igniteConfiguration.setGridLogger(new Slf4jLogger());
>
> igniteConfiguration.setWorkDirectory("/var/tmp/ignite/work");
>
> return igniteConfiguration;
> }
> }
>
>
> Anyone looking to make use @SpringResource &
> @SpringApplicationContextResource please refer the below code,
>
> Compute client
> <
> https://github.com/ashishb888/ignite-2.8-poc/tree/master/ignite-spring-resource-compute-client>
>
>
> Compute server
> <
> https://github.com/ashishb888/ignite-2.8-poc/tree/master/ignite-spring-resource>
>
>
> BR,
> Ashish
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: Using @SpringResource & @SpringApplicationContextResource in IgniteCallable

2020-11-09 Thread ashishb888
Yes Ilya, it worked. Thank you!



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/