DynaCacheReplicationSampleServlet
servlet like this
public class DynaCacheReplicationSampleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private DistributedMap distributeMap;
public void init() throws ServletException {
super.init();
System.out.println("Entering DynaCacheReplicationSampleServlet.init()");
try {
Context ctx = new InitialContext();
System.out.println("Before getting the distributedMap");
distributeMap =(DistributedMap) ctx.lookup("services/cache/distributedmap");
System.out.println("After getting the distributedMap " + distributeMap);
} catch (NamingException e) {
e.printStackTrace(System.out);
}
System.out.println("Exiting DynaCacheReplicationSampleServlet.init()");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Entering DynaCacheReplicationSampleServlet.doGet() " );
String serverName = (String)distributeMap.get("serverName");
System.out.println("Server Name " + serverName);
if(serverName == null){
System.out.println("Server Name is empty. Adding data to distributedMap");
serverName = ServerName.getDisplayName() + new Date();
distributeMap.put("serverName", serverName);
}
response.setContentType("text/html");
response.getWriter().println("Server Name from Distribute Cache " + serverName +"
");
response.getWriter().println("Server Display Name " + ServerName.getDisplayName() +"
");
response.getWriter().println("Server Full Name " + ServerName.getFullName() +"
");
response.getWriter().println("Server Id " + ServerName.getServerId() +"
");
System.out.println("Exiting DynaCacheReplicationSampleServlet.doGet()");
}
}
I did deploy this application on my cluster and then i tried Hitting the servlet on first server followed by second server. On both of them i should have got same data but somehow my DynaCache replication is not working, i need debug it further
1 comment:
Hi Sunil,
Is it possible to add anything else than a String to de DynaCache? I mean a complex object.
If is it possible is there any special requirement (put jars files on the server classpath, etc) o configuration we need to do?
Thank you in advance
Post a Comment