SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL 8.0
Component Infrastructure
Georgi “Joro” Kodinov
Team Lead, MySQL SrvGen Team
Why ? What's in it ? What's next ? How to use it ?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Georgi “Joro” Kodinov, MySQL @ Oracle
 Server General Team Lead
 Works on MySQL since 2006
 Specializes in:
 Security
 Client/server protocol
 Performance monitoring
 Component infrastructure
 Loves history, diverse world cultures, gardening
 A devoted Formula 1 fan (Go, Vettel !)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Agenda
3
 Why ?
 Architecture
 The inventory
 How to write my own …
 Tips & tricks
 What’s next ?
Homework !
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Components: Why ?
• Too much technical debt accumulated in plugins
• Simpler and more extensible infrastructure
• Better code isolation and encapsulation
• Explicit dependencies
• All components are equal: can call and can be called
4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Component Infrastructure Architecture
5
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Server Component
Server Binary
Server Functionality
Persisted Loader
File Scheme
Implementation
MySQL Server Modularization: The Big Picture
The Minimal Chassis
Implementation 1
Implementation 2
…
Registry
Component 1
Component 2
…
Dynamic Loader
Component 1
Component 2
Component 3
Implementation 1
Implementation 2
Plugins
Plugin
Services
Plugin
APIs
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Components: Terminology
7
Component
Code
Service
Implementations
Contains
Services
Implement
Registry
Register
Service
References
Dynamic
Loader
Load
Unload
Persisted Dynamic
Loader
Encapsulate
INSTALL COMPONENT
UNINSTALL COMPONENT
UDFs
Performance Schema
System Variables, etc.
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: A Component
• A container for code.
– Can be an executable or a shared library
– As a compromise it can be a static library too, but that’s making the lines fuzzy, so NO
• Has init() and deinit() methods (called by the dyloader)
– Macros always add a registry reference
• Can consume services from the registry
– Should not access code in other components in any other way (linker) !
– Can have the dyloader fill these references in at load time
• Can provide service implementations to the registry
– Can have the dyloader register these at load time
8
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: A Service
• An ABSTRACT NAMED interface definition !
– Although it can’t be in the registry without at least one implementation
• Can have multiple implementations:
– One implementation is default at any time
• It’s STATELESS !
– If you want state (a.k.a. data instances) you need to provide factories for these and
use handles
• Is an IMMUTABLE definition
– I.e. if you need to add a method or change any definition of any parameter you need
a new name for the service.
9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: A Service Contd.
• Has a public header file to describe the pointer returned
– The header must be self-sufficient (include all of the headers it depends on)
• It better (controversial, but explained later):
– use “simple” data types. A pointer to a 200+ member structure is a RED flag !
– use inout parameters and reserve return value for state.
10
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: A Service Implementation
• A NAMED implementation of an abstract service interface registered in the
registry
– The name is prefixed with the service name and delimited with a dot. E.g. foo.bar is
bar’s implementation of the foo service.
– The implementation name is usually the component name !
• Resides in a component
• Pointer to it is stored in and returned by the registry
– Reference counted !
• Usually a C structure with a bunch of function pointers
– Defined in the service header, registry is agnostic to that. Macros provided to do it
this way
11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: A Related Service Implementation
• A normal service implementation
• Compatible with another service implementation
– Can operate on the same objects as the other service implementation
• Allows implementing sets of services
– And breaking large APIs in small logically independent sub-parts
• Usually residing in the same component as the other service
implementation.
• Example: registry query and registry registration services
12
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic concepts: The Registry
• A set of services to manipulate a global map of services.
• Does reference counting on service implementations
• Allows one to:
– Register service implementations
– Query for implementations by name and get a counted reference
– Release a counted reference to a service implementation
– Enumerate the registered service implementations and their metadata (name/value)
– Search for related implementations to a service already acquired
• Usually the part that’s bootstrapped first as it depends on no services
13
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: The Dynamic Loader
• Requires the registry
• A single global ordered list of component generations.
• Loads and unloads component generations
– Handles registration/unregistration for the service implementations provided by
component(s)
• Can load multiple components in a single “generation” to handle circular
dependencies
• No persistent state
• Loading is done via calling “scheme” service implementations
– Currently only “file://”
14
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Basic Concepts: The Persisted Dynamic Loader
• A separate implementation (usually in a different component)
• Requires the Dynamic loader
• Ensures persistency for the Dynamic loader:
– remembers the sequence of component generations loaded on a persistent storage
– re-loads the stored sequence on startup into the dynamic loader
• The current implementation inside the server component uses a system
table and provides SQL commands.
15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Concepts: The Minimal Chassis
• A static library
• The basic component infrastructure
– The registry
– The dynamic loader
• Enough to bootstrap a functional registry and a dynamic loader
• Can load any compliant component, given its service dependencies are met
by service implementations registered in the registry
• Great for (unit) testing !
• Allows using the component infrastructure outside of the server binary
16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Component Services Inventory
17
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Component Services: The Inventory
• Service Registry
• Dynamic Loader
• Error logging
• System variables
• Status variables
• User defined functions
• Performance Schema
– New tables and Instrumentation
• Security Context
• Password validation
• Runtime errors
• Collated Strings
• Etc.
– 92 service related headers !
18
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
How To Write Your Own Components And
Services
19
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
How To Write Your Own Component/Service
• Use the utility macros
• Copy some of the existing components
– plenty of examples, specially in the tests
• Copy some of the existing services
– The services are done a bit differently in the server component
• Compile using a server source distribution
• Be careful !
– No crash protection, No security checks !
20
The Executive Summary
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Relevant Source Tree Directories
21
Root
Components
Library_mysys
Mysql_server
C1
C2
Include MySQL Components
Services
Library_mysys
sql Server_component
Agenda:
 3d party Component Code
 Minimal Chassis
 Server Component Specific
 Implementation macros
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Write A Component
#include <mysql/components/component_implementation.h>
#include <mysql/components/service_implementation.h>
#include <mysql/components/services/udf_registration.h>
REQUIRES_SERVICE_PLACEHOLDER(udf_registration);
// my code
static mysql_service_status_t deinit() { return false; }
static mysql_service_status_t init() { return false; }
22
Step 1: Add your component code: components/comp1/comp1.cc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Write A Component
BEGIN_COMPONENT_PROVIDES(comp1) END_COMPONENT_PROVIDES();
BEGIN_COMPONENT_REQUIRES(comp1)
REQUIRES_SERVICE(udf_registration),
END_COMPONENT_REQUIRES();
BEGIN_COMPONENT_METADATA(comp1)
METADATA("mysql.author", "Oracle Corporation"),
METADATA("mysql.license", "GPL"), END_COMPONENT_METADATA();
DECLARE_COMPONENT(comp1, “comp1")
init, deinit END_DECLARE_COMPONENT();
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(comp1)
END_DECLARE_LIBRARY_COMPONENTS
23
Step 2: Add the component boilerplate: components/comp1/comp1.cc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Write A Component
MYSQL_ADD_COMPONENT(comp1
comp1.cc
TEST MODULE)
24
Step 3: Add a make file: components/comp1/CMakeFile.txt
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Create a Service
#include <mysql/components/service.h>
/**
@ingroup group_components_services_inventory
*/
BEGIN_SERVICE_DEFINITION(host_application_signal)
/**
Send a signal.
*/
DECLARE_BOOL_METHOD(signal, (int signal_no, void *arg));
END_SERVICE_DEFINITION(host_application_signal)
25
Step 1: Add a Service definition in include/mysql/components/services/
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Create a Service
#include <mysql/components/service_implementation.h>
#include <mysql/components/services/host_application_signal.h>
/**
An implementation of host application signal service for the mysql server as a host application.
*/
class mysql_component_host_application_signal_imp {
public:
static DEFINE_BOOL_METHOD(signal, (int signal_no, void *arg));
};
26
Step 2: OPTIONAL: Add an implementation header (server: sql/server_component/)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Create a Service
#include <mysql/components/service_implementation.h>
#include <sql/server_component/host_application_signal_imp.h>
#include <components/mysql_server/server_component.h>
/**
An implementation of host application signal service for the mysql server as a host application.
*/
class mysql_component_host_application_signal_imp {
public:
static DEFINE_BOOL_METHOD(signal, (int signal_no, void *arg));
};
27
Step 3: Add an implementation file (server: sql/server_component/, your component
dir)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Tutorial: How To Create a Service
#include <sql/server_component/host_application_signal_imp.h>
…
BEGIN_SERVICE_IMPLEMENTATION(comp1, host_application_signal)
mysql_component_host_application_signal_imp::signal
END_SERVICE_IMPLEMENTATION();
…
BEGIN_COMPONENT_PROVIDES(comp1)
PROVIDES_SERVICE(comp1, host_application_signal)
END_COMPONENT_PROVIDES();
28
Step 4: Add it to a component. (components/mysql_server/server_component.cc if
server)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Component Services Tips And Tricks
29
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
C++ Way
• Obj *inst;
• inst = new Obj(12);
• int ret;
• ret = Inst->m1(1);
• delete inst;
The Handle Way
• HOBJ hobj;
• obj_svc->create(&hobj);
– obj_svc->init(hobj, 12);
• int ret;
• obj_svc->m1(hobj, 1, &ret);
• obj_svc->dispose(hobj);
30
Working with State: Handles
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Single Service
• HOBJ hobj;
• obj_svc->create(&hobj);
– obj_svc->init(hobj, 12);
• int ret;
• obj_svc->m1(hobj, 1, &ret);
• obj_svc->dispose(hobj);
Related Services
• HOBJ hobj;
• obj_factory_svc->create(&hobj);
– obj_integer_init_svc->init(hobj, 12);
• int ret;
• obj_svc->m1(hobj, 1, &ret);
• obj_factory_svc->dispose(hobj);
31
Working with State: Related Services
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 32
Related Service Sets: Why ?
C1
obj_svc.C1 obj_factory_svc.C1
obj_svc.C1 obj_svc.C1
obj_svc obj_svc.C1
obj_factory_svc.C1 obj_factory_svc.C1
obj_factory_svc obj_factory_svc.C2
obj_svc.C2 obj_svc.C2
obj_factory_svc.C2 obj_factory_svc.C2
C2
obj_svc.C2 obj_factory_svc.C2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 33
Overloading
C1
obj_svc.C1 obj_factory_svc.C1
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc”, registry);
C2
obj_svc.C2 obj_factory_svc.C2
my_service<SERVICE_TYPE(obj_svc)>
obj_svc2(“obj_svc”, registry);
obj_svc
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Random Guidelines
• Try to use the component infrastructure macros
• Use basic parameter types. Anything more complex goes into an
ANONYMOUS(!) handle and has service(s) to drive it
• Taking references is “expensive” (global structure). Reuse references.
• Do not make high volume calls services. Price to call a function pointer may
be too much !
• Make sure to avoid reference or handle leaks !
• Always use the designated destructor for handles !
• Keep the service reference with the consumer.
34
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
DEFINE_SERVICE_HANDLE(HOBJ);
BEGIN_SERVICE_DEFINITION(obj_svc)
DECLARE_BOOL_METHOD(create, (HOBJ *outHandle));
DECLARE_BOOL_METHOD(dispose, (HOBJ outHandle));
DECLARE_BOOL_METHOD(init, (HOBJ handle, int arg));
DECLARE_BOOL_METHOD(m1, (HOBJ handle, int arg, int
*outRet));
END_SERVICE_DEFINITION(obj_svc)
DEFINE_SERVICE_HANDLE(HOBJ);
BEGIN_SERVICE_DEFINITION(obj_factory_svc)
DECLARE_BOOL_METHOD(create, (HOBJ *outHandle));
DECLARE_BOOL_METHOD(dispose, (HOBJ outHandle));
END_SERVICE_DEFINITION(obj_factory_svc)
BEGIN_SERVICE_DEFINITION(obj_integer_init_svc)
DECLARE_BOOL_METHOD(init, (HOBJ handle, int arg));
END_SERVICE_DEFINITION(obj_integer_init_svc)
BEGIN_SERVICE_DEFINITION(obj_svc)
DECLARE_BOOL_METHOD(m1, (HOBJ handle, int arg, int
*outRet));
END_SERVICE_DEFINITION(obj_svc)
35
Working with State: Related Services Definitions
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc”, registry);
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc”, registry);
my_service<SERVICE_TYPE(obj_factory_svc)>
obj_factory_svc(“obj_factory_svc”, registry);
my_service<SERVICE_TYPE(obj_integer_init_svc)>
obj_int_init_svc(“obj_integer_init_svc”, registry);
36
Working with State: Related Services Use
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc.c1”, registry);
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc.c1”, registry);
my_service<SERVICE_TYPE(obj_factory_svc)>
obj_factory_svc(“obj_factory_svc.c1”, registry);
my_service<SERVICE_TYPE(obj_integer_init_svc)>
obj_int_init_svc(“obj_integer_init_svc.c1”, registry);
37
Working with State: 2nd Try
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc”, registry);
my_service<SERVICE_TYPE(obj_svc)>
obj_svc(“obj_svc”, registry);
my_service<SERVICE_TYPE(obj_factory_svc)>
obj_factory_svc(“obj_factory_svc”, obj_svc, registry);
my_service<SERVICE_TYPE(obj_integer_init_svc)>
obj_int_init_svc(“obj_integer_init_svc”, obj_svc, registry);
38
Working with State: Final !
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What’s Next ?
39
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
What’s Ahead ?
• Migration of major plugin APIs and plugin services into components
– Current State
• No new plugin APIs
• No new plugin service APIs
– Goal
• Deprecate the plugins !
• Further sub-division of the (now extremely chunky) server component
40
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The preceding is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
41
FOSDEM19 MySQL Component Infrastructure

