我的目标是让我自己设置HDFS的副本块的位置节点。 看了HDFS的代码后,我在这里找到了通话轨道(hadoop 2.2版本)
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Next Action"message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
UIWebView *webView = [[UIWebView alloc] init];
[webView setFrame:CGRectMake(0,0,300,300)];
[webView loadHTMLString:[@"https://app.acuityscheduling.com/schedule.php?owner=11673736" description] baseURL:nil];
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
[view addSubview:webView];
[alert setValue:view forKey:@"accessoryView"];
[alert show];
我发现BlockManager.java有一个BlockManager.getDatanodeDescriptors(List<String>) line: 1400
BlockManager.chooseTarget(String, int, DatanodeDescriptor, HashMap<Node,Node>, long, List<String>) line: 1378
FSNamesystem.getAdditionalBlock(String, long, String, ExtendedBlock, HashMap<Node,Node>, List<String>) line: 2477
NameNodeRpcServer.addBlock(String, String, ExtendedBlock, DatanodeInfo[], long, String[]) line: 555
ClientNamenodeProtocolServerSideTranslatorPB.addBlock(RpcController, ClientNamenodeProtocolProtos$AddBlockRequestProto) line: 387
ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(Descriptors$MethodDescriptor, RpcController, Message) line: 59582
ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(RPC$Server, String, Writable, long) line: 585
ProtobufRpcEngine$Server(RPC$Server).call(RPC$RpcKind, String, Writable, long) line: 928
方法:
chooseTarget
我想如果我可以设置 public DatanodeDescriptor[] chooseTarget(final String src,
final int numOfReplicas, final DatanodeDescriptor client,
final HashMap<Node, Node> excludedNodes,
final long blocksize, List<String> favoredNodes) throws IOException {
的值,那么我的目标就可以实现。
答案 0 :(得分:0)
我从DistributedFileSystem.java(hadoop 2.2版本)中找到了API
/**
* Same as
* {@link #create(Path, FsPermission, boolean, int, short, long,
* Progressable)} with the addition of favoredNodes that is a hint to
* where the namenode should place the file blocks.
* The favored nodes hint is not persisted in HDFS. Hence it may be honored
* at the creation time only. HDFS could move the blocks during balancing or
* replication, to move the blocks from favored nodes. A value of null means
* no favored nodes for this create
*/
public HdfsDataOutputStream create(final Path f,
final FsPermission permission, final boolean overwrite,
final int bufferSize, final short replication, final long blockSize,
final Progressable progress, final InetSocketAddress[] favoredNodes)
throws IOException {