LandRegistry/system-of-record

Name: system-of-record

Owner: HM Land Registry

Description: Beta version of the system of record

Created: 2015-01-22 12:26:36.0

Updated: 2016-01-27 12:01:00.0

Pushed: 2016-03-30 11:12:41.0

Homepage: null

Size: 1521

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

system-of-record

At the moment this service posts data to a postgres database.

requirements:
How to run
ant up

ant ssh

vagrant

ce ~/venvs/system-of-record/bin/activate

n.sh -d

Note: Occasionally there is an issue starting Rabbitmq if you are already running a Register Publisher VM.

how to run tests

In virtual machine

st.sh
How to run the tester service
vagrant
n-tester.sh -d
To count the rows on postgres
 http://127.0.0.1:5002/count
To get the data for the last row on postgres
 http://127.0.0.1:5002/getlastrecord
To delete the last row on postgres
 http://127.0.0.1:5002/deletelastrecord
To get and remove the last message from RabbitMQ
 http://127.0.0.1:5002/getnextqueuemessage
How to insert a row

Note: Use 0.0.0.0 when running from host. Use 10.0.2.2 when calling from another VM.

 -X POST -d '{"sig":"some_signed_data","data":{"title_number": "DN1", "application_reference":"ABR123"}}' -H "Content-Type: application/json" http://127.0.0.1:5001/insert
How to republish messages for stored titles:
Republish latest version of one title:
 -X POST -d '{"titles": [{"title_number":"DN1"}]}' -H "Content-Type: application/json" http://127.0.0.1:5001/republish
Republish all versions of a title with the same ABR (NB. Multiple versions are possible where geometry application references differ)
 -X POST -d '{"titles": [{"title_number":"DN1", "application_reference": "ABR123"}]}' -H "Content-Type: application/json" http://127.0.0.1:5001/republish
Republish specific version of a title
 -X POST -d '{"titles": [{"title_number":"DN1", "application_reference": "ABR123", "geometry_application_reference": "GEO123"}]}' -H "Content-Type: application/json" http://127.0.0.1:5001/republish
Republish more than one title in a single message:
 -X POST -d '{"titles": [{"title_number":"DN1", "application_reference": "ABR123"}, {"title_number":"DN2", "application_reference": "ABR1234"}, {"title_number":"DN3", "application_reference": "ABR12345"} ]}' -H "Content-Type: application/json" http://127.0.0.1:5001/republish
Republish all versions of a title:
 -X POST -d '{"titles": [{"title_number":"DN1", "all_versions":true}]}' -H "Content-Type: application/json" http://127.0.0.1:5001/republish
Republish everything:
 http://127.0.0.1:5001/republish/everything

The republisheverything endpoint creates a 'republish_progress.json' file. This file is populated with a count value and the last id on the target database. After the file is created, a thread iterates through the system of record database 100 rows at a time and writes the json record and title number to the 'register_publisher' queue.
When the 'last_id' value is reached, the file will be deleted.

The threads are spawned in republish_all.py, which is called in the init of the flask app.

How to check that the service is running:
 http://127.0.0.1:5001/
How to manage rabbitmq:

Status of the server

ice rabbitmq-server status

Stop the server

ice rabbitmq-server stop

Start the server

ice rabbitmq-server start

List queues, and show queue detail

itmqadmin list queues

or

 rabbitmqctl list_queues

put a message on the queue:

itmqadmin publish exchange=amq.default routing_key=system_of_record payload="hello, world"
How to update the database, if necessary
ce ./environment.sh

on3 manage.py db upgrade
How to query the database with PSQL
 -i
 -U systemofrecord systemofrecord

The main table in the systemofrecord database is called records. To describe this table use the following command

ecords

To query, update, delete from the table use sql.

ct * from records;

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.