// Path: src/main/java/com/reachcall/pretty/peering/beats/Heartbeat.java
// public class Heartbeat implements Serializable {
//     
//     
//     
//     public final String instanceName;
//     public final long timestamp;
//     
//     public Heartbeat(String instanceName){
//         this.instanceName = instanceName;
//         this.timestamp = System.currentTimeMillis();
//     }
// 
//     @Override
//     public String toString() {
//         return "HB "+instanceName+" @ "+timestamp;
//     }
//     
// }


import com.reachcall.pretty.peering.beats.Heartbeat;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Timer;
import java.util.TimerTask;
/**
 * Copyright 2013, Robert Cooper, Reach Health
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.reachcall.pretty.peering;





/**
 *
 * @author robert.cooper
 */
public class Heart {
    private String hostname;
    private Timer timer;
    private Agent agent;

    public Heart(Agent agent) throws UnknownHostException {
        this(null, agent);
    }

    public Heart(String hostname, Agent agent) throws UnknownHostException {
        this.hostname = (hostname == null) ? getHostname() : hostname;
        this.agent = agent;
    }

    private String getHostname() throws UnknownHostException {
        InetAddress addr = InetAddress.getLocalHost();

        return addr.getHostName();
    }

// Path: src/main/java/com/reachcall/pretty/peering/beats/Heartbeat.java
// public class Heartbeat implements Serializable {
//     
//     
//     
//     public final String instanceName;
//     public final long timestamp;
//     
//     public Heartbeat(String instanceName){
//         this.instanceName = instanceName;
//         this.timestamp = System.currentTimeMillis();
//     }
// 
//     @Override
//     public String toString() {
//         return "HB "+instanceName+" @ "+timestamp;
//     }
//     
// }


// Path: src/main/java/com/reachcall/pretty/peering/Heart.java
import com.reachcall.pretty.peering.beats.Heartbeat;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Copyright 2013, Robert Cooper, Reach Health
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.reachcall.pretty.peering;





/**
 *
 * @author robert.cooper
 */
public class Heart {
    private String hostname;
    private Timer timer;
    private Agent agent;

    public Heart(Agent agent) throws UnknownHostException {
        this(null, agent);
    }

    public Heart(String hostname, Agent agent) throws UnknownHostException {
        this.hostname = (hostname == null) ? getHostname() : hostname;
        this.agent = agent;
    }

    private String getHostname() throws UnknownHostException {
        InetAddress addr = InetAddress.getLocalHost();

        return addr.getHostName();
    }

    public Heartbeat buildHeartbeat() {