dubbo学习笔记-初步认识dubbo及dubbo的简单使用

Dubbo学习笔记(一)—— 创建一个简单的Dubbo入门项目演示HelloWorld 一、Dubbo简介1、dubbo是什么?▶ 一个分布式服务框架▶ 一个RPC远程服务调用方案▶ 一个SOA服务治理方案2、dubbo架构图3、节点说明Provider:暴露服务的服务提供方Consumer:调用远程服务的服务消费方Registry:发现并注册服务的服务注册中心Monitor:统计服务调用次数和调用时间的监控中心Container:服务的运行容器4、调用流程说明① 服务容器负责启动、... 阅读详情

dubbo学习笔记

初步认识dubbo

dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的RPC实现服务的输出和输入功能,可以和Spring框架无缝集成。
随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,亟需一个治理系统确保架构有条不紊的演进。
dubbo就是在这种背景中产生的。
下面有几大文档能极大帮助开发者熟悉dubbo这个框架的,建议大家有事没事去看看:
Dubbo用户手册(中文)
Dubbo开发手册(中文)
Dubbo管理手册(中文)

dubbo简单使用

下面将以一个简单的例子来说明dubbo的用法。
首先dubbo是面向接口开发的,所以第一步得先定义一个接口。
- api

package com.github.wenj91.kotlin.api

interface TestService {
    fun sayHello(name: String): String
}

接口的实现
- service.impl

package com.github.wenj91.kotlin.provider.service.impl

import com.github.wenj91.kotlin.api.TestService

class TestServiceImpl : TestService{
    override fun sayHello(name: String): String {
        return "hello, $name!"
    }
}

接口的export
- provider

package com.github.wenj91.kotlin.provider

import com.alibaba.dubbo.config.ApplicationConfig
import com.alibaba.dubbo.config.ProtocolConfig
import com.alibaba.dubbo.config.RegistryConfig
import com.alibaba.dubbo.config.ServiceConfig
import com.github.wenj91.kotlin.api.TestService
import com.github.wenj91.kotlin.provider.service.impl.TestServiceImpl

fun main(args: Array<String>){
    val applicationConfig = ApplicationConfig()
    applicationConfig.name = "dubbo-provider" //配置服务名

    val registryConfig = RegistryConfig()
    registryConfig.address = "N/A" //配置注册中心,这里不使用任何注册中心

    val protocolConfig = ProtocolConfig()
    protocolConfig.name = "dubbo" //配置协议及端口
    protocolConfig.port = 9090

    val serviceConfig = ServiceConfig<TestService>()
    serviceConfig.application = applicationConfig
    serviceConfig.registry = registryConfig
    serviceConfig.protocol = protocolConfig
    serviceConfig.setInterface(TestService::class.java)
    serviceConfig.ref = TestServiceImpl()
    serviceConfig.export() //export接口,暴露接口

    System.`in`.read()
}

服务已经暴露出来,下来就是接口的调用
- consumer

package com.github.wenj91.kotlin.consumer

import com.alibaba.dubbo.config.ApplicationConfig
import com.alibaba.dubbo.config.ReferenceConfig
import com.alibaba.dubbo.config.RegistryConfig
import com.github.wenj91.kotlin.api.TestService

fun main(args: Array<String>){
    val applicationConfig = ApplicationConfig()
    applicationConfig.name = "dubbo-consumer" //配置服务名

    val registryConfig = RegistryConfig()
    registryConfig.address = "N/A" //配置注册中心,这里不使用任何注册中心

    val referenceConfig = ReferenceConfig<TestService>()
    referenceConfig.application = applicationConfig
    referenceConfig.registry = registryConfig
    referenceConfig.url = "dubbo://127.0.0.1:9090" //配置直连链接,这样配置就把dubbo当作普通的RPC框架来使用,最简单最直接最本质
    referenceConfig.setInterface(TestService::class.java) //需要获取接口类型

    var testService = referenceConfig.get() //获取接口代理对象
    println(testService.sayHello("wenj91")) //远程调用接口并打印接口返回值

}

至此,dubbo已经能正常的工作了,当然这是最简单的配置使用,没有用到dubbo的一些高级特性,甚至没有用注册中心,这其实就是dubbo最本质的东西吧,抛开其它东西,它的本质就是一个rpc框架。

dubbo配置说明

