Monday, 19 August 2013

JBOSS EAP6 extension,subsystems and profiles

                              JBOSS EAP6 extension,subsystems and profiles

Jboss eap 6 application server default is very lightweight and extremely fast.you can start default standalone server instance more or less than in 3 sec.

For understanding jboss eap6 it is very important to understand extension,subsystems and profiles.

so let start with extensions..

Extensions

In simple terms extension are modules that extends core capabilities of EAP.
Java EE capabilities, clustering, transactions, security and logging are all extensions of the EAP core.

An extension is added using the <extension> tag in the beginning of the EAP configuration file. (standalone.xml or domain.xml)

Subsystems 

A subsystem is the set of capabilities added by an extension.It defines how it will be used and configured. It is also defined in the EAP configuration file (standalone.xml or domain.xml) using the <subsystem> tag under a profile.

                             For every extension added in an EAP instance, the  capabilities and attributes of that extension are configured with the <subsystem> element. If no setting is required then you may simply leave the element empty. (e.g. <subsystem xmlns=”urn:jboss:domain:ee:1.0″/>)

Profiles

A profile is defined in the EAP configuration file using the <profile> element.It is  a collection of subsystems, along with the details of each subsystem’s configuration.

                     Profile is a set of subsystems combined for different purposes. For domain-mode, four profiles are defined by default. (default, ha, full, full-ha) For standalone-mode, an un-named profile is set.

Tuesday, 13 August 2013

Difference between JSON and XML

                                Difference between JSON and XML


JSON's concise syntax makes it very light and compact. It is also easier to parse from JavaScript, and that’s one of the main reasons it’s preferred for browser-based client-side applications (note that JSON stands for JavaScript Object Notation, it’s just natural). If you want to work with XML from JavaScript, you'll need to use an extra library for that. With JSON, you can just parse the message (let’s say with JSON.Parse() ) and work directly with js objects.


JSON.parse('{"name":"ram"}');

Difference between SOAP and REST

                                Difference Between soap and REST

SOAP

- A service architecture
- XML based
- Runs on HTTP but envelopes the message
- Slower than REST
- Very mature, a lot of functionality
- Not suitable for browser-based clients

REST

- A service architecture (resource-oriented)
- Uses the HTTP headers to hold meta information (although it is protocol-agnostic)
- Can be used with XML, JSON or whatever necessary
- Usually used with JSON due to the easily parsable content
- Faster than SOAP
- It uses semantic media types


The Representational State Transfer (REST) is another architectural pattern (resource-oriented), an alternative to SOAP. Unlike SOAP, RESTful applications use the HTTP build-in headers (with a variety of media-types) to carry meta information and use the GET, POST, PUT and DELETE verbs to perform CRUD operations. REST is resource-oriented and uses clean URLs (or RESTful URLs). 

 
For example :
http://www.developingthefuture.com/index.php?page=foo

 
becomes
 
http://www.developingthefuture.com/foo

 
This kind of URLs syntax greatly improves both visibility and usability. It doesn’t use any query strings, and it also provides certain SEO benefits (the crawlers just love plain text). The body of the REST message can be XML, JSON or any other format, although JSON is usually the preferred choice. On the other hand, you can’t use JSON with SOAP. Or at least not entirely, because SOAP uses XML by definition for it’s envelope. It should also mentioned that REST is, by design, protocol-agnostic, although it is usually used with HTTP
 

Saturday, 1 December 2012

Garbage collection Document



What is Garbage Collection?
Garbage Collection in computer science is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Garbage collection does not traditionally manage limited resources other than memory that typical programs use, such as network sockets, database handles, user interaction windows, and file and device descriptors.

History:
Garbage collection was invented by John McCarthy around 1959 to solve problems in Lisp.

Basic principle of Garbage Collection:
The basic principles of garbage collection are:
Find data objects in a program that cannot be accessed in the futureReclaim the resources used by those objects
It is kind of interesting to know how the objects without reference are found. Java normally finds all the objects that have reference and then regards rest of the objects are reference less – which is in fact a very smart way of finding the unreferenced java objects.

Types of Java Garbage Collectors/Garbage Collection Algorithms:
On J2SE 5.0 and above, one can normally find the following types of Java Garbage collectors that the programmers can normally choose to do a garbage collection through JVM Parameters.

1.) Serial Collector:
JVM Option Parameter: -XX:+UseSerialGC

2.) Throughput Collector or The Parallel Collector:
 JVM Option Parameter: -XX:+UseParallelGC
    Young Generation GC done in parallel threads
    Tenured Generation GC done in serial threads.

Parallel Old Generation Collector:
 JVM Option Parameter: -XX:+UseParallelOldGC
    Certain phases of an ‘Old Generation’ collection can be performed in parallel, speeding up a old generation collection.

The Concurrent Low Pause Collector:
  JVM Option Parameter -Xincgc or -XX:+UseConcMarkSweepGC
    The concurrent collector is used to collect the tenured generation and does most of the collection concurrently with the execution of the application. The application is paused for short periods during the collection.
    A parallel version of the young generation copying collector is used with the concurrent collector.
    The concurrent low pause collector is used if the option -XX:+UseConcMarkSweepGC is passed on the command line.
    -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
        Selects the Concurrent Mark Sweep collector.
        This collector may deliver better response time properties for the application (i.e., low application pause time).
        It is a parallel and mostly-concurrent collector and and can be a good match for the threading ability of an large multi-processor systems.

The incremental (sometimes called train) low pause collector:
JVM Option Parameter: -XX:+UseTrainGC
This collector has not changed since the J2SE Platform version 1.4.2 and is currently not under active development.
It will not be supported in future releases.

