Example usage for java.lang ThreadGroup ThreadGroup

List of usage examples for java.lang ThreadGroup ThreadGroup

Introduction

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

Prototype

public ThreadGroup(String name) 

Source Link

Document

Constructs a new thread group.

Usage

From source file:com.ibm.jaggr.service.impl.deps.DepTree.java

/**
 * Object constructor. Attempts to de-serialize the cached dependency lists
 * from disk and then validates the dependency lists based on last-modified
 * dates, looking for any new or removed files. If the cached dependency
 * list data cannot be de-serialized, new lists are constructed. Once the
 * dependency lists have been validated, the list data is serialized back
 * out to disk.//from w ww  .  j a  va  2 s  .co m
 * 
 * @param paths
 *            Collection of URIs which specify the target resources
 *            to be scanned for javascript files.
 * @param aggregator
 *            The servlet instance for this object
 * @param stamp
 *            timestamp associated with external override/customization 
 *            resources that are check on every server restart                     
 * @param clean
 *            If true, then the dependency lists are generated from scratch
 *            rather than by de-serializing and then validating the cached
 *            dependency lists.
 * @param validateDeps
 *            If true, then validate existing cached dependencies using
 *            file last-modified times.
 * @throws IOException
 */
public DepTree(Collection<URI> paths, IAggregator aggregator, long stamp, boolean clean, boolean validateDeps)
        throws IOException {
    this.stamp = stamp;
    IConfig config = aggregator.getConfig();
    rawConfig = config.toString();

    File cacheDir = new File(aggregator.getWorkingDirectory(), DEPCACHE_DIRNAME);
    File cacheFile = new File(cacheDir, CACHE_FILE);

    /*
     * The de-serialized dependency map. If we have a cached dependency map,
     * then it will be validated against the last-modified dates of the
     * current files and only the files that have changed will need to be
     * re-parsed to update the dependency lists.
     */
    DepTree cached = null;

    if (!clean) {
        // If we're not starting clean, try to de-serialize the map from
        // cache
        try {
            ObjectInputStream is = new ObjectInputStream(new FileInputStream(cacheFile));
            try {
                cached = (DepTree) is.readObject();
            } finally {
                try {
                    is.close();
                } catch (Exception ignore) {
                }
            }
        } catch (FileNotFoundException e) {
            /*
             * Not an error. Just means that the cache file hasn't been
             * written yet or else it's been deleted.
             */
            if (log.isLoggable(Level.INFO))
                log.log(Level.INFO, Messages.DepTree_1);
        } catch (Exception e) {
            if (log.isLoggable(Level.SEVERE))
                log.log(Level.SEVERE, e.getMessage(), e);
        }
    }

    // If the cacheBust config param has changed, then do a clean build
    // of the dependencies.
    if (cached != null) {
        if (stamp == 0) {
            // no init stamp provided.  Preserve the cached one.
            stamp = cached.stamp;
        }
        if (stamp > cached.stamp) {
            // init stamp has been updated.  Validate dependencies.
            validateDeps = true;
        }
        cacheBust = aggregator.getOptions().getCacheBust();
        if (!StringUtils.equals(cacheBust, cached.cacheBust)) {
            if (log.isLoggable(Level.INFO)) {
                log.info(Messages.DepTree_2);
            }
            cached = null;
        }
    }

    /*
     * If we de-serialized a previously saved dependency map, then go with
     * that.
     */
    if (cached != null && rawConfig.equals(cached.rawConfig) && !validateDeps && !clean) {
        depMap = cached.depMap;
        return;
    }

    // Initialize the dependency map
    depMap = new ConcurrentHashMap<URI, DepTreeNode>();

    // This can take a while, so print something to the console
    String msg = MessageFormat.format(Messages.DepTree_3, new Object[] { aggregator.getName() });

    ConsoleService cs = new ConsoleService();
    cs.println(msg);

    if (log.isLoggable(Level.INFO)) {
        log.info(msg);
    }
    // Make sure that all the paths are unique and orthogonal
    paths = DepUtils.removeRedundantPaths(paths);

    /*
     * Create the thread pools, one for the tree builders and one for the
     * parsers. Since a tree builder thread will wait for all the outstanding
     * parser threads started by that builder to complete, we need to use two
     * independent thread pools to guard against the possibility of deadlock
     * caused by all the threads in the pool being consumed by tree builders
     * and leaving none available to service the parsers.
     */
    final ThreadGroup treeBuilderTG = new ThreadGroup(TREEBUILDER_TGNAME),
            parserTG = new ThreadGroup(JSPARSER_TGNAME);
    ExecutorService treeBuilderExc = Executors.newFixedThreadPool(10, new ThreadFactory() {
        public Thread newThread(Runnable r) {
            return new Thread(treeBuilderTG, r, MessageFormat.format(THREADNAME,
                    new Object[] { treeBuilderTG.getName(), treeBuilderTG.activeCount() }));
        }
    }), parserExc = Executors.newFixedThreadPool(20, new ThreadFactory() {
        public Thread newThread(Runnable r) {
            return new Thread(parserTG, r, MessageFormat.format(THREADNAME,
                    new Object[] { parserTG.getName(), parserTG.activeCount() }));
        }
    });

    // Counter to keep track of number of tree builder threads started
    AtomicInteger treeBuilderCount = new AtomicInteger(0);

    // The completion services for the thread pools
    final CompletionService<URI> parserCs = new ExecutorCompletionService<URI>(parserExc);
    CompletionService<DepTreeBuilder.Result> treeBuilderCs = new ExecutorCompletionService<DepTreeBuilder.Result>(
            treeBuilderExc);

    // Start the tree builder threads to process the paths
    for (final URI path : paths) {
        /*
         * Create or get from cache the root node for this path and
         * add it to the new map.
         */
        DepTreeNode root = new DepTreeNode(PathUtil.getModuleName(path));
        DepTreeNode cachedNode = null;
        if (cached != null) {
            cachedNode = cached.depMap.get(path);
            if (log.isLoggable(Level.INFO)) {
                log.info(MessageFormat.format(Messages.DepTree_4, new Object[] { path }));
            }
        } else {
            if (log.isLoggable(Level.INFO)) {
                log.info(MessageFormat.format(Messages.DepTree_5, new Object[] { path }));
            }
        }
        depMap.put(path, root);

        treeBuilderCount.incrementAndGet();
        treeBuilderCs.submit(new DepTreeBuilder(aggregator, parserCs, path, root, cachedNode));
    }

    // List of parser exceptions
    LinkedList<Exception> parserExceptions = new LinkedList<Exception>();

    /*
     * Pull the completed tree builder tasks from the completion queue until
     * all the paths have been processed
     */
    while (treeBuilderCount.decrementAndGet() >= 0) {
        try {
            DepTreeBuilder.Result result = treeBuilderCs.take().get();
            if (log.isLoggable(Level.INFO)) {
                log.info(MessageFormat.format(Messages.DepTree_6,
                        new Object[] { result.parseCount, result.dirName }));
            }
        } catch (Exception e) {
            if (log.isLoggable(Level.SEVERE))
                log.log(Level.SEVERE, e.getMessage(), e);
            parserExceptions.add(e);
        }
    }

    // shutdown the thread pools now that we're done with them
    parserExc.shutdown();
    treeBuilderExc.shutdown();

    // If parser exceptions occurred, then rethrow the first one 
    if (parserExceptions.size() > 0) {
        throw new RuntimeException(parserExceptions.get(0));
    }

    // Prune dead nodes (nodes with no children or dependency lists)
    for (Map.Entry<URI, DepTreeNode> entry : depMap.entrySet()) {
        entry.getValue().prune();
    }

    /*
     * Make sure the cache directory exists before we try to serialize the
     * dependency map.
     */
    if (!cacheDir.exists())
        if (!cacheDir.mkdirs()) {
            throw new IOException(
                    MessageFormat.format(Messages.DepTree_0, new Object[] { cacheDir.getAbsolutePath() }));
        }

    // Serialize the map to the cache directory
    ObjectOutputStream os;
    os = new ObjectOutputStream(new FileOutputStream(cacheFile));
    try {
        os.writeObject(this);
    } finally {
        try {
            os.close();
        } catch (Exception ignore) {
        }
    }
    msg = MessageFormat.format(Messages.DepTree_7, new Object[] { aggregator.getName() });

    // Output that we're done.
    cs.println(msg);
    if (log.isLoggable(Level.INFO)) {
        log.info(msg);
    }
}

