Ejemplo n.º 1
0
  public void cleanSimulation(HttpServletRequest req) {
    User user = getUser(req);

    if (user == null) return;

    Iterator it = ReMoto.simulations.values().iterator();

    while (it.hasNext()) {
      Simulation sim = (Simulation) it.next();

      if (sim.getStatus() != Simulation.SIM_RUNNING) {
        Date dateSim = sim.getDateFinish();
        Date dateNow = new Date();

        // TRECHO PROVISORIAMENTE COMENTADO
        /*
        // Remove old simulations - time in milliseconds
        if( user.getCdUser().equals( ReMoto.cdGuestUser ) )
        {
        	// Keep during 30 minutes
        	if( dateNow.getTime() > dateSim.getTime() + 1000 * 60 * 30 )
        		it.remove();
        }
        else
        {
        	// Keep during 12 hours
        	if( dateNow.getTime() > dateSim.getTime() + 1000 * 60 * 60 * 12 )
        		it.remove();
        }
        */

      }
    }
  }
Ejemplo n.º 2
0
  public boolean isThereSimulationRunning(HttpServletRequest req) {
    int numSims = 0;
    Iterator it = ReMoto.simulations.values().iterator();

    while (it.hasNext()) {
      Simulation sim = (Simulation) it.next();

      if (sim.getStatus() == Simulation.SIM_RUNNING) {
        numSims = numSims + 1;
      }
    }

    System.out.println("numSims: " + numSims);

    if (numSims >= 4) return true;

    return false;
  }