dubbo功能丰富多样,这就说明dubbo的配置也是很丰富的,这样才能灵活的使用dubbo来实现我们的需求.当然这里只是简单的说明一下dubbo的配置使用,更多更全的说明请参考dubbo的schema 配置参考手册,里面有对dubbo的配置做详细的说明.

api配置

一开始我们使用的样例就是通过api简单配置来使用的,api配置跟其它配置是一对一的关系,完全通过api来进行配置使用,不依赖任何框架.
比如:applicationConfig.name = "dubbo-provider" 对应 <dubbo:application name="dubbo-provider" />

provider的api配置:

    //当前应用的配置
    val applicationConfig = ApplicationConfig()
    applicationConfig.name = "dubbo-provider" //配置服务名

    //注册中心的配置
    val registryConfig = RegistryConfig()
    registryConfig.address = "N/A" //配置注册中心,这里不使用任何注册中心

    //协议的配置
    val protocolConfig = ProtocolConfig()
    protocolConfig.name = "dubbo" //配置协议及端口
    protocolConfig.port = 9090

    //暴露服务配置
    val serviceConfig = ServiceConfig<TestService>()
    serviceConfig.application = applicationConfig
    serviceConfig.registry = registryConfig
    serviceConfig.protocol = protocolConfig
    serviceConfig.setInterface(TestService::class.java) //配置接口服务
    serviceConfig.ref = TestServiceImpl() //接口实现
    serviceConfig.export() //export接口,暴露接口

consumer的api配置:

    //当前应用的配置
    val applicationConfig = ApplicationConfig()
    applicationConfig.name = "dubbo-consumer" //配置服务名

    //注册中心的配置
    val registryConfig = RegistryConfig()
    registryConfig.address = "N/A" //配置注册中心,这里不使用任何注册中心

    // 引用远程服务
    val referenceConfig = ReferenceConfig<TestService>()
    referenceConfig.application = applicationConfig
    referenceConfig.registry = registryConfig
    referenceConfig.url = "dubbo://127.0.0.1:9090" //配置直连链接,这样配置就把dubbo当作普通的RPC框架来使用,最简单最直接最本质
    referenceConfig.setInterface(TestService::class.java) //需要获取接口类型

    var testService = referenceConfig.get() //获取接口代理对象
    println(testService.sayHello("wenj91")) //远程调用接口并打印接口返回值
xml配置

有关XML的详细配置项,请参见:dubbo的schema 配置参考手册

基于spring配置的provider.xml示例:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
       http://code.alibabatech.com/schema/dubbo
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <!-- 这里的配置与api配置是一对一关系 -->
    <bean id="testService" class="com.github.wenj91.kotlin.provider.service.impl.TestServiceImpl" />
    <dubbo:application name="dubbo-provider" />
    <dubbo:registry address="N/A" />
    <dubbo:protocol name="dubbo" port="9090" />
    <dubbo:service interface="com.github.wenj91.kotlin.api.TestService" ref="testService" />
</beans>

provider加载配置并暴露服务:

package com.github.wenj91.kotlin.provider

import org.springframework.context.support.ClassPathXmlApplicationContext

fun main(args: Array<String>){
    val applicationContext = ClassPathXmlApplicationContext("classpath:provider.xml")
    applicationContext.start()
    System.`in`.read()
}

基于spring配置consumer.xml示例:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
       http://code.alibabatech.com/schema/dubbo
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
    <dubbo:application name="dubbo-consumer"  />

    <!-- 不使用注册中心 -->
    <dubbo:registry address="N/A" />

    <!-- 生成远程服务代理,可以和本地bean一样使用testService -->
    <dubbo:reference id="demoService" url="dubbo://127.0.0.1:9090" interface="com.github.wenj91.kotlin.api.TestService" />
</beans>

consumer加载配置并引用服务:

package com.github.wenj91.kotlin.consumer

import com.github.wenj91.kotlin.api.TestService
import org.springframework.context.support.ClassPathXmlApplicationContext

fun main(args: Array<String>){
    val applicationContext = ClassPathXmlApplicationContext("classpath:consumer.xml")
    applicationContext.start()

    val testService = applicationContext.getBean(TestService::class.java)
    println(testService.sayHello("wenj91"))
}
注解配置并与spring boot集成

