Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: TeamGamma/directedstudies
base: 6a28fe49e5
...
head fork: TeamGamma/directedstudies
compare: a10b653b53
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
9 deployment/fabfile.py
@@ -28,7 +28,7 @@
env.roledefs = {
'db': ['a01'],
'web': ['a02', 'a04', 'a06'],
- 'transaction': ['a03'],
+ 'transaction': ['a03', 'a05'],
'tsung': ['a10', 'a11', 'a09'],
'vm': ['vagrant@127.0.0.1:2222'],
'master': ['a09'],
@@ -86,9 +86,14 @@ def update_config_file(quote_client='sps.quotes.client.RandomQuoteClient'):
"""
Updates the remote config file with the local one
"""
+
+ trans_serv_index = env.roledefs['web'].index(env.host) % len(env.roledefs['transaction'])
+ backup_trans_serv_index = (env.roledefs['web'].index(env.host)+1) %len(env.roledefs['transaction'])
+
# Use fabfile's predefined server names
context = {
- "transaction_server": _machine_num(env.roledefs['transaction'][0]),
+ "transaction_server": _machine_num(env.roledefs['transaction'][trans_serv_index]),
+ "backup_transaction_server": _machine_num(env.roledefs['transaction'][backup_trans_serv_index]),
"database_server": _machine_num(env.roledefs['db'][0]),
"quote_client": quote_client,
}
View
2  sps/transactions/commands.py
@@ -636,7 +636,7 @@ def check_trigger(self, trigger_id):
# buy the stock and update reserve balance
log.debug("Trigger %d activated: %s > %s",
trigger.id, quote, trigger.trigger_value)
- return self.process_transaction(quote, trigger)
+ return self.process_transaction(session, quote, trigger)
except Exception, e:
log.error('Trigger %d: %s : %s', trigger_id, type(e), e)
View
10 sps/web/app.py
@@ -47,6 +47,16 @@ def hello():
config.TRANSACTION_SERVER_PORT,
trans_server_message)
+ if response == False:
+ #resend to backup server
+
+ response = transaction_interface.send(
+ config.BACKUP_TRANSACTION_SERVER_HOST,
+ config.TRANSACTION_SERVER_PORT,
+ trans_server_message)
+
+
+
log.info('Received from transaction server: %s', repr(response))
# Try to parse XML response and determine HTTP code
View
11 sps/web/transaction_interface.py
@@ -5,10 +5,15 @@
def send(HOST, PORT, message):
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((HOST, PORT))
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.connect((HOST, PORT))
+
+ s.sendall(message + '\n')
+ except socket.error:
+ return False
+
- s.sendall(message + '\n')
# Read an entire line of variable length
confirmation_msg = s.makefile().readline()

No commit comments for this range

Something went wrong with that request. Please try again.