Skip to content

Commit 1941b77

Browse files
author
Matthew Sackman
committed
merge from default
2 parents 823ca36 + 02973d4 commit 1941b77

17 files changed

+893
-137
lines changed

build.xml

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,64 @@
106106
</fileset>
107107
</javadoc>
108108
</target>
109-
109+
110+
<target name="detect-ssl">
111+
<property environment="env"/>
112+
<property name="SSL_CERTS_DIR" value="${env.SSL_CERTS_DIR}"/>
113+
<available property="SSL_AVAILABLE" file="${SSL_CERTS_DIR}/client"/>
114+
<property name="CLIENT_KEYSTORE_PHRASE" value="bunnies"/>
115+
<property environment="env"/>
116+
<property name="SSL_P12_PASSWORD" value="${env.PASSWORD}"/>
117+
</target>
118+
119+
<target name="make-client-keystore" if="SSL_AVAILABLE" depends="detect-ssl">
120+
<exec executable="mktemp" outputproperty="CLIENT_KEYSTORE" failonerror="true" osfamily="unix">
121+
<arg value="-u"/>
122+
</exec>
123+
<exec executable="keytool" failonerror="true" osfamily="unix">
124+
<arg line="-import"/>
125+
<arg value="-alias"/>
126+
<arg value="server1"/>
127+
<arg value="-file"/>
128+
<arg value="${SSL_CERTS_DIR}/testca/cacert.pem"/>
129+
<arg value="-keystore"/>
130+
<arg value="${CLIENT_KEYSTORE}"/>
131+
<arg value="-noprompt"/>
132+
<arg value="-storepass"/>
133+
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
134+
</exec>
135+
<exec executable="mktemp" outputproperty="CLIENT_KEYSTORE_EMPTY" failonerror="true" osfamily="unix">
136+
<arg value="-u"/>
137+
</exec>
138+
<!-- can't create an empty keystore, so add cert in and then delete it! -->
139+
<exec executable="keytool" failonerror="true" osfamily="unix">
140+
<arg line="-import"/>
141+
<arg value="-alias"/>
142+
<arg value="server1"/>
143+
<arg value="-file"/>
144+
<arg value="${SSL_CERTS_DIR}/testca/cacert.pem"/>
145+
<arg value="-keystore"/>
146+
<arg value="${CLIENT_KEYSTORE_EMPTY}"/>
147+
<arg value="-noprompt"/>
148+
<arg value="-storepass"/>
149+
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
150+
</exec>
151+
<exec executable="keytool" failonerror="true" osfamily="unix">
152+
<arg line="-delete"/>
153+
<arg value="-alias"/>
154+
<arg value="server1"/>
155+
<arg value="-keystore"/>
156+
<arg value="${CLIENT_KEYSTORE_EMPTY}"/>
157+
<arg value="-storepass"/>
158+
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
159+
</exec>
160+
</target>
161+
162+
<target name="remove-client-keystore" if="SSL_AVAILABLE">
163+
<delete file="${CLIENT_KEYSTORE}" failonerror="false"/>
164+
<delete file="${CLIENT_KEYSTORE_EMPTY}" failonerror="false"/>
165+
</target>
166+
110167
<target name="test-prepare">
111168
<property name="haltOnFailureJunit" value="yes" />
112169
<property name="haltOnFailureJava" value="true" />
@@ -261,7 +318,7 @@
261318
</fail>
262319
</target>
263320

264-
<target name="test-suite-run" depends="test, test-persister-restart, test-functional, test-main-silent"/>
321+
<target name="test-suite-run" depends="test, test-ssl, test-persister-restart, test-functional, test-main-silent"/>
265322

266323
<target name="test" depends="test-build">
267324
<junit printSummary="withOutAndErr"
@@ -276,6 +333,26 @@
276333
</junit>
277334
</target>
278335

336+
<target name="test-ssl" depends="test-build, make-client-keystore" if="SSL_AVAILABLE">
337+
<junit printSummary="withOutAndErr"
338+
haltOnFailure="${haltOnFailureJunit}"
339+
failureproperty="test.failure"
340+
fork="yes">
341+
<classpath refid="test.classpath"/>
342+
<jvmarg value="-Dkeystore.path=${CLIENT_KEYSTORE}"/>
343+
<jvmarg value="-Dkeystore.empty.path=${CLIENT_KEYSTORE_EMPTY}"/>
344+
<jvmarg value="-Dkeystore.passwd=${CLIENT_KEYSTORE_PHRASE}"/>
345+
346+
<jvmarg value="-Dp12.path=${SSL_CERTS_DIR}/client/keycert.p12"/>
347+
<jvmarg value="-Dp12.passwd=${SSL_P12_PASSWORD}"/>
348+
349+
<formatter type="plain"/>
350+
<formatter type="xml"/>
351+
<test todir="${build.out}" name="com.rabbitmq.client.test.ssl.SSLTests"/>
352+
</junit>
353+
<antcall target="remove-client-keystore"/>
354+
</target>
355+
279356
<target name="test-functional" depends="test-build">
280357
<junit printSummary="withOutAndErr"
281358
haltOnFailure="${haltOnFailureJunit}"

scripts/stresspersister.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/sh
2+
3+
commentText=$1
4+
shift
5+
6+
if [ -z "$commentText" ]; then
7+
echo "Comment text must be supplied!"
8+
exit 1
9+
fi
10+
11+
echo "Comment text: $commentText. Press enter to continue."
12+
read dummy
13+
14+
function run1 {
15+
(while true; do (date +%s.%N; ps ax -o '%mem rss sz vsz args' | grep "beam.*-s rabbit" | grep -v grep) | tr '\n' ' ' | awk '{print $1,$2/100,$3,$4,$5}'; sleep 1; done) > memlog.txt &
16+
memlogger=$!
17+
echo "STARTED MEMLOGGER $memlogger"
18+
sleep 2
19+
sh ./runjava.sh com.rabbitmq.examples.StressPersister -B $1 -b $2 -C $commentText | tee stressoutput.txt
20+
logfile=$(head -1 stressoutput.txt)
21+
sleep 2
22+
kill $memlogger
23+
echo "STOPPED MEMLOGGER $memlogger"
24+
baselog=$(basename $logfile .out)
25+
mv memlog.txt $baselog.mem
26+
grep -v '^#' $logfile > stressoutput.txt
27+
mv stressoutput.txt $logfile
28+
}
29+
30+
function run32b {
31+
run1 32b 5000
32+
run1 32b 10000
33+
run1 32b 20000
34+
run1 32b 40000
35+
run1 32b 80000
36+
}
37+
38+
function run1m {
39+
run1 1m 125
40+
run1 1m 250
41+
run1 1m 500
42+
run1 1m 1000
43+
run1 1m 2000
44+
run1 1m 4000
45+
}
46+
47+
function chartall {
48+
for logfile in *.out
49+
do
50+
echo $logfile
51+
baselog=$(basename $logfile .out)
52+
firsttimestamp=$(cat $baselog.mem | head -1 | awk '{print $1}')
53+
cat > $baselog.gnuplot <<EOF
54+
set terminal png size 1024, 768
55+
set logscale y
56+
set xlabel "Time, seconds"
57+
set ylabel "Round-trip time, microseconds"
58+
set y2label "VSZ, megabytes"
59+
set y2range [0 : 1048576]
60+
set y2tics
61+
set ytics nomirror
62+
set autoscale y2
63+
plot '$logfile' using ((\$1 / 1000) - $firsttimestamp):2 title 'RTT' axes x1y1 with lines, \
64+
'$baselog.mem' using (\$1 - $firsttimestamp):(\$5 / 1024) title 'VSZ' axes x1y2 with lines
65+
EOF
66+
gnuplot $baselog.gnuplot > $baselog.png
67+
done
68+
}
69+
70+
run32b
71+
run1m
72+
chartall

src/com/rabbitmq/client/Channel.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,27 @@ Queue.DeclareOk queueDeclare(String queue, boolean passive, boolean durable, boo
355355
*/
356356
Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
357357

358+
/**
359+
* Purges the contents of the given queue and awaits a completion.
360+
* @see com.rabbitmq.client.AMQP.Queue.Purge
361+
* @see com.rabbitmq.client.AMQP.Queue.PurgeOk
362+
* @param queue the name of the queue
363+
* @return a purge-confirm method if the purge was executed succesfully
364+
* @throws java.io.IOException if an error is encountered
365+
*/
366+
Queue.PurgeOk queuePurge(String queue) throws IOException;
367+
368+
/**
369+
* Purges the contents of the given queue.
370+
* @see com.rabbitmq.client.AMQP.Queue.Purge
371+
* @see com.rabbitmq.client.AMQP.Queue.PurgeOk
372+
* @param queue the name of the queue
373+
* @param nowait whether to await completion of the purge
374+
* @return a purge-confirm method if the purge was executed succesfully
375+
* @throws java.io.IOException if an error is encountered
376+
*/
377+
Queue.PurgeOk queuePurge(String queue, boolean nowait) throws IOException;
378+
358379
/**
359380
* Retrieve a message from a queue using {@link com.rabbitmq.client.AMQP.Basic.Get}
360381
* @see com.rabbitmq.client.AMQP.Basic.Get

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ConnectionFactory {
5555
* Holds the SocketFactory used to manufacture outbound sockets.
5656
*/
5757
private SocketFactory _factory = SocketFactory.getDefault();
58-
58+
5959
/**
6060
* Instantiate a ConnectionFactory with a default set of parameters.
6161
*/
@@ -131,6 +131,17 @@ public void useSslProtocol(String protocol, TrustManager trustManager)
131131
setSocketFactory(c.getSocketFactory());
132132
}
133133

134+
/**
135+
* Convenience method for setting up an SSL socket factory.
136+
* Pass in an initialized SSLContext.
137+
*
138+
* @param context An initialized SSLContext
139+
*/
140+
public void useSslProtocol(SSLContext context)
141+
{
142+
setSocketFactory(context.getSocketFactory());
143+
}
144+
134145
/**
135146
* The default SSL protocol (currently "SSLv3").
136147
*/
@@ -162,7 +173,10 @@ private Connection newConnection(Address[] addrs,
162173
redirectCount = 0;
163174
boolean allowRedirects = redirectCount < maxRedirects;
164175
try {
165-
return new AMQConnection(_params, !allowRedirects, frameHandler);
176+
AMQConnection conn = new AMQConnection(_params,
177+
frameHandler);
178+
conn.start(!allowRedirects);
179+
return conn;
166180
} catch (RedirectException e) {
167181
if (!allowRedirects) {
168182
//this should never happen with a well-behaved server

0 commit comments

Comments
 (0)