Re: Deploying service programmatically hangs the app
Hi, apparently the issue we had was related to the service. It had injected some other classes that weren't serialized. In the end we relied on checking which node was the oldest to do the stuff we needed from only one node after there has been a change in the topology. Thanks. -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Deploying-service-programmatically-hangs-the-app-tp6791p7352.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Deploying service programmatically hangs the app
Hi, sorry I haven't replied before but I'm on holidays at the moment. Someone in my team may have tried it already but I won't know until next Tuesday. I'll reply back once I get back to work. Thanks. 2016-08-08 11:50 GMT+02:00 vdpyatkov [via Apache Ignite Users] < ml-node+s70518n6848...@n6.nabble.com>: > Hello, > > I try to reproduce your issue, but my code not hangs. > See attachment example. > > On Fri, Aug 5, 2016 at 7:03 PM, juanma.cvega <[hidden email] > <http:///user/SendEmail.jtp?type=node&node=6848&i=0>> wrote: > >> Hi, >> >> I already replied to the confirmation email twice. Is there any other >> thing >> I have to do? >> >> The place were it hangs is when calling >> ignite.services().deploy(serviceConfiguration()) from inside the bean >> IgniteClusterSingletonStarter. The full code is in the first post. If I >> remove that bean and simply provide ServiceConfiguration in the >> IgniteConfiguration bean (code is also in the first post), I can see it's >> registered by the logs from inside the init() method in the TestService >> implementation. So basically, registering the cluster singleton through >> xml >> configuration before create the Ignite instance works. If I create the >> Ignite instance and then try to create the cluster singleton it hangs. >> I don't know exactly what you mean with reusing IgniteConfiguration, >> CommunicationSPI and discoverySPI, sorry. The whole Ignite configuration >> is >> attached in the first post. From there, what I do in some beans is inject >> the Ignite instance to create a queue, a topic and listeners to node >> events. >> This is the code for that. The only part missing in the code is the >> cluster >> singleton that should produce messages to the distributed queue: >> >> public TopicSubscriber(Ignite ignite, >> String topicName, >> Service service){ >> this.service = service; >> this.ignite = ignite; >> this.topicName = topicName; >>} >> >>@PostConstruct >>private void initSubscriber() { >> ignite.message(ignite.cluster().forRemotes()).localListen(to >> picName, >> (uuid, deleteRequest) -> { >> service.remove((Request) deleteRequest); >> return true; >> }); >>} >> >> public class EventListener { >> >>private final Service service; >>private final IgniteEvents igniteEvents; >> >>public PriceChangeAlertClusterEventListener(IgniteEvents igniteEvents, >>Service service) { >> this.service = service; >> this.igniteEvents = igniteEvents; >>} >> >>@PostConstruct >>private void initializeEventsListener() { >> igniteEvents.localListen(this::clearSubscriptions, >> EventType.EVT_NODE_FAILED, EventType.EVT_NODE_JOINED, >> EventType.EVT_NODE_LEFT); >>} >> >>private boolean clearSubscriptions(Event event) { >> service.unsubscribeAll(); >> return true; >>} >> >> public QueueConsumer(Service service >> IgniteQueue queue) { >> this.service = service; >> this.queue = queue; >>} >> >>@PostConstruct >>private void startConsuming() { >> Executors.newFixedThreadPool(1).execute(() -> >> service.update(queue.take())); >>} >> >> >> The implementation of TestService is basically this >> >> public class TestService implements Service { >>@Override >>public void cancel(ServiceContext ctx) { >> log.info("Cancle"); >>} >> >>@Override >>public void init(ServiceContext ctx) throws Exception { >> log.info("Init"); >>} >> >>@Override >>public void execute(ServiceContext ctx) throws Exception { >> log.info("execute"); >>} >> } >> >> Thanks. >> >> >> >> -- >> View this message in context: http://apache-ignite-users.705 >> 18.x6.nabble.com/Deploying-service-programmatically-hangs- >> the-app-tp6791p6807.html >> Sent from the Apache Ignite Users mailing list archive at Nabble.com. >> > > > > -- > Vladislav Pyatkov > > *DeployingService.zip* (6K) Download Attachment > <http://apa
Re: Deploying service programmatically hangs the app
Hi, I already replied to the confirmation email twice. Is there any other thing I have to do? The place were it hangs is when calling ignite.services().deploy(serviceConfiguration()) from inside the bean IgniteClusterSingletonStarter. The full code is in the first post. If I remove that bean and simply provide ServiceConfiguration in the IgniteConfiguration bean (code is also in the first post), I can see it's registered by the logs from inside the init() method in the TestService implementation. So basically, registering the cluster singleton through xml configuration before create the Ignite instance works. If I create the Ignite instance and then try to create the cluster singleton it hangs. I don't know exactly what you mean with reusing IgniteConfiguration, CommunicationSPI and discoverySPI, sorry. The whole Ignite configuration is attached in the first post. From there, what I do in some beans is inject the Ignite instance to create a queue, a topic and listeners to node events. This is the code for that. The only part missing in the code is the cluster singleton that should produce messages to the distributed queue: public TopicSubscriber(Ignite ignite, String topicName, Service service){ this.service = service; this.ignite = ignite; this.topicName = topicName; } @PostConstruct private void initSubscriber() { ignite.message(ignite.cluster().forRemotes()).localListen(topicName, (uuid, deleteRequest) -> { service.remove((Request) deleteRequest); return true; }); } public class EventListener { private final Service service; private final IgniteEvents igniteEvents; public PriceChangeAlertClusterEventListener(IgniteEvents igniteEvents, Service service) { this.service = service; this.igniteEvents = igniteEvents; } @PostConstruct private void initializeEventsListener() { igniteEvents.localListen(this::clearSubscriptions, EventType.EVT_NODE_FAILED, EventType.EVT_NODE_JOINED, EventType.EVT_NODE_LEFT); } private boolean clearSubscriptions(Event event) { service.unsubscribeAll(); return true; } public QueueConsumer(Service service IgniteQueue queue) { this.service = service; this.queue = queue; } @PostConstruct private void startConsuming() { Executors.newFixedThreadPool(1).execute(() -> service.update(queue.take())); } The implementation of TestService is basically this public class TestService implements Service { @Override public void cancel(ServiceContext ctx) { log.info("Cancle"); } @Override public void init(ServiceContext ctx) throws Exception { log.info("Init"); } @Override public void execute(ServiceContext ctx) throws Exception { log.info("execute"); } } Thanks. -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Deploying-service-programmatically-hangs-the-app-tp6791p6807.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Deploying service programmatically hangs the app
Hello, Please properly subscribe to the mailing list so that the community can receive email notifications for you messages. Here is the instruction: http://apache-ignite-users.70518.x6.nabble.com/mailing_list/MailingListOptions.jtp?forum=1 Could you please provide full example, where hang taking place? You will be careful when reusing IgniteConfiguration, CommunicationSPI and discoverySPI. The beans can not reuse, because instances of it store state in private fields. juanma.cvega wrote > Hi, > > I'm trying to create a cluster service but the application hangs. > I've tried to deploy a simple service that does nothing following the > example from the documentation. When I do that, the application just > hangs. I've tried using xml configuration and setting the service before > calling Ignition.start(). At that point it works but I need to create the > service post context initialization so the service gets injected some > application services. > This is what I'm trying to do: > > public class IgniteClusterSingletonStarter { > @PostConstruct >public void init() { > log.info("APP_INIT: initializing Ignite Cluster service '{}'", > RELOAD_SERVICE_NAME); > ignite.services().deploy(serviceConfiguration()); >} > >private ServiceConfiguration serviceConfiguration() { > ServiceConfiguration configuration = new ServiceConfiguration(); > configuration.setMaxPerNodeCount(1); > configuration.setName("test"); > configuration.setService(testService); //This implementation just > adds a log on each method > configuration.setTotalCount(1); > return configuration; >} > } > > And this is my xml configuration: > > > class="com.reload.IgniteClusterSingletonStarter"> > > > > > > > > > > > > > > > > > > class="org.apache.ignite.configuration.CollectionConfiguration"> > > > > > > > > > > > factory-method="start"> > > > > > > > > > class="org.apache.ignite.configuration.IgniteConfiguration"> > > > > > > > > > > > > static-field="org.apache.ignite.events.EventType.EVT_NODE_FAILED"/> > > static-field="org.apache.ignite.events.EventType.EVT_NODE_JOINED"/> > > static-field="org.apache.ignite.events.EventType.EVT_NODE_LEFT"/> > > > > > > > > > > class="org.apache.ignite.services.ServiceConfiguration"> > > > > > > > > > > > > class="com.iggroup.wt.pricechangealerts.reload.TestService"/> > > > Thanks. -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Deploying-service-programmatically-hangs-the-app-tp6791p6805.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.