Skip to content

Commit

Permalink
Another baby step towards a vecdbsrv
Browse files Browse the repository at this point in the history
  • Loading branch information
mkromberg committed Aug 24, 2016
1 parent 0a72427 commit dd1eea8
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 90 deletions.
14 changes: 5 additions & 9 deletions BootServers.dyalog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BootServers dummy;port;getenv;getnum;path
Start a vecdb server process if VECDBSRV=config.xml PORT=nnnn
vecdb slave process if VECDBSLAVE="file,[VECDBSHARD=n]" PORT=nnnn
BootServers dummy;port;getenv;getnum;path
Start a vecdb server process if VECDBSRV="config.json" PORT=nnnn
vecdb slave process if VECDBSLAVE="file" SHARDS="n" PORT=nnnn

getenv{0=2 ⎕NQ'.' 'GetEnvironment':}
getnum{2⎕VFI }
Expand Down Expand Up @@ -28,11 +28,7 @@

:If VECDBSRV vecdbsrv.Start CONFIG port
:ElseIf VECDBSLAVE vecdbslave.Start VECDB port

portgetnum port
'Starting slave, listening on port ',port
RPCServer.Run'RPCSRV'port
:Else
'See TestRPCServer'
'Invalid configuration...'
:EndIf
:EndIf
:EndIf
34 changes: 20 additions & 14 deletions TestVecdbSrv.dyalog
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

(⎕IO ⎕ML)1 1
LOG1
toJson(0 1)7160
toJson(0 1)(7160)

zRunAll;path;source
⎕FUNTIE ⎕FNUMS ⎕NUNTIE ⎕NNUMS
Expand All @@ -14,17 +14,9 @@
path{(-/()'\/')}source
ServerBasic

zServerBasic;columns;data;options;params;folder;types;name;db;ix;vecdbsrv;config;users;user;srvproc;clt;TEST
Test database with 2 shards
Also acts as test for add/remove columns

folderpath,'/',(name'srvtest'),'/'
'Clearing: ',folder
:Trap 22 #.vecdb.Delete folder :EndTrap

--- Create configuration file ---


configCreateTestConfig filename;db;config;user;vecdbsrv
user⎕NS ''
user.(Name Id Admin)'mkrom' 1001 1
vecdbsrv⎕NS''
Expand All @@ -36,8 +28,22 @@
config⎕NS''
config.Servervecdbsrv
config.DBs,db
(folder,'config.json')⎕NPUT toJson folder,'config.json'

(toJson config)⎕NPUT filename

zServerBasic;columns;data;options;params;folder;types;name;ix;users;srvproc;clt;TEST
Test database with 2 shards
Also acts as test for add/remove columns

folderpath,'/',(name'srvtest'),'/'
'Clearing: ',folder
:Trap 22 #.vecdb.Delete folder :EndTrap
⎕MKDIR folder

--- Create configuration file ---

CreateTestConfig folder,'config.json'

--- Create database ---

columns'Name' 'BlockSize' 'Flag'
Expand Down
Binary file modified vecdbboot.dws
Binary file not shown.
7 changes: 4 additions & 3 deletions vecdbclt.dyalog
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
rConnect(address port user)
Connect to vecdb server process

:If 0=rDRC.Init''
{}DRC.Close CONNECTION'VECDB'
:AndIf 0=rDRC.Clt CONNECTION address port
:If 0=r##.DRC.Init''
{}##.DRC.Close CONNECTION'VECDB'
:AndIf 0=r##.DRC.Clt CONNECTION address port
:AndIf 0=rSrvDo CONNECTION('CltSetUser'user)
rSrvDo CONNECTION('CltSetUser'user)
:Else
Expand Down Expand Up @@ -55,6 +55,7 @@

:Class vecdbproxy
Produce a vecdb proxy object for a served vecdb

Open (name connection)
:Access Public
Expand Down
120 changes: 56 additions & 64 deletions vecdbsrv.dyalog
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
:Namespace vecdbsrv
Uses #.vecdbclt

(⎕IO ⎕ML ⎕WX)1 0 3
(⎕IO ⎕ML)1 0
RUNTIME0 Use runtimes?

