Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
Diagnostics code added.

Version updated.

Changes to be committed:
	modified:   Base/JackrabbitLocker
	modified:   Base/JackrabbitOliverTwist
	modified:   Base/JackrabbitRelay
	modified:   Base/Library/CONDoanda.py
	modified:   Base/Library/JRRmimic.py
	modified:   Base/Library/JackrabbitProxy.py
	modified:   Base/Library/JackrabbitRelay.py
	modified:   Base/MIMIC-PlaceOrder
	modified:   Extras/OliverTwist/otcWatch
  • Loading branch information
rapmd73 committed Aug 2, 2024
1 parent 9fe0185 commit a240e11
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 124 deletions.
31 changes: 17 additions & 14 deletions Base/JackrabbitLocker
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import json

import JRRsupport

Version="0.0.0.1.875"
Version="0.0.0.1.900"
BaseDirectory='/home/JackrabbitRelay2/Base'
ConfigDirectory='/home/JackrabbitRelay2/Config'
LogDirectory="/home/JackrabbitRelay2/Logs"
Expand Down Expand Up @@ -62,10 +62,13 @@ def WriteLog(addr,msg):

# Convience to build the status and a json payload

def jsonStatus(str,Tag=None,Data=None):
def jsonStatus(str,id=None,Tag=None,Data=None):
res={}
res['Status']=str

if id!=None:
res['ID']=id

if Tag!=None and Data!=None:
res[Tag]=Data

Expand Down Expand Up @@ -114,16 +117,16 @@ def ProcessPayload(data):
dataLock['ID']=dataDB['ID']
dataLock['Expire']=time.time()+float(dataDB['Expire'])
Locker[FileName]=dataLock
return jsonStatus("Locked")
return jsonStatus("Locked",Locker[FileName]['ID'])
# Lock has expired, now unlocked
elif time.time()>Locker[FileName]['Expire']:
Locker[FileName]['ID']=dataDB['ID']
Locker[FileName]['ID']=dataDB['ID'] # assign the new ID
Locker[FileName]['Expire']=time.time()+float(dataDB['Expire'])
return jsonStatus("Locked")
return jsonStatus("Locked",Locker[FileName]['ID'])
# The current owner wwant the lock reset to a specific duration/held longer
elif Locker[FileName]['ID']==dataDB['ID']:
Locker[FileName]['Expire']=time.time()+float(dataDB['Expire'])
return jsonStatus("Locked")
return jsonStatus("Locked",Locker[FileName]['ID'])
# Lock access by a non-owner ID
else:
return jsonStatus("NotOwner")
Expand All @@ -135,11 +138,11 @@ def ProcessPayload(data):
# Verify owner and unlock
elif Locker[FileName]['ID']==dataDB['ID']:
Locker[FileName]['Expire']=0
return jsonStatus("Unlocked")
return jsonStatus("Unlocked",Locker[FileName]['ID'])
# Unock access by a non-owner ID. This may seem idiotic, but its an
# absolute for keeping the lock from being hijacked.
else:
return jsonStatus("Failure")
return jsonStatus("NotOwner")
# Get memory reference
elif action=='get':
# Memory item doesn't exist
Expand All @@ -148,9 +151,9 @@ def ProcessPayload(data):
# Verify owner and unlock/Erase memory
elif Locker[FileName]['ID']==dataDB['ID']:
if 'DataStore' in Locker[FileName]:
return jsonStatus("Done",Tag="DataStore",Data=Locker[FileName]['DataStore'])
return jsonStatus("Done",Locker[FileName]['ID'],Tag="DataStore",Data=Locker[FileName]['DataStore'])
else:
return jsonStatus("NoData")
return jsonStatus("NoData",Locker[FileName]['ID'])
# Not the rightful owner
else:
return jsonStatus("NotOwner")
Expand All @@ -162,26 +165,26 @@ def ProcessPayload(data):
dStore['Expire']=time.time()+float(dataDB['Expire'])
dStore['DataStore']=dataDB['DataStore']
Locker[FileName]=dStore
return jsonStatus("Done")
return jsonStatus("Done",Locker[FileName]['ID'])
# Existing memory object, verify owner and reset expiration timeout
elif Locker[FileName]['ID']==dataDB['ID']:
Locker[FileName]['Expire']=time.time()+float(dataDB['Expire'])
Locker[FileName]['DataStore']=dataDB['DataStore']
return jsonStatus("Done")
return jsonStatus("Done",Locker[FileName]['ID'])
# Not the rightful owner
else:
return jsonStatus("NotOwner")
# Erase request
elif action=='erase':
# Just pass through erase
if FileName not in Locker:
return jsonStatus("Done")
return jsonStatus("Done",Locker[FileName]['ID'])
# Verify owner and erase memory. Erase is just resetting expiration to 0.
# Will be remove in main function.
elif Locker[FileName]['ID']==dataDB['ID']:
Locker[FileName]['Expire']=0
Locker[FileName]['DataStore']=None
return jsonStatus("Done")
return jsonStatus("Done",Locker[FileName]['ID'])
# Not the rightful owner
else:
return jsonStatus("NotOwner")
Expand Down
15 changes: 11 additions & 4 deletions Base/JackrabbitOliverTwist
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@

# ANY order (direct orphan or conditional) is an ORPHAN at all times withis THIS framework.

# IMPORTANT: This fraework treats conditionals the same as orphans. The separation and distinction takes place in the
# transactor. While this has plenty of issues to be aware of, it is the most effecient way of handling the situation since at
# this level (dispatcher), they are syntactically the same.
# IMPORTANT: This fraework treats conditionals the same as orphans. The separation and distinction takes
# place in the transactor. While this has plenty of issues to be aware of, it is the most effecient way of
# handling the situation since at this level (dispatcher), they are syntactically the same.

# Framework identification, along with any other order verification, is done in the PlaceOrder

import sys
sys.path.append('/home/JackrabbitRelay2/Base/Library')
import os
import importlib
from datetime import datetime
import time
import json
import random
Expand All @@ -40,7 +41,7 @@ import subprocess
import JRRsupport
import JackrabbitRelay as JRR

Version="0.0.0.1.875"
Version="0.0.0.1.900"
BaseDirectory='/home/JackrabbitRelay2/Base'
DataDirectory='/home/JackrabbitRelay2/Data'
ConfigDirectory='/home/JackrabbitRelay2/Config'
Expand Down Expand Up @@ -387,6 +388,7 @@ def main():
ReceiveOrphans('Conditional')

while True:
StartTime=datetime.now()
ReceiveOrphans()

# Dynamic factor for memory timeouts
Expand All @@ -409,6 +411,11 @@ def main():
while interceptor.GetChildren()>(NumberProcesses-1):
JRRsupport.ElasticSleep(1)

EndTime=datetime.now()
Elapsed=(EndTime-StartTime)
if len(keyList)>NumberProcesses:
JRLog.Write(f"{len(keyList)} orders scanned in "+str(Elapsed)+" seconds")

JRRsupport.ElasticSleep(1)

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion Base/JackrabbitRelay
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import json

import JRRsupport

Version="0.0.0.1.875"
Version="0.0.0.1.900"
BaseDirectory='/home/JackrabbitRelay2/Base'
ConfigDirectory='/home/JackrabbitRelay2/Config'
LogDirectory="/home/JackrabbitRelay2/Logs"
Expand Down
Loading

0 comments on commit a240e11

Please sign in to comment.