Note that -XX:+UseParallelGC should not be used with -XX:+UseConcMarkSweepGC .

Benefits of Garbage Collection:
Garbage collection frees the programmer from manually dealing with memory deallocation. As a result, certain categories of bugs are eliminated or substantially reduced:
 Dangling pointer bugs, which occur when a piece of memory is freed while there are still pointers to it, and one of those pointers is then used. By then the memory may have been re-assigned to another use, with unpredictable results.
    Double free bugs, which occur when the program tries to free a region of memory that has already been freed, and perhaps already been allocated again.
    Certain kinds of memory leaks, in which a program fails to free memory occupied by objects that will not be used again, leading, over time, to memory exhaustion.

Disadvantages of Garbage Collection:
 Consumes computing resources in deciding what memory is to be freed, reconstructing facts that may have been known to the programmer often leading to decreased or uneven performance.
    Interaction with memory hierarchy effects can make this overhead intolerable in circumstances that are hard to predict or to detect in routine testing.
    The moment when the garbage is actually collected can be unpredictable, resulting in stalls scattered throughout a session.
    Memory may leak despite the presence of a garbage collector, if references to unused objects are not themselves manually disposed of. This is described as a logical memory leak.The belief that garbage collection eliminates all leaks leads many programmers not to guard against creating such leaks.
    In virtual memory environments, it can be difficult for the garbage collector to notice when collection is needed, resulting in large amounts of accumulated garbage, a long, disruptive collection phase, and other programs’ data swapped out.
    Garbage collectors often exhibit poor locality (interacting badly with cache and virtual memory systems), occupy more address space than the program actually uses at any one time, and touch otherwise idle pages.
    Garbage collectors may cause thrashing, in which a program spends more time copying data between various grades of storage than performing useful work.



what's the difference between the serial, parallel and CMS (Concurrent-Mark-Sweep) collectors?
 first of all, let's take a look which collectors operate on the young generation and which on the tenured (old) generation:
 the following collectors operate on the young generation:
-XX:+UseSerialGC
-XX:+UseParallelGC
-XX:+UseParNewGC

the following collectors operate on the old generation:
-XX:+UseParallelOldGC
-XX:+UseConcMarkSweepGC

what's the difference between the Serial and the Parallel collector?
both the serial and parallel collectors cause a stop-the-world during the GC.
so what's the difference between them?
a serial collector is a default copying collector which uses only one GC thread for the GC operation, while a parallel collector uses multiple GC threads for the GC operation.

what's the difference between the Parallel and the CMS collector?
the CMS performs the following steps (all made by only one GC thread):
- initial mark
- concurrent marking
- remark
- concurrent sweeping
 there are two differences between a parallel and a CMS collectors:
1) the parallel uses multiple GC threads, while the CMS uses only one.
2) the parallel is a 'stop-the-world' collector, while the CMS stops the world only during the initial mark and remark phases.
during the concurrent marking and sweeping phases, the CMS thread runs along with the application's threads.
  if you wish to combine both parallelism and concurrency in your GC, you can use the following:
-XX:UserParNewGC for the new generation (multiple GC threads)
-XX:+UseConcMarkSweepGC for the old generation (one GC thread, freezes the JVM only during the initial mark and remark phases)

Selecting a Garbage Collector
 If the application has a small data set (up to approximately 100MB), then
        select the serial collector with -XX:+UseSerialGC.

    If the application will be run on a single processor and there are no pause time requirements, then
        let the VM select the collector, or
        select the serial collector with -XX:+UseSerialGC.

    If (a) peak application performance is the first priority and (b) there are no pause time requirements or pauses of one second or longer are acceptable, then
        let the VM select the collector, or
        select the parallel collector with -XX:+UseParallelGC and (optionally) enable parallel compaction with -XX:+UseParallelOldGC.

    If response time is more important than overall throughput and garbage collection pauses must be kept shorter than approximately one second, then
        select the concurrent collector with -XX:+UseConcMarkSweepGC. If only one or two processors are available, consider using incremental mode

Parameter to Enable Garbage Collection Logs
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails

Monday, 19 November 2012

kdump configuration on rhel6



Kdump Configuration on RHEL 6

1.  Installing the kdump Service.
~]# yum install kexec-tools
2.  Run the following Command to configure kdump in graphical environment.
~]# system-config-kdump

3.  The target setting tab.

 
 4.  The Filtering setting tab.
5.  The Expert setting tab.
6.  After completing this process first click on Apply button then reboot your machine to test the configuration and make sure service is running after reboot.
7.  After rebooting login with root
~]# /etc/init.d/kdump status
Kdump is operational
8.  Now download the debuginfo kernel from https://rhn.redhat.com
~] # rpm -ivh kernel-debuginfo-common-x86_64-2.6.32-279.5.2.el6.x86_64.rpm
~] # rpm -ivh kernel-debuginfo-x86_64-2.6.32-279.5.2.el6.x86_64
9.  Now run the following command at a shell prompt.
~] # echo 1 > /proc/sys/kernel/sysreq
~] # echo c > /proc/sysrq-trigger
Note:- This will force the linux kernel to crash, and the address-YYYY-MM-DD-HH:MM:SS/vmcore file will be copied to the location which you have selected in the configuration (/var/crash).
10.              Analyzing the core dump
~] # yum install  crash
~] # crash /var/crash/127.0.0.1-2012-09-05-16:40:44/vmcore  /usr/lib/debug/lib/module/2.6.32-279.el6.x86_64/vmlinux