SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
Implementações paralelas
        Willian Molinari
         a.k.a PotHix
WTF
1996!!




John Carmack
https://github.com/id-Software
#AltDevBlogADay
Várias formas de
implementações paralelas
1. Substitution
Master
Código no branch principal
class VirtualMachine
 def name
   hypervisor_session.VM.get_name(uuid)
 end
 .
 .
 .
end
Código código no branch novo
class VirtualMachine
 def name
   on_hypervisor.VM.get_name(uuid)
 end
 .
 .
 .
end
Master    NewFeature




Feature
"Virar a chave"
Dá para evitar?
2. Feature Toggle
2. Feature Toggle
Para adição de funcionalidade
Martin Fowler



       http://martinfowler.com/bliki/FeatureToggle.html
Master



Feature1

           Merge   Release

Feature2



Feature3
Martin Fowler



       http://martinfowler.com/bliki/FeatureToggle.html
Nando Vieira



     http://simplesideias.com.br/usando-presenters-no-rails/
2. Feature Toggle
Para várias implementações
Fabio Kung

 http://fabiokung.com/2010/10/16/dsls-one-interface-multiple-implementations/
Qual a idéia?
module Resque
 class Consumer
  class << self
    def queue(name)
     @queue = name
    end

   def timeout(seconds=nil)
    @lock_timeout = seconds unless seconds
    @lock_timeout || 1.hour
   end

   def exclusive(param)
    @exclusive = param
    self.extend(Resque::Plugins::LockTimeout) if exclusive?
    @lock_timeout ||= 1.hour
   end
   def publish(message={})
    Resque.enqueue(self, message)
   end
   ...
  end
 end
end
module ActiveMQ
 class Consumer
  class << self
    attr_reader :queue_name, :queued_process, :headers, :timeout_value

   def queue(name)
    @queue_name = "/queue/#{name}"
   end

   def timeout(seconds)
    @timeout_value = seconds
   end

   def exclusive(param)
    @exclusive = param
   end

   def publish(message = {})
     client = Stomp::Client.new(NephelaeConfig[:broker].merge(:max_reconnect_attempts => 1))
     client.publish(queue_name, message.to_yaml, {
       :persistent => true, :suppress_content_length => true
     })
   end
   ...
  end
 end
end
require 'xmpp4r'
module XMPP
 class Consumer
  class << self
    attr_reader :queue_name, :queued_process, :timeout_value

   def queue(name)
    @queue_name = "#{name}@localhost"
   end

   def timeout(seconds)
    @timeout_value = seconds
   end

   def exclusive(param)
    @exclusive = param
   end

   def publish(message={})
    publisher_client.send(Jabber::Message.new(queue_name, message.to_yaml))
   end
   ...
  end
 end
end
app/consumers/consumer.rb
  Consumer = ActiveMQ::Consumer
app/consumers/consumer.rb
  Consumer = XMPP::Consumer
app/consumers/consumer.rb
  Consumer = Resque::Consumer
Injeção de dependencia
MyQueue.new(Resque::Consumer)
Por configuração
3. Feature versioning
Manager




Ver1             Ver2
module Network
 class Ver1
  def insert_filter_rule(filter_rule)
    filter_rule.firewalls.in_parallel do |firewall|
      ssh_executor = SSHExecutor.new(firewall.ip_address, 'sservice')
      result = ssh_executor.exec(
        :insert_filter_firewall_rules, :rule => filter_rule,
        :internal_address => filter_rule.ip_pair.private_ip,
        :firewall => firewall
      )
      raise "Insertion failed: #{result[:out]}" if result[:status] != 0
    end
    filter_rule.update_attribute(:status, :done)
  end
  def insert_dhcp_entry(vm)
    vm.zone.dhcps.in_parallel do |dhcp_server|
      result = dhcp_server.synchronize
      raise "DHCP failed: #{result[:out]}" if result[:status] != 0
    end
  end
 end
end
Manager




Ver1             Ver2
module Network
 class Ver2
  def insert_filter_rule(filter_rule)
    quantum = Openstack::QuantumClient::L2l3.new(NephelaeConfig[:quantum])
    quantum_response = quantum.filter_rule.create(
      filter_rule.filter_address,
      filter_rule.ip_pair.public_ip.to_s,
      filter_rule.filter_port,
      filter_rule.filter_protocol
    )
    filter_rule.update_attribute(:quantum_uuid, quantum_response["filter_rule"]["id"])
  end

 def insert_dhcp_entry(vm)
   quantum = Openstack::QuantumClient::L2l3.new(NephelaeConfig[:quantum])
   quantum_response = quantum.dhcp_entry.create(vm.public_ip.to_s, vm.mac, vm.name)
  end
