Hadoop - LeaseExpiredException(Hadoop - LeaseExpiredException)
我有多个压缩文件,每个压缩文件包含8 xml大小为5-10kb的文件。 我将这些数据用于测试目的,否则实时数据有1000个xml文件。 我写了map only程序来解压缩压缩文件
for(FileStatus status : status_list){ this.unzip(status.getPath().toString() , DestPath, fs); }
此方法将创建文件并读取未压缩的数据
FSDataOutputStream out = fs.create(new Path(filePath)); byte[] bytesIn = new byte[BUFFER_SIZE]; int read = 0; while ((read = zipIn.read(bytesIn)) != -1) { out.write(bytesIn, 0, read); } out.flush(); out.close();
当mapper尝试编写每个不同名称的多个文件时,hadoop返回
LeaseExpiredException.
15/09/26 19:53:46 INFO mapreduce.Job: Task Id : attempt_1443265405944_0005_m_000000_0, Status : FAILED Error: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException): No lease on /test_poc/x/injection_00001 (163rd copy).xml (inode 400006): File does not exist. [Lease. Holder: DFSClient_attempt_1443265405944_0005_m_000000_0_-657768289_1, pendingcreates: 1] at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkLease(FSNamesystem.java:3431) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.analyzeFileState(FSNamesystem.java:3236) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNewBlockTargets(FSNamesystem.java:3074) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:3034) at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.addBlock(NameNodeRpcServer.java:723) at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.addBlock(ClientNamenodeProtocolServerSideTranslatorPB.java:492) at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java) at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:616) at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:969) at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2049) at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2045) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657) at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2043) at org.apache.hadoop.ipc.Client.call(Client.java:1476) at org.apache.hadoop.ipc.Client.call(Client.java:1407) at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:229) at com.sun.proxy.$Proxy12.addBlock(Unknown Source) at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.addBlock(ClientNamenodeProtocolTranslatorPB.java:418) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102) at com.sun.proxy.$Proxy13.addBlock(Unknown Source) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.locateFollowingBlock(DFSOutputStream.java:1430) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1226) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:449)
我不知道如何在不使用循环的情况下处理多个压缩文件。
I wrote map reduce program using MR2 API and using Hadoop 2.7.1 in psuedo distributed mode
。 任何指针?I have multiple compressed files and each compressed file contains 8 xml files of size 5-10kb. I took this data for testing purpose otherwise live data has 1000s of xml files. I wrote map only program to uncompress the compressed file
for(FileStatus status : status_list){ this.unzip(status.getPath().toString() , DestPath, fs); }
This method will create file and read uncompressed data
FSDataOutputStream out = fs.create(new Path(filePath)); byte[] bytesIn = new byte[BUFFER_SIZE]; int read = 0; while ((read = zipIn.read(bytesIn)) != -1) { out.write(bytesIn, 0, read); } out.flush(); out.close();
When mapper tried to write multiple files each of different name, hadoop returns
LeaseExpiredException.
15/09/26 19:53:46 INFO mapreduce.Job: Task Id : attempt_1443265405944_0005_m_000000_0, Status : FAILED Error: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException): No lease on /test_poc/x/injection_00001 (163rd copy).xml (inode 400006): File does not exist. [Lease. Holder: DFSClient_attempt_1443265405944_0005_m_000000_0_-657768289_1, pendingcreates: 1] at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkLease(FSNamesystem.java:3431) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.analyzeFileState(FSNamesystem.java:3236) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNewBlockTargets(FSNamesystem.java:3074) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:3034) at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.addBlock(NameNodeRpcServer.java:723) at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.addBlock(ClientNamenodeProtocolServerSideTranslatorPB.java:492) at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java) at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:616) at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:969) at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2049) at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2045) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657) at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2043) at org.apache.hadoop.ipc.Client.call(Client.java:1476) at org.apache.hadoop.ipc.Client.call(Client.java:1407) at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:229) at com.sun.proxy.$Proxy12.addBlock(Unknown Source) at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.addBlock(ClientNamenodeProtocolTranslatorPB.java:418) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102) at com.sun.proxy.$Proxy13.addBlock(Unknown Source) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.locateFollowingBlock(DFSOutputStream.java:1430) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1226) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:449)
I don't know how to handle multiple compressed files without using the loop.
I wrote map reduce program using MR2 API and using Hadoop 2.7.1 in psuedo distributed mode
. Any pointers?
原文:https://stackoverflow.com/questions/32799677
最满意答案
这似乎工作:
type Conversions = Conversions with static member ($) (Conversions, value: int) = value.ToString() static member ($) (Conversions, value: bool) = value.ToString() let inline conv value = Conversions $ value conv 1 |> ignore conv true |> ignore conv "foo" |> ignore //won't compile
This seems to work:
type Conversions = Conversions with static member ($) (Conversions, value: int) = value.ToString() static member ($) (Conversions, value: bool) = value.ToString() let inline conv value = Conversions $ value conv 1 |> ignore conv true |> ignore conv "foo" |> ignore //won't compile
相关问答
更多-
你的方法对我来说似乎是正确的 你的代码不能编译的原因是因为F#类型推断是推断类型变量'T的静态约束(编译时),它与类型定义相同。 类型定义的泛型参数不能静态解析(没有“帽子”类型),但是没有什么能阻止你定义一个使用这些编译时间约束的函数或成员。 只需在静态成员(+)定义中将您的类型变量'T 'U更改为'U 。 尽管如此,你仍然可以创建一个不支持(+)的类型的TimeSeries实例(即: TimeSeries
),但你将无法使用(+)作为这些实例,无论如何,如果你这样做在编译时会得到一个很好的错误 ... -
在F#中使用`inline`(Use of `inline` in F#)[2024-02-17]
inline关键字表示函数定义应该插入任何使用它的代码。 大多数时候,这不会对函数的类型有任何影响。 然而,在极少数情况下,它可以导致具有更一般类型的函数,因为存在不能用.NET中的代码编译形式表达的约束,但是当函数内联时可以强制执行。 适用的主要情况是运营商的使用。 let add a b = a + b 将会有一个单一的推断类型(大概是int -> int -> int ,但是如果你有这个代码使用这个函数的代码,那么它可能是float -> float -> float )。 但是,通过内联标记这个函 ... -
这里有几个其他的选项可以帮助你更好地理解这类问题: let A = [| [| [|"1";"Albert"|];[|"2";"Ben"|] |];[| [|"1";"Albert"|];[|"3";"Carl"|] |] |] //Matthew's answer //This is exactly what you were asking for. //It takes all the subarrays and combines them into one A |> Array.concat ...
-
F#枚举到字符串转换(F# enum to string conversion)[2023-08-26]
首先,正如几位人士在评论中提到的那样,你定义的类型不是枚举 ,而是一个歧视联盟。 枚举实际上只是一个赋予整数的标签,而在F#中,则使用以下语法声明: type DataType = |Auction = 1 |Transaction = 2 使用这种语法,您已经获得了该值和相关整数之间的关系,您可以使用该整数来获取Enumeration的值,例如 let transaction = enum(2) // Transaction 请注意,即使我们没有定义这种情况,也没 ... -
了解F#内联和静态解析的类型参数:F#强制示例(Understanding F# inline & statically resolved type parameters: F# casting example)[2022-02-08]
这是不可能的,但它与静态成员约束无关。 由于同样的原因,使用正常的通用约束同样注定要失败: // doesn't work let myUpcast<'a, 'b when 'a :> 'b) (x: 'a) : 'b = unbox (box x) 基本上F#不允许涉及两个不同类型参数的类型约束; 他们总是被限制在平等。 有关更多评论,请参阅我对如何将一个类型参数约束另一个类型参数的回答。 This isn't possible, but it's unrelated to static member ... -
int函数有什么问题? let someString = "123" let someInt = someString |> int // someInt now contains 123 int value Try built-in int function. let someString = "123" let someInt = someString |> int // someInt now contains 123 int value
-
这似乎工作: type Conversions = Conversions with static member ($) (Conversions, value: int) = value.ToString() static member ($) (Conversions, value: bool) = value.ToString() let inline conv value = Conversions $ value conv 1 |> ignore conv true |> i ...
-
正如你注意到的那样,F#把字符序列看作是一个中缀运算符,所以你需要用空格分隔它们。 至于什么时候需要明确指定约束的问题,我相信规则是当你明确地给出一个函数类型参数时,你还需要指定任何必要的约束。 否则,如果F#可以推断出类型参数和约束,则不需要指定它们。 所以你的问题的这个例子工作正常: let inline bar() :^a = (^a : (static member Bar : unit -> ^a)()) 如下所示: let inline bar(x : ^a) = (^a : (sta ...
-
我肯定会看看FSLex 。 FSYacc , FParsec 。 但是,如果您只想标记化seq
,则可以使用序列表达式以正确的顺序生成标记。 重用你的递归内部函数的想法,并结合序列表达式,我们可以保持尾递归,如下所示,并避免像可变数据结构这样的非惯用工具。 我更改了分隔符char以便于调试和函数的签名。 这个版本产生了一个seq (你的标记)作为结果,它可能比使用当前标记和文本其余部分的元组更容易消费。 如果你只想要第一个令牌,你就可以领先一步。 请注意,序列是“按需”生成的,即 ... -
从F#中的字符串中去除字符(Stripping chars from string in F#)[2021-03-08]
正如Guy Coder在上面的评论中指出的那样,函数体具有非正统的格式。 如果将累加器函数提取到内部嵌套函数,它可能更具可读性: let stripchars chars str = let removeOneChar (str : string) chr = str.Replace(chr |> Char.ToUpper |> string, "").Replace(chr |> Char.ToLower |> string, "") Seq.fold removeOneC ...