Weitere ähnliche Inhalte

Was ist angesagt?

(ATS6-PLAT03) What's behind Discngine collections
(ATS6-PLAT03) What's behind Discngine collections(ATS6-PLAT03) What's behind Discngine collections
(ATS6-PLAT03) What's behind Discngine collections
BIOVIA
 

Was ist angesagt? (20)

Hive2.0 big dataspain-nov-2016
Hive2.0 big dataspain-nov-2016Hive2.0 big dataspain-nov-2016
Hive2.0 big dataspain-nov-2016
 
Java Library for High Speed Streaming Data
Java Library for High Speed Streaming Data Java Library for High Speed Streaming Data
Java Library for High Speed Streaming Data
 
MySQL Fabric
MySQL FabricMySQL Fabric
MySQL Fabric
 
(ATS6-PLAT07) Managing AEP in an enterprise environment
(ATS6-PLAT07) Managing AEP in an enterprise environment(ATS6-PLAT07) Managing AEP in an enterprise environment
(ATS6-PLAT07) Managing AEP in an enterprise environment
 
Aioug2017 deploying-ebs-on-prem-and-on-oracle-cloud v2
Aioug2017 deploying-ebs-on-prem-and-on-oracle-cloud v2Aioug2017 deploying-ebs-on-prem-and-on-oracle-cloud v2
Aioug2017 deploying-ebs-on-prem-and-on-oracle-cloud v2
 
