小编Ank*_*sal的帖子

Spring Boot 2执行器指标

是否有任何有关Spring Boot 2指标的参考详细文档。

我的意思是

{
  "names": [
    "jvm.memory.max",
    "http.server.requests",
    "process.files.max",
    "jvm.gc.memory.promoted",
    "tomcat.cache.hit",
    "rabbitmq.channels",
    "system.load.average.1m",
    "tomcat.cache.access",
    "jvm.memory.used",
    "jvm.gc.max.data.size",
    "jdbc.connections.max",
    "jdbc.connections.min",
    "jvm.gc.pause",
    "jvm.memory.committed",
    "system.cpu.count",
    "logback.events",
    "rabbitmq.connections",
    "tomcat.global.sent",
    "jvm.buffer.memory.used",
    "tomcat.sessions.created",
    "jvm.threads.daemon",
    "system.cpu.usage",
    "jvm.gc.memory.allocated",
    "tomcat.global.request.max",
    "hikaricp.connections.idle",
    "hikaricp.connections.pending",
    "tomcat.global.request",
    "rabbitmq.rejected",
    "tomcat.sessions.expired",
    "hikaricp.connections",
    "jvm.threads.live",
    "jvm.threads.peak",
    "tomcat.global.received",
    "hikaricp.connections.active",
    "hikaricp.connections.creation",
    "process.uptime",
    "tomcat.sessions.rejected",
    "process.cpu.usage",
    "tomcat.threads.config.max",
    "jvm.classes.loaded",
    "hikaricp.connections.max",
    "hikaricp.connections.min",
    "rabbitmq.consumed",
    "jvm.classes.unloaded",
    "tomcat.global.error",
    "tomcat.sessions.active.current",
    "tomcat.sessions.alive.max",
    "jvm.gc.live.data.size",
    "tomcat.servlet.request.max",
    "hikaricp.connections.usage",
    "tomcat.threads.current",
    "tomcat.servlet.request",
    "hikaricp.connections.timeout",
    "process.files.open",
    "jvm.buffer.count",
    "jvm.buffer.total.capacity",
    "tomcat.sessions.active.max",
    "hikaricp.connections.acquire",
    "tomcat.threads.busy",
    "rabbitmq.published",
    "process.start.time",
    "tomcat.servlet.error",
    "rabbitmq.acknowledged"
  ]
}
Run Code Online (Sandbox Code Playgroud)
  • 我应该使用哪些指标来衡量内存/ GC / CPU使用率。值也代表什么。

  • 同样在Spring Boot 1.5.x中,我可以简单地获取使用过的堆,已提交的堆,gc计数等。如何获得这些值?

还有一种方法可以让我一次调用所有指标。我的意思是要获取所有指标,我现在需要在引导2中调用许多点击仪式。

java spring-boot-actuator micrometer

4
推荐指数
1
解决办法
5104
查看次数

ELK Stack on微服务架构

您好,我试图在微服务架构中使用ELK堆栈,该架构具有分布在许多服务器上的大量服务。

现在,我已经配置了Kibana和ElasticSearch。现在我的疑问是我必须在哪里安装Logstash。我的意思是说有三个不同的服务器A,B和C,所有服务器都有3个服务。现在总共有9个服务,我想使用ELK Stack捕获其日志。

但是我的问题是我必须在每个不同的服务器上安装Logstash并将已解析的日志发送到Elastic还是我可以在单个服务器上安装Logstash并指定远程输入。

我还需要使用Filebeat吗?

elastic-stack

3
推荐指数
1
解决办法
1216
查看次数

Spring Webflux弹性线程中获取Request对象

我面临一个问题。我正在使用 Spring Webflux 并行调用一些 API。如果任何子线程遇到任何问题,它需要记录请求。现在的问题是,为了记录一个普通的 POJO 类,其中有一个静态方法可以通过 ApplicationContent 获取 bean 并将数据存储在队列中。

