Skip to main content

在linux中通过启用swapfile来增加虚拟内存并提高性能

· One min read
orange
programmer on jvm platform

swapfilelinux中的一种虚拟内存, 与windows中的pagefile类似.
swapfile的作用是当RAM不足时, 将一部分RAM中的数据写入到swapfile中, 从而释放出RAM的空间.
例如, 平时使用浏览器时会开启页面, 这些页面通常会占用一定的RAM空间.
如果开启了太多的页面, 会导致RAM不足, 这时就需要将一部分页面的数据写入到swapfile中, 从而释放出RAM的空间

在TestContainers中实现配置的容器hostname以解决容器之间访问问题

· One min read
orange
programmer on jvm platform

在使用TestContainers启动容器时, 可能会存在容器之间依赖的情况.
如果其中一个容器依赖于另外一个容器, 那么需要在启动被依赖的容器时, 指定hostname.
这样有依赖需求的容器可以直接通过hostname来访问被依赖的容器.
以便于被依赖的容器能够正确的解析依赖容器的hostname. 下面将介绍如何在TestContainers中实现配置的容器hostname以解决容器之间访问问题.

跳过SSH连接时的确认提示

· 2 min read
orange
programmer on jvm platform

平时在写一些脚本的时候, 需要频繁地连接在云上新创建的机器.
在ssh中第一次连接时, 会输出如下提示.

RSA key fingerprint is 96:a9:23:5c:cc:d1:0a:d4:70:22:93:e9:9e:1e:74:2f.
Are you sure you want to continue connecting (yes/no)? yes

这样会导致每次都需要输入yes来确认是否连接.
因为脚本不可以交互, 会导致脚本卡在这一步无法执行后续的操作.
因此需要跳过这一步的确认.

使用pyenv实现python多版本管理

· 3 min read
orange
programmer on jvm platform

pyenv是一个python版本管理工具, 可以方便的管理多个python版本.
对于开发者来说有的时候会有多个python版本的需求.
例如, 有的项目需要python3.6, 有的项目需要python3.7. 这个时候就需要使用pyenv来管理多个python版本.
目前市面上有很多python版本管理工具, 例如pyenv, conda等.
pyenv是一个轻量级的工具, 但是功能也很强大, 适合于开发者使用.
下面将以python3.11.0为例介绍如何使用pyenv来管理多个python版本

JDK改进项目的介绍

· 2 min read
orange
programmer on jvm platform

以下列表是截至到目前Open JDK中部分进行的对JDK的改进项目

  • Amber
  • Galahad
  • Leyden
  • Lilliput
  • Loom
  • Panama
  • Valhalla

这些改进项目的主要目的是为了改进Java的性能和开发体验. 从而使Java能够更好地适应目前的软件开发需求.
以下是这些项目的简单介绍.

在TestContainers中实现Docker registry认证

· 2 min read
orange
programmer on jvm platform

docker registry配置了认证后, 项目中CICD中运行的test case失败, 错误日志如下

Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=hub.fastonetech.com/cce/fastone-auditing:latest, imagePullPolicy=AlwaysPullPolicy(), imageNameSubstitutor=org.testcontainers.utility.ImageNameSubstitutor$LogWrappedImageNameSubstitutor@3b68a50c)
at app//org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1371)
at app//org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:651)
at app//org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
... 153 more
Caused by: org.testcontainers.containers.ContainerFetchException: Failed to pull image: hub.fastonetech.com/cce/fastone-auditing:latest
at app//org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:119)
at app//org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:28)
at app//org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:17)
at app//org.testcontainers.utility.LazyFuture.get(LazyFuture.java:39)
at app//org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1369)
... 155 more
Caused by: com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"unauthorized: unauthorized to access repository: cce/fastone-auditing, action: pull: unauthorized to access repository: cce/fastone-auditing, action: pull"}

at app//org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:247)
at app//org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
at java.base@17.0.1/java.lang.Thread.run(Thread.java:833)