Tuesday, January 9, 2018

Angular 4

First of all, I’m going to tell you what kind of thing you are going to read. As an internet user, you must have visited lot of responsive and dynamic web applications. Wait, Have you ever notice, some applications only reload the required section and remain other sections as it is rather than reload whole page. All you have experienced with Gmail, PayPal etc. These applications are called Single Page Application (SPA).They are developed by Angular. SPAs heavily use AJAX- a way to communicate with back-end servers without doing a full page refresh to get data loaded into application.

Angular is a JavaScript based open source framework for building client-side web applications. JavaScript process with dynamic content. Based on JavaScript , many custom libraries can be create and jQuery is one which is fast small and feature-rich for DOM manipulation, event handling, animation and  Ajax much simpler with an easy-to-use API. But jQuery doesn’t have any proper structure and developer have the freedom for build the project structure. When considering a large project it may easily fall into trap of “spaghetti code” which leads to confusion of code maintainability. Angular provides a structured environment to build SPAs.

                Angular
jQuery
DOM Manipulation
yes
yes
RESTful API
yes
No
Animation Support
Yes
Yes
Deep Linking Routing
Yes
No
Form Validation
yes
No
2 Way Data Binding
yes
No
AJAX/JSON
yes
yes

Two-way binding is when properties in the model get updated, so does the UI and When UI elements get updated, the changes get propagated back to the model. Don’t get confuse now you may experience it while coding. Angular community has decided to consider any version of Angular (Angular 2 onwards) as just Angular and Angular 1 as AngularJS. Angular is normally called TypeScript based open source client side web application by Google and community. TypeScript is a super set of Java Script. Angular is completely rewrite of AngularJS. Now I guess you have a depiction of Angular origination.

Tuesday, January 2, 2018

Java Parallel Processing Framework(JPPF)

JPPF is an open source grid computing framework that can be used to run multiple java applications in parallel in a distributed execution environment. It also written in java

JPPF features
·         A JPPF grid can be up and running in minutes
·         Simple programming model for abstracts the complexity of distributed and parallel processing.
·         Highly scalable, distributed framework for the parallel execution of CPU intensive tasks.
·         Graphical and programmatic tools for fine-grained monitoring and administration
·         Fault-tolerance and self-repair capabilities ensure service and reliability.
·         A set of fully documented sample applications of JPPF to real-life problems
·         Very flexible and business-friendly open source licensing
·         Multiple built-in load-balancing algorithms are available at client and server levels.

Requirements and install
Current version of JPPF is v6.0 (alpha).Java 1.7 or later and Apache Ant 1.7.0 or later should already be installed on your machine.
·         You need to download and install the following JPPF components:
·         JPPF application template: this is the JPPF-x.y.z-application-template.zip file
·         JPPF driver: this is the JPPF-x.y.z-driver.zip file
·         JPPF node: this is the JPPF-x.y.z-node.zip file
·         JPPF administration console: this is the JPPF-x.y.z-admin-ui.zip file

JPPF Topology

A JPPF grid is made of three different types of components,
·         clients are entry points to the grid and enable developers to submit work
·         servers are the components that receive work from the clients, dispatch it to the nodes, receive the results from the nodes, and redirect the results to the clients
·         nodes perform the job execution.
To mitigate single point of failure, JPPF provides the ability to connect multiple servers together in a peer-to-peer network and additional connectivity options for clients and nodes, as illustrated in this figure:


There are a number of major advantages to this design: 
·         It enables a greater scalability of the JPPF grid, by allowing the "pluging-in" of additional servers dynamically. This way, a server can delegate a part of its load to other servers.
·         No matter how many servers are present, nodes and clients communicate with them in the exact same way
·         Peer server connections benefit from the same failover and recovery features available to nodes and clients

How it works
There are 2 steps.
·     Dividing an application into smaller parts that can be executed independently and in parallel. 
JPPF provides facilities that make this effort a lot easier, faster and much less painful than without them. The result is a JPPF object called a "job", itself made of smaller independent parts called "tasks".
·         Executing the application on the JPPF Grid.
The simplest possible JPPF Grid is made of a server, to which any number of execution nodes are attached. A node is a JPPF software component that is generally installed and running on a separate machine. This is commonly called a master/slave architecture, where the work is distributed by the server to the nodes. In JPPF terms, a unit of work is called a "job", and its constituting "tasks" are distributed by the server among the nodes for parallel execution. 

