Jd/Admin

From J Wiki
Jump to: navigation, search
Jd | Overview | General | Ops | Admin | Guide | Technical | Release | License | Support

Admin is done in the Jd task. Admin names have a jd prefix and are defined in the z or jd locales. See tutorial admin_tut.

jd... base verbs in z locale:
jd  jdae  jdtx 

jd... access/admin verbs in the z locale:
jdaccess  jdadmin  jdadminx

jd... admin utilities in the jd locale:
jdadminfp  jdadminlk  jdadminop  jdadminup

admin topics:
admin.ijs  custom.ijs 

jd... utilities in the jd locale:
jdcdef jdclocs jdcols jdcreatefolder jddamage jddeletefolder jddeletefolderok jddropstop jdex jdfixcolnames jdfread jdfrom jdfroms jdfwrite jdgl jdgs jdlinkmove jdlinkset jdlinktargets jdlogijfshow jdlogtxtshow jdpath jdrt jdserverstop jdshare jdshuffle jdtables jdtesterrors jdtests jdtesterrors jdtests

jd

jd'op...'

jdae

jd that expects and error and returns the error text

jdaccess

Set DAN (db access name), user/pwd, and server for jd ops:

server intask       - op runs in the current J task
server localhost:x  - op runs in the J JHS task at port x
server ipaddress:x  - op runs in the J JHS task at ipaddress port x
server hostname:x   - op runs in the J JHS task at hostname t port x

A SSH tunnel can securely connect localhost:x to a J task on a server:

jdaccess 'test me/xx intask'         NB. DAN test, user/pswd u/p
jdaccess 'foo'                       NB. same as 'foo u/p intask'
jdaccess 'zz me/xx localhost:65002'
jdaccess ''                          NB. report
jdaccess 0                           NB. clear access 

jdadmin

This loads admin.ijs in the db folder to make it available.

  • jdaccess is done for the first dan and user/pwd in admin.ijs
  • opens all tables/cols and maps all mapped files
  • jd'validate' is done to validate the db
jdadmin 'ab'     NB. make ~temp/jd/ab available
jdadmin '.../ab' NB. make .../ab available
jdadmin ''       NB. report 
jdadmin 0        NB. clear all admin and release all locks

The DAN (db access name) maps to folder, user/pwds, ops.

Different DANs can access the same or different folders.

The DAN rules are set by admin.ijs in db folder.

A default admin.ijs is created if it does not exist. In the default, DAN is last path folder, and u/p is user/pwd

A lock on the db folder prevents interference by other tasks

jdadmin '...'    NB. gets lock
jdadmin 0        NB. releases all locks

jdadminx

This is used to start a new database, replacing any old database. It deletes any old folder, creates a new db folder, then does jdadmin.

jdadminx'aa'     NB. create new database ~temp/jd/aa
jdadminx'.../bb' NB. create new database .../bb

A new database can be created in an empty folder. A new database overwrites an old database unless jddropstop is set.

fails if folder:

  • is a jd folder but not class database
  • is a jd folder with jddropstop
  • is not a jd folder and is not empty

If jdadminx fails, you can force delete of the folder with:

'force'jddeletefolder_jd_'...'

admin.ijs

admin.ijs is a script in the db folder, and is loaded by jdadmin.

The default contents are:

'ab' jdadminfp ''       NB. DAN ab maps to ~temp/jd/ab     
'ab' jdadminup 'u/p'    NB. requires default user/pwd
'ab' jdadminop '*'      NB. allow all ops

Other examples:

'test'   jdadminfp ''                 NB. DAN test maps to this db folder
'test'   jdadminup 'u/p'              NB. requires this user/pswd
'test'   jdadminop '*'                NB. allow all ops
'testro' jdadminfp ''                 NB. DAN testro maps to this db folder
'testro' jdadminup 'ab/de gh/jk'      NB. requires these user/pwds
'testro' jdadminop 'read reads'       NB. allow only read and reads

The verbs jdadminfp/jdadminup/jdadminop are usually run only in admin.ijs, and are used directly for temp changes or tests.

custom.ijs

This is an optional script in the db folder. If present, it is loaded into the db locale when the db is opened.

It defines:

  • dynamic - creates ref/reference cols
  • jd_xxx - a jd op
  • ... addagg ... - custom aggregation
   jd'loadcustom'     NB. reloads custom.ijs

See tutorials custom and aggregation.

jdadminfp

Set DAN file path:

'test' jdadminfp_jd_ ''
       jdadminfp_jd_ ''     NB. report

jdadminlk

Set lock on DAN db folder:

'test' jdadminlk_jd_ ''
       jdadminlk_jd_ ''     NB. report 

jdadminop

Set ops allowed with DAN:

'test' jdadminop_jd_ 'read reads insert'
       jdadminop_jd_ ''     NB. report 

jdadminup

Set user/pswds allowed with DAN:

'test' jdadminup_jd_ 'fred/secret sam/birthday'
       jdadminup_jd_ ''     NB. report 

jdcdef

Set column defs for createtable from labeled row data:

   jdcdef d

See tutorial table_from_array.

jdclocs

Get column locales:

   jdclocs t;c
  • t is '' for all tables or 'tab' for just that table
  • c is '' for all cols or 'col' for just that col

The result is sorted by table names.

Column names int a table are in created order followed by jd... names

jdcols

Return column names and locales sorted by name:

   jdcols'tab'

jdcreatefolder

Creates required folders for path:

   jdcreatefolder'~temp/jd/a/b'

jddamage

