try { IOStreamPair saslStreams = datanode.saslServer.receive(peer, socketOut, socketIn, datanode.getXferAddress().getPort(), datanode.getDatanodeId()); input = new BufferedInputStream(saslStreams.in,
private InetSocketAddress[] getDatanodes(Random rand) { //Get some unique random indexes int idx1 = rand.nextInt(NUM_DATA_NODES); int idx2; do { idx2 = rand.nextInt(NUM_DATA_NODES); } while (idx1 == idx2); int idx3; do { idx3 = rand.nextInt(NUM_DATA_NODES); } while (idx2 == idx3 || idx1 == idx3); InetSocketAddress[] addrs = new InetSocketAddress[3]; addrs[0] = datanodes.get(idx1).getXferAddress(); addrs[1] = datanodes.get(idx2).getXferAddress(); addrs[2] = datanodes.get(idx3).getXferAddress(); return addrs; }
private InetSocketAddress getArbitraryLocalHostAddr() throws UnknownHostException{ Random rand = new Random(System.currentTimeMillis()); int port = rand.nextInt(65535); while (true) { boolean conflict = false; for (DataNode d : datanodes) { if (d.getXferAddress().getPort() == port) { port = rand.nextInt(65535); conflict = true; } } if (conflict == false) { break; } } return new InetSocketAddress(InetAddress.getLocalHost(), port); } }
/** * Restart a datanode, on the same port if requested * @param dnprop the datanode to restart * @param keepPort whether to use the same port * @return true if restarting is successful * @throws IOException */ public synchronized boolean restartDataNode(DataNodeProperties dnprop, boolean keepPort) throws IOException { Configuration conf = dnprop.conf; String[] args = dnprop.dnArgs; SecureResources secureResources = dnprop.secureResources; Configuration newconf = new HdfsConfiguration(conf); // save cloned config if (keepPort) { InetSocketAddress addr = dnprop.datanode.getXferAddress(); conf.set(DFS_DATANODE_ADDRESS_KEY, addr.getAddress().getHostAddress() + ":" + addr.getPort()); conf.set(DFS_DATANODE_IPC_ADDRESS_KEY, addr.getAddress().getHostAddress() + ":" + dnprop.ipcPort); } DataNode newDn = DataNode.createDataNode(args, conf, secureResources); dataNodes.add(new DataNodeProperties( newDn, newconf, args, secureResources, newDn.getIpcPort())); numDataNodes++; return true; }
/** * Stores the information related to a namenode in the cluster */ public static class NameNodeInfo { final NameNode nameNode; final Configuration conf; final String nameserviceId; final String nnId; StartupOption startOpt; NameNodeInfo(NameNode nn, String nameserviceId, String nnId, StartupOption startOpt, Configuration conf) { this.nameNode = nn; this.nameserviceId = nameserviceId; this.nnId = nnId; this.startOpt = startOpt; this.conf = conf; } public void setStartOpt(StartupOption startOpt) { this.startOpt = startOpt; } }
try { IOStreamPair saslStreams = datanode.saslServer.receive(peer, socketOut, socketIn, datanode.getXferAddress().getPort(), datanode.getDatanodeId()); input = new BufferedInputStream(saslStreams.in,
DataNode dn = dns.get(0); String selfSocketAddr = dn.getXferAddress().toString(); System.out.println("DN Self Socket Addr == " + selfSocketAddr); assertTrue(selfSocketAddr.contains("/127.0.0.1:")); dn = dns.get(0); selfSocketAddr = dn.getXferAddress().toString(); System.out.println("DN Self Socket Addr == " + selfSocketAddr); dn = dns.get(0); selfSocketAddr = dn.getXferAddress().toString(); System.out.println("DN Self Socket Addr == " + selfSocketAddr);
final String[] hosts = new String[addrs.length]; for (int i = 0; i < addrs.length; i++) { addrs[i] = datanodes.get(i).getXferAddress(); hosts[i] = addrs[i].getAddress().getHostAddress() + ":" + addrs[i].getPort();
String ipAddr = dn.getXferAddress().getAddress().getHostAddress(); if (racks != null) { int port = dn.getXferAddress().getPort(); if (nodeGroups == null) { LOG.info("Adding node with IP:port : " + ipAddr + ":" + port +
String dnAddress = dnProp.datanode.getXferAddress().toString(); if (dnAddress.startsWith("/")) { dnAddress = dnAddress.substring(1);
InetSocketAddress target = datanode.getXferAddress(); Socket s = new Socket(target.getAddress(), target.getPort());
String dnAddress = dnProp.datanode.getXferAddress().toString(); if (dnAddress.startsWith("/")) { dnAddress = dnAddress.substring(1);
try { IOStreamPair saslStreams = datanode.saslServer.receive(peer, socketOut, socketIn, datanode.getXferAddress().getPort(), datanode.getDatanodeId()); input = new BufferedInputStream(saslStreams.in,
int port = cluster.getDataNodes().get(i).getXferAddress().getPort(); favoredNodes[i] = new InetSocketAddress(hosts[i], port);