Example usage for java.lang Thread getName

List of usage examples for java.lang Thread getName

Introduction

In this page you can find the example usage for java.lang Thread getName.

Prototype

public final String getName() 

Source Link

Document

Returns this thread's name.

Usage

From source file:org.apache.flink.client.minicluster.NepheleMiniCluster.java

public void start() throws Exception {

    String forkNumberString = System.getProperty("forkNumber");
    int forkNumber = -1;
    try {/*w  w w . j a  v a2  s.c  o  m*/
        forkNumber = Integer.parseInt(forkNumberString);
    } catch (NumberFormatException e) {
        // running inside and IDE, so the forkNumber property is not properly set
        // just ignore
    }
    if (forkNumber != -1) {
        // we are running inside a surefire/failsafe test, determine forkNumber and set
        // ports accordingly so that we can have multiple parallel instances

        jobManagerRpcPort = 1024 + forkNumber * 300;
        taskManagerRpcPort = 1024 + forkNumber * 300 + 100;
        taskManagerDataPort = 1024 + forkNumber * 300 + 200;
    }

    synchronized (startStopLock) {
        // set up the global configuration
        if (this.configDir != null) {
            GlobalConfiguration.loadConfiguration(configDir);
        } else {
            Configuration conf = getMiniclusterDefaultConfig(jobManagerRpcPort, taskManagerRpcPort,
                    taskManagerDataPort, memorySize, hdfsConfigFile, lazyMemoryAllocation,
                    defaultOverwriteFiles, defaultAlwaysCreateDirectory, taskManagerNumSlots, numTaskTracker);
            GlobalConfiguration.includeConfiguration(conf);
        }

        // force the input/output format classes to load the default values from the configuration.
        // we need to do this here, because the format classes may have been initialized before the mini cluster was started
        initializeIOFormatClasses();

        // before we start the JobManager, we need to make sure that there are no lingering IPC threads from before
        // check that all threads are done before we return
        Thread[] allThreads = new Thread[Thread.activeCount()];
        int numThreads = Thread.enumerate(allThreads);

        for (int i = 0; i < numThreads; i++) {
            Thread t = allThreads[i];
            String name = t.getName();
            if (name.startsWith("IPC")) {
                t.join();
            }
        }

        // start the job manager
        jobManager = new JobManager(ExecutionMode.LOCAL);

        waitForJobManagerToBecomeReady(numTaskTracker);
    }
}

From source file:net.darkmist.clf.IndexedLogFileHandler.java

protected void nextHandler(File file) {
    Matcher matcher;//from   ww w .  jav  a2s  .  co m
    String base;
    String previousThreadName;
    Thread thread;

    // get the base name...
    matcher = getMatcher();
    base = matcher.group(1);

    // check the index for it
    if (notInIndex(file, base))
        return;

    // pass it on
    thread = Thread.currentThread();
    previousThreadName = thread.getName();
    thread.setName("log: " + file);
    logger.info("scanning");
    try {
        super.nextHandler(file);
    } finally {
        thread.setName(previousThreadName);
    }
}

From source file:ca.uviccscu.lp.server.main.ShutdownListener.java

@Deprecated
public boolean isAzThread(Thread t) {
    String s = t.getName();
    if (s.contains("AE") || s.contains("UP") || s.contains("MC") || s.contains("Timer") || s.contains("Plugin")
            || s.contains("Read") || s.contains("Write") || s.contains("PRUD") || s.contains("GM")
            || s.contains("Connect") || s.contains("Thread") || s.contains("Async") || s.contains("Resource")) {
        return true;
    } else {/*w w  w  . j a v  a  2s .com*/
        return false;
    }
}

From source file:org.hillview.utils.HillviewLogger.java

private String createMessage(String message, String format, Object... arguments) {
    message = this.checkCommas(message);
    String text = MessageFormat.format(format, arguments);
    Thread current = Thread.currentThread();
    StackTraceElement[] stackTraceElements = current.getStackTrace();
    StackTraceElement caller = stackTraceElements[3];
    String quoted = this.quote(text);
    return String.join(",", current.getName(), caller.getClassName(), caller.getMethodName(), message, quoted);
}