From source file:com.npower.dm.setup.task.DeviceGeneratorTask.java

@Override
protected void process() throws SetupException {

    int totalThread = this.getTotalThread();
    this.getSetup().getConsole().println("Starting total thread: " + totalThread);
    try {/*  w  w  w  .  j  a  v  a 2  s . c o m*/
        ThreadGroup group = new ThreadGroup(this.getClass().getName());
        List<Thread> threads = new ArrayList<Thread>();
        for (int i = 0; i < totalThread; i++) {
            TaskThread runnable = new TaskThread(this);
            Thread t = new Thread(group, runnable, "Thread#" + i);
            threads.add(t);
            t.start();
            this.getSetup().getConsole().println("Started thread: " + t.getName());
        }
        /*
        try {
          Thread.sleep(1000 * 3600 * 12);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
        */
        for (Thread t : threads) {
            t.join();
        }
    } catch (InterruptedException e) {
        throw new SetupException(e.getMessage(), e);
    }

    this.getSetup().getConsole().println("All of thread finished.");
}

From source file:org.apache.synapse.transport.nhttp.HttpCoreNIOSender.java

/**
 * Initialize the transport sender, and execute reactor in new separate thread
 * @param cfgCtx the Axis2 configuration context
 * @param transportOut the description of the http/s transport from Axis2 configuration
 * @throws AxisFault thrown on an error/*  ww w. j  av  a2 s  .  c  o m*/
 */
