首页 文章 精选 留言 我的

精选列表

搜索[云帮],共10000篇文章
优秀的个人博客,低调大师

阿里云HBase Ganos在海量实时轨迹中的应用(一)

场景需求 在移动对象轨迹监控与分析的项目中,收集了数十万的车辆信息,每个车辆会定时的上报当前位置、事件、状态等信息,每天约数亿条轨迹点,需要能够存储。且前端用户在查询时,要能快速返回目标船舶的信息。 入库需求: 轨迹数据,每日新增10亿条左右,包括时间点、经纬度坐标、对象当前的属性信息基本不涉及到数据的修改(不断的追加数据) 查询需求: 区域回放:根据时间和空间范围两个维度共同查询。例如:查询东经110°~120°,北纬25°~35°空间范围内,2019.3.1~2019.3.10时间范围内的所有轨迹点。 轨迹线查询:根据某个移动对象的id,查出某段时间内的轨迹。例如:查询编号为"205073000"的船舶在2019.3.1~2019.3.10时间范围内的所有轨迹点。 要求: 要能支撑每日10亿量级的写入,要能承载千亿轨迹规模的存储 时空查询(区域

优秀的个人博客,低调大师

spring cloud微服务分布式云架构--hystrix的使用

hystrix主要作用在服务消费者,进行应用的保护,当请求的服务请求超时时,做出相应的处理,避免客户端一直进行请求等待,避免在高并发的情况出现服务器死机(请求过多,内存不足) 接下来的通过一个案例对hystrix的使用进行说明,案例完成的功能: 服务消费者根据Id调用服务提供者的接口,获取User表单的对应的记录,若请求超时则返回id为-1的User记录 一、基于Ribbon <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> <mybatis-spring-boot.version>1.2.0</mybatis-spring-boot.version> <mysql-connector.version>5.1.39</mysql-connector.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> <version>1.3.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> <version>1.3.5.RELEASE</version> </dependency> </dependencies> 2、application.yml server: port: 8089 spring: application: name: customer-user eureka: client: serviceUrl: defaultZone: http://user:zj123@localhost:8761/eureka instance: prefer-ip-address: true instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}} provider-user: ribbon: NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule 3、Controller调用类 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import com.zhuojing.bean.User; @RestController public class UserController { @Autowired private RestTemplate restTemplate; @GetMapping(value="/simple/{id}",produces=MediaType.APPLICATION_JSON_VALUE+";charset=utf-8") @HystrixCommand(fallbackMethod = "findByIdFallback") public User findUserById(@PathVariable Long id){ //服务提供者地址 PROVIDER-USER return this.restTemplate.getForObject("http://PROVIDER-USER/simple/"+id, User.class); } /** * 断路器模式,当请求的消费者provider-user超时的情况下,就会直接调用此方法,此方法的参数和返回类型必须和findUserById方法一致,请求超时时间为1秒 * @param id * @return */ public User findByIdFallback(Long id){ User user = new User(); user.setId(0L); return user; } } hystrix的默认的超时时间为1秒,若自定hystrix超时时间有一下两种方式 a、@HystrixCommand注解配置 @HystrixCommand(fallbackMethod = "findByIdFallback",commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "3000") }) b、在application.yml配置 hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000 4、启动类 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.web.client.RestTemplate; @SpringBootApplication @EnableEurekaClient @EnableCircuitBreaker public class AppCusRibbonPropertiesTest { @Bean @LoadBalanced public RestTemplate restTemplate(){ return new RestTemplate(); } public static void main(String[] args) { SpringApplication.run(AppCusRibbonPropertiesTest.class, args); } } 二、dashboard的使用 1、pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> <version>1.3.5.RELEASE</version> </dependency> </dependencies> 2、application.yml server: port: 8030 3、启动类 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; @EnableHystrixDashboard @SpringBootApplication public class DashboardApplication { public static void main(String[] args) { SpringApplication.run(DashboardApplication.class, args); } } 启动后访问:http:/ /localhost:8030/hystrix 进入首页,在地址栏上输入http:/ /localhost:8089/hystrix.stream(hystrix.stream)进行监控,在使用了hystrix的服务调用后才有数据。 三、Turbine的使用,Turbine是对微服务集群的监听 1、pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine</artifactId> <version>1.3.5.RELEASE</version> </dependency> </dependencies> 2、application.yml server: port: 8031 spring: application: name: microservice-hystrix-turbine eureka: client: serviceUrl: defaultZone: http://user:zj123@localhost:8761/eureka instance: prefer-ip-address: true turbine: aggregator: clusterConfig: default #默认defualt,只有一个服务时候可以写服务名称的大写CUSTOMER-USER appConfig: customer-user clusterNameExpression: "'default'" 3、启动类 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.turbine.EnableTurbine; @EnableTurbine @SpringBootApplication public class TurbineApplication { public static void main(String[] args) { SpringApplication.run(TurbineApplication.class, args); } } hystrix 主页面中将localhost:8031/turbine.stream?cluster=CUSTOMER-USER填入,便可进行数据的图像化。

优秀的个人博客,低调大师

云原生实践之 RSocket 从入门到落地:Servlet vs RSocket

技术实践的作用在于:除了用于构建业务,也是为了验证某项技术或框架是否值得大规模推广。 本期开始,我们推出《RSocket 从入门到落地》系列文章,通过实例和对比来介绍RSocket。主要围绕RSocket如何实现Polyglot RPC、Service Registry、 Service Discovery、 IoT联结等维度,为读者们揭开RSocket的面纱,希望对大家在Java API规范的技术选型过程中有所借鉴。 第一篇文章我们将通过Servlet和RSocket的对比,快速了解RSocket的一些基本知识。要说明的是其实RSocket与Servlet并不是同类的产品,但是大家对Servlet都很熟悉,功能对比相对方便一些。 阅读本系列文章,需要大家对Java有了解,其中可能会涉及到Kotlin,有少部分C++和Python(不做

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

用户登录
用户注册
修改密码
忘记密码