SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
MARIO 
chenzongzhi@360.cn 
https://github.com/baotiao/Mario
• Overview 
• Implement 
• Todo
OVERVIEW 
• A Library that make the write from synchronous 
to asynchronous. 
• It is thread safe and easily used.
EXAMPLE 
/** 
* 
@brief 
The 
handler 
inherit 
from 
the 
Consumer::Handler 
* 
The 
processMsg 
is 
pure 
virtual 
function, 
so 
you 
need 
implementation 
your 
own 
* 
version 
*/ 
class 
FileHandler 
: 
public 
mario::Consumer::Handler 
{ 
public: 
FileHandler() 
{}; 
virtual 
void 
processMsg(const 
std::string 
&item) 
{ 
log_info("consume 
data 
%s", 
item.data()); 
} 
};
EXAMPLE 
int 
main() 
{ 
mario::Status 
s; 
FileHandler 
*fh 
= 
new 
FileHandler(); 
/** 
* 
@brief 
* 
* 
@param 
1 
is 
the 
thread 
number 
* 
@param 
fh 
is 
the 
handler 
that 
you 
implement. 
It 
tell 
the 
mario 
how 
* 
to 
consume 
the 
data 
* 
* 
@return 
*/ 
mario::Mario 
*m 
= 
new 
mario::Mario(1, 
fh); 
std::string 
item 
= 
"Put 
data 
in 
mario"; 
s 
= 
m-­‐>Put(item); 
if 
(!s.ok()) 
{ 
log_err("Put 
error"); 
exit(-­‐1); 
} 
delete 
m; 
delete 
fh; 
return 
0; 
}
EXAMPLE 
└─[$] ./mario 
[INFO] (demo.cc:22) consume data Put data in mario
IMPLEMENT 
• The base idea of the Mario is that if you have operators 
that cost lots of time. But you want quickly return from 
the operator, and leave the work to the background. 
• So mario library can easily solve your problem. You just 
need the implement your own consume message 
function. Then mario will create background thread do 
the other things.
ENGINE 
• Memory 
• make ENGINE=memory 
• File 
• make ENGINE=file 
• write2file 
• manifest
USAGE 
• make ENGINE=memory 
• ls output 
• include/ lib/
IMPLEMENT 
Block 
Len Len 
Block 
Len Len
IMPLEMENT 
• Why Block? 
• Handle error 
• Batch read
TODO 
• The benchmark 
• Batch read
Mario

Más contenido relacionado

Destacado

Destacado (14)

Log experience
Log experienceLog experience
Log experience
 
Beanstalk
BeanstalkBeanstalk
Beanstalk
 
bada-data-beautiful
bada-data-beautifulbada-data-beautiful
bada-data-beautiful
 
Disk and page cache
Disk and page cacheDisk and page cache
Disk and page cache
 
Pika
PikaPika
Pika
 
PFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - BasicPFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - Basic
 
PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - Advanced
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 
Level db
Level dbLevel db
Level db
 
Paxos introduction
Paxos introductionPaxos introduction
Paxos introduction
 
Leveldb background
Leveldb backgroundLeveldb background
Leveldb background
 
Heroku CIを触ってみる
Heroku CIを触ってみるHeroku CIを触ってみる
Heroku CIを触ってみる
 
Awk programming
Awk programming Awk programming
Awk programming
 
Czzawk
CzzawkCzzawk
Czzawk
 

Similar a Mario

Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Andrei KUCHARAVY
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangLyon Yang
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
D3 in Jupyter : PyData NYC 2015
D3 in Jupyter : PyData NYC 2015D3 in Jupyter : PyData NYC 2015
D3 in Jupyter : PyData NYC 2015Brian Coffey
 
Build your own discovery index of scholary e-resources
Build your own discovery index of scholary e-resourcesBuild your own discovery index of scholary e-resources
Build your own discovery index of scholary e-resourcesMartin Czygan
 
Brillo/Weave Part 2: Deep Dive
Brillo/Weave Part 2: Deep DiveBrillo/Weave Part 2: Deep Dive
Brillo/Weave Part 2: Deep DiveJalal Rohani
 
XPages Blast - Lotusphere 2011
XPages Blast - Lotusphere 2011XPages Blast - Lotusphere 2011
XPages Blast - Lotusphere 2011Tim Clark
 
Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"
Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"
Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"LogeekNightUkraine
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Mike Willbanks
 
Mobile Developer Summit 2012, Pune
Mobile Developer Summit 2012, PuneMobile Developer Summit 2012, Pune
Mobile Developer Summit 2012, PuneBhuvan Khanna
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with BlackfireMarko Mitranić
 
Intel parallel programming
Intel parallel programmingIntel parallel programming
Intel parallel programmingNirma University
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part IIEugene Lazutkin
 
Monitoring and Debugging your Live Applications
Monitoring and Debugging your Live ApplicationsMonitoring and Debugging your Live Applications
Monitoring and Debugging your Live ApplicationsRobert Coup
 
Statically Compiling Ruby with LLVM
Statically Compiling Ruby with LLVMStatically Compiling Ruby with LLVM
Statically Compiling Ruby with LLVMLaurent Sansonetti
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Mandi Walls
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOCCarl Lu
 

Similar a Mario (20)

Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 
Us 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimesUs 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimes
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
D3 in Jupyter : PyData NYC 2015
D3 in Jupyter : PyData NYC 2015D3 in Jupyter : PyData NYC 2015
D3 in Jupyter : PyData NYC 2015
 
Build your own discovery index of scholary e-resources
Build your own discovery index of scholary e-resourcesBuild your own discovery index of scholary e-resources
Build your own discovery index of scholary e-resources
 
Pythonpresent
PythonpresentPythonpresent
Pythonpresent
 
Brillo/Weave Part 2: Deep Dive
Brillo/Weave Part 2: Deep DiveBrillo/Weave Part 2: Deep Dive
Brillo/Weave Part 2: Deep Dive
 
XPages Blast - Lotusphere 2011
XPages Blast - Lotusphere 2011XPages Blast - Lotusphere 2011
XPages Blast - Lotusphere 2011
 
Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"
Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"
Oleksandr Smoktal "Parallel Seismic Data Processing Using OpenMP"
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
 
Mobile Developer Summit 2012, Pune
Mobile Developer Summit 2012, PuneMobile Developer Summit 2012, Pune
Mobile Developer Summit 2012, Pune
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire
 
Intel parallel programming
Intel parallel programmingIntel parallel programming
Intel parallel programming
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 
Monitoring and Debugging your Live Applications
Monitoring and Debugging your Live ApplicationsMonitoring and Debugging your Live Applications
Monitoring and Debugging your Live Applications
 
Statically Compiling Ruby with LLVM
Statically Compiling Ruby with LLVMStatically Compiling Ruby with LLVM
Statically Compiling Ruby with LLVM
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 

Mario

  • 2. • Overview • Implement • Todo
  • 3. OVERVIEW • A Library that make the write from synchronous to asynchronous. • It is thread safe and easily used.
  • 4. EXAMPLE /** * @brief The handler inherit from the Consumer::Handler * The processMsg is pure virtual function, so you need implementation your own * version */ class FileHandler : public mario::Consumer::Handler { public: FileHandler() {}; virtual void processMsg(const std::string &item) { log_info("consume data %s", item.data()); } };
  • 5. EXAMPLE int main() { mario::Status s; FileHandler *fh = new FileHandler(); /** * @brief * * @param 1 is the thread number * @param fh is the handler that you implement. It tell the mario how * to consume the data * * @return */ mario::Mario *m = new mario::Mario(1, fh); std::string item = "Put data in mario"; s = m-­‐>Put(item); if (!s.ok()) { log_err("Put error"); exit(-­‐1); } delete m; delete fh; return 0; }
  • 6. EXAMPLE └─[$] ./mario [INFO] (demo.cc:22) consume data Put data in mario
  • 7. IMPLEMENT • The base idea of the Mario is that if you have operators that cost lots of time. But you want quickly return from the operator, and leave the work to the background. • So mario library can easily solve your problem. You just need the implement your own consume message function. Then mario will create background thread do the other things.
  • 8. ENGINE • Memory • make ENGINE=memory • File • make ENGINE=file • write2file • manifest
  • 9. USAGE • make ENGINE=memory • ls output • include/ lib/
  • 10. IMPLEMENT Block Len Len Block Len Len
  • 11. IMPLEMENT • Why Block? • Handle error • Batch read
  • 12. TODO • The benchmark • Batch read