注解配置将与Spring Boot集成使用,在这里,采用redis(redis://127.0.0.1:6379)做注册中心,服务配置版本号(version=”v1.0.0”)并分组(group=”wenj91”)

provider注解配置示例:

//dubbo provider config
package com.github.wenj91.kotlin.provider.config

import com.alibaba.dubbo.config.ApplicationConfig
import com.alibaba.dubbo.config.ProtocolConfig
import com.alibaba.dubbo.config.RegistryConfig
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class DubboProviderConfig{
    @Bean
    fun applicationConfig(): ApplicationConfig {
        var applicationConfig = ApplicationConfig()
        applicationConfig.name = "dubbo-provider" //应用配置

        return applicationConfig
    }

    @Bean
    fun registerConfig(): RegistryConfig {
        var registryConfig = RegistryConfig()
        registryConfig.address = "redis://127.0.0.1:6379" //注册中心配置,这里采用redis做注册中心

        return registryConfig
    }

    @Bean
    fun protocolConfig(): ProtocolConfig {
        var protocolConfig = ProtocolConfig()
        protocolConfig.port = 8888 //protocol配置

        return protocolConfig
    }
}

//service impl
package com.github.wenj91.kotlin.provider.service.impl

import com.alibaba.dubbo.config.annotation.Service
import com.github.wenj91.kotlin.api.TestService

//service config, 这里配置了版本号,以及给服务分组
@Service(version = "v1.0.0", group = "wenj91")
class TestServiceImpl: TestService {
    override fun sayHello(name: String): String {
        return "hello, $name!"
    }
}

//provider app
package com.github.wenj91.kotlin.provider

import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication
@DubboComponentScan
class ProviderApp

//启动应用并暴露服务
fun main(args: Array<String>){
    SpringApplication.run(ProviderApp::class.java, *args)
}

consumer注解配置示例:

//dubbo consumer config
package com.github.wenj91.kotlin.consumer.config

import com.alibaba.dubbo.config.ApplicationConfig
import com.alibaba.dubbo.config.ProtocolConfig
import com.alibaba.dubbo.config.RegistryConfig
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class DubboConsumerConfig{
    @Bean
    fun applicationConfig(): ApplicationConfig {
        var applicationConfig = ApplicationConfig()
        applicationConfig.name = "dubbo-consumer" //应用配置

        return applicationConfig
    }

    @Bean
    fun registerConfig(): RegistryConfig {
        var registryConfig = RegistryConfig()
        registryConfig.address = "redis://127.0.0.1:6379" //redis注册中心配置

        return registryConfig
    }

    @Bean
    fun protocolConfig(): ProtocolConfig {
        var protocolConfig = ProtocolConfig()
        protocolConfig.port = 8888 //protocol配置

        return protocolConfig
    }
}

//dubbo reference config
package com.github.wenj91.kotlin.consumer.config

import com.alibaba.dubbo.config.annotation.Reference
import com.github.wenj91.kotlin.api.TestService
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class DubboReferenceConfig{
    //引用服务配置, 这里需要与provider同样配置version与group
    @Reference(version = "v1.0.0", group = "wenj91")
    lateinit var testService: TestService

    @Bean
    fun testService(): TestService {
        return testService
    }
}

//consumer app
package com.github.wenj91.kotlin.consumer

import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan
import com.github.wenj91.kotlin.api.TestService
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication
@DubboComponentScan
class ConsumerApp

//启动应用并调用
fun main(args: Array<String>){
    var applicationContext = SpringApplication.run(ConsumerApp::class.java, *args)
    var testService = applicationContext.getBean(TestService::class.java)
    println(testService.sayHello("wenj91"))
}

dubbo注册中心

dubbo目前支持zookeeper,redis,multicast,simple作为注册中心,但是官方推荐使Zookeeper 注册中心

以下是这些注册中心成熟度说明,可以根据这个来选择合适的注册中心:

FeatureMaturityStrengthProblemAdviseUser
Zookeeper注册中心Stable支持基于网络的集群方式,有广泛周边开源产品,建议使用dubbo-2.3.3以上版本(推荐使用) 依赖于Zookeeper的稳定性可用于生产环境
Redis注册中心Stable支持基于客户端双写的集群方式,性能高要求服务器时间同步,用于检查心跳过期脏数据可用于生产环境
Multicast注册中心Tested去中心化,不需要安装注册中心依赖于网络拓普和路由,跨机房有风险小规模应用或开发测试环境
Simple注册中心TestedDogfooding,注册中心本身也是一个标准的RPC服务没有集群支持,可能单点故障试用

dubbo高级用法简介

JDK的SPI

SPI是英文Service Provider Interface的缩写。中文意思是服务提供商接口。满足某种服务标准的供应商提供的符合该标准的应用程序接口,SPI应该和该服务的API标准是兼容的,应用程序一般应该是基于API编写,除非是SPI中包含API中没有提供的功能而又必须使用。
SPI机制有点类似IOC的思想,就是将装配的控制权移到程序之外.

约定:
当服务的提供者,提供了服务接口的一种实现之后,在jar包的META-INF/services/目录里同时创建一个以服务接口命名的文件。该文件里就是实现该服务接口的具体实现类。而当外部程序装配这个模块的时候,就能通过该jar包META-INF/services/里的配置文件找到具体的实现类名,并装载实例化,完成模块的注入。 基于这样一个约定就能很好的找到服务接口的实现类,而不需要再代码里制定。jdk提供服务实现查找的一个工具类:java.util.ServiceLoader

SPI具体实现示例:

//service
package com.github.wenj91.kotlin.spi.service

interface SpiService {
    fun spiMethod()
}

//service 1 impl
package com.github.wenj91.kotlin.spi.service.impl

import com.github.wenj91.kotlin.spi.service.SpiService

class Spi1ServiceImpl: SpiService{
    override fun spiMethod() {
        println("spi 1 method!")
    }
}

//service 2 impl
package com.github.wenj91.kotlin.spi.service.impl

import com.github.wenj91.kotlin.spi.service.SpiService

class Spi2ServiceImpl: SpiService{
    override fun spiMethod() {
        println("spi 2 method!")
    }
}

约定配置META-INF/services/com.github.wenj91.kotlin.spi.service.SpiService:

com.github.wenj91.kotlin.spi.service.impl.Spi1ServiceImpl
com.github.wenj91.kotlin.spi.service.impl.Spi2ServiceImpl

service加载调用:

//service loading
package com.github.wenj91.kotlin.spi

import com.github.wenj91.kotlin.spi.service.SpiService
import java.util.*

fun main(args: Array<String>){
    //加载服务
    var loader = ServiceLoader.load(SpiService::class.java)
    var it = loader.iterator()
    while (it.hasNext()){
        //获取服务并执行服务方法
        var s = it.next()
        println(s.spiMethod())
    }
}
dubbo扩展点加载与配置

Dubbo的扩展点加载从JDK标准的SPI (Service Provider Interface)扩展点发现机制加强而来。
Dubbo改进了JDK标准的SPI的以下问题:

JDK 标准的 SPI 会一次性实例化扩展点所有实现,如果有扩展实现初始化很耗时,但如果没用上也加载,会很浪费资源。
如果扩展点加载失败,连扩展点的名称都拿不到了。比如:JDK 标准的 ScriptEngine,通过 getName() 获取脚本类型的名称,但如果 RubyScriptEngine 因为所依赖的 jruby.jar 不存在,导致 RubyScriptEngine 类加载失败,这个失败原因被吃掉了,和 ruby 对应不起来,当用户执行 ruby 脚本时,会报不支持 ruby,而不是真正失败的原因。
增加了对扩展点 IoC 和 AOP 的支持,一个扩展点可以直接 setter 注入其它扩展点。

约定:
在扩展类的jar包内,放置扩展点配置文件META-INF/dubbo/接口全限定名,内容为:配置名=扩展实现类全限定名,多个实现类用换行符分隔。

更多细节可以查阅dubbo官方手册Dubbo开发手册(中文)

dubbo之自定义filter

服务提供方和服务消费方调用过程拦截,Dubbo本身的大多功能均基于此扩展点实现,每次远程方法执行,该拦截都会被执行,请注意对性能的影响。

约定:

用户自定义 filter 默认在内置 filter 之后。
特殊值 default,表示缺省扩展点插入的位置。比如:filter=”xxx,default,yyy”,表示 xxx 在缺省 filter 之前,yyy 在缺省 filter 之后。
特殊符号 -,表示剔除。比如:filter=”-foo1”,剔除添加缺省扩展点 foo1。比如:filter=”-default”,剔除添加所有缺省扩展点。
provider 和 service 同时配置的 filter 时,累加所有 filter,而不是覆盖。比如: 和 ,则 xxx,yyy,aaa,bbb 均会生效。如果要覆盖,需配置:

扩展接口:
com.alibaba.dubbo.rpc.Filter

例子:
下面一个例子来说明filter的实现,例子实现的功能是在每次服务调用前打印hello world!

//TestFilter
package com.github.wenj91.kotlin.filter

import com.alibaba.dubbo.rpc.Filter
import com.alibaba.dubbo.rpc.Invocation
import com.alibaba.dubbo.rpc.Invoker
import com.alibaba.dubbo.rpc.Result

class TestFilter: Filter{
    override fun invoke(invoker: Invoker<*>?, invocation: Invocation?): Result {
        println("hello world!")
        return invoker!!.invoke(invocation)
    }
}

约定配置META-INF/dubbo/com.alibaba.dubbo.rpc.Filter:

testFilter=com.github.wenj91.kotlin.filter.TestFilter

consumer配置filter:

<!-- 新增filter属性 -->
<dubbo:reference id="demoService" filter="testFilter" url="dubbo://127.0.0.1:9090" interface="com.github.wenj91.kotlin.api.TestService" />

上述例子filter是通过手工配置指定激活的,如果想要自动激活filter,可以添加@Activate注解

对于可以被框架中自动激活加载扩展,此Annotation用于配置扩展被自动激活加载条件。
比如,过滤扩展,有多个实现,使用Activate Annotation的扩展可以根据条件被自动加载。{@link Activate#group()}生效的Group。具体的有哪些Group值由框架SPI给出。 {@link Activate#value()}在{@link com.alibaba.dubbo.common.URL}中Key集合中有,则生效。
底层框架SPI提供者通过{@link com.alibaba.dubbo.common.extension.ExtensionLoader}的{@link ExtensionLoader#getActivateExtension}方法获得条件的扩展。

如果需要自动激活可以将filter改造成下例子:

//TestFilter
package com.github.wenj91.kotlin.filter

import com.alibaba.dubbo.common.Constants
import com.alibaba.dubbo.common.extension.Activate
import com.alibaba.dubbo.rpc.Filter
import com.alibaba.dubbo.rpc.Invocation
import com.alibaba.dubbo.rpc.Invoker
import com.alibaba.dubbo.rpc.Result

//group配置默认消费者激活
@Activate(group = arrayOf(Constants.CONSUMER))
class TestFilter: Filter{
    override fun invoke(invoker: Invoker<*>?, invocation: Invocation?): Result {
        println("hello world!")
        return invoker!!.invoke(invocation)
    }
}
SpringBoot+Dubbo+Zookeeper的简单整合 之前写过dubbo的简单项目,用的是Spring+Dubbo,约摸看了下博客的创建时间,然后默默捂了下脸,已经是一年多前的事了。 由于Dubbo最近在疯狂地更新,相信死灰复燃还是有小宇宙可以燃烧的。 这次带来的是SpringBoot+Dubbo+Zookeeper的简单整合,客官们可要赏脸看一看。 首先看下项目的结构,如下图所示(发现现在博客强制加了水印,这水印真的是人类交流的最大阻碍了):... 阅读详情

相关推荐

Dubbo 简单入门

Dubbo 的核心原理包括通过注册中心实现服务注册与发现、采用高效的通信协议、提供多种负载均衡策略和容错机制,并且支持通过 SPI 机制进行扩展。Dubbo 为构建高性能、可扩展的分布式服务系统提供了强有力的支持。

Casual_Lei的博客 1203

Dubbo Filter用法详解

Filter是Dubbo中使用较为频繁的组件,其作用在于对所指定的请求进行过滤,功能非常类似于AOP,可以实现诸如请求过滤器和全局异常捕获器等组件。本文首先会讲解Filter的用法,然后会从源码的角度讲解其实现原理。 1. 用法示例 对于Filter的划分,根据...

chicaoxia5444的博客 7798

逆向解析M团外卖mtgsig与waimai_sign加密参数实战指南⊙ω⊙

本文详细解析了M团外卖App中mtgsig与waimai_sign两个核心加密参数的逆向分析与生成方法。通过抓包定位、静态逆向与Frida动态调试,拆解了waimai_sign的RSA签名逻辑与mtgsig的复杂参数组装加密流程,并提供了Python模拟实现的框架与调试心得,为安全研究及合规数据分析提供实战指南。

weixin_29327525的博客 1300

dubbo 过滤器

dubbo 过滤器

weixin_43931625的博客 1337

深入解析SVPWM七段式与五段式调制的电压波形差异及优化策略

本文深入解析了SVPWM七段式与五段式调制在相电压和线电压波形上的核心差异。七段式波形对称、谐波含量低,适合追求静音与性能的场景;五段式开关次数少、损耗低,适用于对效率与散热要求高的应用。文章提供了基于谐波与损耗权衡的优化策略与选型指南。

weixin_29216957的博客 452

实测有效防止colab自动断开连接

实测有效防止colab自动断开连接

Thebest_jack的博客 1万+

Dubbo 学习笔记

Dubbo 学习笔记

老顽固也可爱 771

【WRF-Chem 工具】CAMStoWRF详解:CAMS数据下载及处理

【WRF-Chem 工具】CAMStoWRF详解:CAMS数据下载及处理

WW、forever的博客 203

dubbo学习笔记---dubbo开发实战

dubbo学习笔记—dubbo开发实战 1.接口协定—api模块 2.dubbo的配置介绍 注解: 基于注解可以快速的将程序配置,无需多余的配置信息,包含提供者和消费者。但是这种方 式有一个弊端,有些时候配置信息并不是特别好找,无法快速定位。 XML: 一般这种方式我们会和Spring做结合,相关的Service和Reference均使用Spring集成后的。 通过这样的方式可以很方便的通过几个文件进行管理整个集群配置。可以快速定位也可以快速更 改。 基于代码方式: 基于代码方式的对上述配置进行配置。这个

qq_39314972的博客 603

发那科 Fanuc PLC 报文通讯,报文解析。附源程序

发那科 Fanuc PLC 报文通讯,最详细的发那科 PLC报文解析,不再局限在官方提供的库,也不用再局限在windows平台。

ITOfDragon的博客 1755

[RK3568 Android11] 开发之调试RK809 codec音频-SPK喇叭

目录 前言 一、注册声卡顺序 二、SPK喇叭路由配置 三、tinyalsa调试工具 前言 瑞芯微RK809是一种复杂的功率管理集成电路(PMIC)集成编解码器,适用于由外部电源供电的多核系统应用;同时它也集成了音频编解码器,这样在硬件设计上可以直接使用RK809 codec功能,不必再外挂个其他codec芯片;RK809 codec不仅支持SPK,还支持耳机,MIC功能; 一、注册声卡顺序 设备树dts里面原厂帮我们配置好了rk809_sound,我们直接...

~未来可期~ 7427

Dubbo的简单使用

一、架构演进 单体架构 垂直应用架构:根据业务边界拆分,每个功能称为一个服务 公共的业务service,导致很多部分的冗余 分布式应用架构:把公共服务器的service提取成一个服务 网络通讯的问题,使用RPC框架 服务集群的负载均衡处理 服务如何被发现 服务如何被治理 服务之间如何高效的通信 微服务架构,主要解决以下几个问题 服务的注册和发现 服务的搞笑通信 服务的治理:服务权重、负载均衡、服务熔断、限流等等 二、注册中心 1、概述 主流的注册中心:

liming0025的专栏 7378

基于未来出行解决方案的场景实例:城市空中交通(UAM)的飞行路径规划与避障

本文介绍了使用Simulink进行城市空中交通(UAM)飞行路径规划与避障的仿真方法。主要内容包括:1)UAM系统架构与核心挑战;2)详细建模步骤,从城市3D环境构建到飞行器动力学模拟;3)全局路径规划(A*/RRT*)和局部避障(DWA/APF)算法实现;4)多机协同与冲突解决;5)关键场景仿真与性能评估;6)高级功能拓展方向。通过Simulink的数字孪生系统,可有效验证UAM在复杂城市环境中的可行性,为未来立体交通发展提供技术支撑。

