Skip to content

Commit

Permalink
Merge branch 'release-2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tofu-rocketry committed Jun 4, 2014
2 parents 99c9361 + 0c443c0 commit 1f10265
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 19 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
Changelog for ssm
=================

* Wed Oct 30 2013 Adrian Coveney <adrian.coveney@stfc.ac.uk - 2.1.1-0
- Change behaviour of ping to start and abort a transaction
instead of sending empty message.
- Raise exception when not connected during send_all.
* Mon Jun 02 2014 Adrian Coveney <adrian.coveney@stfc.ac.uk> - 2.1.2-0
- The output of brokers.py has been improved so that it can be used to query
the BDII for valid brokers.
- The outgoing message directory will now be regularly cleared of empty
directories and locked messages will be unlocked after five minutes.

* Wed Oct 30 2013 Adrian Coveney <adrian.coveney@stfc.ac.uk> - 2.1.1-0
- Reduced impact on message brokers of sending pings to refresh the connection.
- Improved lost connection behaviour.

* Tue Apr 16 2013 Will Rogers <will.rogers@stfc.ac.uk> - 2.1.0-0
- Verify any certificate supplied for encrypting messages
Expand Down
15 changes: 10 additions & 5 deletions apel-ssm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%endif

Name: apel-ssm
Version: 2.1.1
Version: 2.1.2
Release: 0%{?dist}
Summary: Secure stomp messenger

Expand Down Expand Up @@ -91,10 +91,15 @@ rm -rf $RPM_BUILD_ROOT
%doc %_defaultdocdir/%{name}

%changelog
* Wed Oct 30 2013 Adrian Coveney <adrian.coveney@stfc.ac.uk - 2.1.1-0
- Change behaviour of ping to start and abort a transaction
instead of sending empty message.
- Raise exception when not connected during send_all.
* Mon Jun 02 2014 Adrian Coveney <adrian.coveney@stfc.ac.uk> - 2.1.2-0
- The output of brokers.py has been improved so that it can be used to query
the BDII for valid brokers.
- The outgoing message directory will now be regularly cleared of empty
directories and locked messages will be unlocked after five minutes.

* Wed Oct 30 2013 Adrian Coveney <adrian.coveney@stfc.ac.uk> - 2.1.1-0
- Reduced impact on message brokers of sending pings to refresh the connection.
- Improved lost connection behaviour.

* Tue Apr 16 2013 Will Rogers <will.rogers@stfc.ac.uk> - 2.1.0-0
- Verify any certificate supplied for encrypting messages
Expand Down
2 changes: 1 addition & 1 deletion ssm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import logging
import sys

__version__ = (2, 1, 1)
__version__ = (2, 1, 2)

LOG_BREAK = '========================================'

Expand Down
23 changes: 16 additions & 7 deletions ssm/brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,24 @@ def parse_stomp_url(stomp_url):
raise ValueError('URL %s does not have an integer as its third part.')

return host, int(port)


if __name__ == '__main__':
# BDII URL
BDII = 'ldap://lcg-bdii.cern.ch:2170'
BDII = 'ldap://lcg-bdii.cern.ch:2170'
BG = StompBrokerGetter(BDII)
print(BG.get_broker_hosts_and_ports(STOMP_SSL_SERVICE, 'PROD'))
print(BG.get_broker_hosts_and_ports(STOMP_SERVICE, 'PROD'))
print(BG.get_broker_hosts_and_ports(STOMP_SSL_SERVICE, 'TEST-NWOB'))
print(BG.get_broker_hosts_and_ports(STOMP_SERVICE, 'TEST-NWOB'))


def print_brokers(text, service, network):
brokers = BG.get_broker_hosts_and_ports(service, network)
# Print section heading
print '==', text, '=='
# Print brokers in form 'host:port'
for broker in brokers:
print '%s:%i' % (broker[0], broker[1])
# Leave space between sections
print

print_brokers('SSL production brokers', STOMP_SSL_SERVICE, 'PROD')
print_brokers('Production brokers', STOMP_SERVICE, 'PROD')
print_brokers('SSL test brokers', STOMP_SSL_SERVICE, 'TEST-NWOB')
print_brokers('Test brokers', STOMP_SERVICE, 'TEST-NWOB')
12 changes: 10 additions & 2 deletions ssm/ssm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class Ssm2Exception(Exception):
'''
pass

class Ssm2(object):

class Ssm2(stomp.ConnectionListener):
'''
Minimal SSM implementation.
'''
Expand Down Expand Up @@ -274,7 +275,7 @@ def send_all(self):
log.info('Found %s messages.' % self._outq.count())
for msgid in self._outq:
if not self._outq.lock(msgid):
log.warn('Message queue was locked. %s will not be sent.' % msgid)
log.warn('Message was locked. %s will not be sent.' % msgid)
continue

text = self._outq.get(msgid)
Expand All @@ -290,6 +291,13 @@ def send_all(self):
self._last_msg = None
self._outq.remove(msgid)

log.info('Tidying message directory.')
try:
# Remove empty dirs and unlock msgs older than 5 min (default)
self._outq.purge()
except OSError, e:
log.error('OSError raised while purging message queue: %s' % e)

############################################################################
# Connection handling methods
############################################################################
Expand Down

0 comments on commit 1f10265

Please sign in to comment.