Getting Started With Node.js and Apache Ignite

Getting Started With Node.js and Apache Ignite

<strong>This article looks at getting started with Node.js and Apache Ignite. Learn how to quickly install the Node.js Thin Client package for Ignite.</strong>

This article looks at getting started with Node.js and Apache Ignite. Learn how to quickly install the Node.js Thin Client package for Ignite.

Introduction

Apache Ignite provides support for a number of major programming languages. Recently, support for additional programming languages has also been added using what is termed as a Thin Client. New Thin Clients include Python, PHP, and Node.js.

The characteristics of a Thin Client are as follows:

  • It is a lightweight Ignite client that connects to a cluster using a standard socket connection.
  • It does not become a part of the cluster topology.
  • It never holds any data.
  • It is not used as a destination for Compute Grid calculations.

In summary, a Thin Client just establishes a socket connection to a standard Ignite node and performs all operations through that node.

In this article, we’ll focus on Node.js and see how we can quickly use this with Ignite


Prerequisites

In order to use Node.js with Ignite, we need the following:

  • Node.js v8 or higher.
  • Ignite v2.7 or higher.

In the following examples, we will use an Apple Macintosh computer running macOS Mojave.

Installation

We’ll use the binary distribution of Ignite, which can be downloaded directly from the Apache Ignite download page.

An easy way to install Node.js on macOS is to use Homebrew. This is as simple as typing the following in a terminal window:

brew install node

Once the installation is complete, we can check the software version as shown in Figure 1.

Figure 1: Check Software Version.

Node.js source code or installers for other operating systems can also be downloaded from the Node.js website.

Next, we need to install the Node.js Thin Client package for Ignite. The quickest way to do this is as follows from a terminal window:

npm install -g apache-ignite-client

The output should be similar to Figure 2.

Figure 2: Install Node.js Thin Client.

We can also build the Thin Client from sources, and the official documentation contains full details on how to do this.

Node.js Examples

Ignite ships with a number of Node.js examples. However, before we can use them, we need to start at least one Ignite server node. We can do this as follows from a terminal window:

$IGNITE_HOME/bin/ignite.sh

The variable $IGNITE_HOME being set to the Ignite installation directory.

The output should be similar to Figure 3.

Figure 3: Start Ignite Server Node.

Next, we need to link the Ignite Node.js examples. We can do this as follows from a terminal window:

cd $IGNITE_HOME/platforms/nodejs/examples
npm link apache-ignite-client

Using link provides a quick and easy way to test the Ignite Node.js examples.

Run Example

We are now ready to try an example, and from the terminal window in the examples directory, we can do the following:

node CachePutGetExample.js

The output should be similar to Figure 4.

Figure 4: CachePutGetExample.js Output.

Web Console

We can check the Ignite storage by using Web Console. Web Console requires a Web Agent to be running and the option to download the Web Agent is provided from the Web Console. We also need to ensure that the directory:

$IGNITE_HOME/libs/optional/ignite-rest-http

is copied one level up, so that we have the following:

$IGNITE_HOME/libs/ignite-rest-http

Also, in the CachePutGetExample.js file, we need to comment out the following line:

await igniteClient.destroyCache(CACHE_NAME);

Once we have done these steps, we can restart our Ignite server node, start the Web Agent by navigating to the directory where the Web Agent files have been unpacked and run the following command:

./ignite-web-agent.sh

and run CachePutGetExample.js again. From the Web Console, if we navigate to Monitoring > Dashboard > Caches, we can see that Ignite storage has been created with four Primary values, similar to Figure 5.

Figure 5: Ignite Storage.

Next Steps

There are additional Node.js examples that ship with Ignite and these can also be tested from a terminal window. The official documentation contains further details about the Node.js Thin Client for Ignite.

Summary

In this first article, we have quickly installed the Node.js Thin Client package for Ignite and tested an example that ships with the Ignite binary distribution. In future articles, we will look at additional application examples beyond those provided with the Ignite binary distribution. Until next time!

Originally published by Akmal Chaudhri at https://dzone.com

Learn more

The Complete Node.js Developer Course (3rd Edition)

☞ http://school.learn4startup.com/p/BJQWO5_Wnx

Learn and Understand NodeJS

☞ http://school.learn4startup.com/p/S1BhR8YZx

Angular & NodeJS - The MEAN Stack Guide

☞ http://school.learn4startup.com/p/Skf7ILFw3l

React Node FullStack - Social Network from Scratch to Deploy

☞ http://school.learn4startup.com/p/C3uq0BAYL

Selenium WebDriver - JavaScript nodeJS webdriver IO & more!

☞ http://school.learn4startup.com/p/EulR5bsYy

NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL)

☞ http://school.learn4startup.com/p/KCK49_imV

Top 7 Most Popular Node.js Frameworks You Should Know

Top 7 Most Popular Node.js Frameworks You Should Know

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser. In this post, you'll see top 7 of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser.

