Wednesday, 16 November 2016

[UPDATED] Top 20 Anisible Interview Questions and Answers

What is Ansible?


Ansible is a software tool to deploy application using ssh without any downtime. It is also used to manage and configure software applications. You don't need any agent on server to deploy application using Anisible. It is developed in Python language.


Brief me some advantages of Ansible?

(a) Agent-less
(b) Very low overhead
(c) Good performance.

Monday, 14 November 2016

Docker Interview Questions and Answers

In this article we will see important questions and answers on Docker for the purpose of interview preparation


What is Docker?

Docker is a platform to run each application isolated and securely. Internally it achieves it by using kernel containerization feature.


What is the advantage of Docker over hypervisors?

Docker is light weight and more efficient in terms of resource uses because it uses the host underlying kernel rather than creating its own hypervisor. 


What is Docker Image?

Docker Image is the source of the docker container. In other words, docker images are used to create containers. It is possible create multiple isolated containers from a single image.

What is Docker Container?

Docker Container is the instantiation of docker image. In other words, it is the run time instance of images. Images are set of files whereas containers is the one who run the image inside isolated.


Difference between Docker Image and container?

Docker container is the runtime instance of docker image.

Docker Image doesn't have a state and its state never changes as it is just set of files whereas docker container has its execution state.


How do you create docker image?

Docker image are created using Docker file. Docker build is command to create docker image out of docker file

So you have the docker image, what is the next step?

With docker image, we can spawn as many containers as needed. All containers can be same instance or it can also be different instance, what I mean that if we are using the same command for creating multiple containers, all container will behave as same. However, if you choose different command to create container out of same image, it will provide different functionality altogether.

How to create docker container?

We can create docker container by running this command

docker run -t -i <image name> <command name>

This will create and start the container


How to know the container status?

Just fire docker ps -a to list out all running container with stauts (running or stopped) on a host


How to stop and restart the container?

  • To stop container, we can use docker stop <container id>
  • To start a stopped container, docker start <container id> is the command
  • To restart a running container, docker restart <container id>


That's all for Docker Interview Questions. I will keep posting more questions with more depth analysis.

Thursday, 10 November 2016

Control M Interview Questions and Answers

What is Control-M?

Control-M is a workload automation software. In other words, it is a batch scheduling software and originally developed for Mainframe but later expanded for distributed computing platform like Windows, Wnix, Linux and OpenVMS environments.


Can we adjust the display in Control-M?


Yes.


What are the different intervals to schedule workloads in Control-M?


You can schedule workloads on daily, weekly or monthly intervals depends on the requirement.


What all types of functions that Control-M can automate?


It can automate the following type of functions:

  • JCL (Job Control Language)
  • Batch Files
  • Shell Scripts
  • Database stored procedures
  • File Transfer
  • Web Services

How can we return panes to their original positions in Control-M?

From View Menus -> Dockable Windows -> Reset to Default Layout, we can return panes to their original positions.

What are the different data display format?

  • Flow Diagram
  • List
  • Gantt Chart

How to change password in Control-M?

You can change the password from Tools menu (Tools->Change Password) if change password option is not visible on Control-M/EM or Control-M/Desktop.


Sunday, 23 October 2016

Laravel Interview Questions and Answers

Laravel is the PHP framework created by Taylor Otwell. Here are some important interview questions and answers on Laravel for experienced.


1. What is Laravel

Laravel is the PHP web framework developed for the purpose of developing web application on MVC (Model-View-Controller) design pattern.


2. Brief few features of Laravel

Here are some few features:

  • Bundles
  • Query Builder
  • Reverse Routing
  • IOC Container feature
  • Database Seeding
  • Automatic pagination

3. What are the official packages provided by Laravel

The following are the official packages provided by Laravel
  • Cashier
  • Envoy
  • Passport
  • Scout
  • Socialite

4. Explain Laravel Service Container

