Hi,

we need to implement a rest service which have to perform all the crud
operations on ignite grid and as well as configure the cache store to
persist the data in RDBMS.

As per  following link,

http://apache-ignite-users.70518.x6.nabble.com/WebServer-on-Ignite-td314.html  


i have created a service and started the jetty server in init method,here
how i can to get the ignite instance to perform the operations on ignite
grid.  Is this correct way or any other way is there?

following is the code snippet

@Path("/service/test")
public class InmemoryService implements Service {


@IgniteInstanceResource
        private Ignite ignite;
        private IgniteCache<String, String> cache;

@GET
        @Path("/create")
        public String create(@QueryParam("tenantId")String tenantId,
@QueryParam("key") String key, @QueryParam("value") String value) {
                
                String result = "SUCCESS";
                
                try {
                        System.out.println("Inside create ");
                        cache = createOrGetCache(tenantId, 
CacheAtomicityMode.ATOMIC);
                        cache.put(key, value);
                        
                } catch (Exception e) {
                        return e.getMessage();
                }
                return result;

        }
@Override
        public void init(ServiceContext ctx) throws Exception {
                // TODO Auto-generated method stub
                        
                        
                        
                         ServletContextHandler context = new
ServletContextHandler(ServletContextHandler.NO_SESSIONS);
                            context.setContextPath("/");

                            Server jettyServer = new Server(9999);
                            jettyServer.setHandler(context);

                            ServletHolder jerseyServlet =
context.addServlet(ServletContainer.class, "/*");
                            jerseyServlet.setInitOrder(0);

                            // Tells the Jersey Servlet which REST 
service/class to load.
                           
jerseyServlet.setInitParameter("jersey.config.server.provider.packages","com.v2r.service");

                            try {
                               jettyServer.start();
                               jettyServer.join();
                              } catch (Exception e) {
                               e.printStackTrace();
                            } 
        }

}


        
Thanks









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

Reply via email to