xiaoheshang_123的博客 261

Windows下dubbo环境搭建及初步使用

今天的积累都是为了更好的明天,加油!我是java程序员可以关注我一起学习哈! 一、dubbo简介   Dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和Spring框架无缝集成。 二、环境准备   本案例使用环境:jdk(1.8)、maven(3.2+)、zookeeper(3.4.12)、idea、tomcat(tom...

zhuang_kang 857

【华为OD技术面-手撕算法代码真题】- 最长公共前缀

🌟 强烈推荐:华为OD技术面试手撕算法代码真题 🌟大家好!今天我给大家推荐一份备受赞誉的华为OD技术面试手撕算法代码真题。所有题目均为华为od实际面试过程中出现的算法代码真题。

算法大师! 4898

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

初步理解 Dubbo 与 Zookeeper

一、dubbo 与 zookeeper 的本质及其关系? Dubbo是管理中间层的工具,在业务层到数据仓库间有非常多服务的接入和服务提供者需要调度,dubbo提供一个框架解决这个问题。 Zookeeper用来注册服务和进行负载均衡,哪一个服务有哪一个机器来提供必需让调用者知道,简单来说就是ip地址和服务名称的对应关系。 Dubbo和zookeeper的关系: dubbo会将注册中心...

喜欢历史的码农 1万+

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

dubbo-admin安装以及dubbo-admin简单使用

一、dubbo-admin安装 1、环境准备 dubbo-admin 是一个前后端分离的项目。前端使用vue,后端使用springboot,安装 dubbo-admin 其实就是部署该项目。我们将dubbo-admin安装到开发环境上。要保证开发环境有jdk,maven,nodejs 安装node**(如果当前机器已经安装请忽略)** 因为前端工程是用vue开发的,所以需要安装node.js,node.js中自带了npm,后面我们会通过npm启动 下载地址 https://nodejs.org/en/

听雨少年的博客 1万+

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

初步理解 Dubbo 与 Zookeeper

个人博客网:https://wushaopei.github.io/ (你想要这里多有) 一、dubbo 与 zookeeper 的本质及其关系? Dubbo是管理中间层的工具,在业务层到数据仓库间有非常多服务的接入和服务提供者需要调度,dubbo提供一个框架解决这个问题。 Zookeeper用来注册服务和进行负载均衡,哪一个服务有哪一个机器来提供必需让调用者知道,简单来说就是ip地址和服务名称的对应关系。 Dubbo和zookeeper的关系: dubbo会将注册中心进行抽象,使得它可以连接不同

web13618542420的博客 1万+

dubbo-admin 的安装和简单使用

dubbo-admin安装 文章目录dubbo-admin安装dubbo-admin简单使用 1、node下载和安装 dubbo-admin 是一个前后端分离的项目。前端使用vue,后端使用springboot,安装 dubbo-admin 其实就是部署该项目。我们将dubbo-admin安装到开发环境上。要保证开发环境有jdk,maven,nodejs 安装node 因为前端工程是用vue开发的,所以需要安装node.js,node.js中自带了npm,后面我们会通过npm启动 下载地址 https://

立志成为一个前端、后端、测试全方位发展的程序员 5484

简单的使用dubbo

环境:W7 + jdk1.8+myeclipse+tomcat7+maven3+zookeeper-3.4.6为什么要用dubbo?当我们的网站规模达到了一定的量级的时候,普通的MVC框架已经不能满足我们的需求,于是分布式的服务框架和流动式的架构就凸显出来了。 单一应用架构 当网站流量很小时,只需一个应用,将所有功能都部署在一起,以减少部署节点和成本。 此时,用于简化增删改查工作量的 数据访问框

Tate的博客 1167

SpringBoot中Dubbo的简单使用方式

SpringBoot集成Dubbo

itsniu的博客 1746

dubbo--使用IDEA搭建简单的dubbo项目

dubbo--使用IDEA搭建简单的dubbo项目第一步,创建一个dubbotest名字的maven项目第二步,分别创建名字为dubbo_api,produce,consumer的module子项目第三步,分别修改pom文件第四步,分别在dubbo_api,produce,consumer的module子项目中创建java根目录和resources库第五步,在dubbo_api中创建一个接口,并在...

BIackMamba的博客 5069

Dubbo--简单介绍和使用(Simple)

内容简介 此篇文章是介绍Dubbo以及它的简单使用,会列举运用spring boot + dubbo搭建项目运用dubbo的步骤,主要是介绍一下dubbo的作用以及简单的配置,若有兴趣的朋友可以继续关注后续的dubbo系列文章,也可以参考官方文档进行学习.个人的一点心得和想法,有错误还请指正。 Dubbo介绍1.什么是Dubbo 一个分布式服务治理框架 2.为什么用Dubbo官方介绍 当

Little__Dragon的博客 1529

dubbo学习笔记(一)——dubbo的作用及简单应用

dubbo的简单运用

飞!!!的博客 4048
上一篇: zipkin maven配置
下一篇: dubbo集成zipkin
wenj91
博客等级 码龄15年 17粉丝 66原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值