目前我有这段代码,我想使用内置的 Spring 功能。我将 @Async 用于一个我不关心它何时完成的方法。有没有办法使用它,但要等到池中的线程完成?
Runnable thread = () -> {
for (String date : dates) {
Path dir = Paths.get(primaryDisk, partition, folder, date);
File tmp = dir.toFile();
deleteDir(tmp);
}
};
executor.submit(thread);
Run Code Online (Sandbox Code Playgroud)
稍后在函数中我使用以下代码等待它们完成。
executor.shutdown();
try {
executor.awaitTermination(5, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud) 我试图找出 kubernetes 主副本集中允许整个集群正常运行的 kubernetes 主节点的最小数量。他们的官方文档提到您需要三个主节点中的一个。
当您失去 3 个主节点中的 1 个时会发生什么?您可以在丢失副本集中的两个主节点的情况下让集群正常运行吗?
我正在尝试在 Kubernetes 中部署 redis 哨兵部署。我已经完成了这一点,但希望使用 ConfigMaps 来允许我们更改 sentinel.conf 文件中主服务器的 IP 地址。我启动了此操作,但 Redis 无法写入配置文件,因为 configMap 的挂载点是只读的。
我希望运行一个 init 容器并将 redis conf 复制到 pod 中的另一个目录。但是init容器找不到conf文件。
我有什么选择?初始化容器?除了 ConfigMap 之外还有什么?
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: redis-sentinel
spec:
replicas: 3
template:
metadata:
labels:
app: redis-sentinel
spec:
hostNetwork: true
containers:
- name: redis-sentinel
image: IP/redis-sentinel
ports:
- containerPort: 63790
- containerPort: 26379
volumeMounts:
- mountPath: /redis-master-data
name: data
- mountPath: /usr/local/etc/redis/conf
name: config
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: sentinel-redis-config …Run Code Online (Sandbox Code Playgroud) kubernetes ×2
asynchronous ×1
configmap ×1
docker ×1
java ×1
redis ×1
spring ×1
spring-boot ×1