SlideShare uma empresa Scribd logo
1 de 65
Developing  Replication Plugins for Drizzle Jay Pipes [email_address] http://joinfu.com Padraig O'Sullivan [email_address] http://posulliv.com These slides released under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
what we'll cover today ,[object Object]
Code walkthrough of Drizzle plugin basics
Overview of Drizzle's replication system
Understanding Google Protobuffers
The Transaction message
In depth walkthrough of the filtered replicator
In-depth walkthrough of the transaction log
Overview of Drizzle's Architecture
drizzle's system architecture ,[object Object]
The kernel is really just the parser, optimizer, and runtime ,[object Object]
We use open source libraries as much as possible ,[object Object]
Don't reinvent the wheel
drizzle's system architecture ,[object Object]
And that's fine – it's what the plugin system is all about ,[object Object]
Drizzle is just one part of a large ecosystem ,[object Object]
kernel Clients Parser Optimizer Listener Plugin (Protocol) Pluggable Storage Engine API MyISAM InnoDB MEMORY Archive PBXT Executor Authentication Plugin Query Cache Plugin Logging Plugin (Pre) Logging Plugin (Post) Replication Plugins Replication Services Transaction Services Scheduler Plugin Authorization Plugin User-Defined Function Plugins Dictionary Plugin Plugin Registration Metadata Services
ignore the kernel ,[object Object]
Plugin developers should focus on their plugin or module and not change anything in the kernel
If you need to meddle with or change something in the kernel, it is a sign of a bad interface ,[object Object]
Walkthrough of Drizzle Plugin Basics
plugin/module development basics ,[object Object]
plugin/module development basics ,[object Object]
A plugin class is any class interface declared in  /drizzled/plugin/ ,[object Object]
The header files contain documentation for the plugin interfaces
You can also see documentation on the drizzle.org website:  http://drizzle.org/doxygen/
the plugin.ini ,[object Object]
Read during compilation and Pandora build system creates appropriate linkage for you
Required fields: ,[object Object]
sources= <list of all source files in module>
title= <name of the module/plugin>
description= <decription for the module>
from plugin.ini to data dictionary [plugin] title =Filtered Replicator author =Padraig O Sullivan version =0.2 license =PLUGIN_LICENSE_GPL description = A simple filtered replicator which allows a user to filter out events based on a schema or table name load_by_default =yes sources =filtered_replicator.cc headers =filtered_replicator.h drizzle> SELECT * FROM DATA_DICTIONARY.MODULES -> WHERE MODULE_NAME LIKE 'FILTERED%' *************************** 1. row *************************** MODULE_NAME: filtered_replicator MODULE_VERSION: 0.2 MODULE_AUTHOR: Padraig O'Sullivan IS_BUILTIN: FALSE MODULE_LIBRARY: filtered_replicator MODULE_DESCRIPTION: Filtered Replicator MODULE_LICENSE: GPL drizzle> SELECT * FROM DATA_DICTIONARY.PLUGINS -> WHERE PLUGIN_NAME LIKE 'FILTERED%' *************************** 1. row *************************** PLUGIN_NAME: filtered_replicator PLUGIN_TYPE: TransactionReplicator IS_ACTIVE: TRUE MODULE_NAME: filtered_replicator
module initialization ,[object Object]
Required: an initialization function taking a reference to the  module::Context  object for your module as its only parameter ,[object Object],[object Object]
Required:  DECLARE_PLUGIN($init, $vars)  macro inside above source file
module initialization example static  DefaultReplicator *default_replicator= NULL;  /* The singleton replicator */ static   int  init(module::Context &context) { default_replicator=  new  DefaultReplicator( &quot;default_replicator&quot; ); context.add(default_replicator); return  0; } DRIZZLE_PLUGIN(init,  NULL);
what are plugin hooks? ,[object Object]
During the course of a query's execution, many plugin hooks can be called
The subclass of  plugin::Plugin  determines on which events a plugin is notified and what gets passed as a state parameter to the plugin during notification
These plugin hooks define the plugin's  API
Example: plugin::Authentication class Authentication : public Plugin { public: explicit Authentication(std::string name_arg) : Plugin(name_arg, &quot;Authentication&quot;) {} virtual ~Authentication() {} virtual bool authenticate(const SecurityContext &sctx, const std::string &passwd)= 0; static bool isAuthenticated(const SecurityContext &sctx, const std::string &password); }; ,[object Object]
isAuthenticated()  is the plugin hook that is called by the kernel to determine authorization
example plugin hook class  AuthenticateBy :  public  unary_function<plugin::Authentication *,  bool > { ... inline  result_type operator()(argument_type auth) { return   auth->authenticate(sctx, password); } }; bool  plugin::Authentication::isAuthenticated( const  SecurityContext &sctx, const  string &password) { ... /* Use find_if instead of foreach so that we can collect return codes */ vector<plugin::Authentication *>::iterator iter= find_if(all_authentication.begin(), all_authentication.end(), AuthenticateBy(sctx, password) ); ... if (iter == all_authentication.end()) { my_error(ER_ACCESS_DENIED_ERROR, MYF(0), sctx.getUser().c_str(), sctx.getIp().c_str(), password.empty() ? ER(ER_NO) : ER(ER_YES)); return  false; } return  true; }
testing your plugin ,[object Object]
Luckily, again because of the work of Monty Taylor, your plugin can easily hook into the Drizzle testing system
Create a  tests/  directory in your plugin's directory, containing a  t/  and an  r/  subdirectory (for “test” and “result”)
creating test cases ,[object Object]
To activate your plugin, you need to start the server during your tests with: --plugin-add=$module ,[object Object]
running your test cases ,[object Object],jpipes@serialcoder:~/repos/drizzle/trunk$ cd tests/ jpipes@serialcoder:~/repos/drizzle/trunk/tests$ ./test-run --suite=transaction_log Drizzle Version 2010.04.1439 ... ================================================================================ DEFAULT STORAGE ENGINE: innodb TEST  RESULT  TIME (ms) -------------------------------------------------------------------------------- transaction_log.alter  [ pass ]  1025 transaction_log.auto_commit  [ pass ]  650 transaction_log.blob  [ pass ]  661 transaction_log.create_select  [ pass ]  688 transaction_log.create_table  [ pass ]  413 transaction_log.delete  [ pass ]  1744 transaction_log.filtered_replicator  [ pass ]  6132 ... transaction_log.schema  [ pass ]  137 transaction_log.select_for_update  [ pass ]  6496 transaction_log.slap  [ pass ]  42522 transaction_log.sync_method_every_write  [ pass ]  23 transaction_log.temp_tables  [ pass ]  549 transaction_log.truncate  [ pass ]  441 transaction_log.truncate_log  [ pass ]  390 transaction_log.udf_print_transaction_message  [ pass ]  408 transaction_log.update  [ pass ]  1916 -------------------------------------------------------------------------------- Stopping All Servers All 28 tests were successful.
Overview of Drizzle's Replication System
not in  Kansas  MySQL anymore ,[object Object]
Drizzle is entirely row-based
Forget the terms  master ,  slave , and  binlog
We use the terms  publisher ,  subscriber ,  replicator  and  applier
We have a transaction log, but it is  not required  for replication ,[object Object]
The transaction log module has example implementations of an  applier
role of the kernel in replication ,[object Object]
Construct  objects of type  message::Transaction  that represent the changes made in the server
Push  the Transaction messages out to the replication streams
Coordinate  requests from Subscribers with registered Publishers
kernel Flow of events when client changes data state Client issues DML that modifies data TransactionServices constructs Transaction message object ReplicationServices pushes Transaction  message out to all replication streams plugin::StorageEngine makes changes to data store TransactionServices calls  commitTransaction() plugin::TransactionReplicator calls replicate() plugin::TransactionApplier calls apply()
what is a  replication stream ? ,[object Object]
Each applier must be matched with a replicator ,[object Object]
Can be hard-coded ,[object Object],drizzle> select * from data_dictionary.replication_streams; +--------------------+-------------------------+ | REPLICATOR  | APPLIER  | +--------------------+-------------------------+ | default_replicator | transaction_log_applier |  +--------------------+-------------------------+ 1 row in set (0 sec)