public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
    this.configurationContext = cfgCtx;

    cfg = NHttpConfiguration.getInstance();
    params = new BasicHttpParams();
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
            cfg.getProperty(NhttpConstants.SO_TIMEOUT_SENDER, 60000))
            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                    cfg.getProperty(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000))
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,
                    cfg.getProperty(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024))
            .setParameter(CoreProtocolPNames.USER_AGENT, "Synapse-HttpComponents-NIO");
    //                .setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET,
    //                        cfg.getStringValue(CoreProtocolPNames.HTTP_ELEMENT_CHARSET,HTTP.DEFAULT_PROTOCOL_CHARSET)); //TODO:This does not works with HTTPCore 4.3

    name = transportOut.getName().toUpperCase(Locale.US) + " Sender";

    ClientConnFactoryBuilder contextBuilder = initConnFactoryBuilder(transportOut);
    connFactory = contextBuilder.createConnFactory(params);

    connpool = new ConnectionPool();

    proxyConfig = new ProxyConfigBuilder().parse(transportOut).build();
    if (log.isInfoEnabled() && proxyConfig.getProxy() != null) {
        log.info("HTTP Sender using Proxy " + proxyConfig.getProxy() + " bypassing "
                + proxyConfig.getProxyBypass());
    }

    Parameter param = transportOut.getParameter("warnOnHTTP500");
    if (param != null) {
        String[] warnOnHttp500 = ((String) param.getValue()).split("\\|");
        cfgCtx.setNonReplicableProperty("warnOnHTTP500", warnOnHttp500);
    }

    IOReactorConfig ioReactorConfig = new IOReactorConfig();
    ioReactorConfig.setIoThreadCount(NHttpConfiguration.getInstance().getClientIOWorkers());
    ioReactorConfig.setSoTimeout(cfg.getProperty(NhttpConstants.SO_TIMEOUT_RECEIVER, 60000));
    ioReactorConfig.setConnectTimeout(cfg.getProperty(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000));
    ioReactorConfig.setTcpNoDelay(cfg.getProperty(CoreConnectionPNames.TCP_NODELAY, 1) == 1);
    if (cfg.getBooleanValue("http.nio.interest-ops-queueing", false)) {
        ioReactorConfig.setInterestOpQueued(true);
    }

    try {
        String prefix = name + " I/O dispatcher";
        ioReactor = new DefaultConnectingIOReactor(ioReactorConfig,
                new NativeThreadFactory(new ThreadGroup(prefix + " thread group"), prefix));
        ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
            public boolean handle(IOException ioException) {
                log.warn("System may be unstable: IOReactor encountered a checked exception : "
                        + ioException.getMessage(), ioException);
                return true;
            }

            public boolean handle(RuntimeException runtimeException) {
                log.warn("System may be unstable: IOReactor encountered a runtime exception : "
                        + runtimeException.getMessage(), runtimeException);
                return true;
            }
        });
    } catch (IOException e) {
        log.error("Error starting the IOReactor", e);
        throw new AxisFault(e.getMessage(), e);
    }

    metrics = new NhttpMetricsCollector(false, transportOut.getName());
    handler = new ClientHandler(connpool, connFactory, proxyConfig.getCreds(), cfgCtx, params, metrics);
    iodispatch = new ClientIODispatch(handler, connFactory);
    final IOEventDispatch ioEventDispatch = iodispatch;

    // start the Sender in a new seperate thread
    Thread t = new Thread(new Runnable() {
        public void run() {
            try {
                ioReactor.execute(ioEventDispatch);
            } catch (InterruptedIOException ex) {
                log.fatal("Reactor Interrupted");
            } catch (IOException e) {
                log.fatal("Encountered an I/O error: " + e.getMessage(), e);
            }
            log.info(name + " Shutdown");
        }
    }, "HttpCoreNIOSender");
    t.start();
    log.info(name + " starting");

    // register with JMX
    mbeanSupport = new TransportMBeanSupport(this, "nio-" + transportOut.getName());
    mbeanSupport.register();

    state = BaseConstants.STARTED;
}

From source file:org.cloudata.core.master.CloudataMaster.java

public void init(CloudataConf conf) throws IOException {
    InetSocketAddress serverAddress = NetworkUtil.getLocalAddress(conf.getInt("masterServer.port", 7000));

    this.hostName = serverAddress.getHostName() + ":" + serverAddress.getPort();

    this.threadGroup = new ThreadGroup("CloudataMaster_" + hostName);

    this.conf = conf;

    this.fs = CloudataFileSystem.get(conf);
    if (this.fs == null) {
        LOG.fatal("FileSystem is not ready. CloudataMaster shutdown");
        shutdown();/*from  w w w  . ja v a 2s .c  om*/
    }

    this.zk = LockUtil.getZooKeeper(conf, hostName, this);
    this.schemaMap = new TableSchemaMap(conf, zk);

    this.server = CRPC.getServer(zk, this, serverAddress.getHostName(), serverAddress.getPort(),
            conf.getInt("masterServer.handler.count", 10), false, conf);

    this.server.start();

    LOG.info("Netune master started at " + hostName);
}

From source file:org.apache.synapse.transport.nhttp.HttpCoreNIOListener.java

/**
 * Initialize the transport listener, and execute reactor in new separate thread
 * @param "cfgCtx" the Axis2 configuration context
 * @param transportIn the description of the http/s transport from Axis2 configuration
 * @throws AxisFault on error//from   w  w  w .j  av a 2  s.co m
 */
public void init(ConfigurationContext ctx, TransportInDescription transportIn) throws AxisFault {

    cfgCtx = ctx;
    Map<String, String> o = (Map<String, String>) cfgCtx.getProperty(NhttpConstants.EPR_TO_SERVICE_NAME_MAP);
    if (o != null) {
        this.eprToServiceNameMap = o;
    } else {
        eprToServiceNameMap = new HashMap<String, String>();
        cfgCtx.setProperty(NhttpConstants.EPR_TO_SERVICE_NAME_MAP, eprToServiceNameMap);
    }

    NHttpConfiguration cfg = NHttpConfiguration.getInstance();

    // Initialize connection factory
    params = new BasicHttpParams();
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
            cfg.getProperty(NhttpConstants.SO_TIMEOUT_RECEIVER, 60000))
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,
                    cfg.getProperty(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024))
            .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "Synapse-HttpComponents-NIO");
    //                .setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET,
    //                        cfg.getStringValue(CoreProtocolPNames.HTTP_ELEMENT_CHARSET, HTTP.DEFAULT_PROTOCOL_CHARSET)); //TODO:This does not works with HTTPCore 4.3

    name = transportIn.getName().toUpperCase(Locale.US) + " Listener";
    scheme = initScheme();

    // Setup listener context
    listenerContext = new ListenerContextBuilder(transportIn).parse().build();

    System.setProperty(transportIn.getName() + ".nio.port", String.valueOf(listenerContext.getPort()));

    // Setup connection factory
    HttpHost host = new HttpHost(listenerContext.getHostname(), listenerContext.getPort(), scheme.getName());
    connFactory = initConnFactoryBuilder(transportIn, host).build(params);

    // configure the IO reactor on the specified port
    try {
        String prefix = name + " I/O dispatcher";
        IOReactorConfig ioReactorConfig = new IOReactorConfig();
        ioReactorConfig.setIoThreadCount(cfg.getServerIOWorkers());
        ioReactorConfig.setSoTimeout(cfg.getProperty(NhttpConstants.SO_TIMEOUT_RECEIVER, 60000));
        ioReactorConfig.setTcpNoDelay(cfg.getProperty(CoreConnectionPNames.TCP_NODELAY, 1) == 1);
        if (cfg.getBooleanValue("http.nio.interest-ops-queueing", false)) {
            ioReactorConfig.setInterestOpQueued(true);
        }
        ioReactorConfig.setSoReuseAddress(cfg.getBooleanValue(CoreConnectionPNames.SO_REUSEADDR, false));

        ioReactor = new DefaultListeningIOReactor(ioReactorConfig,
                new NativeThreadFactory(new ThreadGroup(prefix + " thread group"), prefix));

        ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
            public boolean handle(IOException ioException) {
                log.warn("System may be unstable: IOReactor encountered a checked exception : "
                        + ioException.getMessage(), ioException);
                return true;
            }

            public boolean handle(RuntimeException runtimeException) {
                log.warn("System may be unstable: IOReactor encountered a runtime exception : "
                        + runtimeException.getMessage(), runtimeException);
                return true;
            }
        });
    } catch (IOException e) {
        handleException("Error creating IOReactor", e);
    }

    metrics = new NhttpMetricsCollector(true, transportIn.getName());

    handler = new ServerHandler(cfgCtx, scheme, listenerContext, metrics);
    iodispatch = new ServerIODispatch(handler, connFactory);

    Parameter param = transportIn.getParameter(NhttpConstants.WSDL_EPR_PREFIX);
    if (param != null) {
        serviceEPRPrefix = getServiceEPRPrefix(cfgCtx, (String) param.getValue());
        customEPRPrefix = (String) param.getValue();
        EPRPrefixCheck = false;
    } else {
        serviceEPRPrefix = getServiceEPRPrefix(cfgCtx, listenerContext.getHostname(),
                listenerContext.getPort());
        customEPRPrefix = scheme.getName() + "://" + listenerContext.getHostname() + ":"
                + (listenerContext.getPort() == scheme.getDefaultPort() ? "" : listenerContext.getPort()) + "/";
    }

    // register to receive updates on services for lifetime management
    cfgCtx.getAxisConfiguration().addObservers(axisObserver);

    // register with JMX
    mbeanSupport = new TransportMBeanSupport(this, "nio-" + transportIn.getName());
    mbeanSupport.register();
}

From source file:helma.framework.core.Application.java

/**
 * Build an application with the given name, server instance, sources and
 * db directory./*w w w  .  j a  v a 2 s  .c  om*/
 */
public Application(String name, Server server, Repository[] repositories, File customAppDir, File customDbDir)
        throws RemoteException, IllegalArgumentException {
    if ((name == null) || (name.trim().length() == 0)) {
        throw new IllegalArgumentException("Invalid application name: " + name);
    }

    if (repositories.length == 0) {
        throw new java.lang.IllegalArgumentException("No sources defined for application: " + name);
    }

    this.name = name;

    this.caseInsensitive = "true"
            .equalsIgnoreCase(server.getAppsProperties(name).getProperty("caseInsensitive"));

    this.repositories = new ArrayList();
    this.repositories.addAll(Arrays.asList(repositories));
    resourceComparator = new ResourceComparator(this);

    appDir = customAppDir;
    dbDir = customDbDir;

    // system-wide properties, default to null
    ResourceProperties sysProps;

    // system-wide properties, default to null
    ResourceProperties sysDbProps;

    sysProps = sysDbProps = null;
    hopHome = null;

    if (server != null) {
        hopHome = server.getHopHome();

        if (dbDir == null) {
            dbDir = new File(server.getDbHome(), name);
        }

        // get system-wide properties
        sysProps = server.getProperties();
        sysDbProps = server.getDbProperties();
    }

    if (!dbDir.exists()) {
        dbDir.mkdirs();
    }

    if (appDir == null) {
        for (int i = repositories.length - 1; i >= 0; i--) {
            if (repositories[i] instanceof FileRepository) {
                appDir = new File(repositories[i].getName());
                break;
            }
        }
    }

    // give the Helma Thread group a name so the threads can be recognized
    threadgroup = new ThreadGroup("TX-" + name);

    // create app-level properties
    props = new ResourceProperties(this, "app.properties", sysProps);

    // get log names
    accessLogName = props.getProperty("accessLog",
            new StringBuffer("helma.").append(name).append(".access").toString());
    eventLogName = props.getProperty("eventLog",
            new StringBuffer("helma.").append(name).append(".event").toString());

    // create app-level db sources
    dbProps = new ResourceProperties(this, "db.properties", sysDbProps, false);

    // the passwd file, to be used with the authenticate() function
    CryptResource parentpwfile = null;

    if (hopHome != null) {
        parentpwfile = new CryptResource(new FileResource(new File(hopHome, "passwd")), null);
    }

    pwfile = new CryptResource(repositories[0].getResource("passwd"), parentpwfile);

    // the properties that map java class names to prototype names
    classMapping = new ResourceProperties(this, "class.properties");
    classMapping.setIgnoreCase(false);

    // get class name of root object if defined. Otherwise native Helma objectmodel will be used.
    rootObjectClass = classMapping.getProperty("root");

    updateProperties();

    dbSources = new Hashtable();
    modules = new SystemMap();
}