2015 UJUG, Servlet 4.0 portion
2015 UJUG, Servlet 4.0 portion2015 UJUG, Servlet 4.0 portion
2015 UJUG, Servlet 4.0 portion
 
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
 
Online patching ebs122_aioug_appsdba_nov2017
Online patching ebs122_aioug_appsdba_nov2017Online patching ebs122_aioug_appsdba_nov2017
Online patching ebs122_aioug_appsdba_nov2017
 
Oracle SOA Suite for High availability Enterprises
Oracle SOA Suite for High availability EnterprisesOracle SOA Suite for High availability Enterprises
Oracle SOA Suite for High availability Enterprises
 
(ATS6-PLAT03) What's behind Discngine collections
(ATS6-PLAT03) What's behind Discngine collections(ATS6-PLAT03) What's behind Discngine collections
(ATS6-PLAT03) What's behind Discngine collections
 
Anatomy of Autoconfig in Oracle E-Business Suite
Anatomy of Autoconfig in Oracle E-Business SuiteAnatomy of Autoconfig in Oracle E-Business Suite
Anatomy of Autoconfig in Oracle E-Business Suite
 
Autoconfig r12
Autoconfig r12Autoconfig r12
Autoconfig r12
 
SQL Developer for DBAs
SQL Developer for DBAsSQL Developer for DBAs
SQL Developer for DBAs
 
