Remove redundant use of raw string from test

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add demarcate macro for automatic start/end msgs

We had several bits of code that would log "Starting foo", then do foo,
then log "Finished foo". That can be automated through a simple macro.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add publish-json! func for submitting objs to mq

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add isa-datetime? func for use in preconditions

We had `(satisfies? ICoerce foo)` in a few places, and this captures
that in a function with a handy name.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Remove use of current_timetamp

For time-based interactions with the database, we need to standardize on
one of two approaches:

1) Always use the database's notion of time
2) Always use the JVM's notion of time

Mixing these two things can result in some seriously strange race
conditions between the daemon's idea of time (like when we stamp
messages with a received-time annotation) and the database's idea of
time.

This patchset removes any lingering use of `current_timetamp`, replacing
such usage with JVM time.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add stale-nodes query function

Returns the list of nodes that haven't seen any activity in the supplied
time interval. "Acivity" is defined as having received a new catalog or
set of facts in the given time interval.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add funcs for internal/external command submission

There are 3 different ways in which commands get submitted:

* Send a raw command via HTTP, to an external PuppetDB daemon's
  /commands endpoint. benchmark.clj does this.

* Send an unassembled command (you have access to the command name,
  version and payload) via JMS. In-process code that needs to send a
  specific command needs this.

* Send a raw command via JMS. In-process code that needs to send a
  command, but has received it from an external source (like the
  /commands endpoint)

This patchset creates proper functions for each of these situations.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Auto-deactivation of stale nodes

Adds the `node-ttl-days` parameter, which defines how long a node can
continue without seeing new activity (new catalogs, facts, etc) before
it's automatically deactivated during a garbage-collection run.

The default behavior is the same as before: no automatic deactivation of
anything.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Rename isa-datetime? to datetime?

This is more in line with clojure idioms (string? number? etc).

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Code review fixups

* Default node-ttl-days to 0 instead of nil, and make the conditional
  check simply look for a positive number. That's a better way to handle
  edge cases

* Rename `db-compactor` to `sweep-database!`. It more accurately
  describes what we're doing

* Create a `send-command!` function and pass that into
  `sweep-database!`. That way, the function doesn't need to know the
  implementation details of _how_ to send a command.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Fix typo

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Merge pull request #238 from grimradical/auto-deactivation-of-stale-nodes

Auto deactivation of stale nodes