<commit_before>// Copyright (c) 2012, Joyent, Inc. All rights reserved.
var assert = require('assert-plus');
var EventEmitter = require('events').EventEmitter;
var restify = require('restify');
var shelljs = require('shelljs');
var spawn = require('child_process').spawn;
var util = require('util');
var url = require('url');

function HeartbeatClient(options) {
        assert.object(options, 'options');
        assert.object(options.log, 'options.log');
        assert.string(options.url, 'options.url');
        assert.string(options.primaryUrl, 'options.primaryUrl');
        assert.number(options.heartbeatInterval, 'options.heartbeatInterval');

        EventEmitter.call(this);

        var self = this;

        this.log = options.log;

        /**
        * The primary server's url. http://10.0.0.0:1234
        */
        this.primaryUrl = options.primaryUrl;

        this.url = options.url;
        var parsedUrl = url.parse(self.url);
        if (!parsedUrl.host || !parsedUrl.port) {
                throw new Error('url %s does not contain host or port',
                                self.url);
        }

        this.client = restify.createJsonClient({
                url: self.primaryUrl,
                version: '*',<commit_msg>MANTA-708 check for primary url in heartbeatclient constructor<commit_after>// Copyright (c) 2012, Joyent, Inc. All rights reserved.
var assert = require('assert-plus');
var EventEmitter = require('events').EventEmitter;
var restify = require('restify');
var shelljs = require('shelljs');
var spawn = require('child_process').spawn;
var util = require('util');
var url = require('url');

function HeartbeatClient(options) {
        assert.object(options, 'options');
        assert.object(options.log, 'options.log');
        assert.string(options.url, 'options.url');
        assert.string(options.primaryUrl, 'options.primaryUrl');
        assert.number(options.heartbeatInterval, 'options.heartbeatInterval');

        EventEmitter.call(this);

        var self = this;

        this.log = options.log;

        /**
        * The primary server's url. http://10.0.0.0:1234
        */
        this.primaryUrl = options.primaryUrl;

        this.url = options.url;
        var parsedUrl = url.parse(self.primaryUrl);
        if (!parsedUrl.host || !parsedUrl.port) {
                throw new Error('primaryUrl ' + self.primaryUrl +
                                ' does not contain host or port');
        }

        this.client = restify.createJsonClient({
                url: self.primaryUrl,
                version: '*',
{'fraction_non_alphanumeric': 0.13439194422927964, 'fraction_numerical': 0.011231603408210689, 'mean_word_length': 2.481132075471698, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7282835', 'n_tokens_mistral': 739, 'n_tokens_neox': 706, 'n_words': 164}