SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 1
How Node.js Integrates with
Global Storage Databases
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
Global Storage Databases
• InterSystems Caché
– Proprietary, commercially-licensed
– Windows, Linux, OS X
– http://www.intersystems.com/our-products/cache/cache-overview/
• FIS GT.M
– Free, Open Source
– Linux
– https://www.fisglobal.com/Solutions/Banking-and-Wealth/Services/Database-Engine
• Redis, via ewd-redis-globals
– https://github.com/robtweed/ewd-redis-globals
Copyright © 2016 M/Gateway Developments Ltd
Node.js
• Node.js:
– Server-side JavaScript
– Single thread of execution
– JavaScript is the world's most popular computer
language, by a considerable (and growing) margin
Copyright © 2016 M/Gateway Developments Ltd
Caché
• High-performance multi-model NoSQL
database
– Hierarchical underlying data structure
• "Global Storage"
• Normally accessed via built-in language
– Cache ObjectScript
• Extension/ super-set of MUMPS language
– Considered obsolete by IT mainstream
Copyright © 2016 M/Gateway Developments Ltd
GT.M
• High-performance multi-model NoSQL
database
– Hierarchical underlying data structure
• "Global Storage"
– Normally accessed via built-in language
• MUMPS
• Considered obsolete by IT mainstream
Copyright © 2016 M/Gateway Developments Ltd
Redis / ewd-redis-globals
• Redis:
– Probably the world's most popular Open
Source NoSQL databases
– Also one of the fastest
– Key/Value storage primitive data structures
• ewd-redis-globals:
– Global storage functionality implemented on
top of Redis database key/value primitives
– Database only
• No dependency on Mumps language
• Open source equivalent to InterSystems'
GlobalsDB
Copyright © 2016 M/Gateway Developments Ltd
Making Global Storage
mainstream
• Global Storage has proven to be a very
powerful, flexible, high-performance NoSQL
database model for real-world, demanding
applications
• It has been ignored by the mainstream by virtue
of its integrated access language being seen as
out-dated / obsolete
– "database baby has been thrown out with the
language bathwater"
• JavaScript as a primary language for accessing
Global Storage databases?
Copyright © 2016 M/Gateway Developments Ltd
Node.js Interface
• Actually first implemented for free (but not Open
Source) GlobalsDB database
– Core engine from Caché
– No language parser/engine
– Now deprecated by InterSystems
• Accessed via the database engine's C++ call-in
interface
– Originally Java & .Net only
• Node.js interface developed by Chris Munt
• Interface module file: cache.node
Copyright © 2016 M/Gateway Developments Ltd
Node.js Interface
• cache.node ported to Cache
• function() API added to allow
MUMPS/Cache Objectscript code to be
executed from JavaScript / Node.js
• Cache Object APIs also subsequently
added
• Network (TCP-based) interface is also
available
Copyright © 2016 M/Gateway Developments Ltd
cache.node interface
Node.js
Process
Caché
Process
cache.node
module
C++call-ininterface
JavaScript
Globals Functions Objects
Copyright © 2016 M/Gateway Developments Ltd
GT.M / NodeM
• cache.node APIs re-implemented by Open
Source community (David Wicksell) for
use with GT.M
– https://github.com/dlwicksell/nodem
– Interfaces with GT.M's C Call-in interface
Copyright © 2016 M/Gateway Developments Ltd
NodeM interface
Node.js
Process
GT.M
Process
NodeM
module
Ccall-ininterface
JavaScript
Globals Functions
Copyright © 2016 M/Gateway Developments Ltd
Redis / ewd-redis-globals
• cache.node APIs re-implemented as part
of the ewd-redis-globals module
– Interfaces with Redis via its standard TCP
connection
Copyright © 2016 M/Gateway Developments Ltd
In-process Node.js Interfaces to
Cache & GT.M
• Very closely-coupled, intimate relationship
between Node.js and Caché / GT.M
– In-process
• The Node.js process and connected Caché / GT.M
process are one and the same
– Node.js process.pid === Caché/GT.M $job
– Node.js must be installed on the Caché or
GT.M server
Copyright © 2016 M/Gateway Developments Ltd
cache.node interface
cache.node
module
C++call-ininterface
JavaScript
Globals Functions Objects
CachéNode.jsProcess
Copyright © 2016 M/Gateway Developments Ltd
In-process Node.js Interface
• Very fast connection
– Significantly faster than a networked
connection between Node.js and Caché
– Currently between ⅓ and ¼ the performance
of native Mumps code when accessing Global
storage
– Currently limited by Google V8 API bottleneck
• https://bugs.chromium.org/p/v8/issues/detail?id=5144
• Potential for full native Mumps performance
Copyright © 2016 M/Gateway Developments Ltd
Networked interfaces
• Available for Caché and Redis/ewd-redis-globals
• Allows database and Node.js to be on different
physical servers
• Trade-off between performance and flexibility /
redundancy
Copyright © 2016 M/Gateway Developments Ltd
JavaScript access to Global
Storage
• The JavaScript / Node.js APIs for accessing
Global storage are identical, regardless of
database type and connection type
• Defined by the original cache.node APIs
• http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BXJS
Copyright © 2016 M/Gateway Developments Ltd
Installing cache.node
• Currently included with Cache build kits
– Not distributed separately
– Hoping that InterSystems will soon distribute via NPM
• Different Node.js versions have introduced API changes
– Different versions of cache.node for each main Node.js version
• 12.x
– cache0120.node
• 4.1.x
– cache410.node
• 4.2 and later 4.x versions
– Cache421.node
– Rename to cache.node and copy to main node_modules
directory
• Eg C:ewd3node_modulescache.node
Copyright © 2016 M/Gateway Developments Ltd
Installing NodeM for GT.M
• Node.js Add-in module
• See:
– https://github.com/dlwicksell/nodem
Copyright © 2016 M/Gateway Developments Ltd
ewd-redis-globals
• Assumes you have Redis installed
• ewd-redis-globals:
– Node.js module
• https://github.com/robtweed/ewd-redis-globals
– Implements Global Storage functionality using
Redis primitive data structures
– Provides the JavaScript APIs for accessing
Global Storage
• Complies with the cache.node API definitions
Copyright © 2016 M/Gateway Developments Ltd
Connecting to Caché
var interface = require('cache'); // loads cache.node
var db = new interface.Cache();
// Change these parameters to match your Cache system:
var ok = db.open({
path: '/opt/cache/mgr',
username: '_SYSTEM',
password: 'SYS',
namespace: 'USER'
});
// confirm it connected OK
console.log('ok: ' + JSON.stringify(ok));
console.log(db.version());
Create a test
Script file, eg
C:ewd3test.js
Copyright © 2016 M/Gateway Developments Ltd
Connecting to GT.M
var interface = require('nodem'); // loads NodeM
var db = new interface.Gtm();
// Assuming your process profile is automatically configured
// for GT.M:
var ok = db.open();
// confirm it connected OK
console.log('ok: ' + JSON.stringify(ok));
console.log(db.version());
// once connected, the APIs for GT.M are identical to
// those for Cache
Create a test
Script file, eg
C:ewd3test.js
Copyright © 2016 M/Gateway Developments Ltd
Connecting to Redis
var interface = require('ewd-redis-globals');
var db = new interface();
// Assuming Redis is listening on standard port and
// running on localhost:
var ok = db.open();
// confirm it connected OK
console.log('ok: ' + JSON.stringify(ok));
console.log(db.version());
// once connected, the APIs for Redis are identical to
// those for Cache
Create a test
Script file, eg
C:ewd3test.js
Copyright © 2016 M/Gateway Developments Ltd
Connecting to Global Storage
Run the test script file:
cd ewd3
node test
ok: {"ok":1,"result":1}
Node.js Adaptor for Cache: Version: 1.1.104 (CM); Cache Version: 2015.2 build 664
Connection is working!
The version string will be different for GT.M or ewd-redis-globals
Copyright © 2016 M/Gateway Developments Ltd
Simple examples
• Set a Global Node, eg
– set ^test("foo","bar")="hello world"
var node = {
global: 'test',
subscripts: ['foo', 'bar'],
data: 'hello world'
};
db.set(node, function(error, result) {
// do something when node is created
});
Copyright © 2016 M/Gateway Developments Ltd
Simple examples
• Get a Global Node, eg
– Set value = ^test("foo","bar")
var node = {
global: 'test',
subscripts: ['foo', 'bar']
};
db.get(node, function(error, result) {
console.log('value = ' + result.data);
});
Copyright © 2016 M/Gateway Developments Ltd
cache.node APIs
• Open and close database
• Set, get, kill a global node
• Determine if a node is defined ($data)
• Equivalents to $order and $query (forwards and
backwards)
• Global directory listing
• Increment a global node
• Lock/unlock a global node
• Merge one global sub-tree into another
Copyright © 2016 M/Gateway Developments Ltd
cache.node API Documentation
• http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BXJS_refapi
Copyright © 2016 M/Gateway Developments Ltd
cache.node also has APIs for Caché Objects
• invoke_classmethod
– invoke a class method
• create_instance
– create a new instance of an object
• open_instance
– open an existing instance of an object
• get_property
– retrieve the value of a property
• set_property
– set the value of a property
• invoke_method
– invoke a method
• save_instance
– save an instance
• close_instance
– close an instance
• Note: these are ONLY available for Caché!
Copyright © 2016 M/Gateway Developments Ltd
cache.node APIs
• On all platforms, available as asynchronous &
synchronous versions
– If using a single Node.js process for multi-user
access, you must use the async APIs
– Synchronous APIs:
• Slightly faster
• Simpler and more intuitive to use
– Avoid call-back hell or use of Promises etc
• Allow higher-level database abstractions to be created
on top of the basic global storage primitives
– Multi-model NoSQL functionality via JavaScript
• Allow for "embedded" database functionality in Node.js
Copyright © 2016 M/Gateway Developments Ltd
Synchronous cache.node APIs
• Normal limitations of synchronous APIs:
– They block I/O, so have disastrous results on
Node.js concurrency performance
– So, not normally usable with Node.js except
for single-user testing
• However, new run-time environments for
Node.js that provide an isolated run-time
container for a handler function can safely
use synchronous APIs, eg:
– AWS Lambda
– QEWD (previously known as ewd-xpress)

