Liking cljdoc? Tell your friends :D
Clojure only.

puppetlabs.puppetdb.scf.storage

Catalog persistence

Catalogs are persisted in a relational database. Roughly speaking, the schema looks like this:

  • resource_parameters are associated 0 to N catalog_resources (they are deduped across catalogs). It's possible for a resource_param to exist in the database, yet not be associated with a catalog. This is done as a performance optimization.

  • edges are associated with a single catalog

  • catalogs are associated with a single certname

  • facts are associated with a single certname

The standard set of operations on information in the database will likely result in dangling resources and catalogs; to clean these up, it's important to run garbage-collect!.

Catalog persistence

Catalogs are persisted in a relational database. Roughly speaking,
the schema looks like this:

* resource_parameters are associated 0 to N catalog_resources (they are
deduped across catalogs). It's possible for a resource_param to exist in the
database, yet not be associated with a catalog. This is done as a
performance optimization.

* edges are associated with a single catalog

* catalogs are associated with a single certname

* facts are associated with a single certname

 The standard set of operations on information in the database will
 likely result in dangling resources and catalogs; to clean these
 up, it's important to run `garbage-collect!`.
raw docstring

*note-add-params-insert*clj

source

*note-insert-catalog-resources-insert*clj

source

*note-insert-edges-insert*clj

source

acquire-locks!clj

(acquire-locks! table-modes)

Acquires a lock on the specified table.

Acquires a lock on the specified table.
sourceraw docstring

add-catalog-metadata!clj

(add-catalog-metadata! hash {:keys [certname] :as catalog} received-timestamp)

Stores catalog metadata for certname.

Stores catalog metadata for certname.
sourceraw docstring

add-certname!clj

(add-certname! certname)

Inputs: [certname :- String]

Add the given host to the db

Inputs: [certname :- String]

Add the given host to the db
sourceraw docstring

add-certnamesclj

(add-certnames certnames)

Inserts the collection of certnames.

Inserts the collection of certnames.
sourceraw docstring

add-facts!clj

(add-facts! {:keys [certname values environment timestamp producer_timestamp
                    producer package_inventory]
             :as fact-data})

Inputs: [{:keys [certname values environment timestamp producer_timestamp producer package_inventory], :as fact-data} :- facts-schema]

Given a certname and a map of fact names to values, store records for those facts associated with the certname.

Inputs: [{:keys [certname values environment timestamp producer_timestamp producer package_inventory], :as fact-data} :- facts-schema]

Given a certname and a map of fact names to values, store records for those
facts associated with the certname.
sourceraw docstring

add-new-catalogclj

(add-new-catalog certname-id hash catalog refs-to-hashes received-timestamp)

Inputs: [certname-id :- Long hash :- String catalog :- catalog-schema refs-to-hashes :- {resource-ref-schema String} received-timestamp :- pls/Timestamp]

Creates new catalog metadata and adds the proper associations for the edges and resources

Inputs: [certname-id :- Long hash :- String catalog :- catalog-schema refs-to-hashes :- {resource-ref-schema String} received-timestamp :- pls/Timestamp]

Creates new catalog metadata and adds the proper associations for the edges and resources
sourceraw docstring

add-params!clj

(add-params! refs-to-resources refs-to-hashes)

Inputs: [refs-to-resources :- resource-ref->resource-schema refs-to-hashes :- resource-ref->hash]

Persists the new parameters found in refs-to-resources and populates the resource_params_cache.

Inputs: [refs-to-resources :- resource-ref->resource-schema refs-to-hashes :- resource-ref->hash]

Persists the new parameters found in `refs-to-resources` and populates the
 resource_params_cache.
sourceraw docstring

add-report!clj

(add-report! report received-timestamp db conn-status)
(add-report! {:keys [certname producer_timestamp] :as report}
             received-timestamp
             db
             conn-status
             options-config)

Inputs: ([report received-timestamp db conn-status] [{:keys [certname producer_timestamp], :as report} :- reports/report-wireformat-schema received-timestamp :- pls/Timestamp db conn-status options-config]) Returns: processing-status-schema

Add a report and all of the associated events to the database.

Inputs: ([report received-timestamp db conn-status] [{:keys [certname producer_timestamp], :as report} :- reports/report-wireformat-schema received-timestamp :- pls/Timestamp db conn-status options-config])
Returns: processing-status-schema

Add a report and all of the associated events to the database.
sourceraw docstring

add-report!*clj

(add-report!* orig-report received-timestamp save-event? options-config)

Inputs: [orig-report :- reports/report-wireformat-schema received-timestamp :- pls/WireTimestamp save-event? :- s/Bool options-config] Returns: processing-status-schema

