Sunday, 15 February 2015

Krypto Parameter in Websphere Commerce



When we define a command or view as secured page using https in struts-config file then that will add a krypto parameter as shown in the below URL while redirecting.

Krypto will have all  the parameters encrypted  as shown below.

https://localhost/webapp/wcs/stores/servlet/OrderBillingView?catalogId=10051&langId=-1&storeId=10151&krypto=1pX7e2Nepg9w%2FavOaLt1shhBswovwONoDZJPI8liwcvzrdPaOx1EbnlkrQ3VPLOhpVtYeHFelH5HQ42q9hFv9GQY%2BQPV614V9IOvBtPrRYsDxyPw5BXJXgRz%2F2DsikPE0TLzXyYIzhkv6MTvGcLs8k1B0eNeiwUNT%2BbkNKyiNIs%3D&ddkey=https:IMSyncOrderCreate

How Krypto is created

When redirecting to https url, Commerce will encrypt the query string using  (except the NonEncryptedParameters   from the wc-server.xml)  using merchant key and send that encrypted string as the "krypto" parameter.

If we want to prevent certain parameters to be exempted from being encrypted and added in the Krypto then we need to make an entry for those parameters in  the wc-server.xml in the NonEncryptedParameters  section as below..
 
<NonEncryptedParameters display="false">
<Parameter name="storeId"/>
<Parameter name="langId"/>
<Parameter name="catalogId"/>
<Parameter name="categoryId"/>
<Parameter name="productId"/>
</NonEncryptedParameters>

The above entry will make sure that the above parameters are not encrypted and added in the Krypto parameter.


Friday, 6 February 2015

Clustering in Websphere Commerce



Cluster
Cluster is the logical group of application servers within same cell. Application servers are grouped into Nodes and each node has a node agent.Node Agents communicate with Deployment Manager. Management of Deployment Manager is done by the Administrative Console.  Nodes and Application Servers belong to same cell.Nodes and Application Servers can be created independently and federated to the cell.

Clustering with vertical cluster members
Clustering with vertical cluster members means defining cluster members of an application server on the same physical machine.

Clustering with horizontal cluster members
Clustering with horizontal cluster members means defining cluster members of an application server on multiple physical machines. Clustering with horizontal cluster members can provide increased throughput and high availability.

 
Cluster
Cluster

Deployment Manager
A deployment manager is an application server that runs exactly one application that manages the configuration and behavior of an entire cell. There is only one deployment manager in any cell. Deployment managers talk only to node agents.

Node Agent
A node agent controls, configures and monitors all the servers and services in a node. Node agents talk to a deployment manager and servers in their node.

Node
A node contains a collection of application servers and web servers that all happen to live on the same physical computer. One physical computer can contain many nodes.

Cell
A group of related nodes and their Node Agents Constitute a Cell. A Cell contains a Deployment Manager from which all the administrative tasks for the nodes in that cell are handled. There can be only one deployment manager for the Websphere Application Server, so there can be only one Cell that holds all the nodes.


Load Balancer
A Load Balancer is responsible for distributing the request among HTTP Servers. Then the IBM HTTP Server does the workload management which balances the load using a WAS plugin which directs the requests to the server.

Load Balancer
LoadBalancer

IBM HTTP Server Load Balancing Configuration
IBM HTTP server can be configured to perform basic load balancing to redirect requests to the websphere commerce server in the server cluster.A file  plugin-cfg.xml  contains configurations for virtual hosts, server cluster and other configurations.In order to define  load balance configuration for an application we must  have a plugin-cfg.xml with the below entries.

<ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" LoadBalance="Round Robin" Name="CommerceCluster" PostBufferSize="64" PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60">     
<Server CloneID="15d2hi0gn" ConnectTimeout="0" ExtendedHandshake="false" LoadBalanceWeight="2" MaxConnections="-1" Name="server1" ServerIOTimeout="0" WaitForContinue="false">
</Server>
<Server CloneID="15d2hi3ic" ConnectTimeout="0" ExtendedHandshake="false" LoadBalanceWeight="2" MaxConnections="-1" Name="server2" ServerIOTimeout="0" WaitForContinue="false">
</Server>
<PrimaryServers>
<Server Name="server1"/>
<Server Name="server2"/>
</PrimaryServers>
</ServerCluster>

Each server in the cluster is defined in the Server tag. One of the important attributes of the “Server” xml tag is the “LoadBalanceWeight”. The value assigned to this attribute will be the starting value for the server weight. The server weight is lowered by the HTTP server dynamically whenever a request is allocated to that server. The Plugin can be configured to use either of two load balancing algorithms (Round Robin or Random)for routing the request.
Round robin: The Round Robin is the default load balancing algorithm, in this case when the first request arrives the server is selected on random basis but thereafter the requests are forwarded on round robin basis.This implementation ensures that in multiple process based Web servers, all of the processes don't start up by sending the first request to the same Application Server.
Random: In case of random load balancing the requests would be forwarded to the application servers on random basis.
Session affinity
Every time a web server receives a client request it checks if this is a new request or old request by checking for either session cookie or session URL.If it finds a session it will forward request to the same application server which was used to handle previous request for the client. This is called session affinity.

Command to Start and Stop an application server in windows.
Switch directories to WC_profiledir\bin.
To start an application server:
startServer server1
To stop an application server:
stopServer server1

Deployment manager Start\Stop command   in windows.
Switch directories to WAS_ND_profiledir\bin.
Windows: startManager.bat
Windows: stopManager.bat

Command to Start and Stop Node agent in Windows
cd WC_profiledir/bin
Windows: startNode.bat
Windows: stopNode.bat

su (Switch User)command
The su command stands for "switch user", and allows you to become another user. To switch users before running many commands, enter: su user.

Start and stop an application server in UNIX/LINUX
su - WC_non_root_user (Switch to Non Root User)
cd WC_profiledir/bin

To start an application server
./startServer.sh application_server_name
To stop an application server, enter:
./stopServer.sh application_server_name

Deployment manager Start and Stop in UNIX/LINUX
su – root (Switch to Non Root User)
cd WAS_ND_profiledir/bin
UNIX: ./startManager.sh
UNIX: ./stopManager.sh

Node agent Start and Stop in UNIX /LINUX
su - non_root_user (Switch to Non Root User)
cd WC_profiledir/bin
./startNode.sh
./stopNode.sh

WebSphere Integrated Solutions Console
In a clustered environment, we can also use the deployment manager WebSphere Integrated Solutions Console to stop and start the application servers that are managed by the deployment manager:

Start or Stop a specific application server in a cell.
Open the deployment manager WebSphere Integrated Solutions Console.
Click Servers > Application Servers.
Select the required server and click Start/Stop

Start or Stop the entire cluster .
Open the deployment manager WebSphere Integrated Solutions Console.
Click Servers > Clusters.
Select the cluster and click  Start/stop



Sunday, 1 February 2015

Read Session Data in Websphere Commerce


Use the below code snippet to get session data in Websphere Commerce.

HttpSession httpSession = null;
ViewCommandContext viewCmdCtx = (ViewCommandContext) getCommandContext();
Object reqObject = viewCmdCtx.getRequest();
HttpControllerRequestObject httpControllerRequestObject = (HttpControllerRequestObject) reqObject;
HttpServletRequest httpRequest = httpControllerRequestObject.getHttpRequest();
httpSession = httpRequest.getSession();