现在的问题是,我想访问请求参数,例如请求 URL / 控制器等。我尝试过

ServletRequestAttributes sra = 
        (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
                    logger.error("====="+sra);
                    HttpServletRequest httpRequest = sra.getRequest();
Run Code Online (Sandbox Code Playgroud)

但在这种情况下,sra为空。我尝试添加以下代码,

@Configuration
public class InheritableRequestContextListener extends RequestContextListener {
    private static final String REQUEST_ATTRIBUTES_ATTRIBUTE =
        InheritableRequestContextListener.class.getName() + ".REQUEST_ATTRIBUTES";

    @Override
    public void requestInitialized(ServletRequestEvent requestEvent) {
        System.out.println("111111111111111111");
        if (!(requestEvent.getServletRequest() instanceof HttpServletRequest)) {
            throw new IllegalArgumentException(
                    "Request is not an HttpServletRequest: " + requestEvent.getServletRequest());
        }
        HttpServletRequest request = (HttpServletRequest) requestEvent.getServletRequest();
        ServletRequestAttributes attributes = new ServletRequestAttributes(request);
        request.setAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE, attributes);
        LocaleContextHolder.setLocale(request.getLocale()); …
Run Code Online (Sandbox Code Playgroud)

requestcontext spring-webflux

3
推荐指数
1
解决办法
2409
查看次数

使用配置类时的Spring自动装配

我有一个xml bean文件

<?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:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">
   <context:annotation-config/>
   <bean id="helloWorld" class="com.a.b.HelloWorld"> 
         <property name="attr1" value="Attr1 from XML"></property>
   </bean>
    <bean id="helloWorld2" class="com.a.b.HelloWorld2">
        <property name="attr2" value="Attr2 from XML"></property>
    </bean>
</beans>
Run Code Online (Sandbox Code Playgroud)

我使用像这样的构造函数自动装配

public class HelloWorld2{
       private String attr2;
       public void setAttr2(String message){
          this.attr2  = message;
       }

       public void getAttr2(){
          System.out.println("getAttr2 == " + attr2);
       }


    }

public class HelloWorld{
       private String attr1;
       private HelloWorld2 helloWorld2;    
       public HelloWorld(){

       }
       @Autowired
       public HelloWorld(HelloWorld2 helloWorld2){
           System.out.println("hhh");
           this.helloWorld2 = helloWorld2;
       }


    public …
Run Code Online (Sandbox Code Playgroud)

java spring autowired

2
推荐指数
1
解决办法
2197
查看次数

模拟投影结果Spring Data JPA

我在我的spring boot项目中使用spring data jpa。

我正在触发JPQL查询,并使用投影来存储查询结果。我的投影:

public interface VeryBasicProjection {
    String getTitle();
    String getUrl();
}
Run Code Online (Sandbox Code Playgroud)

我的服务称为此投影:

public List<VeryBasicDTO> getLatestData(int limit){

        // Pageable for Limit
        Pageable pageable = new PageRequest(0, limit);

        // Get Data from DB
        List<VeryBasicProjection> latestData = tableRepository.getLatestData("live", 2,pageable);
        List<VeryBasicDTO> responseDTO = new ArrayList<>();

        // Map Projection to DTO
        for(VeryBasicProjection veryBasicProjection : latestData){
            VeryBasicDTO veryBasicDTO = new VeryBasicDTO();
            veryBasicDTO.buildDTO(veryBasicProjection);
            responseDTO.add(veryBasicDTO);
        }

        return responseDTO;
    }
Run Code Online (Sandbox Code Playgroud)

现在,我想使用Mockito(单元测试用例)测试此服务,我正在使用when和thenReturn模拟对存储库的调用。

我的问题是如何模拟存储库的结果?那么返回应该是什么?我的意思是如何创建投影实例和setData?

mockito spring-boot-test

2
推荐指数
4
解决办法
2121
查看次数

细分是solr

有人可以解释一下solr中的semgents是什么.

我没有在网上找到好的描述.

我还在solr中看过各种段文件?有什么用.如果我删除一个段文件会发生什么.会破坏指数吗?我使用solr 5.3(如果这有任何区别)

whar也是tlogs,有什么作用?

solr

1
推荐指数
1
解决办法
1405
查看次数

具有大型并发请求的Rxjava2 Schedulers.io()与Schedulers.computation()

我在春季启动中使用Rxjava2。

我在服务器上有500个并发请求。

每个请求产生10个线程,这些线程调用其他服务(因此IO工作)

因此,在这种情况下,我应该使用Schedulers.io()还是Schedulers.compuatation()

基本上,我的困惑是理想上io()应该使用的,因为这是IO工作,但这会创建大量线程吗?

还可以指定计算线程的池大小吗?还可以指定io线程的池大小吗?

rx-java2

1
推荐指数
1
解决办法
639
查看次数

Kafka Consumer轮询间隔

我有一个 Kafka 主题,并且已将 1 个消费者附加到它(主题只有 1 个分区)。现在对于超时,我使用默认值(心跳:3秒,会话超时:10秒,轮询超时:5分钟)。

根据文档,轮询超时定义消费者必须先处理消息,否则代理将从消费者组中删除该消费者。现在假设,消费者只需要1分钟就可以处理完消息。

现在我有两个问题

a) Now will it call poll only after 5 mins or it will call poll() as soon as it finishes processing. 
b) Also, suppose consumer is sitting idle for sometime, then what would be the frequency of polling i.e. at what interval consumer will poll the broker for message? Will it be poll timeout or something else?
Run Code Online (Sandbox Code Playgroud)

apache-kafka

1
推荐指数
1
解决办法
1万
查看次数

本地持久卷中的容量

我有一个存储类:

    kubectl describe storageclass my-local-storage

    Name:            my-local-storage
    IsDefaultClass:  No
    Annotations:     kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"my-local-storage"},"provisioner":"kubernetes.io/no-provisioner","volumeBindingMode":"WaitForFirstConsumer"}

    Provisioner:           kubernetes.io/no-provisioner
    Parameters:            <none>
    AllowVolumeExpansion:  <unset>
    MountOptions:          <none>
    ReclaimPolicy:         Delete
    VolumeBindingMode:     WaitForFirstConsumer
    Events:                <none>
