/** * 执行一段文本 * @param expressString 程序文本 * @param context 执行上下文 * @param errorList 输出的错误信息List * @param isCache 是否使用Cache中的指令集 * @param isTrace 是否输出详细的执行指令信息 * @param aLog 输出的log * @return * @throws Exception */ public Object execute(String expressString, IExpressContext<String,Object> context, List<String> errorList, boolean isCache, boolean isTrace, Log aLog) throws Exception { InstructionSet parseResult = null; if (isCache == true) { parseResult = expressInstructionSetCache.get(expressString); if (parseResult == null) { synchronized (expressInstructionSetCache) { parseResult = expressInstructionSetCache.get(expressString); if (parseResult == null) { parseResult = this.parseInstructionSet(expressString); expressInstructionSetCache.put(expressString, parseResult); } } } } else { parseResult = this.parseInstructionSet(expressString); } return InstructionSetRunner.executeOuter(this,parseResult,this.loader,context, errorList, isTrace,false,aLog,false); }
StreamPumper(final Log log, final String logPrefix, final InputStream stream, final StreamType type) { this.log = log; this.logPrefix = logPrefix; this.stream = stream; this.type = type; thread = new Thread(new Runnable() { @Override public void run() { try { pump(); } catch (Throwable t) { ShellCommandFencer.LOG.warn(logPrefix + ": Unable to pump output from " + type, t); } } }, logPrefix + ": StreamPumper for " + type); thread.setDaemon(true); }
/** * Log the current thread stacks at INFO level. * @param log the logger that logs the stack trace * @param title a descriptive title for the call stacks * @param minInterval the minimum time from the last */ public static void logThreadInfo(Log log, String title, long minInterval) { boolean dumpStack = false; if (log.isInfoEnabled()) { synchronized (ReflectionUtils.class) { long now = Time.now(); if (now - previousLogTime >= minInterval * 1000) { previousLogTime = now; dumpStack = true; } } if (dumpStack) { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title); log.info(buffer.toString(Charset.defaultCharset().name())); } catch (UnsupportedEncodingException ignored) { } } } }
/** * Logs a request that failed */ static void logFailedRequest(Log logger, HttpUriRequest request, HttpHost host, Exception e) { if (logger.isDebugEnabled()) { logger.debug("request [" + request.getMethod() + " " + host + getUri(request.getRequestLine()) + "] failed", e); } if (tracer.isTraceEnabled()) { String traceRequest; try { traceRequest = buildTraceRequest(request, host); } catch (IOException e1) { tracer.trace("error while reading request for trace purposes", e); traceRequest = ""; } tracer.trace(traceRequest); } }
/** * Generates the form. * * @param item The object to generate a form for * @param fields Restricted list of fields to include * @param forcedFields List of fields to forcibly include * @param form The form object being generated * @param context Map representing optional context that can be used during * retrieval of the form */ protected void internalGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context) { Log log = getLogger(); if (log.isDebugEnabled()) log.debug("Generating form for: " + item); // generate the form type and URI for the item. Item formItem = form.getItem(); formItem.setType(getItemType(item)); formItem.setUrl(getItemURI(item)); Object itemData = makeItemData(item); FormCreationData data = new FormCreationDataImpl(itemData, forcedFields, context); populateForm(form, fields, data); if (log.isDebugEnabled()) // log.debug("Generated form: " + form); }
/** * Converts a {@link String} containing a comma-separated list of {@link NodeRef} Ids into NodeRefs. * If a <code>logger</code> is supplied then invalid ids are logged as warnings. * @param values the {@link String} of {@link NodeRef} ids. * @param logger Log * @return A {@link List} of {@link NodeRef NodeRefs}. */ public static List<NodeRef> getNodeRefs(String values, Log logger) { if(values==null || values.length()==0) return Collections.emptyList(); String[] nodeRefIds = values.split(","); List<NodeRef> nodeRefs = new ArrayList<NodeRef>(nodeRefIds.length); for (String nodeRefString : nodeRefIds) { String nodeRefId = nodeRefString.trim(); if (NodeRef.isNodeRef(nodeRefId)) { NodeRef nodeRef = new NodeRef(nodeRefId); nodeRefs.add(nodeRef); } else if (logger!=null) { logNodeRefError(nodeRefId, logger); } } return nodeRefs; }
public static boolean isBlacklisted(FiCaSchedulerApp application, FiCaSchedulerNode node, Log LOG) { if (application.isBlacklisted(node.getNodeName())) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping 'host' " + node.getNodeName() + " for " + application.getApplicationId() + " since it has been blacklisted"); } return true; } if (application.isBlacklisted(node.getRackName())) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping 'rack' " + node.getRackName() + " for " + application.getApplicationId() + " since it has been blacklisted"); } return true; } return false; }
/** * Logs each method routing path once per session. * * @param logger * @param route */ static void oneTimeLiveLog(Log logger, ExtensionRoute route) { synchronized (AJExtender.class) { if (oneTimeLogSet == null) { oneTimeLogSet = new ConcurrentHashSet<>(); } } synchronized (oneTimeLogSet) { if (oneTimeLogSet.contains(route)) { return; } else { logger.debug(route.toString()); oneTimeLogSet.add(route); } } }
public static boolean isBlacklisted(SchedulerApplicationAttempt application, SchedulerNode node, Log LOG) { if (application.isBlacklisted(node.getNodeName())) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping 'host' " + node.getNodeName() + " for " + application.getApplicationId() + " since it has been blacklisted"); } return true; } if (application.isBlacklisted(node.getRackName())) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping 'rack' " + node.getRackName() + " for " + application.getApplicationId() + " since it has been blacklisted"); } return true; } return false; }
private static Log doCreateLogger(Class<?> logName) { Log logger; ClassLoader ccl = Thread.currentThread().getContextClassLoader(); // push the logger class classloader (useful when dealing with commons-logging 1.0.x Thread.currentThread().setContextClassLoader(logName.getClassLoader()); try { logger = LogFactory.getLog(logName); } catch (Throwable th) { logger = new SimpleLogger(); logger .fatal( "logger infrastructure not properly set up. If commons-logging jar is used try switching to slf4j (see the FAQ for more info).", th); } finally { Thread.currentThread().setContextClassLoader(ccl); } return logger; }
public DefaultFrameworkTemplate(Object target, Log log) { if (OsgiPlatformDetector.isR42()) { Assert.isInstanceOf(Framework.class, target); fwk = (Framework) target; } else { throw new IllegalStateException("Cannot use OSGi 4.2 Framework API in an OSGi 4.1 environment"); } this.log = log; }
public void executeInnerOrigiInstruction(RunEnvironment environmen,List<String> errorList,Log aLog) throws Exception{ Instruction instruction =null; try { while (environmen.programPoint < this.instructionList.length) { // if (environmen.isExit() == true) { // return; // } instruction = this.instructionList[environmen.programPoint]; instruction.setLog(aLog);// 设置log instruction.execute(environmen, errorList); } } catch (Exception e) { if (printInstructionError) { log.error("当前ProgramPoint = " + environmen.programPoint); log.error("当前指令" + instruction); log.error(e); } throw e; } }
/** * Close the Closeable objects and <b>ignore</b> any {@link IOException} or * null pointers. Must only be used for cleanup in exception handlers. * * @param log the log to record problems to at debug level. Can be null. * @param closeables the objects to close */ public static void cleanup(Log log, java.io.Closeable... closeables) { for (java.io.Closeable c : closeables) { if (c != null) { try { c.close(); } catch(IOException e) { if (log != null && log.isDebugEnabled()) { log.debug("Exception in closing " + c, e); } } } } }
/** * Close the Closeable objects and <b>ignore</b> any {@link IOException} or * null pointers. Must only be used for cleanup in exception handlers. * * @param log the log to record problems to at debug level. Can be null. * @param closeables the objects to close */ public static void cleanup(Log log, java.io.Closeable... closeables) { for (java.io.Closeable c : closeables) { if (c != null) { try { c.close(); } catch(Throwable e) { if (log != null && log.isDebugEnabled()) { log.debug("Exception in closing " + c, e); } } } } }
@Test (timeout=300000) public void testLogExceptions() throws Exception { final Configuration conf = new Configuration(); final Call dummyCall = new Call(0, 0, null, null); Log logger = mock(Log.class); Server server = new Server("0.0.0.0", 0, LongWritable.class, 1, conf) { @Override public Writable call( RPC.RpcKind rpcKind, String protocol, Writable param, long receiveTime) throws Exception { return null; } }; server.addSuppressedLoggingExceptions(TestException1.class); server.addTerseExceptions(TestException2.class); // Nothing should be logged for a suppressed exception. server.logException(logger, new TestException1(), dummyCall); verifyZeroInteractions(logger); // No stack trace should be logged for a terse exception. server.logException(logger, new TestException2(), dummyCall); verify(logger, times(1)).info(anyObject()); // Full stack trace should be logged for other exceptions. final Throwable te3 = new TestException3(); server.logException(logger, te3, dummyCall); verify(logger, times(1)).info(anyObject(), eq(te3)); }
/** * Close the Closeable objects and <b>ignore</b> any {@link IOException} or * null pointers. Must only be used for cleanup in exception handlers. * @param log the log to record problems to at debug level. Can be null. * @param closeables the objects to close */ public static void cleanup(Log log, Closeable... closeables) { for(Closeable c : closeables) { if (c != null) { try { c.close(); } catch(IOException e) { if (log != null && log.isDebugEnabled()) { log.debug("Exception in closing " + c, e); } } } } }
public static FactoriaControlAgteReactivo instancia(){ Log log = LogFactory.getLog(FactoriaControlAgteReactivo.class); if(instancia==null){ String clase = System.getProperty("icaro.infraestructura.patronAgenteReactivo.control.factoriaEInterfaces.imp", "icaro.infraestructura.patronAgenteReactivo.control.factoriaEInterfaces.imp.FactoriaControlAgteReactivoImp2"); try{ instancia = (FactoriaControlAgteReactivo)Class.forName(clase).newInstance(); }catch(Exception ex){ log.error("Implementacion del Control no encontrado",ex); } } return instancia; }
/** * Clean up any temporary streams created during the execution, * and restore the original file and/or input stream. */ public static void cleanupDataSource(S3DataSource req, final File fileOrig, final InputStream inputStreamOrig, InputStream inputStreamCurr, Log log) { if (fileOrig != null) { // We opened a file underneath so would need to release it release(inputStreamCurr, log); } // restore the original input stream so the caller could close // it if necessary req.setInputStream(inputStreamOrig); req.setFile(fileOrig); }
@Override protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable { String name = createInvocationTraceName(invocation); StopWatch stopWatch = new StopWatch(name); stopWatch.start(name); try { return invocation.proceed(); } finally { stopWatch.stop(); logger.trace(stopWatch.shortSummary()); } }
public WorkflowFormPersister(ContentModelItemData<?> itemData, NamespaceService namespaceService, DictionaryService dictionaryService, WorkflowService workflowService, NodeService nodeService, BehaviourFilter behaviourFilter, Log logger) { super(itemData, namespaceService, dictionaryService, logger); WorkflowDefinition definition = (WorkflowDefinition) itemData.getItem(); this.builder = new WorkflowBuilder(definition, workflowService, nodeService, behaviourFilter); }
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */ public void auditStarted(AuditEvent aEvt) { if (mInitialized) { final Log log = mLogFactory.getInstance(Checker.class); log.info("Audit started."); } }
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */ public void addError(AuditEvent aEvt) { final SeverityLevel severityLevel = aEvt.getSeverityLevel(); if (mInitialized && !SeverityLevel.IGNORE.equals(severityLevel)) { final Log log = mLogFactory.getInstance(aEvt.getSourceName()); final String fileName = aEvt.getFileName(); final String message = aEvt.getMessage(); // avoid StringBuffer.expandCapacity final int bufLen = message.length() + BUFFER_CUSHION; final StringBuffer sb = new StringBuffer(bufLen); sb.append("Line: ").append(aEvt.getLine()); if (aEvt.getColumn() > 0) { sb.append(" Column: ").append(aEvt.getColumn()); } sb.append(" Message: ").append(message); if (aEvt.getSeverityLevel().equals(SeverityLevel.WARNING)) { log.warn(sb.toString()); } else if (aEvt.getSeverityLevel().equals(SeverityLevel.INFO)) { log.info(sb.toString()); } else { log.error(sb.toString()); } } }
/** * Writes the supplied message and {@link Throwable} to the * supplied {@code Log} instance. By default messages are written * at {@code TRACE} level. Sub-classes can override this method * to control which level the message is written at. */ protected void writeToLog(Log logger, String message, Throwable ex) { if (ex != null) { logger.trace(message, ex); } else { logger.trace(message); } }
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */ public void addException(AuditEvent aEvt, Throwable aThrowable) { if (mInitialized) { final Log log = mLogFactory.getInstance(aEvt.getSourceName()); log.error("Error auditing " + aEvt.getFileName(), aThrowable); } }
/** * Confirms that it doesn't crash if you */ @Test public void testBadlyConfigured() { mockStatic(LogFactory.class); Log logger = mock(Log.class); when(LogFactory.getLog(any(Class.class))).thenReturn(logger); when(logger.isWarnEnabled()).thenReturn(true); AdapterWatcherThread thread = new AdapterWatcherThread(null); thread.run(); // kick of the run method - this would normally be done by the Thread // just confirm it doesn't crash - just writes out a error (not checking the text as that // is subject to change) Mockito.verify(logger).error(Matchers.anyString()); }
/** * Instantiates a new batch processor. * * @param processName * the process name * @param retryingTransactionHelper * the retrying transaction helper * @param collection * the collection * @param workerThreads * the number of worker threads * @param batchSize * the number of entries we process at a time in a transaction * @param applicationEventPublisher * the application event publisher (may be <tt>null</tt>) * @param logger * the logger to use (may be <tt>null</tt>) * @param loggingInterval * the number of entries to process before reporting progress * * @deprecated Since 3.4, use the {@link BatchProcessWorkProvider} instead of the <tt>Collection</tt> */ public BatchProcessor( String processName, RetryingTransactionHelper retryingTransactionHelper, final Collection<T> collection, int workerThreads, int batchSize, ApplicationEventPublisher applicationEventPublisher, Log logger, int loggingInterval) { this( processName, retryingTransactionHelper, new BatchProcessWorkProvider<T>() { boolean hasMore = true; public int getTotalEstimatedWorkSize() { return collection.size(); } public Collection<T> getNextWork() { // Only return the collection once if (hasMore) { hasMore = false; return collection; } else { return Collections.emptyList(); } } }, workerThreads, batchSize, applicationEventPublisher, logger, loggingInterval); }
/** * Instantiates a new batch processor. * * @param processName * the process name * @param retryingTransactionHelper * the retrying transaction helper * @param workProvider * the object providing the work packets * @param workerThreads * the number of worker threads * @param batchSize * the number of entries we process at a time in a transaction * @param applicationEventPublisher * the application event publisher (may be <tt>null</tt>) * @param logger * the logger to use (may be <tt>null</tt>) * @param loggingInterval * the number of entries to process before reporting progress * * @since 3.4 */ public BatchProcessor( String processName, RetryingTransactionHelper retryingTransactionHelper, BatchProcessWorkProvider<T> workProvider, int workerThreads, int batchSize, ApplicationEventPublisher applicationEventPublisher, Log logger, int loggingInterval) { this.threadFactory = new TraceableThreadFactory(); this.threadFactory.setNamePrefix(processName); this.threadFactory.setThreadDaemon(true); this.processName = processName; this.retryingTransactionHelper = retryingTransactionHelper; this.workProvider = workProvider; this.workerThreads = workerThreads; this.batchSize = batchSize; if (logger == null) { this.logger = LogFactory.getLog(this.getClass()); } else { this.logger = logger; } this.loggingInterval = loggingInterval; // Let the (enterprise) monitoring side know of our presence if (applicationEventPublisher != null) { applicationEventPublisher.publishEvent(new BatchMonitorEvent(this)); } }
@Override public boolean onLogException(Log logger, Throwable t, String message) { if (t instanceof UnimportantTransformException ) { logger.debug(message); return true; } else if (t instanceof UnsupportedTransformationException) { logger.error(message); return true; } return false; }
CommonsLogger(Log logger, String name) { super(name); if (logger == null) { throw new NullPointerException("logger"); } this.logger = logger; }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { // Do the authorization if (!HttpServer.hasAdministratorAccess(getServletContext(), request, response)) { return; } PrintWriter out = ServletUtil.initHTML(response, "Log Level"); String logName = ServletUtil.getParameter(request, "log"); String level = ServletUtil.getParameter(request, "level"); if (logName != null) { out.println("<br /><hr /><h3>Results</h3>"); out.println(MARKER + "Submitted Log Name: <b>" + logName + "</b><br />"); Log log = LogFactory.getLog(logName); out.println(MARKER + "Log Class: <b>" + log.getClass().getName() +"</b><br />"); if (level != null) { out.println(MARKER + "Submitted Level: <b>" + level + "</b><br />"); } if (log instanceof Log4JLogger) { process(((Log4JLogger)log).getLogger(), level, out); } else if (log instanceof Jdk14Logger) { process(((Jdk14Logger)log).getLogger(), level, out); } else { out.println("Sorry, " + log.getClass() + " not supported.<br />"); } } out.println(FORMS); out.println(ServletUtil.HTML_TAIL); }
private boolean skipObject(Object obj) { if (obj instanceof String) { // this will not cause a memory leak since // unused interned Strings will be thrown away if (obj == ((String) obj).intern()) { return true; } } if (obj instanceof Marshaller || obj instanceof EmbeddedCacheManager || obj instanceof Thread || obj instanceof Log || obj instanceof Logger || obj instanceof SolverContainer) return true; return (obj == null) || iVisited.containsKey(obj); }
/** * Stop a service; if it is null do nothing. Exceptions are caught and * logged at warn level. (but not Throwables). This operation is intended to * be used in cleanup operations * * @param log the log to warn at * @param service a service; may be null * @return any exception that was caught; null if none was. * @see ServiceOperations#stopQuietly(Service) */ public static Exception stopQuietly(Log log, Service service) { try { stop(service); } catch (Exception e) { log.warn("When stopping the service " + service.getName() + " : " + e, e); return e; } return null; }
public Object execute(String name,IExpressContext<String,Object> context, List<String> errorList, boolean isTrace,boolean isCatchException, Log aLog){ try { CacheObject cache = (CacheObject) this.getCache(name); if(cache==null){ throw new RuntimeException("未获取到缓存对象."); } return getExpressRunner().execute(cache.getInstructionSet(), context, errorList, isTrace, isCatchException, aLog); } catch (Exception e) { throw new RuntimeException("获取缓存信息,并且执行指令集出现错误.",e); } }
/** * Wraps the invocation with a JAMon Monitor and writes the current * performance statistics to the log (if enabled). * @see com.jamonapi.MonitorFactory#start * @see com.jamonapi.Monitor#stop */ @Override protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable { String name = createInvocationTraceName(invocation); Monitor monitor = MonitorFactory.start(name); try { return invocation.proceed(); } finally { monitor.stop(); if (!this.trackAllInvocations || isLogEnabled(logger)) { logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor); } } }
public DelayAnswer(Log log) { this.LOG = log; }
public static RequestLog getRequestLog(String name) { String lookup = serverToComponent.get(name); if (lookup != null) { name = lookup; } String loggerName = "http.requests." + name; String appenderName = name + "requestlog"; Log logger = LogFactory.getLog(loggerName); boolean isLog4JLogger;; try { isLog4JLogger = logger instanceof Log4JLogger; } catch (NoClassDefFoundError err) { // In some dependent projects, log4j may not even be on the classpath at // runtime, in which case the above instanceof check will throw // NoClassDefFoundError. LOG.debug("Could not load Log4JLogger class", err); isLog4JLogger = false; } if (isLog4JLogger) { Log4JLogger httpLog4JLog = (Log4JLogger)logger; Logger httpLogger = httpLog4JLog.getLogger(); Appender appender = null; try { appender = httpLogger.getAppender(appenderName); } catch (LogConfigurationException e) { LOG.warn("Http request log for " + loggerName + " could not be created"); throw e; } if (appender == null) { LOG.info("Http request log for " + loggerName + " is not defined"); return null; } if (appender instanceof HttpRequestLogAppender) { HttpRequestLogAppender requestLogAppender = (HttpRequestLogAppender)appender; NCSARequestLog requestLog = new NCSARequestLog(); requestLog.setFilename(requestLogAppender.getFilename()); requestLog.setRetainDays(requestLogAppender.getRetainDays()); return requestLog; } else { LOG.warn("Jetty request log for " + loggerName + " was of the wrong class"); return null; } } else { LOG.warn("Jetty request log can only be enabled using Log4j"); return null; } }
/** * processes a <code>BlockDef</code> and resolves references in it * * @param block the <code>BlockDef</code> to process */ protected void handleBlock(BlockDef block) { SymTabAST node = block.getTreeNode(); switch (node.getType()) { case TokenTypes.LITERAL_FOR : handleFor(block); break; case TokenTypes.LITERAL_IF : handleIf(block); break; case TokenTypes.LITERAL_WHILE : handleWhileAndSynchronized(block); break; case TokenTypes.LITERAL_DO : handleDoWhile(block); break; case TokenTypes.LITERAL_TRY : case TokenTypes.LITERAL_FINALLY : SymTabAST slist = node.findFirstToken(TokenTypes.SLIST); handleSList(slist, block); break; case TokenTypes.LITERAL_CATCH : handleCatch(block); break; case TokenTypes.LITERAL_SWITCH : handleSwitch(block); break; case TokenTypes.SLIST : handleSList(node, block); break; case TokenTypes.EXPR : resolveExpression(node, block, null, true); break; case TokenTypes.INSTANCE_INIT : case TokenTypes.STATIC_INIT : handleSList((SymTabAST) node.getFirstChild(), block); break; case TokenTypes.LITERAL_SYNCHRONIZED : handleWhileAndSynchronized(block); break; case TokenTypes.LITERAL_ASSERT : handleAssert(block); break; default : if (mInitialized) { final Log log = mLogFactory.getInstance(this.getClass()); log.error( "Unhandled block " + block + " of type " + node.getType()); } } }
/** * Log events to the given log * @param log destination for events */ public LoggingStateChangeListener(Log log) { //force an NPE if a null log came in log.isDebugEnabled(); this.log = log; }
public static void logAll(Log log, SQLException e) { org.apache.sqoop.util.LoggingUtils.logAll(log, e); }
@Override public int run(String[] args) throws IOException { // silence the minidfs cluster Log hadoopLog = LogFactory.getLog("org"); if (hadoopLog instanceof Log4JLogger) { ((Log4JLogger) hadoopLog).getLogger().setLevel(Level.WARN); } int reps = 1; if (args.length == 1) { try { reps = Integer.parseInt(args[0]); } catch (NumberFormatException e) { printUsage(); return -1; } } else if (args.length > 1) { printUsage(); return -1; } Configuration conf = getConf(); // the size of the file to write long SIZE = conf.getLong("dfsthroughput.file.size", 10L * 1024 * 1024 * 1024); BUFFER_SIZE = conf.getInt("dfsthroughput.buffer.size", 4 * 1024); String localDir = conf.get("mapred.temp.dir"); if (localDir == null) { localDir = conf.get("hadoop.tmp.dir"); conf.set("mapred.temp.dir", localDir); } dir = new LocalDirAllocator("mapred.temp.dir"); System.setProperty("test.build.data", localDir); System.out.println("Local = " + localDir); ChecksumFileSystem checkedLocal = FileSystem.getLocal(conf); FileSystem rawLocal = checkedLocal.getRawFileSystem(); for(int i=0; i < reps; ++i) { writeAndReadLocalFile("local", conf, SIZE); writeAndReadFile(rawLocal, "raw", conf, SIZE); writeAndReadFile(checkedLocal, "checked", conf, SIZE); } MiniDFSCluster cluster = null; try { cluster = new MiniDFSCluster.Builder(conf) .racks(new String[]{"/foo"}).build(); cluster.waitActive(); FileSystem dfs = cluster.getFileSystem(); for(int i=0; i < reps; ++i) { writeAndReadFile(dfs, "dfs", conf, SIZE); } } finally { if (cluster != null) { cluster.shutdown(); // clean up minidfs junk rawLocal.delete(new Path(localDir, "dfs"), true); } } return 0; }