当前位置: 首页 > news >正文

建设工程网站有哪些分销电商

建设工程网站有哪些,分销电商,网站建设规划书万能,一手房发帖网站怎样做Sentinel 实时监控仅存储 5 分钟以内的数据#xff0c;如果需要持久化#xff0c;需要通过调用实时监控接口来定制#xff0c;即自行扩展实现 MetricsRepository 接口#xff08;修改 控制台源码#xff09;。 本文通过使用Mysql持久化监控数据。 1.构建存储表#xff08…Sentinel 实时监控仅存储 5 分钟以内的数据如果需要持久化需要通过调用实时监控接口来定制即自行扩展实现 MetricsRepository 接口修改 控制台源码。 本文通过使用Mysql持久化监控数据。 1.构建存储表mysql CREATE TABLE sentinel_metric (id INT NOT NULL AUTO_INCREMENT COMMENT id主键,gmt_create DATETIME COMMENT 创建时间,gmt_modified DATETIME COMMENT 修改时间,app VARCHAR(100) COMMENT 应用名称,timestamp DATETIME COMMENT 统计时间,resource VARCHAR(500) COMMENT 资源名称,pass_qps INT COMMENT 通过qps,success_qps INT COMMENT 成功qps,block_qps INT COMMENT 限流qps拒绝的qps,exception_qps INT COMMENT 发送异常的次数,rt DOUBLE COMMENT 所有successQps的rt的和,单位ms; 控制台响应时间(平均响应时间)rt/success_qps,count INT COMMENT 本次聚合的总条数: 集群的服务数量,resource_code INT COMMENT 资源的hashCode,INDEX app_idx(app) USING BTREE,INDEX timestamp_idx(timestamp) USING BTREE,PRIMARY KEY (id) ) ENGINEINNODB DEFAULT CHARSETutf8; 2.修改控制台源码 2.1 添加Maven依赖 !-- mysql db --dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion8.0.25/version/dependencydependencygroupIdcom.baomidou/groupIdartifactIdmybatis-plus-boot-starter/artifactIdversion3.5.1/version/dependency 2.2 修改配置文件 spring.datasource.urljdbc:mysql://127.0.0.1:3306/xx?useUnicodetruecharacterEncodingUTF-8 spring.datasource.usernamexx spring.datasource.passwordxxxxx spring.datasource.driver-classcom.mysql.cj.jdbc.Driver2.3 逆向代码生成(新增) 参考Springboot入门之Mybatis逆向工程_Ocean上源码的博客-CSDN博客 package com.alibaba.csp.sentinel.dashboard.metric.dao;import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName;import java.util.Date;TableName(sentinel_metric) public class Metric {/*** 主键ID*/TableId(value id, type IdType.INPUT)private Long id;/*** 创建时间*/TableField(gmt_create)private Date gmtCreate;/*** 修改时间*/TableField(gmt_modified)private Date gmtModified;/*** 应用名称*/private String app;/*** 监控信息的时间戳*/private Date timestamp;/*** 资源名*/private String resource;/*** 通过qps*/TableField(pass_qps)private Long passQps;/*** 成功qps*/TableField(success_qps)private Long successQps;/*** 限流qps*/TableField(block_qps)private Long blockQps;/*** 异常qps*/TableField(exception_qps)private Long exceptionQps;/*** 所有successQps的rt的和*/private Double rt;/*** 本次聚合的总条数*/private Integer count;/*** 资源的hashCode*/TableField(resource_code)private Integer resourceCode;public Metric(MetricEntity metric) {this.id metric.getId();this.gmtCreate metric.getGmtCreate();this.gmtModified metric.getGmtModified();this.app metric.getApp();this.timestamp metric.getTimestamp();this.resource metric.getResource();this.passQps metric.getPassQps();this.successQps metric.getSuccessQps();this.blockQps metric.getBlockQps();this.exceptionQps metric.getExceptionQps();this.rt metric.getRt();this.count metric.getCount();this.resourceCode metric.getResourceCode();}public Metric() {}public Long getId() {return id;}public void setId(Long id) {this.id id;}public Date getGmtCreate() {return gmtCreate;}public void setGmtCreate(Date gmtCreate) {this.gmtCreate gmtCreate;}public Date getGmtModified() {return gmtModified;}public void setGmtModified(Date gmtModified) {this.gmtModified gmtModified;}public String getApp() {return app;}public void setApp(String app) {this.app app;}public Date getTimestamp() {return timestamp;}public void setTimestamp(Date timestamp) {this.timestamp timestamp;}public String getResource() {return resource;}public void setResource(String resource) {this.resource resource;}public Long getPassQps() {return passQps;}public void setPassQps(Long passQps) {this.passQps passQps;}public Long getSuccessQps() {return successQps;}public void setSuccessQps(Long successQps) {this.successQps successQps;}public Long getBlockQps() {return blockQps;}public void setBlockQps(Long blockQps) {this.blockQps blockQps;}public Long getExceptionQps() {return exceptionQps;}public void setExceptionQps(Long exceptionQps) {this.exceptionQps exceptionQps;}public Double getRt() {return rt;}public void setRt(Double rt) {this.rt rt;}public Integer getCount() {return count;}public void setCount(Integer count) {this.count count;}public Integer getResourceCode() {return resourceCode;}public void setResourceCode(Integer resourceCode) {this.resourceCode resourceCode;}Overridepublic String toString() {return SentinelMetricsEntity{ id id , gmtCreate gmtCreate , gmtModified gmtModified , app app \ , timestamp timestamp , resource resource \ , passQps passQps , successQps successQps , blockQps blockQps , exceptionQps exceptionQps , rt rt , count count , resourceCode resourceCode };}}package com.alibaba.csp.sentinel.dashboard.metric.dao;import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper;Mapper public interface MetricMapper extends BaseMapperMetric {}package com.alibaba.csp.sentinel.dashboard.metric.service;import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; import com.alibaba.csp.sentinel.dashboard.metric.dao.Metric; import com.baomidou.mybatisplus.extension.service.IService;import java.util.Collection; import java.util.List;/*** p* 服务类* /p** author ocean* since 2023-05-21*/ public interface MetricService extends IServiceMetric {ListString listResourcesOfApp(String app);ListMetricEntity queryByAppAndResourceBetween(String app, String resource, Long startTime, Long endTime);void saveAll(IterableMetricEntity metrics);}package com.alibaba.csp.sentinel.dashboard.metric.service.impl;import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; import com.alibaba.csp.sentinel.dashboard.metric.dao.Metric; import com.alibaba.csp.sentinel.dashboard.metric.dao.MetricMapper; import com.alibaba.csp.sentinel.dashboard.metric.service.MetricService; import com.alibaba.csp.sentinel.util.StringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; import org.springframework.stereotype.Service;import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.stream.Collectors;Service public class MetricServiceImpl extends ServiceImplMetricMapper, Metric implements MetricService {private final ReentrantReadWriteLock readWriteLock new ReentrantReadWriteLock();Overridepublic void saveAll(IterableMetricEntity metrics) {if (metrics null) {return;}readWriteLock.writeLock().lock();try {ListMetric metricList Lists.newArrayList();metrics.forEach(data - {metricList.add(new Metric(data));});this.saveBatch(metricList);} finally {readWriteLock.writeLock().unlock();}}Overridepublic ListString listResourcesOfApp(String app) {ListString results new ArrayList();if (StringUtil.isBlank(app)) {return results;}readWriteLock.readLock().lock();try {LambdaQueryWrapperMetric metricLambdaQueryWrapper Wrappers.lambdaQuery(Metric.class).eq(Metric::getApp, app).orderByAsc(Metric::getTimestamp);return this.list(metricLambdaQueryWrapper).stream().map(Metric::getResource).collect(Collectors.toList());} finally {readWriteLock.readLock().unlock();}}Overridepublic ListMetricEntity queryByAppAndResourceBetween(String app, String resource, Long startTime, Long endTime) {ListMetricEntity results new ArrayList();if (StringUtil.isBlank(app)) {return results;}readWriteLock.readLock().lock();try {LambdaQueryWrapperMetric metricLambdaQueryWrapper Wrappers.lambdaQuery(Metric.class).eq(Metric::getApp, app).eq(Metric::getResource, resource).ge(Metric::getTimestamp, new Date(startTime)).le(Metric::getTimestamp, new Date(endTime)).orderByAsc(Metric::getTimestamp);ListMetric metricList this.list(metricLambdaQueryWrapper);return metricList.stream().map(MetricEntity::new).collect(Collectors.toList());} finally {readWriteLock.readLock().unlock();}} }2.4 修改源码 2.4.1 MetricController 修改统计时长修改如下标记处代码  2.4.2 MetricFetcher 3. 验证查询数据库
http://www.pierceye.com/news/469901/

