Tuesday, February 14, 2017

Testing Infinispan application on Windows with Jboss EAP 7

The following lab is setup using jboss-eap-7.0.0 running on oracle hotspot JDK 1.8 which runs on windows 7 64bit. The lab showcases storing and retrieving values in a distributed cache environment.
The infinispan application is a basic example that shows how to store and retrieve data to/from the cache. Users can access the cache either from a servlet or from a JSF page through request scoped beans.
Infinispan is configured in clustered distributed mode with synchronous replication. Entries have their lifespan (expiration) and are removed from the cache after 60 seconds since last update.

Artifacts needed

OS: windows 7 enterprise version 64 bit
JAVA: any JDK above 1.7, I have used oracle hotspot 1.8 64 bit. (jdk-8u121-windows-x64)
Development tool: apache-maven-3.3.9-bin
Application server: jboss-eap-7.0.0

Install JAVA

JAVA is the first requirement of any application server installation. Use following command to check if you have java installed already on your system.
# java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Else go ahead and install java jdk-8u121-windows-x64.exe
Then set the classpath and java_home as shown below:
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the CLASSPATH environment variable and select it. Click Edit. If the CLASSPATH environment variable does not exist, click New.
Add the path after   ;
Variable name CLASSPATH
Variable value   ;C:\Program Files\Java\jdk1.8.0_101\bin
In the Edit System Variable (or New System Variable) window, specify the value of the JAVA_HOME environment variable. Click OK. Close all remaining windows by clicking OK
Variable name JAVA_HOME
Variable Value C:\Program Files\Java\jdk1.8.0_101\jre

Quickstarts

Download the quickstart from the jboss website check reference for link.
Unzip the archive

Maven

Download maven from the maven homepage and unzip the archive
apache-maven-3.3.9-bin.zip
Unzip the package and run the .bat file
C:\infinispan\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin\mvn.cmd
Check it by running the command mvn -v

Take the settings.xml from the quickstart and place it under the maven installation directory.
In my example settings.xml is under C:\infinispan\jboss-jdg-quickstarts-jdg-7.0.x\jboss-jdg-quickstarts-jdg-7.0.x
Which I will copy it to
C:\Users\richarob\.m2

Add maven path under system variable, as done in 2.2
Variable path PATH
Variable value C:\infinispan\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin
If you have any proxy settings on the browser, you need to implement it on the maven as well.
Go to tools menu of browser and copy the proxy settings if any.
Now paste this address in a new browser and open the result in a notepad, which will give you the host and port through which you gain access to internet from within your company.
Edit the settings.xml under C:\Users\richarob\.m2\settings.xml to add the host and port under http and https protocol of proxies tag.

<proxies>
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>web-proxy.in.corp.net</host>
      <port>8080</port>
    </proxy>
  <proxy>
      <id>optional_https</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>web-proxy.in.hpecorp.net</host>
      <port>8080</port>
    </proxy>
   </proxies>


Install JBOSS EAP

Download JBOSS EAP archive file by visiting the official site provided in the references section.
Unzip jboss-eap-7.0.0.zip in the desired directory.


Jboss EAP setup

Start the first instance
C:\infinispan\jboss-eap-7.0.0\jboss-eap-7.0\bin>standalone.bat
Access the console http://localhost:8080/
You need to add user to the console
C:\infinispan\jboss-eap-7.0.0\jboss-eap-7.0\bin>add-user.bat

Complete creation of management user and refresh console and login, which redirects you to http://localhost:9990/console/App.html#home

Start the second instance
Make a second copy of EAP folder as 2jboss-eap-7.0.0 and start
C:\infinispan\2jboss-eap-7.0.0\jboss-eap-7.0\bin>standalone.bat -Djboss.socket.binding.port-offset=100
Access the console at http://localhost:10090/console/App.html#home 
The port offset works like (100+9990=10090)

Now Go ahead and deploy the first package as below:
C:\infinispan\jboss-jdg-quickstarts-jdg-7.0.x\jboss-jdg-quickstarts-jdg-7.0.x\helloworld-jdg>mvn clean package jboss:deploy
This will create a war file under
C:\infinispan\jboss-jdg-quickstarts-jdg-7.0.x\jboss-jdg-quickstarts-jdg-7.0.x\helloworld-jdg\target\ jboss-helloworld-jdg.war

Test infinispan application

Login to both of the consoles and deploy the war file

After deployment you will be able to access the application under below URL's

http://localhost:8080/jboss-helloworld-jdg/put.jsf  
http://localhost:8180/jboss-helloworld-jdg/put.jsf 

Access first server at http://localhost:8080/jboss-helloworld-jdg and insert key "Robin" with value "Richard"
Access second server at http://localhost:8180/jboss-helloworld-jdg and do the following
Click on "Get Some"
Get the value for key "robin"
Click "Put Some More"
Insert key "super" with value "cool"
Access the first server at http://localhost:8080/jboss-helloworld-jdg and do the following
Click on "Get Some"
Get all mappings by clicking on "Get All"
All data entered on each server was replicated to the other server
Entries expire and simply disappear after 60 seconds from last update.

 
References 

http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
https://github.com/jboss-developer/jboss-jdg-quickstarts
http://maven.apache.org/download.cgi
http://maven.apache.org/install.html
https://github.com/jboss-developer/jboss-developer-shared- resources/blob/master/guides/CONFIGURE_MAVEN.md#configure-maven---for-use-with-command-line
https://github.com/jboss-developer/jboss-jdg-quickstarts
https://developers.redhat.com/products/eap/download/
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Installation_Guide/Install_JBoss_Enterprise_Application_Platform_6_Zip_Installation.html
https://access.redhat.com/documentation/en-US/JBoss_Operations_Network/3.1/html/How_to_Manage_JBoss_Servers/eap6-management-users.html
http://blog.infinispan.org/
http://infinispan.org/docs/stable/user_guide/user_guide.html

 

2 comments:

Blogger said...

Are you looking to get cash from your websites using popunder advertisments?
If so, did you ever use PropellerAds?

Blogger said...

BlueHost is ultimately one of the best hosting company with plans for all of your hosting needs.