JPPF Supported Platforms
JPPF will run on any system that supports Java: MacOS, Windows, Linux, zOS, on any hardware from a simple laptop up to a mainframe computer. JPPF is not only limited to running Java jobs. You can run any application that is available on your platform as a JPPF job. For instance, you might want to run your favorite graphics suite in batch mode, to render multiple large, complex images all at once.

There are similar framework as JPPF such as GigaSpacesTerracotta and GridGain.

Reference:www.JPPF.org

Sunday, December 10, 2017

Multithreading in Java

Multitasking is a process of executing multiple tasks simultaneously. We use multitasking to utilize the CPU
Multitasking can be achieved by two ways:
  • Process-based Multitasking(Multiprocessing)
  • Thread-based Multitasking(Multithreading)
Process-based Multitasking (Multiprocessing)

Thread-based Multitasking (Multithreading)

Each process have its own address in memory
Threads share the same address space
heavyweight
lightweight
Cost of communication between the process is high
Cost of communication between the thread is low

A thread is a lightweight sub process, a smallest unit of processing. It is a separate path of execution.


Process is an executing instance of an application. For example, when you double click MS Word icon in your computer, you start a process that will run this MS word application.



  
Creating a thread,
1)      By extending java.lang.Thread class.

public class ThreadExtended {
public static void main(String[] arg){
//Creating a thread and starting it 
MyThread mt1 = new MyThread();
mt1.start();
}
}

class MyThread extends Thread{
public void run(){
// task for the thread
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
}
}




2) By implementing java.lang.Runnable interface.

public class RunnableImplementation  {

public static void main(String[] arg){
//Creating a thread and starting it 
//MyThreadRI mt = new MyThreadRI();  // Creating an instance of  MyThreadRI
//Thread thread = new Thread(mt);  // Creating a thread using Runnable implemented object
//thread.start();
// Create a thread using Java 8
Thread t1 = new Thread(()->{
// task for the thread
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
});
t1.start();
}
}

class MyThreadRI implements Runnable{
@Override
public void run() {
// task for the thread
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
}
}

Thursday, December 7, 2017

String in Java


String is an object that represents a sequence of characters. There are two ways of creating String,
1. by using String literal
2. by using new keyword
Strings created using “String Literal” are stored in “String Object Pool”. String Object Pool located in heap.
String Created using “new” keyword, stored String object in Heap memory (non pool) and create a literal in “String Object Pool”.




String is a final class in Java.

String is Immutable in Java hence can be safely used in multi threaded environment.
String Literals are used to get more memory efficient Because It don’t want create any object and if literal is already there it reuses it.

Why String objects are immutable in java?
Because String uses the concept of String literal. If String is mutable, When 5 variables refers to same String then Changing a variable value will affect to all the variables.

Thursday, January 16, 2014

Stored Procedure

Stored Procedure

Stored procedure is a block of code in database catalog and can be invoke later by a program.It just write the procedure in MySql then execute it.The procedure will save in catalog form that function name.You can see the procedure when you creating a backup file of  database schema in backup contain in Objecttype PROCEDURE. There are some advantages and disadvantages also.
Advantages
  •                 Reusable and transparent to any application. Stored procedures are not in our programming file but there in database.An application of any programming language can invoke that procedure  by invoking the stored procedure name.
  •                 It reduce the traffic between database server and application.
  •                 It is secured.Data base Administrator can grant access level by using stored procedure.

Disadvantages
  •                 It need a higher speed and higher capacity   database server.


Example:
DELIMITER //                                                         >>change the standard (;)delimiter to //
CREATE  PROCEDURE getAllUserDetaills()        >> name of the stored procedures
BEGIN                                                                   >> begin the actual query
SELECT * FROM USER                                       >>write the query
END//                                                                     >> end of the procedure
DELIMITER;                                                          >>change the delimiter to standard
 Can invoke the that procedure by using  CALL getAllUserDetails();.


The Hypervisor

 The hypervisor is a piece of software that runs on top of hardware infrastructure that creates a virtualization platform. The hypervisor a...