{r}Start (config port);sink;data;event;obj;rc;wait;z;cmd;name
Run a vecdb Server - based on CONGA RPCServer sample

{}##.DRC.Init''
Init config
{}##.DRC.Close name'VECSRV'

:If 0=1r##.DRC.Srv name''port'Command'
1 Log'Server ''',name,''', listening on port ',port
2 Log'Handler thread started: ',Run&name port
:Else
3 Log'Server failed to start: ',,r
:EndIf

{r}Init config;db;i
Intialise the vecdb server

(DBs Server)config.(DBs Server)

:For i :In DBs
dbiDBs

:EndFor

r Need a result

proc{shards} Launch (target port);path;runtime;args
Launch a full vecdbsrv or, if shards is defined, a slave

:Trap 6 sourceSALT_Data.SourceFile
:Else source⎕WSID
:EndTrap

path{(-/()'\/')}source
runtimeRUNTIME

:If slave2=⎕NC 'shards'
args'VECDBSLAVE="',target,'" SHARDS="',(shards),'" PORT=',(port)
:Else
args'VECDBSRV="',target,'" PORT=',port
:EndIf
proc⎕NEW ##.APLProcess

rCltLock resource
Cover-function for call to Lock from a Client
Expand All @@ -19,7 +67,7 @@

Connect CONNECTION Register the connection
rSetUser CONNECTION userid Set the user id

rCltStatus dummy
Get Status information
Expand Down Expand Up @@ -60,25 +108,6 @@
:EndIf

{r}InitLocks dummy
Intialise the Locks Daemon

r Need a result

LOCKSGRANTED0 Counter

NEXTTASK1 Next Task ID
CONNS TCP Sockets
TASKS TASK IDs
USERS USER IDs
RESOURCES List of resources managed
HELDBY TASK ID holding
QUEUES00 30 Queue for each resource (TASK, CONN, ARRIVAL TIME)

LOGLEVEL1 0=everything, 1=warnings, 2=errors
MOCK0 Mockup

queueLock(cmd Resource);i;task;Conn
Returns queue length

Expand Down Expand Up @@ -291,25 +320,14 @@
taskiTASKS

{r}Start port;sink;data;event;obj;rc;wait;z;cmd;name
Run the Lock Server - based on CONGA RPCServer sample

{}##.DRC.Init''
InitLocks 0
{}##.DRC.Close name'LOCKSRV'

:If 0=1r##.DRC.Srv name''port'Command'
1 Log'Server ''',name,''', listening on port ',port
2 Log'Handler thread started: ',Run&name port
:Else
3 Log'Server failed to start: ',,r
:EndIf

Test;assert;START;resources;nprocesses;nresources;nevents;i;conns;conn;z;s

This should be a stand-alone test of vecdbsrv
Assumes existence of #.TestVecdbSrv

assert{'Assertion failed'⎕SIGNAL(=0)/11}


#.TestVecdbSrv.CreateTestConfig folder,'config.json'

InitLocks 0
LOGLEVEL3 Log everything
MOCK1 Do not send CONGA messages
Expand Down Expand Up @@ -364,32 +382,6 @@
(nevents),' released & locked in',(1s),'s (',(,' '~,'CI12'⎕FMT nevents÷s),' locks/s)'

TestClient user;mine;nevents;START;i;s;z;clt

assert{'Assertion failed'⎕SIGNAL(=0)/11}

clt## Location of Client functions

'Logged in as task #',clt.LockServerInit'127.0.0.1' 8888 user

nevents1000
'Testing performance...'

START3⎕AI
:For i :In nevents
zclt.∆ENQ'/PORTFOLIO'user
zclt.∆CLS'/PORTFOLIO'user
:EndFor

s0.001×(3⎕AI)-START
(nevents),' released & locked in',(1s),'s (',(,' '~,'CI12'⎕FMT nevents÷s),' locks/s)'

#.DRC.Close #.LOCKSERVER
⎕EX'#.LOCKSERVER'

assert{'Assertion failed'⎕SIGNAL(=0)/11}

** Those ops cannot be recreated: clt

:EndNamespace

0 comments on commit dd1eea8

Please sign in to comment.