Mais conteúdo relacionado

Mais procurados

ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packagesQuintagroup
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyAlessandro Cucci
 
Flask patterns
Flask patternsFlask patterns
Flask patternsit-people
 
CMake - Introduction and best practices
CMake - Introduction and best practicesCMake - Introduction and best practices
CMake - Introduction and best practicesDaniel Pfeifer
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python MeetupAreski Belaid
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in detailsMax Klymyshyn
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flaskjuzten
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Daniele Pallastrelli
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdownLarry Cai
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Andrey Karpov
 
CMake Talk 2008
CMake Talk 2008CMake Talk 2008
CMake Talk 2008cynapses
 
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...Puppet
 
short_intro_to_CMake_(inria_REVES_team)
short_intro_to_CMake_(inria_REVES_team)short_intro_to_CMake_(inria_REVES_team)
short_intro_to_CMake_(inria_REVES_team)Jérôme Esnault
 

Mais procurados (20)

C make tutorial
C make tutorialC make tutorial
C make tutorial
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packages
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
CMake - Introduction and best practices
CMake - Introduction and best practicesCMake - Introduction and best practices
CMake - Introduction and best practices
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Oracle applications 11i dba faq
Oracle applications 11i dba faqOracle applications 11i dba faq
Oracle applications 11i dba faq
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++
 