Helper function for adding a report. Accepts an extra parameter, update-latest-report?, which is used to determine whether or not the update-latest-report! function will be called as part of the transaction. This should always be set to true, except during some very specific testing scenarios.

Inputs: [orig-report :- reports/report-wireformat-schema received-timestamp :- pls/WireTimestamp save-event? :- s/Bool options-config]
Returns: processing-status-schema

Helper function for adding a report.  Accepts an extra parameter, `update-latest-report?`, which
is used to determine whether or not the `update-latest-report!` function will be called as part of
the transaction.  This should always be set to `true`, except during some very specific testing
scenarios.
sourceraw docstring

add-resources!clj

(add-resources! certname-id certname refs-to-resources refs-to-hashes)

Inputs: [certname-id :- Long certname :- String refs-to-resources :- resource-ref->resource-schema refs-to-hashes :- {resource-ref-schema String}]

Persist the given resource and associate it with the given catalog.

Inputs: [certname-id :- Long certname :- String refs-to-resources :- resource-ref->resource-schema refs-to-hashes :- {resource-ref-schema String}]

Persist the given resource and associate it with the given catalog.
sourceraw docstring

basic-diffclj

(basic-diff left right)

Inputs: [left right]

Basic diffing that returns only the keys/values of right whose values don't match those of left. This is different from clojure.data/diff in that it treats non-equal sets as completely different (rather than returning only the differing items of the set) and only returns differences from right.

Inputs: [left right]

Basic diffing that returns only the keys/values of `right` whose values don't match those of `left`.
 This is different from clojure.data/diff in that it treats non-equal sets as completely different
 (rather than returning only the differing items of the set) and only returns differences from `right`.
sourceraw docstring

call-with-lock-timeoutclj

(call-with-lock-timeout f timeout-ms)
source

catalog-edges-mapclj

(catalog-edges-map certname)

Inputs: [certname :- String]

Return all edges for a given catalog id as a map

Inputs: [certname :- String]

Return all edges for a given catalog id as a map
sourceraw docstring

catalog-hash-for-certnameclj

(catalog-hash-for-certname certname)

Returns the hash for the certname catalog

Returns the hash for the `certname` catalog
sourceraw docstring

catalog-inputs-hashclj

(catalog-inputs-hash certname inputs)
source

catalog-inputs-metadataclj

(catalog-inputs-metadata certname)
source

catalog-resourcesclj

(catalog-resources certname-id)

Inputs: [certname-id :- Long]

Returns the resource hashes keyed by resource reference

Inputs: [certname-id :- Long]

Returns the resource hashes keyed by resource reference
sourceraw docstring

catalog-row-mapclj

(catalog-row-map hash
                 {:keys [version code_id job_id transaction_uuid catalog_uuid
                         environment producer_timestamp producer]}
                 received-timestamp)

Inputs: [hash {:keys [version code_id job_id transaction_uuid catalog_uuid environment producer_timestamp producer]} :- catalog-schema received-timestamp :- pls/Timestamp]

Creates a row map for the catalogs table, optionally adding envrionment when it was found

Inputs: [hash {:keys [version code_id job_id transaction_uuid catalog_uuid environment producer_timestamp producer]} :- catalog-schema received-timestamp :- pls/Timestamp]

Creates a row map for the catalogs table, optionally adding envrionment when it was found
sourceraw docstring

catalog-schemaclj

This is a bit of a hack to make a more restrictive schema in the storage layer. Moving the more restrictive resource/edge schemas into puppetdb.catalogs is TODO. Upstream code needs to assume a map of resources (not a vector) and tests need to be update to adhere to the new format.

This is a bit of a hack to make a more restrictive schema in the storage layer.
Moving the more restrictive resource/edge schemas into puppetdb.catalogs is TODO. Upstream
code needs to assume a map of resources (not a vector) and tests need to be update to adhere
to the new format.
sourceraw docstring

certname-factset-metadataclj

(certname-factset-metadata certname)

Inputs: [certname :- s/Str] Returns: {:package_hash (s/maybe s/Str), :factset_id s/Int, :certname_id s/Int, :stable_hash (s/maybe (s/pred shash/sha1-bytes?))}

Given a certname, return the factset id, hash and certname id.

Inputs: [certname :- s/Str]
Returns: {:package_hash (s/maybe s/Str), :factset_id s/Int, :certname_id s/Int, :stable_hash (s/maybe (s/pred shash/sha1-bytes?))}

Given a certname, return the factset id, hash and certname id.
sourceraw docstring

certname-idclj

(certname-id name)
source

clean-catalog-dataclj

(clean-catalog-data db)

Delete unassociated resource parameters and environments.

