Skip to content

Commit 011ac3c

Browse files
CLOUDSTACK-10012: Embedded Jetty for CloudStack
WIP embedded jetty support Changes adapted from PR apache#372 and apache#1546 Signed-off-by: Rohit Yadav <[email protected]>
1 parent 553b092 commit 011ac3c

File tree

7 files changed

+179
-6
lines changed

7 files changed

+179
-6
lines changed

client/jetty/pom.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<groupId>org.apache.cloudstack</groupId>
26+
<artifactId>cloudstack-jetty</artifactId>
27+
<parent>
28+
<groupId>org.apache.cloudstack</groupId>
29+
<artifactId>cloudstack</artifactId>
30+
<version>4.9.0-SNAPSHOT</version>
31+
<relativePath>../../pom.xml</relativePath>
32+
</parent>
33+
<name>Apache CloudStack Jetty</name>
34+
<properties>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
37+
</properties>
38+
<dependencies>
39+
<dependency>
40+
<groupId>org.eclipse.jetty</groupId>
41+
<artifactId>jetty-runner</artifactId>
42+
<version>${cs.jetty.version}</version>
43+
<scope>runtime</scope>
44+
</dependency>
45+
</dependencies>
46+
<build>
47+
<finalName>${project.artifactId}</finalName>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-checkstyle-plugin</artifactId>
52+
<executions>
53+
<execution>
54+
<id>cloudstack-checkstyle</id>
55+
<phase>none</phase>
56+
<inherited>false</inherited>
57+
</execution>
58+
</executions>
59+
</plugin>
60+
<plugin>
61+
<artifactId>maven-assembly-plugin</artifactId>
62+
<configuration>
63+
<descriptors>
64+
<descriptor>standalone.xml</descriptor>
65+
</descriptors>
66+
</configuration>
67+
<executions>
68+
<execution>
69+
<id>make-assembly</id>
70+
<phase>package</phase>
71+
<goals>
72+
<goal>single</goal>
73+
</goals>
74+
</execution>
75+
</executions>
76+
</plugin>
77+
</plugins>
78+
</build>
79+
</project>

client/jetty/standalone.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<assembly>
3+
<id>standalone</id>
4+
<formats>
5+
<format>dir</format>
6+
</formats>
7+
<includeBaseDirectory>true</includeBaseDirectory>
8+
<baseDirectory></baseDirectory>
9+
<fileSets>
10+
<fileSet>
11+
<directory>src/main/jetty/bin</directory>
12+
<outputDirectory>/bin</outputDirectory>
13+
<fileMode>755</fileMode>
14+
</fileSet>
15+
</fileSets>
16+
<dependencySets>
17+
<dependencySet>
18+
<useProjectArtifact>false</useProjectArtifact>
19+
<outputDirectory>/lib</outputDirectory>
20+
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
21+
</dependencySet>
22+
<dependencySet>
23+
<useProjectArtifact>true</useProjectArtifact>
24+
<scope>runtime</scope>
25+
<includes>
26+
<include>org.eclipse.jetty:jetty-start:*</include>
27+
</includes>
28+
<outputDirectory>/bin</outputDirectory>
29+
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
30+
</dependencySet>
31+
</dependencySets>
32+
</assembly>

client/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
<version>${project.version}</version>
210210
<exclusions>
211211
<exclusion>
212-
<groupId>org.mortbay.jetty</groupId>
212+
<groupId>org.eclipse.jetty</groupId>
213213
<artifactId>servlet-api</artifactId>
214214
</exclusion>
215215
</exclusions>
@@ -468,7 +468,7 @@
468468
<stopPort>9966</stopPort>
469469
<stopKey>stop-jetty</stopKey>
470470
<connectors>
471-
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
471+
<connector implementation="org.eclipse.jetty.nio.SelectChannelConnector">
472472
<port>8080</port>
473473
<maxIdleTime>60000</maxIdleTime>
474474
</connector>
@@ -477,9 +477,8 @@
477477
<webAppSourceDirectory>${project.build.directory}/generated-webapp</webAppSourceDirectory>
478478
<webAppConfig>
479479
<contextPath>/client</contextPath>
480-
<extraClasspath>${project.build.directory}/utilities/scripts/db/;${project.build.directory}/utilities/scripts/db/db/</extraClasspath>
480+
<extraClasspath>${project.build.directory}/conf;${project.build.directory}/../../setup/db/;${project.build.directory}/../../setup/db/db/</extraClasspath>
481481
</webAppConfig>
482-
483482
<systemProperties>
484483
<systemProperty>
485484
<name>log4j.configuration</name>

debian/rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ override_dh_auto_install:
8787
ln -s tomcat6-nonssl.conf $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/tomcat6.conf
8888
install -D packaging/debian/init/cloud-management $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-management
8989
install -D client/target/utilities/bin/cloud-update-xenserver-licenses $(DESTDIR)/usr/bin/cloudstack-update-xenserver-licenses
90+
91+
# WIP jetty support
92+
cp -r client/jetty/target/cloudstack-jetty-standalone/* $(DESTDIR)/usr/share/$(PACKAGE)-management/
93+
9094
# Remove configuration in /ur/share/cloudstack-management/webapps/client/WEB-INF
9195
# This should all be in /etc/cloudstack/management
9296
rm $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps/client/WEB-INF/classes/*.*

engine/storage/image/resources/META-INF/cloudstack/core/spring-engine-storage-image-core-context.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
>
2929

3030
<bean id="templateServiceImpl"
31-
class="org.apache.cloudstack.storage.image.TemplateServiceImpl"
32-
depends-on="dataObjectManagerImpl, dataStoreManagerImpl, dataMotionServiceImpl, objectInDataStoreManagerImpl, defaultEndPointSelector, templateDataFactoryImpl, imageStoreDetailsUtil" />
31+
class="org.apache.cloudstack.storage.image.TemplateServiceImpl" />
3332

3433
<bean id="templateDataFactoryImpl"
3534
class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />

packaging/cloud-management.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
. /etc/cloudstack/management/tomcat6.conf
4+
SERVLETENGINE='jetty'
5+
# For SELinux we need to use 'runuser' not 'su'
6+
if [ -x "/sbin/runuser" ]; then
7+
SU="/sbin/runuser -s /bin/sh"
8+
else
9+
SU="/bin/su -s /bin/sh"
10+
fi
11+
12+
touch $CLOUD_PID;
13+
chown $CLOUD_USER. $CLOUD_PID
14+
# CLASSPATH munging
15+
if [ -n "$JSSE_HOME" ]; then
16+
CLASSPATH="${CLASSPATH}:$(build-classpath jcert jnet jsse 2>/dev/null)"
17+
fi
18+
CLASSPATH="${CLASSPATH}:$(build-classpath commons-daemon 2>/dev/null)"
19+
20+
CLOUD_HOME="/usr/share/cloudstack-management/"
21+
CLOUD_BASE=$CLOUD_HOME
22+
23+
NAME="cloudstack-management"
24+
25+
# Define the tomcat username
26+
CLOUD_USER="${CLOUD_USER:-cloud}"
27+
28+
# Define the tomcat group
29+
CLOUD_GROUP="${CLOUD_GROUP:-`id -gn $CLOUD_USER`}"
30+
31+
# Define the tomcat log file
32+
CLOUD_LOG="${CLOUD_LOG:-/var/log/${NAME}-initd.log}"
33+
34+
# Define the pid file name
35+
# If change is needed, use sysconfig instead of here
36+
export CLOUD_PID="${CLOUD_PID:-/var/run/${NAME}.pid}"
37+
CLASSPATH="${CLASSPATH}:${CLOUD_HOME}/lib/jetty-runner.jar"
38+
CLASS="org.eclipse.jetty.runner.Runner --classes /etc/cloudstack/management --path /client $CLOUD_HOME/webapps/client --stop-port 8888 --stop-key monkeystop"
39+
40+
if [ "$1" = "start" ]; then
41+
java $JAVA_OPTS $CLOUD_OPTS \
42+
-classpath "$CLASSPATH" \
43+
-D"$SERVLETENGINE".base="$CLOUD_BASE" \
44+
-D"$SERVLETENGINE".home="$CLOUD_HOME" \
45+
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
46+
-Djava.io.tmpdir="$CLOUD_TMPDIR" \
47+
$CLASS \
48+
>> ${CLOUD_BASE}/logs/servlet-engine.out 2>&1 &
49+
if [ ! -z "$CLOUD_PID" ]; then
50+
echo $! > $CLOUD_PID
51+
fi
52+
elif [ "$1" = "stop" ]; then
53+
echo Stopping server
54+
java -jar ${CLOUD_HOME}/start.jar --stop -DSTOP.PORT=8888 -DSTOP.KEY=monkeystop
55+
else
56+
echo "Usage: $0 {start|stop}"
57+
exit 1
58+
fi

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
<module>plugins</module>
209209
<module>framework</module>
210210
<module>client</module>
211+
<module>client/jetty</module>
211212
<module>services</module>
212213
<module>maven-standard</module>
213214
<module>quickcloud</module>
@@ -831,6 +832,7 @@
831832
<exclude>**/.vagrant</exclude>
832833
<exclude>**/*.json</exclude>
833834
<exclude>build/build.number</exclude>
835+
<exclude>client/jetty/standalone.xml</exclude>
834836
<exclude>services/console-proxy/server/js/jquery.js</exclude>
835837
<exclude>debian/cloudstack-usage.dirs</exclude>
836838
<exclude>debian/cloudstack-agent.dirs</exclude>

0 commit comments

Comments
 (0)