From source file:org.apache.hadoop.hdfs.server.datanode.CachingDataNode.java

private void reconfigureDataXceiver(final Configuration conf) throws IOException {

    final ServerSocket ss = ((DataXceiverServer) this.dataNode.dataXceiverServer.getRunnable()).ss;

    // Shut down old dataXceiverServer and replace it with our version
    if (this.dataNode.dataXceiverServer != null) {
        ((DataXceiverServer) this.dataNode.dataXceiverServer.getRunnable()).kill();
        this.dataNode.dataXceiverServer.interrupt();

        // wait for all data receiver threads to exit
        if (this.dataNode.threadGroup != null) {
            int sleepMs = 2;
            while (true) {
                this.dataNode.threadGroup.interrupt();
                LOG.info("Waiting for threadgroup to exit, active threads is "
                        + this.dataNode.threadGroup.activeCount());
                if (this.dataNode.threadGroup.activeCount() == 0) {
                    break;
                }/*from  ww  w.j  a v  a2 s .c  o m*/
                try {
                    Thread.sleep(sleepMs);
                } catch (InterruptedException e) {
                }
                sleepMs = sleepMs * 3 / 2; // exponential backoff
                if (sleepMs > 1000) {
                    sleepMs = 1000;
                }
            }
        }
        // wait for dataXceiveServer to terminate
        try {
            this.dataNode.dataXceiverServer.join();
        } catch (InterruptedException ie) {
        }
    }

    // find free port or use privileged port provided
    final ServerSocket newServerSocket = (dnConf.socketWriteTimeout > 0) ? ServerSocketChannel.open().socket()
            : new ServerSocket();
    newServerSocket.setReceiveBufferSize(HdfsConstants.DEFAULT_DATA_SOCKET_SIZE);
    Server.bind(newServerSocket, (InetSocketAddress) ss.getLocalSocketAddress(), 0);
    newServerSocket.setReceiveBufferSize(HdfsConstants.DEFAULT_DATA_SOCKET_SIZE);

    this.dataNode.threadGroup = new ThreadGroup("cachingDataXceiverServer");
    this.dataNode.dataXceiverServer = new Daemon(this.dataNode.threadGroup,
            new CachingDataXceiverServer(newServerSocket, conf, this.dataNode, this.blockCache));
    this.dataNode.threadGroup.setDaemon(true); // auto destroy when empty
}

From source file:org.apache.axis2.transport.http.server.HttpFactory.java

/**
 * Create the executor use the manage request processing threads
 *//*from ww  w  .ja  va  2  s .  co m*/
public ExecutorService newRequestExecutor(int port) {
    return new ThreadPoolExecutor(requestCoreThreadPoolSize, requestMaxThreadPoolSize, threadKeepAliveTime,
            threadKeepAliveTimeUnit, newRequestBlockingQueue(),
            new DefaultThreadFactory(new ThreadGroup("Connection thread group"), "HttpConnection-" + port));
}

From source file:com.cohesionforce.dis.BinaryConverter.java

public BinaryConverter() {
    unmarshaller = new Unmarshaller();
    threadGroup = new ThreadGroup("LoggerThreads");
}