Package com.simoncat.time

Source Code of com.simoncat.time.RestartTask

package com.simoncat.time;

import java.util.Timer;
import java.util.TimerTask;

import com.simoncat.time.TaskProgrammer;

import com.simoncat.vo.Server;
import com.simoncat.vo.Event;

import com.simoncat.net.RestartServer;

public class RestartTask extends TimerTask {
  private Timer timer = null;
  private Server server;
  private Event event;
  private TaskProgrammer taskProgrammer;
  public RestartTask(Timer timer,Server server,Event event,TaskProgrammer taskProgrammer) {
    this.timer = timer;
    this.server = server;
    this.event = event;
    this.taskProgrammer= taskProgrammer;
  }

  @Override
  public void run() {
    String result="";
   
    //TODO procedimiento para reiniciar servidor
    System.out.println("DatosServer:"+server);
    String ip = server.getAddress();
    String usr = server.getUser();//should be root para restart
    String pwd = server.getPassword();
    int portSSH= new Integer(server.getPortSSH()).intValue();
   
    System.out.println("CORRIENDO EL RESTART EN SERVER:"+server.getName());
    RestartServer rs = new RestartServer(ip,portSSH,usr,pwd);
    boolean r=rs.restart();
    System.out.println("RESULT RESTART:"+r);
       
    //guardar en resultado en el campo results del evento
    event.setResults(result);
    taskProgrammer.addFinishedTask(server,event);
   
  }
}
TOP

Related Classes of com.simoncat.time.RestartTask

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.