DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. Getting Started With Node.js and Apache Ignite

Getting Started With Node.js and Apache Ignite

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.

Akmal Chaudhri user avatar by
Akmal Chaudhri
CORE ·
Mar. 05, 19 · Tutorial
Like (12)
Save
Tweet
Share
12.87K Views

Join the DZone community and get the full member experience.

Join For Free

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.Image title

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.

Image title

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.

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.

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.

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.

Image title

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!

Node.js Apache Ignite

Published at DZone with permission of Akmal Chaudhri. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Secure APIs: Best Practices and Measures
  • Java Code Review Solution
  • When to Choose Redpanda Instead of Apache Kafka
  • 5 Software Developer Competencies: How To Recognize a Good Programmer

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: