Exemplo n.º 1
0
  @Override
  public void run() {
    try {
      if (!streamsReady) openStreams();
      while (true) {
        Packet p = new Packet(account, dis);
        parent.processPacket(this, p);
      }
    } catch (SocketTimeoutException ex) {
      Log.print(uid + " (" + account + ") отключился по таймауту.");
    } catch (SocketException ex) {
      if (ex.getMessage().hashCode() == "Connection reset".hashCode()) {
        Log.print(uid + " (" + account + ") отключился.");
      } else {
        Log.error("Страшная хуйня на соединении " + uid + " (" + account + ").", ex);
      }
    } catch (EOFException ex) {
      Log.print(uid + " (" + account + ") отключился.");
    } catch (IOException ex) {
      Log.error("Страшная хуйня на соединении " + uid + " (" + account + ").", ex);
    } finally {
      parent.connections.remove(this);

      try {
        parent.accountDisonnected(account);
      } catch (IOException ex) {
        // Да похуй уже.
      }
    }
  }
Exemplo n.º 2
0
 public Connection(Server parent, /*SSL*/ Socket s) {
   this.parent = parent;
   this.s = s;
   Log.print(
       "Подключение с IP "
           + s.getInetAddress().getHostAddress()
           + ", дан временный номер "
           + account);
 }
Exemplo n.º 3
0
 /**
  * Create a random salt for use in generating hashes
  *
  * @return A strting of UTF-8 encoded random bytes
  * @throws NoSuchAlgorithmException
  */
 private static String getSalt() throws NoSuchAlgorithmException {
   SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
   byte[] salt = new byte[16];
   sr.nextBytes(salt);
   String ret = null;
   try {
     ret = new String(salt, "UTF-8");
   } catch (UnsupportedEncodingException e) {
     Log.print(e);
   }
   return ret;
 }
Exemplo n.º 4
0
 private void loadExclusions() {
   String s = detectInstallDirUrl() + "/p4j-exclusions.txt";
   List<String> exclusions = new ArrayList<String>();
   try {
     URL u = new URL(s);
     Log.print(0, "loading exclusions from " + u);
     BufferedReader r = new BufferedReader(new InputStreamReader(u.openStream()));
     String cn;
     while ((cn = r.readLine()) != null) {
       cn = cn.trim();
       if (cn.startsWith("#") || cn.length() == 0) {
         continue;
       }
       exclusions.add(cn);
       Log.print(0, "exluding class " + cn);
     }
     this.exclusions = (String[]) exclusions.toArray(new String[0]);
   } catch (Exception e) {
     throw new Profiler4JError("Could not load exclusions");
   }
 }
Exemplo n.º 5
0
 public void openStreams() throws IOException {
   if (streamsReady) {
     Log.print(
         "Предупреждение: вызов openStreams() после открытия потоков, соединение "
             + uid
             + " ("
             + account
             + ").");
     return;
   }
   dis = new DataInputStream(s.getInputStream());
   dos = new DataOutputStream(s.getOutputStream());
   s.setSoTimeout(120_000);
   streamsReady = true;
 }
Exemplo n.º 6
0
  /**
   * Prints the job objects
   *
   * @param list list of jobs
   */
  protected static void printJobList(List<Job> list) {
    String indent = "    ";
    Log.printLine();
    Log.printLine("========== OUTPUT ==========");
    Log.printLine(
        "Job ID"
            + indent
            + "Task ID"
            + indent
            + "STATUS"
            + indent
            + "Data center ID"
            + indent
            + "VM ID"
            + indent
            + indent
            + "Time"
            + indent
            + "Start Time"
            + indent
            + "Finish Time"
            + indent
            + "Depth");
    DecimalFormat dft = new DecimalFormat("###.##");
    for (Job job : list) {
      Log.print(indent + job.getCloudletId() + indent + indent);
      if (job.getClassType() == Parameters.ClassType.STAGE_IN.value) {
        Log.print("Stage-in");
      }
      for (Task task : job.getTaskList()) {
        Log.print(task.getCloudletId() + ",");
      }
      Log.print(indent);

      if (job.getCloudletStatus() == Cloudlet.SUCCESS) {
        Log.print("SUCCESS");
        Log.printLine(
            indent
                + indent
                + job.getResourceId()
                + indent
                + indent
                + indent
                + job.getVmId()
                + indent
                + indent
                + indent
                + dft.format(job.getActualCPUTime())
                + indent
                + indent
                + dft.format(job.getExecStartTime())
                + indent
                + indent
                + indent
                + dft.format(job.getFinishTime())
                + indent
                + indent
                + indent
                + job.getDepth());
      } else if (job.getCloudletStatus() == Cloudlet.FAILED) {
        Log.print("FAILED");
        Log.printLine(
            indent
                + indent
                + job.getResourceId()
                + indent
                + indent
                + indent
                + job.getVmId()
                + indent
                + indent
                + indent
                + dft.format(job.getActualCPUTime())
                + indent
                + indent
                + dft.format(job.getExecStartTime())
                + indent
                + indent
                + indent
                + dft.format(job.getFinishTime())
                + indent
                + indent
                + indent
                + job.getDepth());
      }
    }
  }