美文网首页
开发:如何调用scheduler异步执行demo

开发:如何调用scheduler异步执行demo

作者: 笨手笨脚越 | 来源:发表于2017-06-27 10:26 被阅读90次
  • RPC-API 的存在是为了快速的响应进程服务之间的调用请求。
  • PRC 调用的过程为:
graph LR
  A(api.py)-->B(rpcapi.py)    
  B(rpcapi.py)-->C(manager.py) 
  1. cinder\cinder\scheduler\rpcapi.py
class SchedulerAPI(rpc.RPCAPI):

    """省略代码"""

    def say_hello(self, ctxt):
        version = '3.0'
        cctxt = self.client.prepare(version=version)
        # cast 异步调用, call 同步调用
        # 通过cast方式的远程调用,请求发送后就直接返回了;通过call方式远程调用,需要等响应从服务器返回。
        cctxt.cast(ctxt, 'say_hello')

  1. cinder\cinder\scheduler\manager.py
class _SchedulerV3Proxy(object):
    
    """省略代码"""
    
    def say_hello(self, context):
        """Demo function. test say hello."""
        LOG.debug('===========manager say_hello==============hello,wangyue========================')
        #通知ceilmeter
        rpc.get_notifier("volume", CONF.host).info(context, '======scheduler say hello to you, wangyue======', None)

  1. 调用rpcapi
from cinder.scheduler import rpcapi

"""省略代码"""

    def say_hello(self, req):
        LOG.debug('=============say hello begin===================')
        context = req.environ['cinder.context']
        authorize(context, 'storages')
        rpc = rpcapi.SchedulerAPI()
        rpc.say_hello(context)
        return webob.Response(status_int=202)

相关文章

  • 开发:如何调用scheduler异步执行demo

    RPC-API 的存在是为了快速的响应进程服务之间的调用请求。 PRC 调用的过程为: cinder\cinder...

  • spring boot 异步实现@Async

    一、异步与同步 异步调用:程序在顺序执行时,不等待异步调用的语句返回结果就执行后面的程序; 同步调用:程序按照定义...

  • 11_springboot异步执行方法极简demo

    springboot异步demo 1.开启异步功能@EnableAsync2.在需要异步执行的方法上面增加@Asy...

  • 从零搭建项目开发框架-20异步调用@Async

    何为异步调用?在解释异步调用之前,我们先来看同步调用的定义;同步就是整个处理过程顺序执行,当各个过程都执行完毕,并...

  • SpringBoot线程池异步调用

    异步调用介绍 异步调用异步调用就是在不阻塞主线程的情况下执行高耗时方法 常规异步通过开启新线程实现 在Spring...

  • iOS GCD多线程

    程序中同步和异步是什么意思?有什么区别? 解释一:异步调用是通过使用单独的线程执行的。原始线程启动异步调用,异步调...

  • Javascript进阶——异步编程原理

    理解JS异步 同步和异步 同步:调用之后得到结果,再依次执行其他的任务 异步:调用之后可以不等待结果,继续做其他的...

  • SpringBoot 异步调用

    Spring Boot 中的异步调用 通常我们开发的程序都是同步调用的,即程序按照代码的顺序一行一行的逐步往下执行...

  • Spring Boot Async异步执行

    异步调用就是不用等待结果的返回就执行后面的逻辑,同步调用则需要等带结果再执行后面的逻辑。 通常我们使用异步操作都会...

  • SpringBoot(3) 异步调用升级之旅@Async

    异步调用 "异步调用" 对应 "同步调用",同步调用是指程序按照定义的顺序依次执行,在时间轴上看,这些程序是串行的...

网友评论

      本文标题:开发:如何调用scheduler异步执行demo

      本文链接:https://www.haomeiwen.com/subject/gxrbfxtx.html