Run Code Online (Sandbox Code Playgroud)

持久卷

kubectl describe pv my-local-pv
Name:              my-local-pv
Labels:            <none>
Annotations:       pv.kubernetes.io/bound-by-controller: yes
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      my-local-storage
Status:            Bound
Claim:             default/my-claim
Reclaim Policy:    Retain
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          1Mi
Node Affinity:     
  Required Terms:  
    Term 0:        kubernetes.io/hostname in [kubenode2]
Message:           
Source:
    Type:  LocalVolume (a persistent volume backed by local storage on a node)
    Path:  /home/node/serviceLogsNew …
Run Code Online (Sandbox Code Playgroud)

kubernetes

0
推荐指数
1
解决办法
467
查看次数

如何使用速率限制器/断路器(架构问题)

我们的微服务后端具有以下架构。

< Nginx> -----> <Facade Layer(built in JAVA/Springboot> -------Load Balancer(HAProxy) --- <Service Layer(built in JAVA/Springboot)>
Run Code Online (Sandbox Code Playgroud)

流量到达 Nginx,代理传递到 Facade,Facade 调用服务(通过负载均衡器)。我们没有使用服务发现。它是 Nginx 的 IP Facades/HAProxy 的服务 IPs 的静态映射。

现在我想使用速率限制器/断路器。我们应该在架构中的哪个点执行此操作?我的意思是我们应该再添加一跳还是其他什么?

我们计划为此使用resilience4j

rate-limiting circuit-breaker microservices

0
推荐指数
1
解决办法
2424
查看次数