(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance
 
AMIS Beyond the Horizon - High density deployments using weblogic multitenancy
AMIS Beyond the Horizon - High density deployments using weblogic multitenancyAMIS Beyond the Horizon - High density deployments using weblogic multitenancy
AMIS Beyond the Horizon - High density deployments using weblogic multitenancy
 
Service everywhere using oracle integration repository
Service everywhere using oracle integration repositoryService everywhere using oracle integration repository
Service everywhere using oracle integration repository
 
Introduction To Perl - SpringPeople
Introduction To Perl - SpringPeopleIntroduction To Perl - SpringPeople
Introduction To Perl - SpringPeople
 
De-Mystifying the Apache Phoenix QueryServer
De-Mystifying the Apache Phoenix QueryServerDe-Mystifying the Apache Phoenix QueryServer
De-Mystifying the Apache Phoenix QueryServer
 
Managing Enterprise Hadoop Clusters with Apache Ambari
Managing Enterprise Hadoop Clusters with Apache AmbariManaging Enterprise Hadoop Clusters with Apache Ambari
Managing Enterprise Hadoop Clusters with Apache Ambari
 
Hive ACID Apache BigData 2016
Hive ACID Apache BigData 2016Hive ACID Apache BigData 2016
Hive ACID Apache BigData 2016
 

Ähnlich wie FOSDEM19 MySQL Component Infrastructure

Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Geir Høydalsvik
 

Ähnlich wie FOSDEM19 MySQL Component Infrastructure (20)

OUGLS 2016: Guided Tour On The MySQL Source Code
OUGLS 2016: Guided Tour On The MySQL Source CodeOUGLS 2016: Guided Tour On The MySQL Source Code
OUGLS 2016: Guided Tour On The MySQL Source Code
 
Servlet 4.0 JavaOne 2017
Servlet 4.0 JavaOne 2017Servlet 4.0 JavaOne 2017
Servlet 4.0 JavaOne 2017
 
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
 
Pl17: MySQL 8.0: security
Pl17: MySQL 8.0: securityPl17: MySQL 8.0: security
Pl17: MySQL 8.0: security
 
Openfest15 MySQL Plugin Development
Openfest15 MySQL Plugin DevelopmentOpenfest15 MySQL Plugin Development
Openfest15 MySQL Plugin Development
 
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
 
Provisioning with Oracle Cloud Stack Manager
Provisioning with Oracle Cloud Stack ManagerProvisioning with Oracle Cloud Stack Manager
Provisioning with Oracle Cloud Stack Manager
 
What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0What's new in the OSGi Enterprise Release 5.0
What's new in the OSGi Enterprise Release 5.0
 
MySQL Document Store and Node.JS
MySQL Document Store and Node.JSMySQL Document Store and Node.JS
MySQL Document Store and Node.JS
 
REST - Why, When and How? at AMIS25
REST - Why, When and How? at AMIS25REST - Why, When and How? at AMIS25
REST - Why, When and How? at AMIS25
 
Separation of Concerns through APIs: the Essence of #SmartDB
Separation of Concerns through APIs: the Essence of #SmartDBSeparation of Concerns through APIs: the Essence of #SmartDB
Separation of Concerns through APIs: the Essence of #SmartDB
 
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
Everything You Wanted to Know About JIT Compilation but Were Afraid to Ask [J...
 
What's new in the OSGi Enterprise Release 5.0 - David Bosschaert and Tim Diek...
What's new in the OSGi Enterprise Release 5.0 - David Bosschaert and Tim Diek...What's new in the OSGi Enterprise Release 5.0 - David Bosschaert and Tim Diek...
What's new in the OSGi Enterprise Release 5.0 - David Bosschaert and Tim Diek...
 
Change Management for Oracle Database with SQLcl
Change Management for Oracle Database with SQLcl Change Management for Oracle Database with SQLcl
Change Management for Oracle Database with SQLcl
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
 
PaaS enabling Java EE applications through service meta-data and policies - J...
PaaS enabling Java EE applications through service meta-data and policies - J...PaaS enabling Java EE applications through service meta-data and policies - J...
PaaS enabling Java EE applications through service meta-data and policies - J...
 
Oracle Office Hours - Exposing REST services with APEX and ORDS
Oracle Office Hours - Exposing REST services with APEX and ORDSOracle Office Hours - Exposing REST services with APEX and ORDS
Oracle Office Hours - Exposing REST services with APEX and ORDS
 
MySQL :What's New #GIDS16
MySQL :What's New #GIDS16MySQL :What's New #GIDS16
MySQL :What's New #GIDS16
 
MySQL Shell: The DevOps Tool for MySQL
MySQL Shell: The DevOps Tool for MySQLMySQL Shell: The DevOps Tool for MySQL
MySQL Shell: The DevOps Tool for MySQL
 
West Yorkshire Mulesoft Meetup #6
West Yorkshire Mulesoft Meetup #6West Yorkshire Mulesoft Meetup #6
West Yorkshire Mulesoft Meetup #6
 

Mehr von Georgi Kodinov

Mehr von Georgi Kodinov (20)

2023 TurnovoConf MySQL Authentication.pptx
2023 TurnovoConf MySQL Authentication.pptx2023 TurnovoConf MySQL Authentication.pptx
2023 TurnovoConf MySQL Authentication.pptx
 
2022 TurnovoConf MySQL за начинаещи.pptx
2022 TurnovoConf MySQL за начинаещи.pptx2022 TurnovoConf MySQL за начинаещи.pptx
2022 TurnovoConf MySQL за начинаещи.pptx
 
OpenSUSE Conf 2020 MySQL Clone
OpenSUSE Conf 2020 MySQL CloneOpenSUSE Conf 2020 MySQL Clone
OpenSUSE Conf 2020 MySQL Clone
 
2020 pre fosdem mysql clone
2020 pre fosdem   mysql clone2020 pre fosdem   mysql clone
2020 pre fosdem mysql clone
 
2019 BGOUG Autumn MySQL Clone
2019  BGOUG Autumn MySQL Clone2019  BGOUG Autumn MySQL Clone
2019 BGOUG Autumn MySQL Clone
 
2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server
 
PLe19 How To Instrument Your Code in performance_schema
PLe19 How To Instrument Your Code in performance_schemaPLe19 How To Instrument Your Code in performance_schema
PLe19 How To Instrument Your Code in performance_schema
 
DevTalks.ro 2019 What's New in MySQL 8.0 Security
DevTalks.ro 2019 What's New in MySQL 8.0 SecurityDevTalks.ro 2019 What's New in MySQL 8.0 Security
DevTalks.ro 2019 What's New in MySQL 8.0 Security
 
DevTalks.ro 2019 MySQL Data Masking Talk
DevTalks.ro 2019 MySQL Data Masking TalkDevTalks.ro 2019 MySQL Data Masking Talk
DevTalks.ro 2019 MySQL Data Masking Talk
 
MySQL Enterprise Data Masking
MySQL Enterprise Data MaskingMySQL Enterprise Data Masking
MySQL Enterprise Data Masking
 
Percona Live Europe 2018: What's New in MySQL 8.0 Security
Percona Live Europe 2018: What's New in MySQL 8.0 SecurityPercona Live Europe 2018: What's New in MySQL 8.0 Security
Percona Live Europe 2018: What's New in MySQL 8.0 Security
 
How to add stuff to MySQL
How to add stuff to MySQLHow to add stuff to MySQL
How to add stuff to MySQL
 
Pl18 saving bandwidth
Pl18 saving bandwidthPl18 saving bandwidth
Pl18 saving bandwidth
 
BGOUG17: Cloudy with a chance of MySQL
BGOUG17: Cloudy with a chance of MySQLBGOUG17: Cloudy with a chance of MySQL
BGOUG17: Cloudy with a chance of MySQL
 
Fosdem17 honeypot your database server
Fosdem17 honeypot your database serverFosdem17 honeypot your database server
Fosdem17 honeypot your database server
 
2016 oSC MySQL Firewall
2016 oSC MySQL Firewall2016 oSC MySQL Firewall
2016 oSC MySQL Firewall
 
OUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQLOUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQL
 
OpenSuse 2015: Secure Deployment Changes Coming in MySQL 5.7
OpenSuse 2015: Secure Deployment Changes Coming in MySQL 5.7OpenSuse 2015: Secure Deployment Changes Coming in MySQL 5.7
OpenSuse 2015: Secure Deployment Changes Coming in MySQL 5.7
 
BGOUG 2014 Decrease Your MySQL Attack Surface
BGOUG 2014 Decrease Your MySQL Attack SurfaceBGOUG 2014 Decrease Your MySQL Attack Surface
BGOUG 2014 Decrease Your MySQL Attack Surface
 
BGOUG 2014: Developing Using MySQL
BGOUG 2014: Developing Using MySQLBGOUG 2014: Developing Using MySQL
BGOUG 2014: Developing Using MySQL
 

Kürzlich hochgeladen

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 

FOSDEM19 MySQL Component Infrastructure

  • 1. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL 8.0 Component Infrastructure Georgi “Joro” Kodinov Team Lead, MySQL SrvGen Team Why ? What's in it ? What's next ? How to use it ?
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Georgi “Joro” Kodinov, MySQL @ Oracle  Server General Team Lead  Works on MySQL since 2006  Specializes in:  Security  Client/server protocol  Performance monitoring  Component infrastructure  Loves history, diverse world cultures, gardening  A devoted Formula 1 fan (Go, Vettel !)
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Agenda 3  Why ?  Architecture  The inventory  How to write my own …  Tips & tricks  What’s next ? Homework !
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Components: Why ? • Too much technical debt accumulated in plugins • Simpler and more extensible infrastructure • Better code isolation and encapsulation • Explicit dependencies • All components are equal: can call and can be called 4
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Component Infrastructure Architecture 5
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Server Component Server Binary Server Functionality Persisted Loader File Scheme Implementation MySQL Server Modularization: The Big Picture The Minimal Chassis Implementation 1 Implementation 2 … Registry Component 1 Component 2 … Dynamic Loader Component 1 Component 2 Component 3 Implementation 1 Implementation 2 Plugins Plugin Services Plugin APIs
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Components: Terminology 7 Component Code Service Implementations Contains Services Implement Registry Register Service References Dynamic Loader Load Unload Persisted Dynamic Loader Encapsulate INSTALL COMPONENT UNINSTALL COMPONENT UDFs Performance Schema System Variables, etc.
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: A Component • A container for code. – Can be an executable or a shared library – As a compromise it can be a static library too, but that’s making the lines fuzzy, so NO • Has init() and deinit() methods (called by the dyloader) – Macros always add a registry reference • Can consume services from the registry – Should not access code in other components in any other way (linker) ! – Can have the dyloader fill these references in at load time • Can provide service implementations to the registry – Can have the dyloader register these at load time 8
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: A Service • An ABSTRACT NAMED interface definition ! – Although it can’t be in the registry without at least one implementation • Can have multiple implementations: – One implementation is default at any time • It’s STATELESS ! – If you want state (a.k.a. data instances) you need to provide factories for these and use handles • Is an IMMUTABLE definition – I.e. if you need to add a method or change any definition of any parameter you need a new name for the service. 9
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: A Service Contd. • Has a public header file to describe the pointer returned – The header must be self-sufficient (include all of the headers it depends on) • It better (controversial, but explained later): – use “simple” data types. A pointer to a 200+ member structure is a RED flag ! – use inout parameters and reserve return value for state. 10
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: A Service Implementation • A NAMED implementation of an abstract service interface registered in the registry – The name is prefixed with the service name and delimited with a dot. E.g. foo.bar is bar’s implementation of the foo service. – The implementation name is usually the component name ! • Resides in a component • Pointer to it is stored in and returned by the registry – Reference counted ! • Usually a C structure with a bunch of function pointers – Defined in the service header, registry is agnostic to that. Macros provided to do it this way 11
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: A Related Service Implementation • A normal service implementation • Compatible with another service implementation – Can operate on the same objects as the other service implementation • Allows implementing sets of services – And breaking large APIs in small logically independent sub-parts • Usually residing in the same component as the other service implementation. • Example: registry query and registry registration services 12
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic concepts: The Registry • A set of services to manipulate a global map of services. • Does reference counting on service implementations • Allows one to: – Register service implementations – Query for implementations by name and get a counted reference – Release a counted reference to a service implementation – Enumerate the registered service implementations and their metadata (name/value) – Search for related implementations to a service already acquired • Usually the part that’s bootstrapped first as it depends on no services 13
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: The Dynamic Loader • Requires the registry • A single global ordered list of component generations. • Loads and unloads component generations – Handles registration/unregistration for the service implementations provided by component(s) • Can load multiple components in a single “generation” to handle circular dependencies • No persistent state • Loading is done via calling “scheme” service implementations – Currently only “file://” 14
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Basic Concepts: The Persisted Dynamic Loader • A separate implementation (usually in a different component) • Requires the Dynamic loader • Ensures persistency for the Dynamic loader: – remembers the sequence of component generations loaded on a persistent storage – re-loads the stored sequence on startup into the dynamic loader • The current implementation inside the server component uses a system table and provides SQL commands. 15
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Concepts: The Minimal Chassis • A static library • The basic component infrastructure – The registry – The dynamic loader • Enough to bootstrap a functional registry and a dynamic loader • Can load any compliant component, given its service dependencies are met by service implementations registered in the registry • Great for (unit) testing ! • Allows using the component infrastructure outside of the server binary 16
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Component Services Inventory 17
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Component Services: The Inventory • Service Registry • Dynamic Loader • Error logging • System variables • Status variables • User defined functions • Performance Schema – New tables and Instrumentation • Security Context • Password validation • Runtime errors • Collated Strings • Etc. – 92 service related headers ! 18
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | How To Write Your Own Components And Services 19
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | How To Write Your Own Component/Service • Use the utility macros • Copy some of the existing components – plenty of examples, specially in the tests • Copy some of the existing services – The services are done a bit differently in the server component • Compile using a server source distribution • Be careful ! – No crash protection, No security checks ! 20 The Executive Summary
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Relevant Source Tree Directories 21 Root Components Library_mysys Mysql_server C1 C2 Include MySQL Components Services Library_mysys sql Server_component Agenda:  3d party Component Code  Minimal Chassis  Server Component Specific  Implementation macros
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Write A Component #include <mysql/components/component_implementation.h> #include <mysql/components/service_implementation.h> #include <mysql/components/services/udf_registration.h> REQUIRES_SERVICE_PLACEHOLDER(udf_registration); // my code static mysql_service_status_t deinit() { return false; } static mysql_service_status_t init() { return false; } 22 Step 1: Add your component code: components/comp1/comp1.cc
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Write A Component BEGIN_COMPONENT_PROVIDES(comp1) END_COMPONENT_PROVIDES(); BEGIN_COMPONENT_REQUIRES(comp1) REQUIRES_SERVICE(udf_registration), END_COMPONENT_REQUIRES(); BEGIN_COMPONENT_METADATA(comp1) METADATA("mysql.author", "Oracle Corporation"), METADATA("mysql.license", "GPL"), END_COMPONENT_METADATA(); DECLARE_COMPONENT(comp1, “comp1") init, deinit END_DECLARE_COMPONENT(); DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(comp1) END_DECLARE_LIBRARY_COMPONENTS 23 Step 2: Add the component boilerplate: components/comp1/comp1.cc
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Write A Component MYSQL_ADD_COMPONENT(comp1 comp1.cc TEST MODULE) 24 Step 3: Add a make file: components/comp1/CMakeFile.txt
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Create a Service #include <mysql/components/service.h> /** @ingroup group_components_services_inventory */ BEGIN_SERVICE_DEFINITION(host_application_signal) /** Send a signal. */ DECLARE_BOOL_METHOD(signal, (int signal_no, void *arg)); END_SERVICE_DEFINITION(host_application_signal) 25 Step 1: Add a Service definition in include/mysql/components/services/
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Create a Service #include <mysql/components/service_implementation.h> #include <mysql/components/services/host_application_signal.h> /** An implementation of host application signal service for the mysql server as a host application. */ class mysql_component_host_application_signal_imp { public: static DEFINE_BOOL_METHOD(signal, (int signal_no, void *arg)); }; 26 Step 2: OPTIONAL: Add an implementation header (server: sql/server_component/)
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Create a Service #include <mysql/components/service_implementation.h> #include <sql/server_component/host_application_signal_imp.h> #include <components/mysql_server/server_component.h> /** An implementation of host application signal service for the mysql server as a host application. */ class mysql_component_host_application_signal_imp { public: static DEFINE_BOOL_METHOD(signal, (int signal_no, void *arg)); }; 27 Step 3: Add an implementation file (server: sql/server_component/, your component dir)
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Tutorial: How To Create a Service #include <sql/server_component/host_application_signal_imp.h> … BEGIN_SERVICE_IMPLEMENTATION(comp1, host_application_signal) mysql_component_host_application_signal_imp::signal END_SERVICE_IMPLEMENTATION(); … BEGIN_COMPONENT_PROVIDES(comp1) PROVIDES_SERVICE(comp1, host_application_signal) END_COMPONENT_PROVIDES(); 28 Step 4: Add it to a component. (components/mysql_server/server_component.cc if server)
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Component Services Tips And Tricks 29
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | C++ Way • Obj *inst; • inst = new Obj(12); • int ret; • ret = Inst->m1(1); • delete inst; The Handle Way • HOBJ hobj; • obj_svc->create(&hobj); – obj_svc->init(hobj, 12); • int ret; • obj_svc->m1(hobj, 1, &ret); • obj_svc->dispose(hobj); 30 Working with State: Handles
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Single Service • HOBJ hobj; • obj_svc->create(&hobj); – obj_svc->init(hobj, 12); • int ret; • obj_svc->m1(hobj, 1, &ret); • obj_svc->dispose(hobj); Related Services • HOBJ hobj; • obj_factory_svc->create(&hobj); – obj_integer_init_svc->init(hobj, 12); • int ret; • obj_svc->m1(hobj, 1, &ret); • obj_factory_svc->dispose(hobj); 31 Working with State: Related Services
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 32 Related Service Sets: Why ? C1 obj_svc.C1 obj_factory_svc.C1 obj_svc.C1 obj_svc.C1 obj_svc obj_svc.C1 obj_factory_svc.C1 obj_factory_svc.C1 obj_factory_svc obj_factory_svc.C2 obj_svc.C2 obj_svc.C2 obj_factory_svc.C2 obj_factory_svc.C2 C2 obj_svc.C2 obj_factory_svc.C2
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 33 Overloading C1 obj_svc.C1 obj_factory_svc.C1 my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc”, registry); C2 obj_svc.C2 obj_factory_svc.C2 my_service<SERVICE_TYPE(obj_svc)> obj_svc2(“obj_svc”, registry); obj_svc
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Random Guidelines • Try to use the component infrastructure macros • Use basic parameter types. Anything more complex goes into an ANONYMOUS(!) handle and has service(s) to drive it • Taking references is “expensive” (global structure). Reuse references. • Do not make high volume calls services. Price to call a function pointer may be too much ! • Make sure to avoid reference or handle leaks ! • Always use the designated destructor for handles ! • Keep the service reference with the consumer. 34
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | DEFINE_SERVICE_HANDLE(HOBJ); BEGIN_SERVICE_DEFINITION(obj_svc) DECLARE_BOOL_METHOD(create, (HOBJ *outHandle)); DECLARE_BOOL_METHOD(dispose, (HOBJ outHandle)); DECLARE_BOOL_METHOD(init, (HOBJ handle, int arg)); DECLARE_BOOL_METHOD(m1, (HOBJ handle, int arg, int *outRet)); END_SERVICE_DEFINITION(obj_svc) DEFINE_SERVICE_HANDLE(HOBJ); BEGIN_SERVICE_DEFINITION(obj_factory_svc) DECLARE_BOOL_METHOD(create, (HOBJ *outHandle)); DECLARE_BOOL_METHOD(dispose, (HOBJ outHandle)); END_SERVICE_DEFINITION(obj_factory_svc) BEGIN_SERVICE_DEFINITION(obj_integer_init_svc) DECLARE_BOOL_METHOD(init, (HOBJ handle, int arg)); END_SERVICE_DEFINITION(obj_integer_init_svc) BEGIN_SERVICE_DEFINITION(obj_svc) DECLARE_BOOL_METHOD(m1, (HOBJ handle, int arg, int *outRet)); END_SERVICE_DEFINITION(obj_svc) 35 Working with State: Related Services Definitions
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc”, registry); my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc”, registry); my_service<SERVICE_TYPE(obj_factory_svc)> obj_factory_svc(“obj_factory_svc”, registry); my_service<SERVICE_TYPE(obj_integer_init_svc)> obj_int_init_svc(“obj_integer_init_svc”, registry); 36 Working with State: Related Services Use
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc.c1”, registry); my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc.c1”, registry); my_service<SERVICE_TYPE(obj_factory_svc)> obj_factory_svc(“obj_factory_svc.c1”, registry); my_service<SERVICE_TYPE(obj_integer_init_svc)> obj_int_init_svc(“obj_integer_init_svc.c1”, registry); 37 Working with State: 2nd Try
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc”, registry); my_service<SERVICE_TYPE(obj_svc)> obj_svc(“obj_svc”, registry); my_service<SERVICE_TYPE(obj_factory_svc)> obj_factory_svc(“obj_factory_svc”, obj_svc, registry); my_service<SERVICE_TYPE(obj_integer_init_svc)> obj_int_init_svc(“obj_integer_init_svc”, obj_svc, registry); 38 Working with State: Final !
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | What’s Next ? 39
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | What’s Ahead ? • Migration of major plugin APIs and plugin services into components – Current State • No new plugin APIs • No new plugin service APIs – Goal • Deprecate the plugins ! • Further sub-division of the (now extremely chunky) server component 40
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 41