CakePHP
CakePHPCakePHP
CakePHP
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
 
CMake Talk 2008
CMake Talk 2008CMake Talk 2008
CMake Talk 2008
 
Cmake
CmakeCmake
Cmake
 
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
 
short_intro_to_CMake_(inria_REVES_team)
short_intro_to_CMake_(inria_REVES_team)short_intro_to_CMake_(inria_REVES_team)
short_intro_to_CMake_(inria_REVES_team)
 

Semelhante a Developing Replication Plugins for Drizzle

Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaMark Leith
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-TranslatorDashamir Hoxha
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helperMark Leith
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplicationolegmmiller
 
Django - Python MVC Framework
Django - Python MVC FrameworkDjango - Python MVC Framework
Django - Python MVC FrameworkBala Kumar
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)cgmonroe
 
Coder Presentation Boston
Coder Presentation BostonCoder Presentation Boston
Coder Presentation BostonDoug Green
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
Bgoug 2019.11 test your pl sql - not your patience
Bgoug 2019.11   test your pl sql - not your patienceBgoug 2019.11   test your pl sql - not your patience
Bgoug 2019.11 test your pl sql - not your patienceJacek Gebal
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesLeonardo Fernandes
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 

Semelhante a Developing Replication Plugins for Drizzle (20)

Drizzle plugins
Drizzle pluginsDrizzle plugins
Drizzle plugins
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helper
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Readme
ReadmeReadme
Readme
 
Django - Python MVC Framework
Django - Python MVC FrameworkDjango - Python MVC Framework
Django - Python MVC Framework
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
 
Coder Presentation Boston
Coder Presentation BostonCoder Presentation Boston
Coder Presentation Boston
 
NuGet Nuggets
NuGet NuggetsNuGet Nuggets
NuGet Nuggets
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Dost.jar and fo.jar
Dost.jar and fo.jarDost.jar and fo.jar
Dost.jar and fo.jar
 
