예제 #1
0
    public void updateJitter(long completion_time, long computation_time, long arrival_time) {

      latency = (double) (completion_time) - (double) (computation_time) - (double) (arrival_time);
      latency = latency > 0 ? latency : 0;

      sample_count = sample_count + 1.0;
      avg_latency = (avg_latency * (sample_count - 1.0) + latency) / (sample_count);

      double jitter_ = (double) Math.abs(latency - avg_latency);

      setChanged();
      Double temp_ = new Double(jitter_);
      notifyObservers(temp_);
    }
예제 #2
0
  public synchronized org.omg.CORBA.Object open(String name) {
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object) _registry.get(name);
    if (obj == null) {
      try {
        System.out.println("simulate the delay while creating the new account");
        Thread.currentThread().sleep(1200);
        float balance = new Float(Math.abs(_random.nextInt()) % 100000 / 100f).floatValue();
        AccountImpl account = new AccountImpl(balance, orb, name);
        byte[] accountId = name.getBytes();
        obj = _default_POA().servant_to_reference(account);
        System.out.println("Created " + name + "'s account: " + balance);
        _registry.put(name, obj); // registra l'account come esistente nella tabella
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else System.out.println("Esiste già un account con il nome " + name);

    return obj; // Return object reference
  }