上一节,主要讲了配置方面,接下来azkaban就开始启动server.
talk is cheap, show the code!
================================================
接下来主要是Jetty的Server的初始化,其实主要就是读配置,没啥好说的。
boolean ssl;
int port;//
final Server server = new Server();//org.mortbay.jetty.Server.Server()
if (azkabanSettings.getBoolean("jetty.use.ssl", true)) {//这里为了更快速的
掌握azkaban,我在配置文件里设置jetty.use.ssl=false
int sslPortNumber =
azkabanSettings.getInt("jetty.ssl.port", DEFAULT_SSL_PORT_NUMBER);
port = sslPortNumber;
ssl = true;
logger.info("Setting up Jetty Https Server with port:" + sslPortNumber
+ " and numThreads:" + maxThreads);
SslSocketConnector secureConnector = new SslSocketConnector();
secureConnector.setPort(sslPortNumber);
secureConnector.setKeystore(azkabanSettings.getString("jetty.keystore"));
secureConnector.setPassword(azkabanSettings.getString("jetty.password"));
secureConnector.setKeyPassword(azkabanSettings
.getString("jetty.keypassword"));
secureConnector.setTruststore(azkabanSettings
.getString("jetty.truststore"));
secureConnector.setTrustPassword(azkabanSettings
.getString("jetty.trustpassword"));
secureConnector.setHeaderBufferSize(MAX_HEADER_BUFFER_SIZE);
// set up vulnerable cipher suites to exclude
List<String> cipherSuitesToExclude = azkabanSettings.getStringList("jetty.excludeCipherSuites");
logger.info("Excluded Cipher Suites: " + String.valueOf(cipherSuitesToExclude));
if (cipherSuitesToExclude != null && !cipherSuitesToExclude.isEmpty()) {
secureConnector.setExcludeCipherSuites(cipherSuitesToExclude.toArray(new String[0]));
}
server.addConnector(secureConnector);
} else {//看到这里了
ssl = false;//看到这里了
port = azkabanSettings.getInt("jetty.port", DEFAULT_PORT_NUMBER);//默认端口8081
SocketConnector connector = new SocketConnector();//基于Jetty
connector.setPort(port);//设置端口
connector.setHeaderBufferSize(MAX_HEADER_BUFFER_SIZE);//10M
server.addConnector(connector);//纳入管理体系
}
// setting stats configuration for connectors
for (Connector connector : server.getConnectors()) {
connector.setStatsOn(isStatsOn);//开启统计开关
}
String hostname = azkabanSettings.getString("jetty.hostname", "localhost");
azkabanSettings.put("server.hostname", hostname);//保存起来
azkabanSettings.put("server.port", port);//保存起来
azkabanSettings.put("server.useSSL", String.valueOf(ssl));//保存起来
//看到这里了
这样,基于Jetty Server就构造完毕,接下来会作为参数传入azkaban里面,
欲知后事如何,请听下回分解!