public synchronized String getNewUUID() {
   UID uid = new UID();
   String s = "";
   if (_address != null) {
     byte[] b = _address.getAddress();
     for (int i = 0; i < b.length; i++) s += (new Byte(b[i])).longValue() + "-";
   }
   s += uid.toString();
   cat.debug("new UUID: " + s);
   return s;
 }
Esempio n. 2
0
 /**
  * Compares two activation ids for content equality. Returns true if both of the following
  * conditions are true: 1) the unique identifiers equivalent (by content), and 2) the activator
  * specified in each identifier refers to the same remote object.
  *
  * @param obj the Object to compare with
  * @return true if these Objects are equal; false otherwise.
  * @see java.util.Hashtable
  * @since 1.2
  */
 public boolean equals(Object obj) {
   if (obj instanceof ActivationID) {
     ActivationID id = (ActivationID) obj;
     return (uid.equals(id.uid) && activator.equals(id.activator));
   } else {
     return false;
   }
 }
Esempio n. 3
0
 /** Return string representation of this VMID. */
 public String toString() {
   StringBuffer result = new StringBuffer();
   if (addr != null)
     for (int i = 0; i < addr.length; ++i) {
       int x = (int) (addr[i] & 0xFF);
       result.append((x < 0x10 ? "0" : "") + Integer.toString(x, 16));
     }
   result.append(':');
   result.append(uid.toString());
   return result.toString();
 }
Esempio n. 4
0
 /** Compare this VMID to another, and return true if they are the same identifier. */
 public boolean equals(Object obj) {
   if (obj instanceof VMID) {
     VMID vmid = (VMID) obj;
     if (!uid.equals(vmid.uid)) return false;
     if ((addr == null) ^ (vmid.addr == null)) return false;
     if (addr != null) {
       if (addr.length != vmid.addr.length) return false;
       for (int i = 0; i < addr.length; ++i) if (addr[i] != vmid.addr[i]) return false;
     }
     return true;
   } else {
     return false;
   }
 }
Esempio n. 5
0
  public void executeCall() throws Exception {
    byte returncode;
    ObjectInput oin;

    // signal the call when constructing
    try {
      DataOutputStream dout = conn.getDataOutputStream();
      dout.write(MESSAGE_CALL);

      oout = conn.startObjectOutputStream(); // (re)start ObjectOutputStream
      objid.write(oout);
      oout.writeInt(opnum);
      oout.writeLong(hash);
    } catch (IOException ex) {
      throw new MarshalException("Try to write header but failed.", ex);
    }

    try {
      releaseOutputStream();
      DataInputStream din = conn.getDataInputStream();
      if (din.readByte() != MESSAGE_CALL_ACK) throw new RemoteException("Call not acked");

      oin = startInputStream();
      returncode = oin.readByte();
      UID.read(oin);
    } catch (IOException ex) {
      throw new UnmarshalException("Try to read header but failed:", ex);
    }

    // check return code
    switch (returncode) {
      case RETURN_ACK: // it's ok
        return;
      case RETURN_NACK:
        Object returnobj;
        try {
          returnobj = oin.readObject();
        } catch (Exception ex2) {
          throw new UnmarshalException("Try to read exception object but failed", ex2);
        }

        if (!(returnobj instanceof Exception))
          throw new UnmarshalException("Should be Exception type here: " + returnobj);
        throw (Exception) returnobj;

      default:
        throw new UnmarshalException("Invalid return code");
    }
  }
  @Override
  public JsonObject changeFilterState(JsonObject newFilterState) {
    if (newFilterState != null) {

      // new value of amount
      JsonObject amountJson = newFilterState.getJsonObject("amount");
      setAmount((float) amountJson.getJsonNumber("value").doubleValue());

      JsonObject sizeJson = newFilterState.getJsonObject("radius");
      setRadius(sizeJson.getJsonNumber("value").intValue());

      JsonObject thresholdJson = newFilterState.getJsonObject("threshold");
      setThreshold(thresholdJson.getJsonNumber("value").intValue());

      Main.debug(id.toString() + " \n" + toString());

      return newFilterState;
    }

    return null;
  }
  /**
   * Opens a connection to the given Endpoint and writes DGC ack there.
   *
   * @param uid UID to be send
   */
  public void sendDGCAck(UID uid) {
    ClientConnection conn = null;

    try {
      conn = ClientConnectionManager.getConnection(ep);
      DataOutputStream dout = new DataOutputStream(out);
      dout.writeByte(RMIProtocolConstants.DGCACK_MSG);
      uid.write(dout);
      dout.flush();
      conn.releaseOutputStream();
      conn.done();
    } catch (IOException ioe) {
      if (conn != null) {
        conn.close();
      }
    }

    if (dgcLog.isLoggable(RMILog.VERBOSE)) {
      // rmi.log.93=Sent DGC ack to {0} for {1}
      dgcLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.93", ep, uid)); // $NON-NLS-1$
    }
  }
Esempio n. 8
0
 /** Compute hash code for this VMID. */
 public int hashCode() {
   return uid.hashCode();
 }
Esempio n. 9
0
 void writeID() throws IOException {
   assert resultStream;
   ackID.write(this);
 }