Bgoug 2019.11 test your pl sql - not your patience
Bgoug 2019.11   test your pl sql - not your patienceBgoug 2019.11   test your pl sql - not your patience
Bgoug 2019.11 test your pl sql - not your patience
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Developing Replication Plugins for Drizzle

  • 1. Developing Replication Plugins for Drizzle Jay Pipes [email_address] http://joinfu.com Padraig O'Sullivan [email_address] http://posulliv.com These slides released under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License
  • 2.
  • 3. Code walkthrough of Drizzle plugin basics
  • 4. Overview of Drizzle's replication system
  • 7. In depth walkthrough of the filtered replicator
  • 8. In-depth walkthrough of the transaction log
  • 9. Overview of Drizzle's Architecture
  • 10.
  • 11.
  • 12.
  • 14.
  • 15.
  • 16.
  • 17. kernel Clients Parser Optimizer Listener Plugin (Protocol) Pluggable Storage Engine API MyISAM InnoDB MEMORY Archive PBXT Executor Authentication Plugin Query Cache Plugin Logging Plugin (Pre) Logging Plugin (Post) Replication Plugins Replication Services Transaction Services Scheduler Plugin Authorization Plugin User-Defined Function Plugins Dictionary Plugin Plugin Registration Metadata Services
  • 18.
  • 19. Plugin developers should focus on their plugin or module and not change anything in the kernel
  • 20.
  • 21. Walkthrough of Drizzle Plugin Basics
  • 22.
  • 23.
  • 24.
  • 25. The header files contain documentation for the plugin interfaces
  • 26. You can also see documentation on the drizzle.org website: http://drizzle.org/doxygen/
  • 27.
  • 28. Read during compilation and Pandora build system creates appropriate linkage for you
  • 29.
  • 30. sources= <list of all source files in module>
  • 31. title= <name of the module/plugin>
  • 33. from plugin.ini to data dictionary [plugin] title =Filtered Replicator author =Padraig O Sullivan version =0.2 license =PLUGIN_LICENSE_GPL description = A simple filtered replicator which allows a user to filter out events based on a schema or table name load_by_default =yes sources =filtered_replicator.cc headers =filtered_replicator.h drizzle> SELECT * FROM DATA_DICTIONARY.MODULES -> WHERE MODULE_NAME LIKE 'FILTERED%' *************************** 1. row *************************** MODULE_NAME: filtered_replicator MODULE_VERSION: 0.2 MODULE_AUTHOR: Padraig O'Sullivan IS_BUILTIN: FALSE MODULE_LIBRARY: filtered_replicator MODULE_DESCRIPTION: Filtered Replicator MODULE_LICENSE: GPL drizzle> SELECT * FROM DATA_DICTIONARY.PLUGINS -> WHERE PLUGIN_NAME LIKE 'FILTERED%' *************************** 1. row *************************** PLUGIN_NAME: filtered_replicator PLUGIN_TYPE: TransactionReplicator IS_ACTIVE: TRUE MODULE_NAME: filtered_replicator
  • 34.
  • 35.
  • 36. Required: DECLARE_PLUGIN($init, $vars) macro inside above source file
  • 37. module initialization example static DefaultReplicator *default_replicator= NULL; /* The singleton replicator */ static int init(module::Context &context) { default_replicator= new DefaultReplicator( &quot;default_replicator&quot; ); context.add(default_replicator); return 0; } DRIZZLE_PLUGIN(init, NULL);
  • 38.
  • 39. During the course of a query's execution, many plugin hooks can be called
  • 40. The subclass of plugin::Plugin determines on which events a plugin is notified and what gets passed as a state parameter to the plugin during notification
  • 41. These plugin hooks define the plugin's API
  • 42.
  • 43. isAuthenticated() is the plugin hook that is called by the kernel to determine authorization
  • 44. example plugin hook class AuthenticateBy : public unary_function<plugin::Authentication *, bool > { ... inline result_type operator()(argument_type auth) { return auth->authenticate(sctx, password); } }; bool plugin::Authentication::isAuthenticated( const SecurityContext &sctx, const string &password) { ... /* Use find_if instead of foreach so that we can collect return codes */ vector<plugin::Authentication *>::iterator iter= find_if(all_authentication.begin(), all_authentication.end(), AuthenticateBy(sctx, password) ); ... if (iter == all_authentication.end()) { my_error(ER_ACCESS_DENIED_ERROR, MYF(0), sctx.getUser().c_str(), sctx.getIp().c_str(), password.empty() ? ER(ER_NO) : ER(ER_YES)); return false; } return true; }
  • 45.
  • 46. Luckily, again because of the work of Monty Taylor, your plugin can easily hook into the Drizzle testing system
  • 47. Create a tests/ directory in your plugin's directory, containing a t/ and an r/ subdirectory (for “test” and “result”)
  • 48.
  • 49.
  • 50.
  • 51. Overview of Drizzle's Replication System
  • 52.
  • 53. Drizzle is entirely row-based
  • 54. Forget the terms master , slave , and binlog
  • 55. We use the terms publisher , subscriber , replicator and applier
  • 56.
  • 57. The transaction log module has example implementations of an applier
  • 58.
  • 59. Construct objects of type message::Transaction that represent the changes made in the server
  • 60. Push the Transaction messages out to the replication streams
  • 61. Coordinate requests from Subscribers with registered Publishers
  • 62. kernel Flow of events when client changes data state Client issues DML that modifies data TransactionServices constructs Transaction message object ReplicationServices pushes Transaction message out to all replication streams plugin::StorageEngine makes changes to data store TransactionServices calls commitTransaction() plugin::TransactionReplicator calls replicate() plugin::TransactionApplier calls apply()
  • 63.
  • 64.
  • 65.
  • 66.
  • 67. Represents a set of changes that were made to a server
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78. To set the data, append set_ to the field name
  • 79. To check existence, append has_ to the field name
  • 80. To add a new repeated field, append add_ to the field name
  • 81.
  • 83.
  • 85. Represents a set of changes that were made to a server
  • 86.
  • 87.
  • 88. Start and end timestamps
  • 90.
  • 91. Describes the rows modified in a SQL statement Transaction Context Statements Statement 1 Statement 2 Statement N
  • 92.
  • 93.
  • 94.
  • 95.
  • 96. For DDL: submessage representing a DDL statement Required Fields Statement-dependent Fields Optional SQL string
  • 97. the Statement message message Statement { enum Type { ROLLBACK = 0; /* A ROLLBACK indicator */ INSERT = 1; /* An INSERT statement */ DELETE = 2; /* A DELETE statement */ UPDATE = 3; /* An UPDATE statement */ TRUNCATE_TABLE = 4; /* A TRUNCATE TABLE statement */ CREATE_SCHEMA = 5; /* A CREATE SCHEMA statement */ ALTER_SCHEMA = 6; /* An ALTER SCHEMA statement */ DROP_SCHEMA = 7; /* A DROP SCHEMA statement */ CREATE_TABLE = 8; /* A CREATE TABLE statement */ ALTER_TABLE = 9; /* An ALTER TABLE statement */ DROP_TABLE = 10; /* A DROP TABLE statement */ SET_VARIABLE = 98; /* A SET statement */ RAW_SQL = 99; /* A raw SQL statement */ } required Type type = 1; /* The type of the Statement */ required uint64 start_timestamp = 2; /* Nanosecond precision timestamp of when the Statement was started on the server */ required uint64 end_timestamp = 3; /* Nanosecond precision timestamp of when the Statement finished executing on the server */ optional string sql = 4; /* May contain the original SQL string */ /* ... (cont'd on later slide) */ }
  • 98.
  • 99.
  • 100.
  • 101. insert header and data messages /* * Represents statements which insert data into the database: * * INSERT * INSERT SELECT * LOAD DATA INFILE * REPLACE (is a delete and an insert) * * @note * * Bulk insert operations will have >1 data segment, with the last data * segment having its end_segment member set to true. */ message InsertHeader { required TableMetadata table_metadata = 1; /* Metadata about the table affected */ repeated FieldMetadata field_metadata = 2; /* Metadata about fields affected */ } message InsertData { required uint32 segment_id = 1; /* The segment number */ required bool end_segment = 2; /* Is this the final segment? */ repeated InsertRecord record = 3; /* The records inserted */ } /* * Represents a single record being inserted into a single table. */ message InsertRecord { repeated bytes insert_value = 1; }
  • 102.
  • 103. The /drizzled/message/transaction.proto file has extensive documentation
  • 104. Also check out the statement_transform library in /drizzled/message/statement_transform.cc
  • 105. Shows how to contruct SQL statements from the information in a Transaction message
  • 106. The statement_transform library is used in utility programs such as /drizzled/message/table_raw_reader.cc
  • 107. Code walkthrough of the Filtered Replicator module
  • 108.
  • 109. You can filter or transform a Transaction message before passing it off to the applier
  • 110. Only one method in the API: /** * Replicate a Transaction message to a TransactionApplier. * * @param Pointer to the applier of the command message * @param Reference to the current session * @param Transaction message to be replicated */ virtual ReplicationReturnCode replicate(TransactionApplier *in_applier, Session &session, message::Transaction &to_replicate)= 0;
  • 111.
  • 112.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118. If neither matches a filtering condition, we add the statement to our new filtered transaction: /* convert schema name and table name to lower case */ std::transform(schema_name.begin(), schema_name.end(), schema_name.begin(), ::tolower); std::transform(table_name.begin(), table_name.end(), table_name.begin(), ::tolower); if (! isSchemaFiltered(schema_name) && ! isTableFiltered(table_name)) { message::Statement *s= filtered_transaction.add_statement(); *s= statement; /* copy construct */ }
  • 119.
  • 120. Code walkthrough of the Transaction Log module
  • 121.
  • 122.
  • 123.
  • 124. Supports checksumming of written messages
  • 125.
  • 126.
  • 127. transaction log components TransactionLogApplier vector<WriteBuffer> TransactionLog Data Dictionary TransactionLogView TransactionLogEntriesView TransactionLogTransactionsView TransactionLogIndex vector<TransactionLogIndexEntry> User Defined Functions HexdumpTransactionMessageFunction PrintTransactionMessageFunction
  • 128. code flow through module transaction log entry format TransactionLogApplier::apply() TransactionLog::packTransactionInLogEntry() TransactionLog::writeEntry() TransactionLogIndex::addEntry() MessageLite::SerializeWithCachedSizesToArray() pwrite() entry type (4 bytes) entry length (4 bytes) transaction message (variable # bytes) checksum (4 bytes)
  • 129. TransactionLogApplier header class TransactionLogApplier: public drizzled::plugin::TransactionApplier { public : TransactionLogApplier( const std::string name_arg, TransactionLog *in_transaction_log, uint32_t in_num_write_buffers); /** Destructor */ ~TransactionLogApplier(); /** * Applies a Transaction to the transaction log * * @param Session descriptor * @param Transaction message to be replicated */ drizzled::plugin::ReplicationReturnCode apply(drizzled::Session &in_session, const drizzled::message::Transaction &to_apply); private : TransactionLog &transaction_log; /* This Applier owns the memory of the associated TransactionLog - so we have to track it. */ TransactionLog *transaction_log_ptr; uint32_t num_write_buffers; ///< Number of write buffers used std::vector<WriteBuffer *> write_buffers; ///< array of write buffers /** * Returns the write buffer for the supplied session * * @param Session descriptor */ WriteBuffer *getWriteBuffer( const drizzled::Session &session); };
  • 130. TransactionLog header class TransactionLog { public : static size_t getLogEntrySize(const drizzled::message::Transaction &trx); uint8_t *packTransactionIntoLogEntry(const drizzled::message::Transaction &trx, uint8_t *buffer, uint32_t *checksum_out); off_t writeEntry(const uint8_t *data, size_t data_length); private : static const uint32_t HEADER_TRAILER_BYTES= sizeof ( uint32_t ) + /* 4-byte msg type header */ sizeof ( uint32_t ) + /* 4-byte length header */ sizeof ( uint32_t ); /* 4 byte checksum trailer */ int syncLogFile(); int log_file; ///< Handle for our log file drizzled::atomic< off_t > log_offset; ///< Offset in log file where we write next entry uint32_t sync_method; ///< Determines behaviour of syncing log file time_t last_sync_time; ///< Last time the log file was synced bool do_checksum; ///< Do a CRC32 checksum when writing Transaction message to log? };
  • 131. TransactionLogApplier::apply() plugin::ReplicationReturnCode TransactionLogApplier::apply(Session &in_session, const message::Transaction &to_apply) { size_t entry_size= TransactionLog::getLogEntrySize(to_apply); WriteBuffer *write_buffer= getWriteBuffer(in_session); uint32_t checksum; write_buffer->lock(); write_buffer->resize(entry_size); uint8_t *bytes= write_buffer->getRawBytes(); bytes= transaction_log.packTransactionIntoLogEntry(to_apply, bytes, &checksum); off_t written_to= transaction_log.writeEntry(bytes, entry_size); write_buffer->unlock(); /* Add an entry to the index describing what was just applied */ transaction_log_index->addEntry(TransactionLogEntry(ReplicationServices::TRANSACTION, written_to, entry_size), to_apply, checksum); return plugin::SUCCESS; }
  • 132. What's up with the Publisher and Subscriber plugins?
  • 133.
  • 134.
  • 135. plugin::Subscriber will be responsible for pulling data from a plugin::Publisher and applying that data to a replica node
  • 136.
  • 139.
  • 140. Sends inserts/updates/deletes to a pre-specified keyspace
  • 142. Similar plugin could be developed for any database solution (PostgreSQL?)
  • 143.
  • 144.
  • 145.
  • 146.
  • 148.