相关文章:

  • 企业网站建设制作大连网站建设吗
  • 做网页兼职网站有哪些建设网站需要花费
  • 如何快速写一个网站黄页网络的推广软件下载
  • 网站建设公司注册enfold wordpress
  • 上海网站建设百度推广公司哪家好模具厂咋做网站
  • 网站背景自动切换织梦网站模板使用教程
  • 网站建设的成果怎么写找人做淘宝网站需要多少钱
  • 网站制作 企业网站建设哪家好tiktok海外运营推广
  • 南昌做网站哪个公司好玉溪市住房和城乡建设局网站
  • 男女做暖网站是什么样子的wordpress 时间轴 主题
  • 国外建设网站jsp网站开发工具
  • 网站流量怎么赚钱wordpress 08影院模板
  • win网站建设网站哪个公司做的好
  • 温州网站运营微信公众号服务号网站开发流程
  • 网站宣传的好处山西房地产网站建设
  • 网站seo工作内容大学做视频网站
  • 台州网站建设企业网站 微信开发
  • 安徽省水利厅网站 基本建设营销策划公司名称
  • 网页设计师培训学院开封做网站优化
  • 山西电力建设三公司网站影院禁止18岁以下观众观影
  • 防伪网站模板网站开发怎么赚钱
  • 医院网站建设意义推广咨询
  • 广东省54个市win10最强优化软件
  • 交换链接网站asp.net企业网站框架
  • 惠州网站建设制作推广医疗设备响应式网站
  • 有哪些做ppt的网站cms网站开发涉及的知识
  • 软件开发成本估算表苏州百度seo代理
  • 网站内部链接有什么作用临安做企业网站的公司
  • 整合营销网站网站建设销售话术开场白
  • 永久免费wap自助建站北京家装设计师排名