Weitere ähnliche Inhalte

Was ist angesagt?

Chapter 2 - Operating System Structures
Chapter 2 - Operating System StructuresChapter 2 - Operating System Structures
Chapter 2 - Operating System Structures
Wayne Jones Jnr
 
Advantages and disadvantages solaris
Advantages and disadvantages solarisAdvantages and disadvantages solaris
Advantages and disadvantages solaris
Nur Shukri
 

Was ist angesagt? (20)

La sécurité des systèmes d’information
La sécurité des systèmes d’informationLa sécurité des systèmes d’information
La sécurité des systèmes d’information
 
systemd
systemdsystemd
systemd
 
introduction à MongoDB
introduction à MongoDBintroduction à MongoDB
introduction à MongoDB
 
Tutoriel J2EE
Tutoriel J2EETutoriel J2EE
Tutoriel J2EE
 
Metasploit
MetasploitMetasploit
Metasploit
 
spark_intro_1208
spark_intro_1208spark_intro_1208
spark_intro_1208
 
Đề tài: Hệ thống phát hiện cảnh báo nguy cơ tấn công mạng
Đề tài: Hệ thống phát hiện cảnh báo nguy cơ tấn công mạngĐề tài: Hệ thống phát hiện cảnh báo nguy cơ tấn công mạng
Đề tài: Hệ thống phát hiện cảnh báo nguy cơ tấn công mạng
 
