/** Instantiate & Start a single datanode daemon and wait for it to finish. * If this thread is specifically interrupted, it will stop waiting. */ @VisibleForTesting public static DataNode createDataNode(String args[], Configuration conf) throws IOException { return createDataNode(args, conf, null); }
public static void secureMain(String args[], SecureResources resources) { int errorCode = 0; try { StringUtils.startupShutdownMessage(DataNode.class, args, LOG); DataNode datanode = createDataNode(args, null, resources); if (datanode != null) { datanode.join(); } else { errorCode = 1; } } catch (Throwable e) { LOG.error("Exception in secureMain", e); terminate(1, e); } finally { // We need to terminate the process here because either shutdown was called // or some disk related conditions like volumes tolerated or volumes required // condition was not met. Also, In secure mode, control will go to Jsvc // and Datanode process hangs if it does not exit. LOG.warn("Exiting Datanode"); terminate(errorCode); } }
/** Instantiate & Start a single datanode daemon and wait for it to finish. * If this thread is specifically interrupted, it will stop waiting. */ public static DataNode createDataNode(String args[], Configuration conf) throws IOException { return createDataNode(args, conf, null); }
/** Instantiate & Start a single datanode daemon and wait for it to finish. * If this thread is specifically interrupted, it will stop waiting. */ @VisibleForTesting public static DataNode createDataNode(String args[], Configuration conf) throws IOException { return createDataNode(args, conf, null); }
@Override protected DataNode doCreate(Dictionary properties) throws Exception { Configuration conf = new Configuration(); for (Enumeration e = properties.keys(); e.hasMoreElements();) { Object key = e.nextElement(); Object val = properties.get(key); conf.set( key.toString(), val.toString() ); } DataNode dataNode = DataNode.createDataNode(null, conf); return dataNode; }
/** Instantiate & Start a single datanode daemon and wait for it to finish. * If this thread is specifically interrupted, it will stop waiting. */ @VisibleForTesting public static DataNode createDataNode(String args[], Configuration conf) throws IOException { return createDataNode(args, conf, null); }
/** * Start the datanode. */ public DataNode startDataNode(int index, Configuration config) throws IOException { String dataDir = getTestingDir(); File dataNodeDir = new File(dataDir, "data-" + index); config.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, dataNodeDir.getPath()); String[] args = new String[] {}; // NameNode will modify config with the ports it bound to return DataNode.createDataNode(args, config); }
/** * Check whether the datanode can be started. */ private boolean canStartDataNode(Configuration conf) throws IOException { DataNode dn = null; try { dn = DataNode.createDataNode(new String[]{}, conf); } catch(IOException e) { if (e instanceof java.net.BindException) return false; throw e; } finally { if(dn != null) dn.shutdown(); } return true; }
@Override public void run() { log.info("Starting DataNode..."); while (!ready) { try { if (startupProperties != null) { dataNode = DataNode.createDataNode(null, HadoopUtils.toConfiguration(startupProperties)); ready = true; } else Thread.sleep(10000); } catch (Exception e) { log.warn("Failed start DataNode: {}", e); try { Thread.sleep(10000); } catch (InterruptedException e1) { log.warn("Interrupted"); return; } } } /*new Thread() { public void run() { dataNode.run(); } }.start();*/ log.info("DataNode started"); } });
/** * Start the datanode. */ public DataNode startDataNode(int index, Configuration config) throws IOException { File dataNodeDir = new File(TEST_DATA_DIR, "data-" + index); config.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, dataNodeDir.getPath()); String[] args = new String[] {}; // NameNode will modify config with the ports it bound to return DataNode.createDataNode(args, config); }
/** */ public static void main(String args[]) { try { StringUtils.startupShutdownMessage(DataNode.class, args, LOG); DataNode datanode = createDataNode(args, null); if (datanode != null) datanode.join(); } catch (Throwable e) { LOG.error(StringUtils.stringifyException(e)); System.exit(-1); } }
public static void secureMain(String [] args, SecureResources resources) { try { StringUtils.startupShutdownMessage(DataNode.class, args, LOG); DataNode datanode = createDataNode(args, null, resources); if (datanode != null) datanode.join(); } catch (Throwable e) { LOG.error(StringUtils.stringifyException(e)); System.exit(-1); } finally { // We need to add System.exit here because either shutdown was called or // some disk related conditions like volumes tolerated or volumes required // condition was not met. Also, In secure mode, control will go to Jsvc and // the process hangs without System.exit. LOG.info("Exiting Datanode"); System.exit(0); } }
/** */ public static void main(String args[]) { try { StringUtils.startupShutdownMessage(DataNode.class, args, LOG); DataNode datanode = createDataNode(args, null); if (datanode != null) { datanode.waitAndShutdown(); } } catch (Throwable e) { LOG.error(StringUtils.stringifyException(e)); System.exit(-1); } }
/** * 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; Configuration newconf = new HdfsConfiguration(conf); // save cloned config if (keepPort) { InetSocketAddress addr = dnprop.datanode.getSelfAddr(); conf.set("dfs.datanode.address", addr.getAddress().getHostAddress() + ":" + addr.getPort()); } dataNodes.add(new DataNodeProperties(DataNode.createDataNode(args, conf), newconf, args)); numDataNodes++; return true; }
/** * Check whether the datanode can be started. */ private boolean canStartDataNode(Configuration conf) throws IOException { DataNode dn = null; try { dn = DataNode.createDataNode(new String[]{}, conf); } catch(IOException e) { if (e instanceof java.net.BindException) return false; throw e; } finally { if(dn != null) dn.shutdown(); } return true; }
public static void secureMain(String args[], SecureResources resources) { int errorCode = 0; try { StringUtils.startupShutdownMessage(DataNode.class, args, LOG); DataNode datanode = createDataNode(args, null, resources); if (datanode != null) { datanode.join(); } else { errorCode = 1; } } catch (Throwable e) { LOG.fatal("Exception in secureMain", e); terminate(1, e); } finally { // We need to terminate the process here because either shutdown was called // or some disk related conditions like volumes tolerated or volumes required // condition was not met. Also, In secure mode, control will go to Jsvc // and Datanode process hangs if it does not exit. LOG.warn("Exiting Datanode"); terminate(errorCode); } }
/** * 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; }
public static void secureMain(String args[], SecureResources resources) { int errorCode = 0; try { StringUtils.startupShutdownMessage(DataNode.class, args, LOG); DataNode datanode = createDataNode(args, null, resources); if (datanode != null) { datanode.join(); } else { errorCode = 1; } } catch (Throwable e) { LOG.fatal("Exception in secureMain", e); terminate(1, e); } finally { // We need to terminate the process here because either shutdown was called // or some disk related conditions like volumes tolerated or volumes required // condition was not met. Also, In secure mode, control will go to Jsvc // and Datanode process hangs if it does not exit. LOG.warn("Exiting Datanode"); terminate(errorCode); } }
dn = DataNode.createDataNode(new String[]{}, conf); dn.shutdown(); dn = null; memlockLimit+1); try { dn = DataNode.createDataNode(new String[]{}, conf); } catch (RuntimeException e) { GenericTestUtils.assertExceptionContains(
DataNode dn = null; try { dn = DataNode.createDataNode(new String[]{}, conf); fail(); } catch(Exception e) {