From source file:org.bonitasoft.engine.test.internal.EngineStarter.java

private void printThread(final Thread thread) {
    LOGGER.info("\n");
    LOGGER.info("Thread is still alive:" + thread.getName());
    for (StackTraceElement stackTraceElement : thread.getStackTrace()) {
        LOGGER.info("        at " + stackTraceElement.toString());
    }//from www  . ja  v  a 2 s .co  m
}

From source file:org.apache.hadoop.thriftfs.ThriftHandlerBase.java

/**
 * Return a list of threads that currently exist with their stack traces
 *///from   w  ww .ja  v  a2  s .  com
public List<ThreadStackTrace> getThreadDump(RequestContext ctx) {
    List<ThreadStackTrace> dump = new ArrayList<ThreadStackTrace>();

    Map<Thread, java.lang.StackTraceElement[]> traces = Thread.getAllStackTraces();
    for (Map.Entry<Thread, java.lang.StackTraceElement[]> entry : traces.entrySet()) {
        final Thread t = entry.getKey();
        final java.lang.StackTraceElement[] frames = entry.getValue();

        ThreadStackTrace tst = new ThreadStackTrace();
        tst.threadName = t.getName();
        tst.threadStringRepresentation = String.valueOf(t);
        tst.isDaemon = t.isDaemon();
        tst.stackTrace = new ArrayList<StackTraceElement>();
        for (java.lang.StackTraceElement ste : frames) {
            StackTraceElement tFrame = new StackTraceElement();
            tFrame.className = ste.getClassName();
            tFrame.fileName = ste.getFileName();
            tFrame.lineNumber = ste.getLineNumber();
            tFrame.methodName = ste.getMethodName();
            tFrame.isNativeMethod = ste.isNativeMethod();
            tFrame.stringRepresentation = String.valueOf(ste);
            tst.stackTrace.add(tFrame);
        }
        dump.add(tst);
    }
    return dump;
}

From source file:org.apache.sandesha2.storage.inmemory.InMemoryTransaction.java

InMemoryTransaction(InMemoryStorageManager manager, Thread thread, boolean useSerialization) {
    if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
        log.debug("Entry: InMemoryTransaction::<init>");
    this.manager = manager;
    this.thread = thread;
    this.threadName = thread.getName();
    this.useSerialization = useSerialization;
    if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
        log.debug("Exit: InMemoryTransaction::<init>, " + this);
}

From source file:au.org.intersect.dms.wn.impl.WorkerNodeImpl.java

@Override
public boolean stopJob(Long jobId) {
    boolean resp = false;
    synchronized (trackers) {
        JobTracker tracker = trackers.get(jobId);
        if (tracker != null) {
            Thread thread = tracker.getThread();
            LOGGER.info("Stopping copy thread: " + thread.getName());
            thread.interrupt();/* w  w  w.  j a va2s  .c  o  m*/
            resp = true;
        }
    }
    return resp;
}

From source file:org.netflux.core.task.AbstractTask.java

public void start() {
    // TODO: Thread handling
    // TODO: Improve uncaught exception handling
    Thread taskWorker = this.getTaskWorker();
    taskWorker.setName(this.getName());
    taskWorker.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread thread, Throwable throwable) {
            String message = MessageFormat
                    .format(AbstractTask.messages.getString("exception.uncaught.exception"), thread.getName());
            AbstractTask.log.error(message, throwable);
            for (OutputPort outputPort : AbstractTask.this.outputPorts.values()) {
                outputPort.consume(Record.END_OF_DATA);
            }/*from ww w .ja  va2s. c  o m*/
        }
    });
    taskWorker.start();
}

From source file:org.archive.mapred.ARCMapRunner.java

protected void cleanup(final Thread thread, final ARCReporter reporter) throws IOException {
    if (!thread.isAlive()) {
        return;//  w  ww .  j  a  va  2 s  .c  om
    }
    reporter.setStatus("Killing indexing thread " + thread.getName(), true);
    thread.interrupt();
    try {
        // Give it some time to die.
        thread.join(1000);
    } catch (final InterruptedException e) {
        e.printStackTrace();
    }
    if (thread.isAlive()) {
        LOG.info(thread.getName() + " will not die");
    }
}