Operating System Unit 1
Operating System Unit 1Operating System Unit 1
Operating System Unit 1
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKB
 
Chapter 2 - Operating System Structures
Chapter 2 - Operating System StructuresChapter 2 - Operating System Structures
Chapter 2 - Operating System Structures
 
Kịch bản demo phát hiện xâm nhập sử dụng snort ids
Kịch bản demo phát hiện xâm nhập sử dụng snort idsKịch bản demo phát hiện xâm nhập sử dụng snort ids
Kịch bản demo phát hiện xâm nhập sử dụng snort ids
 
Traitement distribue en BIg Data - KAFKA Broker and Kafka Streams
Traitement distribue en BIg Data - KAFKA Broker and Kafka StreamsTraitement distribue en BIg Data - KAFKA Broker and Kafka Streams
Traitement distribue en BIg Data - KAFKA Broker and Kafka Streams
 
Socket - Lập trình hệ thống
Socket - Lập trình hệ thốngSocket - Lập trình hệ thống
Socket - Lập trình hệ thống
 
Reliability, Availability and Serviceability on Linux
Reliability, Availability and Serviceability on LinuxReliability, Availability and Serviceability on Linux
Reliability, Availability and Serviceability on Linux
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzer
 
Dacs snort
Dacs snortDacs snort
Dacs snort
 