Laravel Service Container is used to perform dependency injection, wherein the dependencies of a class is injected via constructor or other method.

5. What is Service Providers

Laravel Service providers are used for all Laravel applications including Laravel core service applications.
Also, most of the service container bindings are registered inside service providers. 

6. What are Laravel's Contracts

The core services provided by Laravel framework is defined by the set of interfaces which is called contracts. For example, Illuminate\Contracts\Auth\Authenticatable contract defines the methods needed for authentication. Similarly, Illuminate\Contracts\Routing\Registrar contract defines the method for registering the route with the router.

7. Explain Laravel's Facades

Laravel's Facade provides a static-level interface for application's service container classes. It is defined inside Illunminate\support\Facades namespace. 
For eg: Illuminate\Support\Facades\Cache
Illuminate\Support\Facades\Queue and others Facades

That's all for interview questions and answers on Laravel.


Jenkins Interview Questions

Jenkins is one of the tools for continuous integration and these days more applications are using Jenkins for automated integration. Here are few important questions and answers on Jenkins.

1. What is Jenkins?

Jenkins is an open source application for continuous integration and continuous delivery of application software.

2. What is Continuous Integration?

Typically, there are multiple developers writing code for a single application, so we need to perform integration test by integrating each new piece of code via testing it through as many tests as possible. This practice is called continuous Integration. Jenkins besides Hudson, Bamboo etc provides tools for continuous integration.

3. Tell me few advantages of Jenkins?

Here are some advantages of using Jenkins (or by any matter any integration tools) :-

(a) It saves developer time: 

The foremost advantage of using Jenkins is that since most of the integration task is being handled by Jenkins (via automatic integration), the developer time is focused on development activities mostly.

(b) Improved software quality: 

Since the software is being tested immediately after any code check-in, it keeps the quality check frequently, thus improving overall software quality.

(c) Faster Delivery: 

Jenkins automatically does continuous integration, which leads to very early detection of bugs / defects and hence it leads to faster delivery of software.

(d) Decreased development time: 

Since most of the integration work is automated by Jenkins, it leads to the faster development of application.

(e) Easily portable: 

Since Jenkins is developed using Java, it can be easily portable to other platforms.

(f) Early tracking of defects: 

Jenkins helps tacking of defects at very early stage in development environment only rather than production environment.

(g) Email Notification to developers: 

Jenkins can be easily integrated with LDAP server, so developer are notified about build success / failure via mail.

4. What are the commands to start Jenkins manually?

Commands:
<jenkins_url>/restart :  Force restart (will not wait for ongoing build to complete)
<jenkins_url>/safeRestart : Wait for all builds to complete before restarting.

5. Mention few plugins of Jenkins?

Here are some plugins that can be used with Jenkins:

  • Delivery Pipeline
  • Join Plugin
  • Copy Artifact 
  • Git 
  • Android Emulator 
  • Cobertura 
  • Email-ext 
  • Docker 
  • Amazon EC2
  • Openstack Cloud
  • CloudBees Folders

6. What are the two most important components Jenkins is integrated with?

Jenkins is integrated with these two components mainly:
(a) Version Control System like SVN, GIT
(b) Build tools like Maven



That's all for some important questions and answers on Jenkins. I will add more questions and answers later.

Saturday, 13 August 2016

Ansible local action

In this article, we will learn some of the use-cases and advantages of Ansible local_action.



Ansible local_action module:


Consider the problem / usecase scenario where we want to run tasks on the system which runs the Ansible-playbook command. In other words, how can we run for eg. shell command on the local machine parallely while playbook is already running. Also, how can we make sure that some tasks has been fulfilled in order to run the other part of playbook on some other remote machine.

The solution to the above usecase is the local_action option provided by Ansible. It takes the module name and module argument and will run that module locally.

Example:




cat local_action.yml

---

