// Carnegie Mellon University
//   Information Networking Institute and
//   School of Computer Science
//
// Master Thesis: A Monitoring Tool for Overlay Network
// By: TungFai Chan and Annie Cheng
//
// File: DetectDeadHostEvent.java
// Path: eventbase/event
// Description: Derive Class from OverlayEvent

package eventbase.event;
import eventbase.*;

public class DetectDeadHostEvent extends OverlayEvent{

  final String OBJECT_NAME = "DetectDeadHostEvent";
  final private int EVENTID = DETECT_DEAD_HOST;
  private OverlayHost SourceHost;
  private OverlayHost DeadHost;
  private String printStr;

  // SourceNode detect DeadNode is dead
  public DetectDeadHostEvent(OverlayHost SourceNode, OverlayHost DeadNode) {
    this.SourceHost = SourceNode;
    this.DeadHost = DeadNode;
    eventID = EVENTID;
  }

  public int getMemorySize() {
    return OverlayHost.getMemorySize() * 2 + 4; //  + EVENTID
  }

  public OverlayHost getSourceHost() {
    return this.SourceHost;
  }

  public OverlayHost getTargetHost() {
    return this.DeadHost;
  }

  public OverlayHost getDeadHost() {
    return this.DeadHost;
  }

  public String getOutputString(){
    printStr = "Event DetectDeadHostEvent: member " + SourceHost.getName() +
              " believes " + DeadHost.getName() + " is dead";
    printStr += ".";
    return printStr;
  }

}