One of the main advantages of Node is that it enables developers to use JavaScript on both the front-end and the back-end of an application. This not only makes the source code of any app cleaner and more consistent, but it significantly speeds up app development too, as developers only need to use one language.

Node is fast, scalable, and easy to get started with. Its default package manager is npm, which means it also sports the largest ecosystem of open-source libraries. Node is used by companies such as NASA, Uber, Netflix, and Walmart.

But Node doesn't come alone. It comes with a plethora of frameworks. A Node framework can be pictured as the external scaffolding that you can build your app in. These frameworks are built on top of Node and extend the technology's functionality, mostly by making apps easier to prototype and develop, while also making them faster and more scalable.

Below are 7of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).

Express

With over 43,000 GitHub stars, Express is the most popular Node framework. It brands itself as a fast, unopinionated, and minimalist framework. Express acts as middleware: it helps set up and configure routes to send and receive requests between the front-end and the database of an app.

Express provides lightweight, powerful tools for HTTP servers. It's a great framework for single-page apps, websites, hybrids, or public HTTP APIs. It supports over fourteen different template engines, so developers aren't forced into any specific ORM.

Meteor

Meteor is a full-stack JavaScript platform. It allows developers to build real-time web apps, i.e. apps where code changes are pushed to all browsers and devices in real-time. Additionally, servers send data over the wire, instead of HTML. The client renders the data.

The project has over 41,000 GitHub stars and is built to power large projects. Meteor is used by companies such as Mazda, Honeywell, Qualcomm, and IKEA. It has excellent documentation and a strong community behind it.

Koa

Koa is built by the same team that built Express. It uses ES6 methods that allow developers to work without callbacks. Developers also have more control over error-handling. Koa has no middleware within its core, which means that developers have more control over configuration, but which means that traditional Node middleware (e.g. req, res, next) won't work with Koa.

Koa already has over 26,000 GitHub stars. The Express developers built Koa because they wanted a lighter framework that was more expressive and more robust than Express. You can find out more about the differences between Koa and Express here.

Sails

Sails is a real-time, MVC framework for Node that's built on Express. It supports auto-generated REST APIs and comes with an easy WebSocket integration.

The project has over 20,000 stars on GitHub and is compatible with almost all databases (MySQL, MongoDB, PostgreSQL, Redis). It's also compatible with most front-end technologies (Angular, iOS, Android, React, and even Windows Phone).

Nest

Nest has over 15,000 GitHub stars. It uses progressive JavaScript and is built with TypeScript, which means it comes with strong typing. It combines elements of object-oriented programming, functional programming, and functional reactive programming.

Nest is packaged in such a way it serves as a complete development kit for writing enterprise-level apps. The framework uses Express, but is compatible with a wide range of other libraries.

LoopBack

LoopBack is a framework that allows developers to quickly create REST APIs. It has an easy-to-use CLI wizard and allows developers to create models either on their schema or dynamically. It also has a built-in API explorer.

LoopBack has over 12,000 GitHub stars and is used by companies such as GoDaddy, Symantec, and the Bank of America. It's compatible with many REST services and a wide variety of databases (MongoDB, Oracle, MySQL, PostgreSQL).

Hapi

Similar to Express, hapi serves data by intermediating between server-side and client-side. As such, it's can serve as a substitute for Express. Hapi allows developers to focus on writing reusable app logic in a modular and prescriptive fashion.

The project has over 11,000 GitHub stars. It has built-in support for input validation, caching, authentication, and more. Hapi was originally developed to handle all of Walmart's mobile traffic during Black Friday.

Difference between AngularJS, React, Ember, Backbone, and Node.js.

The most common thing between all of them is that they are Single Page Apps. The SPA is a single page where much of the information remains the same and only some piece of data gets modified when you click on other categories/option.

Node.js Tutorial for Beginners | Node.js Crash Course | Node.js Certification Training

This courseis designed for professionals who aspire to be application developers and gain expertise in building real-time, highly-scalable applications in Node.js. The following professionals can go for this course :

Why learn Node.js?

Node.js uses JavaScript - a language known to millions of developers worldwide - thus giving it a much lower learning curve even for complete beginners. Using Node.js you can build simple Command Line programs or complex enterprise level web applications with equal ease. Node.js is an event-driven, server-side, asynchronous development platform with lightning speed execution. Node.js helps you to code the most complex functionalities in just a few lines of code...

Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Learn More

The Complete Node.js Developer Course (3rd Edition)

Angular & NodeJS - The MEAN Stack Guide

NodeJS - The Complete Guide (incl. MVC, REST APIs, GraphQL)

Docker for Node.js Projects From a Docker Captain

Intro To MySQL With Node.js - Learn To Use MySQL with Node!

Node.js Absolute Beginners Guide - Learn Node From Scratch

React Node FullStack - Social Network from Scratch to Deploy

Selenium WebDriver - JavaScript nodeJS webdriver IO & more!

Complete Next.js with React & Node - Beautiful Portfolio App

Build a Blockchain & Cryptocurrency | Full-Stack Edition