Jd/Guide

From J Wiki
Jump to navigation Jump to search
Jd | Overview | General | Docs | Ops | Admin | Server | Replicate | Guide | Technical | Release | License | Support

Guide to Jd terminology.

Definitions

admin - manages DAN (database access name) rules for users
dac - data column - folder for table column
dan - database access name
db - database - folder with all data and metadata for db tables and columns
intask - ops run in the Jd task (jconsole/jijx) - client and server are same task
remote - ops run in different task (socket) - client and server are different tasks
user - access controlled by DAN

db

A db is a folder with a folder for each table. Each table folder has a folder for each column. Each folder has a few metadata files (prefix jd). Following is a simplified db folder/file list:

db
  jdlock           - lock prevents multiple task access
  jdclass          - 'database'
  jdstate          - state (3!:1)
  admin.ijs        - dan rules
  custom.ijs       - custom code
  table folder f
    jdclass        - 'table'
    jdstate
    dac a
      jdclass      - 'column'
      jdstate
      dat          - column data - file mapped as J noun with col data
  table folder g
    ...

Admin

Manages user access to a db with dan rules. A dan selects a db and which user/pswds and ops are allowed. Different dans (different rules) can access the same or different folders.

Admin can configure the Jd task to listen on a socket for requests from remote users.

Dan rules are usually set by the db admin.ijs (defaults used if admin.ijs does not exist).

Following ~temp/jd/test/admin.ijs sets dans all and ro for a db.

'all' jdadminfp ''            NB. all dan uses db that contains this script
'all' jdadminup 'abc/def'     NB.   requires this user/pswd           
'all' jdadminop '*'           NB.   allows all ops                       

'ro'  jdadminfp ''            NB. ro dan uses db that contains this script
'ro'  jdadminup 'ab/de gh/jk' NB.   requires these user/pswds            
'ro'  jdadminop 'read reads ' NB.   allows only read and reads 

Following is intask:

   jdadmin '~temp/jd/test' NB. load ~temp/jd/test/admin.ijs
   jdadmin ''              NB. report
┌───┬───────────────────────────────────────┐
│[w]│c:/users/eric/j64-701-user/temp/jd/test│
├───┼───────────────────────────────────────┤
│all│~temp/jd/test                          │
├───┼───────────────────────────────────────┤
│all│abc/def                                │
├───┼───────────────────────────────────────┤
│all│*                                      │
├───┼───────────────────────────────────────┤
│ro │~temp/jd/test                          │
├───┼───────────────────────────────────────┤
│ro │ab/de gh/jk                            │
├───┼───────────────────────────────────────┤
│ro │read reads                             │
└───┴───────────────────────────────────────┘

[w] line indicates a lock to prevent interference from other tasks.

A user accesses the db with a dan. Access with dan all requires abc/def and allows all ops. Access with dan ro requires a ab/de or gh/jk and allows only read/reads.

custom.ijs

Admin can customize a database with custom.ijs.

  • custom jd ops (e.g., common complex query handled as simpler op with simpler args)
  • custom aggregations

User

A db user performs jd ops such as read/insert/delete/update on a db.

A jd op has implicit args of dan, user/pswd, intask/remote. Remote is indicated by localhost:port

A db user sets the implicit args with verb jdaccess in a Jd client task (or equivalent if a non-J task).

   jdaccess 'all abc/def intask'
   jd'read from j' NB. all dan - intask

   jdaccess 'ro ab/de localhost:65002'
   jd'read from j' NB. ro dan - socket request to localhost:65002