- hosts: dev

  tasks:

    - name: remote running process

      shell: ps

      register: remote_process



    - debug: msg="{{ remote_process.stdout }} "



    - name: Running Local Process

      local_action: shell ps

      register: local_process



    - debug: msg="{{ local_process.stdout }}"

 

Consider this example, which is the playbook I will be using for local_action. If we run the above playbook, we can see that we have two tasks.



- name: remote running process

   shell: ps

   register: remote_process



 - name: Running Local Process

   local_action: shell ps

   register: local_process

 

Ansible local_action shell

The first task will run ps command (shell command) on the remote machine and to check the output of the command a register remote_process has been set.

The second task as shown in above example will run command on local machine due to the local_action module being specified.


How to run local actions?

To run local actions, we just need to define the module name (i.e. local_action module name) for the command or task to run.

For example:




ansible-playbook local_action.yml



PLAY [dev] ********************************************************************



GATHERING FACTS ***************************************************************

ok: [172.16.202.96]



TASK: [remote running process] ************************************************

changed: [172.16.202.96]



TASK: [debug msg="{{ remote_process.stdout }} "] ******************************

ok: [172.16.202.96] => {

    "msg": "  PID TTY          TIME CMD\n12775 pts/1    00:00:00 sh\n12776 pts/1    00:00:00 python\n12777 pts/1    00:00:00 ps "

}



TASK: [Running Local Process] *************************************************

changed: [172.16.202.96 -> 127.0.0.1]



TASK: [debug msg="{{ local_process.stdout }}"] ********************************

ok: [172.16.202.96] => {

    "msg": "  PID TTY          TIME CMD\n24362 pts/0    00:00:02 bash\n30565 pts/0    00:00:00 ansible-playboo\n30587 pts/0    00:00:00 sh\n30588 pts/0    00:00:00 python\n30593 pts/0    00:00:00 ps"

}



PLAY RECAP ********************************************************************

172.16.202.96              : ok=5    changed=2    unreachable=0    failed=0 




Analysis:

If we see the above command result, we find that the both output differ from each other because one is being run on local macine and another being run on remote machine.


Ansible local_action sudo:

If we want to make anisible use the remote user for local_action, use the -u option while running playbook. When it uses the user to sudo, it will ask for sudo password



ansible-playbook -i <inventory> ansible/local_action.yml -u <local user that can sudo with password> --ask-sudo-pass


Conclusion:

Ansible local_action is the way to make double sure that the some things are available before we jump to run on remote machine. Its like running pretest locally before running command or task on remote machine.

Thats all about Ansible local_action usage and its purpose.


Sunday, 3 July 2016

WildFly Interview Questions and Answers

WildFly Application server (previously know as JBoss) implements JAVAEE specification. For interview purpose, here are some questions along with its answers.


What is WildFly ? 

WildFly is an open source application server based on JaVA EE technology. Being JAVAEE based, it can run on cross-platform. It was embedded with Apache Tomcat web server. It runs under any JRE version of 1.3 or later . WildFly supports JNDI, Servlet/JSP (Tomcat or Jetty), EJB, JTS/JTA, JCA, JMS, Clustering (JavaGroups), Web Services (Axis), and IIOP integration (JacORB).


Define WildFly cache? 

Caching usuall comes into picture when there are frequent access to some objects. Likewise, multiple and frequently accessed Java objects are cached by using WildFlycache to improve the performance of e-business applications. 


What is WildFly JBPM? 

WildFly JBPM is a workflow and Business Process Manager engine. As a BPM engine, it enables the creation of business processes that coordinates between people, applications and services. The combination of workflow applications development with process design is a feature of WildFly JBPM. The business process has GUI (Graphical User Interface) to facilitate a strong link between the business analyst and technical developer. This feature is provided by the WildFly JBPM process designer.


How do you monitor WildFly and detect the bottleneck of an application? 