end
Manager


"1.0"             "2.0"


Ver1              Ver2
module Network
 module Manager
  extend self

  def for(versioning_object)
   versioning_object.version == "2.0" ? Network::Ver2.new : Network::Ver1.new
  end
 end
end
module Network
 module Manager
  extend self

  def for(versioning_object)
   versioning_object.version.constantize.new
  end
 end
end



Network::Manager.for(pool).insert_filter_rule(virtual_machine)
Várias formas de
                        atacar o problema
           r bu llet
 os ilve
N
               Resumindo
    Su                              bene fício
      an
         ec              Cu sto X
            es
               sida
                   de
Perguntas?

Contenu connexe

Tendances

Node js presentation
Node js presentationNode js presentation
Node js presentation
martincabrera
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Gosuke Miyashita
 
Europython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & CeleryEuropython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & Celery
Mauro Rocco
 

Tendances (20)

NodeJs
NodeJsNodeJs
NodeJs
 
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기
 
EventMachine for RubyFuZa 2012
EventMachine for RubyFuZa   2012EventMachine for RubyFuZa   2012
EventMachine for RubyFuZa 2012
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Ruby Concurrency and EventMachine
Ruby Concurrency and EventMachineRuby Concurrency and EventMachine
Ruby Concurrency and EventMachine
 
Cooking pies with Celery
Cooking pies with CeleryCooking pies with Celery
Cooking pies with Celery
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Django Celery
Django Celery Django Celery
Django Celery
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Library
 
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
 
Europython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & CeleryEuropython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & Celery
 
Celery
CeleryCelery
Celery
 
Gevent rabbit rpc
Gevent rabbit rpcGevent rabbit rpc
Gevent rabbit rpc
 
RDSDataSource: Мастер-класс по Dip
RDSDataSource: Мастер-класс по DipRDSDataSource: Мастер-класс по Dip
RDSDataSource: Мастер-класс по Dip
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)
 
[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화
 

En vedette (7)

Abertura do Ruby + Rails no Mundo Real
Abertura do Ruby + Rails no Mundo RealAbertura do Ruby + Rails no Mundo Real
Abertura do Ruby + Rails no Mundo Real
 
As escolhas do desenvolvedor
As escolhas do desenvolvedorAs escolhas do desenvolvedor
As escolhas do desenvolvedor
 
Desconstruindo a web
Desconstruindo a webDesconstruindo a web
Desconstruindo a web
 
Desenvolvimento de jogos com HTML5 e javascript
Desenvolvimento de jogos com HTML5 e javascriptDesenvolvimento de jogos com HTML5 e javascript
Desenvolvimento de jogos com HTML5 e javascript
 
Mesos
MesosMesos
Mesos
 
Ruby e xmpp
Ruby e xmppRuby e xmpp
Ruby e xmpp
 
Vim
VimVim
Vim
 

Similaire à Implementações paralelas

Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano Pycon
Luca Foppiano
 

Similaire à Implementações paralelas (20)

Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano Pycon
 
Review unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphpReview unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphp
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Python twisted
Python twistedPython twisted
Python twisted
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Intro django
Intro djangoIntro django
Intro django
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 

Plus de Willian Molinari

Abertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_spAbertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_sp
Willian Molinari
 

Plus de Willian Molinari (10)

Javascript and browser games
Javascript and browser gamesJavascript and browser games
Javascript and browser games
 
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
 
Html5, gamedev e o skeleton jigsaw
Html5, gamedev e o skeleton jigsawHtml5, gamedev e o skeleton jigsaw
Html5, gamedev e o skeleton jigsaw
 
Game network programming
Game network programmingGame network programming
Game network programming
 
Locasberos
LocasberosLocasberos
Locasberos
 
Simplestack
SimplestackSimplestack
Simplestack
 
TDC2011 - Desenvolvimento de jogos com Javascript e HTML5
TDC2011 - Desenvolvimento de jogos com Javascript e HTML5TDC2011 - Desenvolvimento de jogos com Javascript e HTML5
TDC2011 - Desenvolvimento de jogos com Javascript e HTML5
 
FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5
FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5
FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5
 
Abertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_spAbertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_sp
 
What is and how does work RubyLearning.org
What is and how does work RubyLearning.orgWhat is and how does work RubyLearning.org
What is and how does work RubyLearning.org
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Implementações paralelas