Delete unassociated resource parameters and environments.
sourceraw docstring

command-sql-statement-timeout-msclj

source

create-package-mapclj

(create-package-map certname-id)
source

create-storage-metricsclj

(create-storage-metrics prefix)
source

daily-partition-drop-lock-timeout-msclj

source

deactivate-node!clj

(deactivate-node! certname)
(deactivate-node! certname timestamp)

Inputs: ([certname :- String] [certname :- String timestamp :- pls/Timestamp])

Deactivate the given host, recording the current time. If the node is currently inactive, no change is made.

Inputs: ([certname :- String] [certname :- String timestamp :- pls/Timestamp])

Deactivate the given host, recording the current time. If the node is
currently inactive, no change is made.
sourceraw docstring

delete-catalog-inputs!clj

(delete-catalog-inputs! certid)
source

delete-catalog-resources!clj

(delete-catalog-resources! certname-id certname old-resources refs-to-delete)

Inputs: [certname-id :- Long certname :- String old-resources refs-to-delete]

Inputs: [certname-id :- Long certname :- String old-resources refs-to-delete]
sourceraw docstring

delete-certname!clj

(delete-certname! certname)

Delete the given host from the db

Delete the given host from the db
sourceraw docstring

delete-certnames!clj

(delete-certnames! certnames)

Delete the list of hosts from the db

Delete the list of hosts from the db
sourceraw docstring

delete-edges!clj

(delete-edges! certname edges)

Inputs: [certname :- String edges :- edge-db-schema]

Delete edges for a given certname.

Edges must be either nil or a collection of lists containing each element of an edge, e.g.:

[[<source> <target> <type>] ...]

Inputs: [certname :- String edges :- edge-db-schema]

Delete edges for a given certname.

Edges must be either nil or a collection of lists containing each element
of an edge, e.g.:

  [[<source> <target> <type>] ...]
sourceraw docstring

delete-reports-older-than!clj

(delete-reports-older-than!
  {:keys [report-ttl resource-events-ttl incremental? update-lock-status]
   :or {incremental? false update-lock-status (constantly true)}})

Delete all reports in the database which have a producer-timestamp that is prior to the specified report-time. When event-time is specified, delete all the events that are older than whichever time is more recent.

Delete all reports in the database which have a producer-timestamp
that is prior to the specified report-time. When event-time is
specified, delete all the events that are older than whichever time
is more recent.
sourceraw docstring

delete-reports-older-than-in-pg-11!clj

(delete-reports-older-than-in-pg-11! report-ttl
                                     resource-events-ttl
                                     incremental?
                                     update-lock-status)

PostgreSQL 11 workflow for deleting all reports in the database which have a producer-timestamp that is prior to the specified report-time. When event-time is specified, delete all the events that are older than whichever time is more recent.

PostgreSQL 11 workflow for deleting all reports in the database which have
a producer-timestamp that is prior to the specified report-time.  When
event-time is specified, delete all the events that are older than whichever
time is more recent.
sourceraw docstring

delete-resource-events-older-than!clj

(delete-resource-events-older-than! date incremental? update-lock-status)

Delete all resource events in the database by dropping any partition older than the day of the year of the given date. Note: this ignores the time in the given timestamp, rounding to the day.

Delete all resource events in the database by dropping any partition older than the day of the year of the given
date.
Note: this ignores the time in the given timestamp, rounding to the day.
sourceraw docstring

delete-unassociated-environments!clj

(delete-unassociated-environments!)

Remove any environments that aren't associated with a catalog, report or factset

Remove any environments that aren't associated with a catalog, report or factset
sourceraw docstring

delete-unassociated-packages!clj

(delete-unassociated-packages!)
source

delete-unassociated-params!clj

(delete-unassociated-params!)

Remove any resources that aren't associated with a catalog

Remove any resources that aren't associated with a catalog
sourceraw docstring

delete-unused-fact-pathsclj

(delete-unused-fact-paths)