At first, you need to measure different components of the application and then observe where the degradation is, and whether it is internal or external and which component is consuming maximum cpu. Using Joss JMX agents and monitoring the deployed components to the application server involves in the first step.

After observing which specific components or libraries spent most of time, one can then use Jprobe to examine that single object or the objects loaded in the memory.


What is JTA? 

Java Transaction API (JTA) specifies standard Java interfaces between a transaction manager and the parties involved in a distributed transaction system: the resource manager, the application server, and the transactional applications. It allows applications to perform distributed transactions, that is, transactions that access and update data on two or more resources.It consists of three elements: a high-level application transaction demarcation interface, a high-level transaction manager interface intended for an application server, and a standard Java mapping of the X/Open XA protocol intended for a transactional resource manager.


Which Hibernate object wraps the JDBC Connection? 

The Session interface wraps a JDBC Connection which is a single threaded object representing a single unit for application and persistent database. You can get the Session object from SessionFactory's openSession() method


Is the Session Factory Thread safe? 

Yes because many threads can simultaneously access it and request for sessions. It holds cached data that has been read in one unit of work and is likely to be reused in future unit of work. The best practice to create Session Factory object is when the application is initialized.


How can you start a JTA transaction from a Servlet deployed on WildFly? 

WildFly registers in the JNDI tree a JTA UserTransaction Object which can be user to manage a distributed transaction.


What if you need to span your transaction across multiple Servlet invocations?

You can't with a Servlet. A JTA transaction must start and finish within a single invocation (of the service() method). You should consider using a Stateful SB. In a SFSB with a JTA transaction, the association between the bean instance and the transaction is retained across multiple client calls.


What are the differences between EJB 3.0 and EJB 2.0? 

EJBs are now plain old Java objects (POJO) that expose regular business interfaces (POJO), and there is no requirement for home interfaces.
  • Use of metadata annotations, an extensible, metadata-driven, attribute-oriented framework that is used to generate Java code or XML deployment descriptors.
  • Removal of the requirement for specific interfaces and deployment descriptors (deployment descriptor information can be replaced by annotations).
  • Interceptor facility to invoke user methods at the invocation of business methods or at life cycle events.
  • Default values are used whenever possible (“configuration by exception” approach).
  • Reduction in the requirements for usage of checked exception.
  • A complete new persistence model (based on the JPA standard), that supersedes EJB 2.x entity beans

What is the difference between a local-tx-datasource and a xa-datasource? can you use transactions in both? 

A local-tx-datasource identifies a data source that uses transactions, even distributed trans actions within the local application server, but doesn’t use distributed transactions among multiple application servers. An xa-datasource on the other hand identifies a data source that uses distributed transaction among multiple application servers.

What optimization could I use if the EJB container is the only point of write access to the database? 

You could activate the "Commit Option A" that is the container caches entity bean state between transactions. This option assumesthat the container has exclusive access to the persistentstore and therefore it doesn’t need to synchronizethe in-memory bean state from the persistent store at the beginning of each transaction.


Which component handles cluster communication in WildFly ?

The JGroups framework provides services to enable peer-to-peer communications between nodes in a cluster. It is built on top a stack of network communication protocols that provide transport, discovery, reliability and failure detection, and cluster membership management services.


Is it possible to put a WildFly server instance into multiple cluster at the same time? 

It is technically possible to put a WildFly server instance into multiple clusters at the same time, this practice is generally not recommended, as it increases the management complexity.


What do you know about Seam? 

Built on the standards JavaServer Faces and EJB 3.0, WildFly Seam unifies component and programming models and delivers a consistent and powerful framework for rapid creation of web applications with Java EE 5.0. Seam simplifies web application development and enables new functionality that was difficult to implement by hand before, such as stateful conversations, multi-window operation, and handling concurrent fine-grained AJAX requests. Seam also unifies and integrates popular open source technologies like Facelets, Hibernate, iText, and Lucene.


Which JDK is needed to run Seam? 

