我们正在尝试从NiFi缓存中检索密钥,该密钥被频繁使用并且具有大量条目。但是我们遇到了错误
java -jar groovy-all-2.4.13.jar dcache.groovy xxxxxxx.systems.xx.xxxx 9999 keys | wc -l
Caught: java.io.EOFException
java.io.EOFException
at java_io_DataInput$readInt.call(Unknown Source)
at dcache$_run_closure1$_closure5.doCall(dcache.groovy:141)
at dcache$_run_closure1.doCall(dcache.groovy:140)
at dcache.run(dcache.groovy:44)
5097
我们不熟悉groovy。但是,此命令可与条目较少且不经常使用的另一个缓存一起使用。这是我们正在使用的代码
def dos = new DataOutputStream(output)
def dis = new DataInputStream(input)
dos.writeUTF('keySet')
dos.flush()
int numKeys = dis.readInt()
(0..numKeys-1).each {
def length = dis.readInt()
def bytes = new byte[length]
dis.readFully(bytes)
println new String(bytes)
}