Package hu.u_szeged.nbo.server.plugins

Source Code of hu.u_szeged.nbo.server.plugins.GEOMSolver

package hu.u_szeged.nbo.server.plugins;

import hu.u_szeged.nbo.geometria.exception.GeomFileNotFoundException;
import hu.u_szeged.nbo.geometria.exception.GeomKAPMatrixFillException;
import hu.u_szeged.nbo.geometria.exception.GeomWrongFileTypeException;
import hu.u_szeged.nbo.geometria.exception.GeomWrongIndexException;
import hu.u_szeged.nbo.geometria.main.GeomResources;
import hu.u_szeged.nbo.geometria.main.GeomResult;
import hu.u_szeged.nbo.geometria.main.algorithm.GeomAlgorithm;
import hu.u_szeged.nbo.server.NBOServer;
import hu.u_szeged.nbo.server.User;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;

public class GEOMSolver extends NBOPlugin {
  private static final String subDirectoryName = "geometria";
 
  public GEOMSolver(User user, String problemName, HashMap<String, String> inputFiles) {
    super(user, problemName,inputFiles, subDirectoryName);
  }
 
  public void run() {   
   
    this.pluginLogger.info("The server began to compute the "+
        user.getUserName()+"'s "+ task+" with GEOMSolver ...");
    NBOServer.log("The server began to compute the "+
        user.getUserName()+"'s "+ task+" with GEOMSolver ...", 1);

    String resultString="";
    long runtime = new Date().getTime();
    GeomResources resources;
    String dirName = this.task;
   
    try {
      resources = new GeomResources(dirName);
      GeomAlgorithm algorithm = new GeomAlgorithm();
      GeomResult result = algorithm.solve(resources);
      resultString+=result.writeOut(dirName + "/"+ problemName  +".out");
    } catch (GeomFileNotFoundException e) {
      this.pluginLogger.warning(e.toString());
      NBOServer.log(e.toString(), 2);
    } catch (GeomWrongFileTypeException e) {
      this.pluginLogger.warning(e.toString());
      NBOServer.log(e.toString(), 2);
    } catch (GeomWrongIndexException e) {
      this.pluginLogger.warning(e.toString());
      NBOServer.log(e.toString(), 2);
    } catch (IOException e) {
      this.pluginLogger.warning(e.toString());
      NBOServer.log(e.toString(), 2);
    } catch (GeomKAPMatrixFillException e) {
      this.pluginLogger.warning(e.toString());
      NBOServer.log(e.toString(), 2);
    }
   
    runtime = new Date().getTime()-runtime;
    runtime = runtime/10;
    long szmp = runtime%100;
    runtime = runtime/100;
    long mp = runtime%60;
    long perc = runtime/60;
    System.out.println();
    System.out.println("Futasi ido: "+perc+":"+mp+"."+szmp);
    resultString+="\nFutasi ido: "+perc+":"+mp+"."+szmp;
    System.out.println(resultString);
/*    try {
      user.getNewResults().put(this.problemName, resultString);
      this.pluginLogger.info("The server finished computing "+
          user.getUserName()+"'s "+ task+" with GEOMSolver ...");
      NBOServer.log("The server finished computing "+
          user.getUserName()+"'s "+ task+" with GEOMSolver ...", 1);
    } catch(Exception e) {
      this.pluginLogger.warning(e.toString());
      NBOServer.log(e.toString(), 2);
    } finally {
      this.fileHandler.close();
    }*/
  }
TOP

Related Classes of hu.u_szeged.nbo.server.plugins.GEOMSolver

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.