Deletes paths from fact_paths that are no longer needed by any factset. In the unusual case where a path changes type, the previous version will linger. This requires a parent transaction with at least a repeatable-read isolation level (and may or may not need postgres' "stronger than the standard" repeatable-read behavior). Otherwise paths could be added to fact_paths elsewhere during the gc, not be noticed, and then be deleted at the end.

Deletes paths from fact_paths that are no longer needed by any
factset.  In the unusual case where a path changes type, the
previous version will linger.  This requires a parent transaction
with at least a repeatable-read isolation level (and may or may not
need postgres' "stronger than the standard" repeatable-read
behavior).  Otherwise paths could be added to fact_paths elsewhere
during the gc, not be noticed, and then be deleted at the end.
sourceraw docstring

detach-daily-partitionsclj

(detach-daily-partitions parent-table
                         date
                         incremental?
                         update-lock-status
                         status-key)

Detaches declarative partitions concurrently in PG14+, which runs with a less restrictive SHARE UPDATE EXCLUSIVE lock instead of ACCESS EXCLUSIVE. Once it's detached, it should no longer participate in queries to the parent table and the subsequent drop should be able to acquire an ACCESS EXCLUSIVE lock more quickly.

NOTE: This must be run outside of a transaction.

Detaches declarative partitions concurrently in PG14+, which runs with a
less restrictive SHARE UPDATE EXCLUSIVE lock instead of ACCESS EXCLUSIVE.
Once it's detached, it should no longer participate in queries to the parent
table and the subsequent drop should be able to acquire an ACCESS EXCLUSIVE
lock more quickly.

NOTE: This must be run outside of a transaction.
sourceraw docstring

detach-partitions-concurrently?clj

(detach-partitions-concurrently?)

True if Postgresql server supports ALTER TABLE DETACH PARTITION CONCURRENTLY. (PG 14+)

True if Postgresql server supports ALTER TABLE DETACH PARTITION CONCURRENTLY. (PG 14+)
sourceraw docstring

diff-resources-metadataclj

(diff-resources-metadata left right certname)

Inputs: [left right certname]

Return resource references with values that are only the key/values that from right that are different from those of the left. The keys/values here are suitable for issuing update statements that will update resources to the correct (new) values.

Inputs: [left right certname]

Return resource references with values that are only the key/values that from `right` that
 are different from those of the `left`. The keys/values here are suitable for issuing update
 statements that will update resources to the correct (new) values.
sourceraw docstring

drop-partition-tables!clj

(drop-partition-tables! old-partition-tables update-lock-status status-key)

Drops the given set of tables. Will throw an SQLException termination if the operation takes much longer than PDB_GC_DAILY_PARTITION_DROP_LOCK_TIMEOUT_MS.

Drops the given set of tables. Will throw an SQLException termination if the
operation takes much longer than PDB_GC_DAILY_PARTITION_DROP_LOCK_TIMEOUT_MS.
sourceraw docstring

edge-db-schemaclj

source

edge-relationship-schemaclj

source

edge-schemaclj

source

ensure-certnameclj

(ensure-certname certname)

Inputs: [certname :- String]

Adds the given host to the db iff it isn't already there.

Inputs: [certname :- String]

Adds the given host to the db iff it isn't already there.
sourceraw docstring

ensure-environmentclj

(ensure-environment name)
source

ensure-named-rowclj

(ensure-named-row table col name)

Returns the id (primary key) of the named row, creating it if necessary.

Returns the id (primary key) of the named row, creating it if necessary.
sourceraw docstring

ensure-producerclj

(ensure-producer name)
source

ensure-statusclj

(ensure-status name)
source

environment-idclj

(environment-id name)
source

environments-schemaclj

source

execute-with-bulldozerclj

(execute-with-bulldozer db f)
source

expire-stale-nodesclj

(expire-stale-nodes horizon)

Inputs: [horizon :- Period]

Expires nodes with no activity within the provided horizon (prior to now) and returns a collection of the affected certnames.

Inputs: [horizon :- Period]

Expires nodes with no activity within the provided horizon (prior
to now) and returns a collection of the affected certnames.
sourceraw docstring

fact-path-gcclj

(fact-path-gc db)
source

fact-path-gc-lock-timeout-msclj

source

factset-paths-hashclj

(factset-paths-hash factset_id)
source

finalize-pending-detachclj

(finalize-pending-detach parent)

Finalize a previously failed detach operation. A partitioned table can only have one partition pending detachment at any time.

Finalize a previously failed detach operation. A partitioned table can
only have one partition pending detachment at any time.
sourceraw docstring

find-certname-id-and-hashclj

(find-certname-id-and-hash certname)
source

find-containing-classclj

(find-containing-class containment-path)

Given a containment path from Puppet, find the outermost 'class'.

Given a containment path from Puppet, find the outermost 'class'.
sourceraw docstring

find-package-hashesclj

(find-package-hashes package-hashes)
source

find-stranded-partitionsclj

(find-stranded-partitions child-format)

Identify tables that match the child format of a partitioned table (like reports_historical) that are not present in the pg_inherits table. These partitions have been detached, but failed to be deleted.

Tables that are not partitioned will also not be in the pg_inherits table, so you MUST write a child-format that does not match any non-partitioned tables.

Returns a list of strings. Each string is a stranded partition that should be removed.

Identify tables that match the child format of a partitioned table (like reports_historical)
that are not present in the pg_inherits table. These partitions have been detached, but failed
to be deleted.

Tables that are not partitioned will also not be in the pg_inherits table, so you MUST
write a child-format that does not match any non-partitioned tables.

Returns a list of strings. Each string is a stranded partition that should be removed.
sourceraw docstring

garbage-collect!clj

(garbage-collect! db)

Delete any lingering, unassociated data in the database

Delete any lingering, unassociated data in the database
sourceraw docstring

gc-query-bulldozer-timeout-msclj

source

get-storage-metricclj

(get-storage-metric metric)
(get-storage-metric metric db)
source

handle-resource-insert-sql-exclj

(handle-resource-insert-sql-ex ex certname row-or-rows)

Handles a SQLException encountered while inserting a resource. This may occur when the inserted resource has a value too big for a postgres btree index.

Handles a SQLException encountered while inserting a resource. This
may occur when the inserted resource has a value too big for a
postgres btree index.
sourceraw docstring

hash-pathmaps-pathsclj

(hash-pathmaps-paths pathmaps)
source

have-newer-record-for-certname?clj

(have-newer-record-for-certname? certname timestamp)

Inputs: [certname :- String timestamp :- Timestamp]

Returns a truthy value indicating whether a record exists that has a producer_timestamp newer than the given timestamp.

Inputs: [certname :- String timestamp :- Timestamp]

Returns a truthy value indicating whether a record exists that has
a producer_timestamp newer than the given timestamp.
sourceraw docstring

init-storage-metricsclj

(init-storage-metrics scf-write-dbs)
source

insert-catalog-resources!clj

(insert-catalog-resources! certname-id
                           certname
                           refs-to-hashes
                           refs-to-resources
                           refs-to-insert)

Inputs: [certname-id :- Long certname :- String refs-to-hashes :- {resource-ref-schema String} refs-to-resources :- resource-ref->resource-schema refs-to-insert]

Inputs: [certname-id :- Long certname :- String refs-to-hashes :- {resource-ref-schema String} refs-to-resources :- resource-ref->resource-schema refs-to-insert]
sourceraw docstring

insert-edges!clj

(insert-edges! certname edges)

Inputs: [certname :- String edges :- edge-db-schema]

Insert edges for a given certname.

Edges must be either nil or a collection of lists containing each element of an edge, eg:

[[<source> <target> <type>] ...]

Inputs: [certname :- String edges :- edge-db-schema]

Insert edges for a given certname.

Edges must be either nil or a collection of lists containing each element
of an edge, eg:

  [[<source> <target> <type>] ...]
sourceraw docstring

insert-missing-packagesclj

(insert-missing-packages existing-hashes-map new-hashed-package-tuples)
source

insert-packagesclj

(insert-packages certname inventory)
source

insert-resource-eventsclj

(insert-resource-events certname cert-id report-id resource-events ttl latest)
source

json-primitive-schemaclj

source

latest-catalog-metadataclj

(latest-catalog-metadata certname)

Returns the id, hash, certname_id and producer_timestamp of certname's catalog.

Returns the id, hash, certname_id and producer_timestamp of certname's
catalog.
sourceraw docstring

latest-events-metadataclj

(latest-events-metadata report-id)
source

latest-report-metadataclj

(latest-report-metadata certname)

Return the latest report timestamp for the given certname

Return the latest report timestamp for the given certname
sourceraw docstring

load-stable-factsclj

(load-stable-facts factset-id)
source

log-catalog-resource-changes?clj

source

maybe-activate-node!clj

(maybe-activate-node! certname time)

Inputs: [certname :- String time :- pls/Timestamp]

Reactivate the given host, only if it was deactivated or expired before time. Returns true if the node is activated, or if it was already active.

Adds the host to the database if it was not already present.

Inputs: [certname :- String time :- pls/Timestamp]

Reactivate the given host, only if it was deactivated or expired before
`time`.  Returns true if the node is activated, or if it was already active.

Adds the host to the database if it was not already present.
sourceraw docstring

maybe-log-query-terminationclj

(maybe-log-query-termination result)

Takes a seq of maps containing information about PostgreSQL pids which the query-bulldozer attempted to call pg_terminate_backend(<pid>) on and logs information about the termination attempt. Example input: [{:pg_terminate_backend t/f :pid <pid>}]

Takes a seq of maps containing information about PostgreSQL pids
which the query-bulldozer attempted to call pg_terminate_backend(<pid>)
on and logs information about the termination attempt.
Example input: [{:pg_terminate_backend t/f :pid <pid>}]
sourceraw docstring

merge-resource-hashclj

(merge-resource-hash refs-to-hashes refs-to-resources)

Assoc each hash from refs-to-hashes as :resource on refs-to-resources

Assoc each hash from `refs-to-hashes` as :resource on `refs-to-resources`
sourceraw docstring

munge-edges-for-storageclj

(munge-edges-for-storage edges)
source

munge-resources-for-storageclj

(munge-resources-for-storage resources)
source

named-row-idclj

(named-row-id table col name)

Returns the id (primary key) from the table for the row with col = name.

Returns the id (primary key) from the table for the row with col = name.
sourceraw docstring

new-params-onlyclj

(new-params-only persisted-params refs-to-resources refs-to-hashes)

Inputs: [persisted-params :- #{String} refs-to-resources :- resource-ref->resource-schema refs-to-hashes :- resource-ref->hash]

Returns a map of not persisted parameters, keyed by hash

Inputs: [persisted-params :- #{String} refs-to-resources :- resource-ref->resource-schema refs-to-hashes :- resource-ref->hash]

Returns a map of not persisted parameters, keyed by hash
sourceraw docstring

node-deactivated-timeclj

(node-deactivated-time certname)

Returns the time the node specified by certname was deactivated, or nil if the node is currently active.

Returns the time the node specified by `certname` was deactivated, or nil if
the node is currently active.
sourceraw docstring

node-expired-timeclj

(node-expired-time certname)

Returns the time the node specified by certname expired, or nil if the node is currently active.

Returns the time the node specified by `certname` expired, or nil if
the node is currently active.
sourceraw docstring

normalize-reportclj

(normalize-report {:keys [resources] :as report})

Prep the report for comparison/computation of a hash

Prep the report for comparison/computation of a hash
sourceraw docstring

normalize-resource-eventclj

(normalize-resource-event event)

Prep event for comparison/computation of a hash

Prep `event` for comparison/computation of a hash
sourceraw docstring

oldest-allowed-dbclj

source

oldest-supported-dbclj

source

package-id-set-for-certnameclj

(package-id-set-for-certname certname-id)
source

path-insertion-chunk-sizeclj

source

pathmap-digestorclj

(pathmap-digestor digest)
source

pg14-dbclj

source

processing-status-schemaclj

source

producer-idclj

(producer-id name)
source

prune-daily-partitionsclj

(prune-daily-partitions parent-table
                        date
                        incremental?
                        update-lock-status
                        status-key)
(prune-daily-partitions parent-table
                        date
                        incremental?
                        update-lock-status
                        status-key
                        just-detach?)

Either detaches or drops obsolete day-oriented partitions older than the date. Deletes or detaches only the oldest such candidate if incremental? is true. Will throw an SQLException termination if the operation takes much longer than PDB_GC_DAILY_PARTITION_DROP_LOCK_TIMEOUT_MS.

Either detaches or drops obsolete day-oriented partitions
older than the date. Deletes or detaches only the oldest such candidate if
incremental? is true. Will throw an SQLException termination if the operation
takes much longer than PDB_GC_DAILY_PARTITION_DROP_LOCK_TIMEOUT_MS.
sourceraw docstring

purge-deactivated-and-expired-nodes!clj

(purge-deactivated-and-expired-nodes! horizon)
(purge-deactivated-and-expired-nodes! horizon batch-limit)

Delete nodes from the database which were deactivated before horizon.

Delete nodes from the database which were deactivated before horizon.
sourceraw docstring

query-bulldozerclj

(query-bulldozer db gc-pid connected gc-finished?)

Creates a thread which will loop and wait for the gc-pid to get blocked waiting on an AccessExclusiveLock. Once this thread detects that GC is blocked it will terminate all running queries from the pdb user against the pdb database which have been granted locks with the exception of queries from the gc-pid or the bulldozer's pid. This should clear the way for GC to grab the lock it's requesting in the main GC thread. This loop repeats until the bulldozer thread is interrupted or receives confirmation from the GC thread via the gc-finished? atom that the GC thread has dropped the partition.

Creates a thread which will loop and wait for the gc-pid to get blocked
waiting on an AccessExclusiveLock. Once this thread detects that GC is
blocked it will terminate all running queries from the pdb user against the
pdb database which have been granted locks with the exception of queries
from the gc-pid or the bulldozer's pid. This should clear the way for GC
to grab the lock it's requesting in the main GC thread. This loop repeats
until the bulldozer thread is interrupted or receives confirmation from the
GC thread via the gc-finished? atom that the GC thread has dropped the
partition.
sourceraw docstring

realize-pathsclj

(realize-paths pathmaps)
(realize-paths pathmaps notice-pathmap)

Ensures that every path in the pathmaps has a corresponding row in fact_paths.

Ensures that every path in the pathmaps has a corresponding row in
fact_paths.
sourceraw docstring

replace-catalog!clj

(replace-catalog! catalog)
(replace-catalog! {:keys [producer_timestamp resources certname] :as catalog}
                  received-timestamp)

Inputs: ([catalog :- catalog-schema] [{:keys [producer_timestamp resources certname], :as catalog} :- catalog-schema received-timestamp :- pls/Timestamp]) Returns: processing-status-schema

Persist the supplied catalog in the database, returning its similarity hash.

Inputs: ([catalog :- catalog-schema] [{:keys [producer_timestamp resources certname], :as catalog} :- catalog-schema received-timestamp :- pls/Timestamp])
Returns: processing-status-schema

Persist the supplied catalog in the database, returning its
 similarity hash.
sourceraw docstring

replace-catalog-inputs!clj

(replace-catalog-inputs! certname catalog_uuid inputs updated)

Inputs: [certname :- s/Str catalog_uuid :- s/Str inputs :- [[s/Str]] updated :- pls/Timestamp] Returns: processing-status-schema

Inputs: [certname :- s/Str catalog_uuid :- s/Str inputs :- [[s/Str]] updated :- pls/Timestamp]
Returns: processing-status-schema
sourceraw docstring

replace-edges!clj

(replace-edges! certname edges refs-to-hashes)

Inputs: [certname :- String edges :- #{edge-schema} refs-to-hashes :- {resource-ref-schema String}]

Persist the given edges in the database

Each edge is looked up in the supplied resources map to find a resource object that corresponds to the edge. We then use that resource's hash for persistence purposes.

For example, if the source of an edge is {'type' 'Foo' 'title' 'bar'}, then we'll lookup a resource with that key and use its hash.

Inputs: [certname :- String edges :- #{edge-schema} refs-to-hashes :- {resource-ref-schema String}]

Persist the given edges in the database

Each edge is looked up in the supplied resources map to find a
resource object that corresponds to the edge. We then use that
resource's hash for persistence purposes.

For example, if the source of an edge is {'type' 'Foo' 'title' 'bar'},
then we'll lookup a resource with that key and use its hash.
sourceraw docstring

replace-existing-catalogclj

(replace-existing-catalog certname-id
                          catalog-id
                          hash
                          catalog
                          refs-to-hashes
                          received-timestamp)

Inputs: [certname-id :- Long catalog-id :- Long hash :- String catalog :- catalog-schema refs-to-hashes :- {resource-ref-schema String} received-timestamp :- pls/Timestamp]

New catalogs for a given certname needs to have their metadata, resources and edges updated.

Inputs: [certname-id :- Long catalog-id :- Long hash :- String catalog :- catalog-schema refs-to-hashes :- {resource-ref-schema String} received-timestamp :- pls/Timestamp]

New catalogs for a given certname needs to have their metadata, resources and
edges updated.
sourceraw docstring

replace-facts!clj

(replace-facts! {:keys [certname producer_timestamp] :as fact-data})

Inputs: [{:keys [certname producer_timestamp], :as fact-data} :- facts-schema] Returns: processing-status-schema

Updates the facts of an existing node, if the facts are newer than the current set of facts. Adds all new facts if no existing facts are found. Invoking this function under the umbrella of a repeatable read or serializable transaction enforces only one update to the facts of a certname can happen at a time. The first to start the transaction wins. Subsequent transactions will fail as the factsets will have changed while the transaction was in-flight.

Inputs: [{:keys [certname producer_timestamp], :as fact-data} :- facts-schema]
Returns: processing-status-schema

Updates the facts of an existing node, if the facts are newer than the current set of facts.
 Adds all new facts if no existing facts are found. Invoking this function under the umbrella of
 a repeatable read or serializable transaction enforces only one update to the facts of a certname
 can happen at a time.  The first to start the transaction wins.  Subsequent transactions will fail
 as the factsets will have changed while the transaction was in-flight.
sourceraw docstring

replace-null-bytesclj

(replace-null-bytes x)
source

resource-event-expired?clj

(resource-event-expired? timestamp resource-events-ttl)
source

resource-ref->hashclj

source

resource-ref->resource-schemaclj

source

resource-ref-schemaclj

source

resource-ref?clj

Returns true of the map is a resource reference

Returns true of the map is a resource reference
sourceraw docstring

resource-schemaclj

source

resources-exist?clj

(resources-exist? resource-hashes)

Inputs: [resource-hashes :- #{String}] Returns: #{String}

Given a collection of resource-hashes, return the subset that already exist in the database.

Inputs: [resource-hashes :- #{String}]
Returns: #{String}

Given a collection of resource-hashes, return the subset that
 already exist in the database.
sourceraw docstring

set-certname-facts-expirationclj

(set-certname-facts-expiration certname expire? updated)

Inputs: [certname :- s/Str expire? :- s/Bool updated :- pls/Timestamp] Returns: processing-status-schema

Inputs: [certname :- s/Str expire? :- s/Bool updated :- pls/Timestamp]
Returns: processing-status-schema
sourceraw docstring

status-idclj

(status-id name)
source

storage-metricsclj

source

storage-metrics-registryclj

source

store-catalog-inputs!clj

(store-catalog-inputs! certid inputs)
source

store-corrective-change?clj

source

store-resources-column?clj

source

strip-paramsclj

(strip-params resource)

Remove params from the resource as it is stored (and hashed) separately from the resource metadata

Remove params from the resource as it is stored (and hashed) separately
from the resource metadata
sourceraw docstring

table-lock-orderclj

This provides a partial ordering of tables, to ensure that we always lock them in a consistent order.

This provides a partial ordering of tables, to ensure that we always lock
them in a consistent order.
sourceraw docstring

timestamp-of-newest-recordclj

(timestamp-of-newest-record entity certname)
source

update-catalog-associations!clj

(update-catalog-associations! certname-id
                              {:keys [resources edges certname]}
                              refs-to-hashes)

Inputs: [certname-id :- Long {:keys [resources edges certname]} :- catalog-schema refs-to-hashes :- {resource-ref-schema String}]

Adds/updates/deletes the edges and resources for the given certname

Inputs: [certname-id :- Long {:keys [resources edges certname]} :- catalog-schema refs-to-hashes :- {resource-ref-schema String}]

Adds/updates/deletes the edges and resources for the given certname
sourceraw docstring

update-catalog-input-metadata!clj

(update-catalog-input-metadata! certid catalog-uuid last-updated inputs-hash)
source

update-catalog-metadata!clj

(update-catalog-metadata! id hash catalog received-timestamp)

Inputs: [id :- Long hash :- String catalog :- catalog-schema received-timestamp :- pls/Timestamp]

Given some catalog metadata, update the db

Inputs: [id :- Long hash :- String catalog :- catalog-schema received-timestamp :- pls/Timestamp]

Given some catalog metadata, update the db
sourceraw docstring

update-catalog-resources!clj

(update-catalog-resources! certname-id
                           certname
                           refs-to-hashes
                           refs-to-resources
                           old-resources
                           maybe-updated-refs)

Inputs: [certname-id :- Long certname :- String refs-to-hashes :- {resource-ref-schema String} refs-to-resources old-resources maybe-updated-refs]

Inputs: [certname-id :- Long certname :- String refs-to-hashes :- {resource-ref-schema String} refs-to-resources old-resources maybe-updated-refs]
sourceraw docstring

update-existing-catalogclj

(update-existing-catalog catalog-id hash catalog received-timestamp)

Inputs: [catalog-id :- Long hash :- String catalog :- catalog-schema received-timestamp :- pls/Timestamp]

When a new incoming catalog has the same hash as an existing catalog, update storage-metrics and the transaction id for the new catalog

Inputs: [catalog-id :- Long hash :- String catalog :- catalog-schema received-timestamp :- pls/Timestamp]

When a new incoming catalog has the same hash as an existing catalog, update
 storage-metrics and the transaction id for the new catalog
sourceraw docstring

update-facts!clj

(update-facts! {:keys [certname values environment timestamp producer_timestamp
                       producer package_inventory]
                :as fact-data})

Inputs: [{:keys [certname values environment timestamp producer_timestamp producer package_inventory], :as fact-data} :- facts-schema]

Given a certname, querys the DB for existing facts for that certname and will update, delete or insert the facts as necessary to match the facts argument. (cf. add-facts!)

Inputs: [{:keys [certname values environment timestamp producer_timestamp producer package_inventory], :as fact-data} :- facts-schema]

Given a certname, querys the DB for existing facts for that
 certname and will update, delete or insert the facts as necessary
 to match the facts argument. (cf. add-facts!)
sourceraw docstring

update-packagesclj

(update-packages certname_id package_hash inventory)

Inputs: [certname_id :- s/Int package_hash :- (s/maybe s/Str) inventory :- [pkg-util/package-tuple]]

Compares inventory to the stored package inventory for certname. Differences will result in updates to the database

Inputs: [certname_id :- s/Int package_hash :- (s/maybe s/Str) inventory :- [pkg-util/package-tuple]]

Compares `inventory` to the stored package inventory for
`certname`. Differences will result in updates to the database
sourceraw docstring

volatile-fact-keys-for-factsetclj

(volatile-fact-keys-for-factset factset-id)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close