为什么Kafka Streams应用程序在Windows上因AccessDeniedException失败而无法进行状态清理?

时间:2019-01-24 14:17:11

标签: apache-kafka apache-kafka-streams

此处在MS Windows上提供Kafka Streams 2.1.0。

我使用的是macOS,因此无法自己进行操作,但是在与使用MS Windows的用户一起工作时,他们每次在Kafka Streams应用程序中使用KafkaStreams.cleanUp时报告java.nio.file.AccessDeniedException启动应用程序(第一次除外)。

Deleting topics throws exception #196中,有人问为什么运行java.nio.file.AccessDeniedException时Kafka Streams应用程序会因EmbeddedSingleNodeKafkaCluster#deleteTopicsAndWait而失败。

Caused by: java.nio.file.AccessDeniedException: C:\Users\gwade\AppData\Local\Temp\junit6747789160683566966\junit5490786451417386230\topic-0 -> C:\Users\gwade\AppData\Local\Temp\junit6747789160683566966\junit5490786451417386230\topic-0.a3c80cfca5e740bd8c1be434d817af2c-delete
        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
        at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387)
        at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
        at java.nio.file.Files.move(Files.java:1395)
        at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:809)
        at kafka.log.Log$$anonfun$renameDir$1.apply$mcV$sp(Log.scala:728)
        at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:726)
        at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:726)
        at kafka.log.Log.maybeHandleIOException(Log.scala:1927)
        at kafka.log.Log.renameDir(Log.scala:726)
        at kafka.log.LogManager.asyncDelete(LogManager.scala:842)
        at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:353)
        at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:251)
        at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:259)
        at kafka.cluster.Partition.delete(Partition.scala:347)
        at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:350)
        at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:380)
        at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:378)
        at scala.collection.Iterator$class.foreach(Iterator.scala:893)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:378)
        at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:200)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:111)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
        at java.lang.Thread.run(Thread.java:748)

你知道根本原因是什么吗?

1 个答案:

答案 0 :(得分:0)

一种解决方法是关闭Zookeeper并删除/tmp/zookeeper(这只是删除了Kafka集群的整个状态,包括要删除的主题及其在代理上的本地目录)。