Writes a db jddamage file.

   jddamage_jd_'reason'      NB. writes db jddamage file - prevents jd ops
   jddamage_jd_''            NB. erases db jddamage file - allows jd ops

jddeletefolder

This deletes a folder, and is used internally by jd drop... ops.

   jddeletefolder_jd_'~/jd/test'

See drop/delete.

It follows these rules in order:

  • allowed if jddeletok exists
  • not allowed if jddropstop exists
  • not allowed if too few "/" characters (e.g. /abc/def is ok, but /abc fails)
  • allowed if empty or a jd folder (jdclass exists) or in ~temp
  • otherwise, not allowed

The jddeletefolderok verb writes jddeleteok to override the rules.

jddeletefolderok

This writes a jddeleteok file to a folder to allow jddeletefolder:

   jddeletefolderrok_jd_'~/jd/test'

jddropstop

This writes a jddropstop file to a folder:

[1] jddropstop ''        NB. write jddropstop file in folder and subfolders
[1] jddropstop 'tab'
[1] jddropstop 'tab col'

 0 jddropstop ''         NB. erase jddropstop file in folder and subfolders
 1 jddropstop 'tab'
 1 jddropstop 'tab col'

dropdb/droptable/dropcol fail if there is a jddropstop file in the folder.

See tutorial dropstop.

jdex

Run insert example from User:

   jdex'insert'

jdfixcolnames

Make col names valid in labeled row data:

   jdfixcolnames d
  • table.col changes to table-col
  • blank changes to underscore (_)

jdflush

Performance measurement (pm) scripts use jdflush for more accurate benchmarks.

   jdflush_jd_''

On Windows this is a noop.

On Linux, this calls a jdflush shell script, which should be defined in the path as appropriate for your system. For example:

#!/bin/bash
sudo sync
sudo blockdev --flushbuf /dev/sda
sudo blockdev --flushbuf /dev/sdb
sudo sysctl vm/drop_caches=3

jdfread

Calls fread with handle limit error assert.

jdfrom

Returns a column from a jd'read...'

   'col' jdfrom_jd_ jd'read from f'

jdfroms

Returns a column from a jd'reads...'

   'col' jdfroms_jd_ jd'reads from f'

jdfwrite

Calls fwrite with handle limit error assert.

jdgl

Get locales:

   jdgl_jd_'tab'          NB. get locale for table
   jdgl_jd_'tab col'      NB. get locale for table column

jdgs

Get states:

   jdgs_jd_'tab'        NB. get state for table
   jdgs_jd_'tab col'    NB. get state for table column

jdlinkmove

Move column data files:

   jdlinkmove_jd_ 'tab/col ~temp/linker'

Column data files can be moved (usually to another drive). The folder structure is updated so the column folder points to the new location.

Some reasons for relocating cols:

  • improve performance by having i/o on multiple drives
  • take advantage of particular drives
  • ssd or slower or faster or high capacity

See tutorial link.

jdlinkset

Set (table/column path) definitions in the db folder link.txt file.

jdlinkset_jd_ 0 : 0
f/int     ~temp/linker0
f/varbyte ~temp/linker1
)
   jdlinkset_jd_'' NB. report db links.txt

Create column (including csvrd/csvrestore) uses link.txt to do folder links.

See tutorial link.

jdlinktargets

Report jdlinkmove/jdlinkset folder targets:

   jdlinktargets_jd_''      

See tutorial link.

jdlogijfshow

Show log.ijf:

   jdlogijfshow_jd_''      NB. log.ijf summary
   jdlogijfshow_jd_ 0      NB. component 0

See tutorial log.

jdlogtxtshow

Show log.txt:

   jdlogtxtshow_jd_ 10      NB. log.txt last 10 lines

See tutorial log.

jdpath

Return path (ending in /) to db folder:

   jdpath_jd_''      

jdrt

List or run tutorials:

   jdrt_jd_''           NB. list tutorials
   jdrt_jd_'intro'      NB. run tutorial

jdserverstop

Stop Jd JHS server:

   jdserverserverstop_jd_''

This sets OKURL_jhs_ to empty to stop Jd from serving clients.

jdshare

This sets permissions for accessing the db from another account. This may be best done with host tools by someone who understands security, but jdshare might be useful in simple situations.

    jdshare_jd_'rwrwrw' NB. rw or r- or -- for owner/group/others

Normally the Jd task account owns the db folder.

Giving another account access to the db folder allows Jd tasks running as that account to access the db.

Lock prevents problems with multiple Jd tasks running as the owner or another account from using the db at the same time.

jdshuffle

This randomly deletes and reinserts rows, and can be used in tests for the proper functioning of dynamic cols. The table at the end has the same number rows it started with.

   jdshuffle_jd_ 'tab'

jdtables

Lists table names and locales sorted by names:

   jdtables_jd_'tab'

jdtesterrors

Test error formatting:

   jdtesterrors_jd_''        

jdtests

Run tests:

   [0 or 1] jdtests_jd_ y     NB. 1 echos names as tests are run

The right argument is:

  • '' - csv-tests, build-demos, and all tests/tutorials
  • 'fast' - skip csv-tests and build-demos
  • 'csv' - run only csv-tests

The source folders are:

  • ~addons/data/jd/test/core - original non api tests (0!:3 implied assert on every line)
  • ~addons/data/jd/test - tests with asserts
  • ~addons/data/jd/tutorial - tutorials with asserts
  • ~addons/data/jd/demo - scripts that build/test northwind,sandp,sed,vr

jdtx

jd'op... ' run under timex