Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.netflix.recipes.rss.util.DescriptiveThreadFactory;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.*;
import org.jboss.netty.channel.group.ChannelGroup;
Expand Down Expand Up @@ -143,12 +144,14 @@ public NettyServer build() {
ThreadPoolExecutor bossPool = new ThreadPoolExecutor(
numBossThreads, numBossThreads, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
new DescriptiveThreadFactory("Boss-Thread"));
new ThreadFactoryBuilder().setNameFormat("Boss-Thread-%d")
.setDaemon(false).setPriority(Thread.NORM_PRIORITY).build());

ThreadPoolExecutor workerPool = new ThreadPoolExecutor(
numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
new DescriptiveThreadFactory("Worker-Thread"));
new ThreadFactoryBuilder().setNameFormat("Worker-Thread-%d")
.setDaemon(false).setPriority(Thread.NORM_PRIORITY).build());

ChannelFactory nioServer = new NioServerSocketChannelFactory(
bossPool, workerPool, numWorkerThreads);
Expand Down Expand Up @@ -191,7 +194,8 @@ public PipelineFactory(Map<String, ChannelHandler> handlers,
ThreadPoolExecutor executorThreadPool = new ThreadPoolExecutor(
NettyServer.cpus, NettyServer.cpus * 4, 60,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
new DescriptiveThreadFactory("Executor-Thread"));
new ThreadFactoryBuilder().setNameFormat("Executor-Thread-%d")
.setDaemon(false).setPriority(Thread.NORM_PRIORITY).build());

this.executionHandler = new ExecutionHandler(executorThreadPool);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import com.netflix.karyon.server.KaryonServer;
import com.netflix.recipes.rss.RSSConstants;

/**
* Base Jetty Server
Expand All @@ -48,8 +47,19 @@ public class BaseJettyServer implements Closeable {

protected final Injector injector;

public BaseJettyServer() {
System.setProperty(DynamicPropertyFactory.ENABLE_JMX, "true");
private final String portPropertyName;

private String webAppsDir;

private String hystrixStreamPath;

public BaseJettyServer(String portPropertyName, String webAppsDir, String hystrixStreamPath) {

System.setProperty(DynamicPropertyFactory.ENABLE_JMX, "true");

this.portPropertyName = portPropertyName;
this.webAppsDir = webAppsDir;
this.hystrixStreamPath = hystrixStreamPath;

this.karyonServer = new KaryonServer();
this.injector = karyonServer.initialize();
Expand All @@ -58,15 +68,15 @@ public BaseJettyServer() {

public void start() {

final int port = ConfigurationManager.getConfigInstance().getInt(RSSConstants.JETTY_HTTP_PORT, Integer.MIN_VALUE);
final int port = ConfigurationManager.getConfigInstance().getInt(portPropertyName, Integer.MIN_VALUE);

final Context context = new Context(jettyServer, "/", Context.SESSIONS);
context.setResourceBase(RSSConstants.WEBAPPS_DIR);
context.setResourceBase(webAppsDir);
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.addServlet(JspServlet.class, "*.jsp");

// Enable hystrix.stream
context.addServlet(HystrixMetricsStreamServlet.class, RSSConstants.HYSTRIX_STREAM_PATH);
context.addServlet(HystrixMetricsStreamServlet.class, hystrixStreamPath);

final Server server = new Server(port);
server.setHandler(context);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.netflix.config.ConfigurationManager;
import com.netflix.karyon.spi.PropertyNames;
import com.netflix.recipes.rss.RSSConstants;

/**
* Edge Server
Expand All @@ -31,8 +32,10 @@ public class EdgeServer extends BaseJettyServer {
.getLogger(EdgeServer.class);

public EdgeServer() {
super(RSSConstants.JETTY_HTTP_PORT, RSSConstants.WEBAPPS_DIR,
RSSConstants.HYSTRIX_STREAM_PATH);
}

public static void main(final String[] args) throws Exception {
System.setProperty("archaius.deployment.applicationId", "edge");
System.setProperty(PropertyNames.SERVER_BOOTSTRAP_BASE_PACKAGES_OVERRIDE, "com.netflix");
Expand Down