Advantages and disadvantages solaris
Advantages and disadvantages solarisAdvantages and disadvantages solaris
Advantages and disadvantages solaris
 
Xen Project: Windows PV Drivers
Xen Project: Windows PV DriversXen Project: Windows PV Drivers
Xen Project: Windows PV Drivers
 
Báo cáo snort
Báo cáo snortBáo cáo snort
Báo cáo snort
 
Ibm spectrum scale_backup_n_archive_v03_ash
Ibm spectrum scale_backup_n_archive_v03_ashIbm spectrum scale_backup_n_archive_v03_ash
Ibm spectrum scale_backup_n_archive_v03_ash
 

Ähnlich wie EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Databases

DRILETT_AWS_VPC_Presentation_2MB
DRILETT_AWS_VPC_Presentation_2MBDRILETT_AWS_VPC_Presentation_2MB
DRILETT_AWS_VPC_Presentation_2MB
David Rilett
 
Drilett aws vpc_presentation_shared
Drilett aws vpc_presentation_sharedDrilett aws vpc_presentation_shared
Drilett aws vpc_presentation_shared
David Rilett
 
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Felix Gessert
 

Ähnlich wie EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Databases (20)

EWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage DatabasesEWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
EWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 19: The cache.node APIsEWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 19: The cache.node APIs
 
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
Making Distributed Data Persistent Services Elastic (Without Losing All Your ...
 
On Docker and its use for LHC at CERN
On Docker and its use for LHC at CERNOn Docker and its use for LHC at CERN
On Docker and its use for LHC at CERN
 
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWDEWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWD
 
DRILETT_AWS_VPC_Presentation_2MB
DRILETT_AWS_VPC_Presentation_2MBDRILETT_AWS_VPC_Presentation_2MB
DRILETT_AWS_VPC_Presentation_2MB
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Drilett aws vpc_presentation_shared
Drilett aws vpc_presentation_sharedDrilett aws vpc_presentation_shared
Drilett aws vpc_presentation_shared
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 
Michael stack -the state of apache h base
Michael stack -the state of apache h baseMichael stack -the state of apache h base
Michael stack -the state of apache h base
 
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleulsapidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
 
Local Storage for Web Applications
Local Storage for Web ApplicationsLocal Storage for Web Applications
Local Storage for Web Applications
 
On CloudStack, Docker, Kubernetes, and Big Data…Oh my ! By Sebastien Goasguen...
On CloudStack, Docker, Kubernetes, and Big Data…Oh my ! By Sebastien Goasguen...On CloudStack, Docker, Kubernetes, and Big Data…Oh my ! By Sebastien Goasguen...
On CloudStack, Docker, Kubernetes, and Big Data…Oh my ! By Sebastien Goasguen...
 
Mongo and node mongo dc 2011
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011
 
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on AzureDevoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
 
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
 

Mehr von Rob Tweed

Mehr von Rob Tweed (20)

QEWD Update
QEWD UpdateQEWD Update
QEWD Update
 
Data Persistence as a Language Feature
Data Persistence as a Language FeatureData Persistence as a Language Feature
Data Persistence as a Language Feature
 
LNUG: Having Your Node.js Cake and Eating It Too
LNUG: Having Your Node.js Cake and Eating It TooLNUG: Having Your Node.js Cake and Eating It Too
LNUG: Having Your Node.js Cake and Eating It Too
 
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService FunctionalityEWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
 
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.jsEWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
 
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST ServicesEWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
 
QEWD.js, JSON Web Tokens & MicroServices
QEWD.js, JSON Web Tokens & MicroServicesQEWD.js, JSON Web Tokens & MicroServices
QEWD.js, JSON Web Tokens & MicroServices
 
QEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It TooQEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It Too
 
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Servicesewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
 
qewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tierqewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tier
 
EWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 42: The QEWD Docker ApplianceEWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 42: The QEWD Docker Appliance
 
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
 
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
 
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5b: First Steps in Building a QEWD ApplicationEWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
 
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
 
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
 
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 35: QEWD Session LockingEWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 35: QEWD Session Locking
 
EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 34: QEWD Resilient ModeEWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 34: QEWD Resilient Mode
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Kürzlich hochgeladen (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Databases

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 1 How Node.js Integrates with Global Storage Databases Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd Global Storage Databases • InterSystems Caché – Proprietary, commercially-licensed – Windows, Linux, OS X – http://www.intersystems.com/our-products/cache/cache-overview/ • FIS GT.M – Free, Open Source – Linux – https://www.fisglobal.com/Solutions/Banking-and-Wealth/Services/Database-Engine • Redis, via ewd-redis-globals – https://github.com/robtweed/ewd-redis-globals
  • 3. Copyright © 2016 M/Gateway Developments Ltd Node.js • Node.js: – Server-side JavaScript – Single thread of execution – JavaScript is the world's most popular computer language, by a considerable (and growing) margin
  • 4. Copyright © 2016 M/Gateway Developments Ltd Caché • High-performance multi-model NoSQL database – Hierarchical underlying data structure • "Global Storage" • Normally accessed via built-in language – Cache ObjectScript • Extension/ super-set of MUMPS language – Considered obsolete by IT mainstream
  • 5. Copyright © 2016 M/Gateway Developments Ltd GT.M • High-performance multi-model NoSQL database – Hierarchical underlying data structure • "Global Storage" – Normally accessed via built-in language • MUMPS • Considered obsolete by IT mainstream
  • 6. Copyright © 2016 M/Gateway Developments Ltd Redis / ewd-redis-globals • Redis: – Probably the world's most popular Open Source NoSQL databases – Also one of the fastest – Key/Value storage primitive data structures • ewd-redis-globals: – Global storage functionality implemented on top of Redis database key/value primitives – Database only • No dependency on Mumps language • Open source equivalent to InterSystems' GlobalsDB
  • 7. Copyright © 2016 M/Gateway Developments Ltd Making Global Storage mainstream • Global Storage has proven to be a very powerful, flexible, high-performance NoSQL database model for real-world, demanding applications • It has been ignored by the mainstream by virtue of its integrated access language being seen as out-dated / obsolete – "database baby has been thrown out with the language bathwater" • JavaScript as a primary language for accessing Global Storage databases?
  • 8. Copyright © 2016 M/Gateway Developments Ltd Node.js Interface • Actually first implemented for free (but not Open Source) GlobalsDB database – Core engine from Caché – No language parser/engine – Now deprecated by InterSystems • Accessed via the database engine's C++ call-in interface – Originally Java & .Net only • Node.js interface developed by Chris Munt • Interface module file: cache.node
  • 9. Copyright © 2016 M/Gateway Developments Ltd Node.js Interface • cache.node ported to Cache • function() API added to allow MUMPS/Cache Objectscript code to be executed from JavaScript / Node.js • Cache Object APIs also subsequently added • Network (TCP-based) interface is also available
  • 10. Copyright © 2016 M/Gateway Developments Ltd cache.node interface Node.js Process Caché Process cache.node module C++call-ininterface JavaScript Globals Functions Objects
  • 11. Copyright © 2016 M/Gateway Developments Ltd GT.M / NodeM • cache.node APIs re-implemented by Open Source community (David Wicksell) for use with GT.M – https://github.com/dlwicksell/nodem – Interfaces with GT.M's C Call-in interface
  • 12. Copyright © 2016 M/Gateway Developments Ltd NodeM interface Node.js Process GT.M Process NodeM module Ccall-ininterface JavaScript Globals Functions
  • 13. Copyright © 2016 M/Gateway Developments Ltd Redis / ewd-redis-globals • cache.node APIs re-implemented as part of the ewd-redis-globals module – Interfaces with Redis via its standard TCP connection
  • 14. Copyright © 2016 M/Gateway Developments Ltd In-process Node.js Interfaces to Cache & GT.M • Very closely-coupled, intimate relationship between Node.js and Caché / GT.M – In-process • The Node.js process and connected Caché / GT.M process are one and the same – Node.js process.pid === Caché/GT.M $job – Node.js must be installed on the Caché or GT.M server
  • 15. Copyright © 2016 M/Gateway Developments Ltd cache.node interface cache.node module C++call-ininterface JavaScript Globals Functions Objects CachéNode.jsProcess
  • 16. Copyright © 2016 M/Gateway Developments Ltd In-process Node.js Interface • Very fast connection – Significantly faster than a networked connection between Node.js and Caché – Currently between ⅓ and ¼ the performance of native Mumps code when accessing Global storage – Currently limited by Google V8 API bottleneck • https://bugs.chromium.org/p/v8/issues/detail?id=5144 • Potential for full native Mumps performance
  • 17. Copyright © 2016 M/Gateway Developments Ltd Networked interfaces • Available for Caché and Redis/ewd-redis-globals • Allows database and Node.js to be on different physical servers • Trade-off between performance and flexibility / redundancy
  • 18. Copyright © 2016 M/Gateway Developments Ltd JavaScript access to Global Storage • The JavaScript / Node.js APIs for accessing Global storage are identical, regardless of database type and connection type • Defined by the original cache.node APIs • http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BXJS
  • 19. Copyright © 2016 M/Gateway Developments Ltd Installing cache.node • Currently included with Cache build kits – Not distributed separately – Hoping that InterSystems will soon distribute via NPM • Different Node.js versions have introduced API changes – Different versions of cache.node for each main Node.js version • 12.x – cache0120.node • 4.1.x – cache410.node • 4.2 and later 4.x versions – Cache421.node – Rename to cache.node and copy to main node_modules directory • Eg C:ewd3node_modulescache.node
  • 20. Copyright © 2016 M/Gateway Developments Ltd Installing NodeM for GT.M • Node.js Add-in module • See: – https://github.com/dlwicksell/nodem
  • 21. Copyright © 2016 M/Gateway Developments Ltd ewd-redis-globals • Assumes you have Redis installed • ewd-redis-globals: – Node.js module • https://github.com/robtweed/ewd-redis-globals – Implements Global Storage functionality using Redis primitive data structures – Provides the JavaScript APIs for accessing Global Storage • Complies with the cache.node API definitions
  • 22. Copyright © 2016 M/Gateway Developments Ltd Connecting to Caché var interface = require('cache'); // loads cache.node var db = new interface.Cache(); // Change these parameters to match your Cache system: var ok = db.open({ path: '/opt/cache/mgr', username: '_SYSTEM', password: 'SYS', namespace: 'USER' }); // confirm it connected OK console.log('ok: ' + JSON.stringify(ok)); console.log(db.version()); Create a test Script file, eg C:ewd3test.js
  • 23. Copyright © 2016 M/Gateway Developments Ltd Connecting to GT.M var interface = require('nodem'); // loads NodeM var db = new interface.Gtm(); // Assuming your process profile is automatically configured // for GT.M: var ok = db.open(); // confirm it connected OK console.log('ok: ' + JSON.stringify(ok)); console.log(db.version()); // once connected, the APIs for GT.M are identical to // those for Cache Create a test Script file, eg C:ewd3test.js
  • 24. Copyright © 2016 M/Gateway Developments Ltd Connecting to Redis var interface = require('ewd-redis-globals'); var db = new interface(); // Assuming Redis is listening on standard port and // running on localhost: var ok = db.open(); // confirm it connected OK console.log('ok: ' + JSON.stringify(ok)); console.log(db.version()); // once connected, the APIs for Redis are identical to // those for Cache Create a test Script file, eg C:ewd3test.js
  • 25. Copyright © 2016 M/Gateway Developments Ltd Connecting to Global Storage Run the test script file: cd ewd3 node test ok: {"ok":1,"result":1} Node.js Adaptor for Cache: Version: 1.1.104 (CM); Cache Version: 2015.2 build 664 Connection is working! The version string will be different for GT.M or ewd-redis-globals
  • 26. Copyright © 2016 M/Gateway Developments Ltd Simple examples • Set a Global Node, eg – set ^test("foo","bar")="hello world" var node = { global: 'test', subscripts: ['foo', 'bar'], data: 'hello world' }; db.set(node, function(error, result) { // do something when node is created });
  • 27. Copyright © 2016 M/Gateway Developments Ltd Simple examples • Get a Global Node, eg – Set value = ^test("foo","bar") var node = { global: 'test', subscripts: ['foo', 'bar'] }; db.get(node, function(error, result) { console.log('value = ' + result.data); });
  • 28. Copyright © 2016 M/Gateway Developments Ltd cache.node APIs • Open and close database • Set, get, kill a global node • Determine if a node is defined ($data) • Equivalents to $order and $query (forwards and backwards) • Global directory listing • Increment a global node • Lock/unlock a global node • Merge one global sub-tree into another
  • 29. Copyright © 2016 M/Gateway Developments Ltd cache.node API Documentation • http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BXJS_refapi
  • 30. Copyright © 2016 M/Gateway Developments Ltd cache.node also has APIs for Caché Objects • invoke_classmethod – invoke a class method • create_instance – create a new instance of an object • open_instance – open an existing instance of an object • get_property – retrieve the value of a property • set_property – set the value of a property • invoke_method – invoke a method • save_instance – save an instance • close_instance – close an instance • Note: these are ONLY available for Caché!
  • 31. Copyright © 2016 M/Gateway Developments Ltd cache.node APIs • On all platforms, available as asynchronous & synchronous versions – If using a single Node.js process for multi-user access, you must use the async APIs – Synchronous APIs: • Slightly faster • Simpler and more intuitive to use – Avoid call-back hell or use of Promises etc • Allow higher-level database abstractions to be created on top of the basic global storage primitives – Multi-model NoSQL functionality via JavaScript • Allow for "embedded" database functionality in Node.js
  • 32. Copyright © 2016 M/Gateway Developments Ltd Synchronous cache.node APIs • Normal limitations of synchronous APIs: – They block I/O, so have disastrous results on Node.js concurrency performance – So, not normally usable with Node.js except for single-user testing • However, new run-time environments for Node.js that provide an isolated run-time container for a handler function can safely use synchronous APIs, eg: – AWS Lambda – QEWD (previously known as ewd-xpress)