Seam only works on JDK 5.0 and above. It uses annotations and other JDK 5.0 features.


How would you convince my IT department to adopt SOA? 

In my opinion one of the biggest obstacle in the movement towards SOA adoption is the organization’s own IT department.Too many people in the IT organization conceive SOA as a technology concept only, and as such think of SOA as just a set of technologies and infrastructure for exposing, securing, running, and managing Services. Put it this way, SOA is nothing more than Web Services and standardized middleware. The critical flaw in thinking is confusing the technology that sits beneath the Services level of abstraction and the mechanism by which Services are accessed with the architectural approach that aims to decouple the implementation from the consumption and focus on sustainable architecture that allows for continuous change.

Successful SOA adoption requires a cultural shift in the way IT is done. The Service-oriented movement to agility and loose coupling demands a shift from traditional, waterfall styles of development (design-build-test-deploy-manage) to iterative approaches to continuous Service modeling


What do you think about BPEL and BPM ? How do they compare? 

In my opinion BPEL and BPM are quite different things so they cannot even be compared. The problems boils down to the fact that these years maybe BPEL has been marketed for something which isn't: that is a Business Process Management framework.
BPEL is made up for service orchestration, that is publishing new services as a function of other services.
while BPM si needed for handling human task management functionalities and subprocess management.


What is the difference between JAX--WS and JAX-RPC? 

Java API for XML-Based RPC (JAX-RPC) is a Legacy Web Services Java API, it uses SOAP and HTTP to do RPCs over the network and enables building of Web services and Web applications based on the SOAP 1.1 specification, Java SE 1.4 or lower.JAX-WS 2.0 is the successor to JAX-RPC 1.1. JAX-WS still supports SOAP 1.1 over HTTP 1.1, so interoperability will not be affected. However there are lots of differences:


  • JAX-WS maps to Java 5.0 and relies on many of the features new in Java 5.0 like Web Service annotations.
  • JAX-RPC has its own data mapping model, JAX-WS's data mapping model is JAXB. JAXB promises mappings for all XML schemas.
  • JAX-WS introduces message-oriented functionality, dynamic asynchronous functionality which are missing in JAX-RPC.
  • JAX-WS also add support, via JAXB, for MTOM, the new attachment specification.

Can I run Seam in a JAVAEE environment? 

Yes, as of Seam 1.1, you can use Seam in any JAVAEE application server, with one caveat: you will not be able to use EJB 3.0 session beans. However, you can use either Hibernate or JPA for persistence, and you can use Seam JavaBean components instead of session beans.


Can I run Seam with JDK 1.4 and earlier? 

No, Seam only works on JDK 5.0 and above. It uses annotations and other JDK 5.0 features.


Where can I find Seam examples and documentation? 

The source code and build script of all Seam example applications are included in the examples directory of the Seam distribution.


Is it true that Seam only works with JSF? 

Seam only supports JSF as a view framework at this time. We plan to support other web frameworks in the future. We like JSF because it is a component-based UI framework, which fits really well with Seam's component-based approach to business objects and persistence objects. Seam made a major improvement to JSF by eliminating almost all XML configuration for backing beans i.e. you can now define back beans from POJOs or EJB3 components using simple annotations. We recommend you use Facelets, instead of JSP, with JSF. Facelets provide a powerful templating framework, better appplication performance, and allows us to write much simpler JSF pages. 


Can I use AJAX with Seam? 

Yes, Seam provides excellent support for AJAX. First, Seam supports the ICEfaces and Ajax4JSF Ajax component libraries for JSF. If you prefer a more "old fashioned" approach, Seam provides a complete JavaScript remoting framework which lets you call Seam components and subscribe to JMS topics directly from the client. 


Can I unit test Seam applications without starting the Application Server?

Yes, Seam provides its own integration test framework based on TestNG. You can easily mock all Seam services using those facilities without ever loading an application server or a database.