Exemplo n.º 1
0
    void checkThreadInfo(ThreadInfo info) {
      if (!getName().equals(info.getThreadName())) {
        throw new RuntimeException(
            "Name: " + info.getThreadName() + " not matched. Expected: " + getName());
      }

      MonitorInfo[] monitors = info.getLockedMonitors();
      if (monitors.length != OWNED_MONITORS) {
        throw new RuntimeException(
            "Number of locked monitors = "
                + monitors.length
                + " not matched. Expected: "
                + OWNED_MONITORS);
      }
      MonitorInfo m = monitors[0];
      StackTraceElement ste = m.getLockedStackFrame();
      int depth = m.getLockedStackDepth();
      StackTraceElement[] stacktrace = info.getStackTrace();
      if (!ste.equals(stacktrace[depth])) {
        System.out.println("LockedStackFrame:- " + ste);
        System.out.println("StackTrace at " + depth + " :-" + stacktrace[depth]);
        throw new RuntimeException(
            "LockedStackFrame does not match " + "stack frame in ThreadInfo.getStackTrace");
      }

      String className = lock.getClass().getName();
      int hcode = System.identityHashCode(lock);
      if (!className.equals(m.getClassName())
          || hcode != m.getIdentityHashCode()
          || !m.getLockedStackFrame().getMethodName().equals("run")) {
        System.out.println(info);
        throw new RuntimeException("MonitorInfo " + m + " doesn't match.");
      }

      LockInfo[] syncs = info.getLockedSynchronizers();
      if (syncs.length != OWNED_SYNCS) {
        throw new RuntimeException(
            "Number of locked syncs = " + syncs.length + " not matched. Expected: " + OWNED_SYNCS);
      }
      AbstractOwnableSynchronizer s = mutex.getSync();
      String lockName = s.getClass().getName();
      hcode = System.identityHashCode(s);
      if (!lockName.equals(syncs[0].getClassName())) {
        throw new RuntimeException(
            "LockInfo : " + syncs[0] + " class name not matched. Expected: " + lockName);
      }
      if (hcode != syncs[0].getIdentityHashCode()) {
        throw new RuntimeException(
            "LockInfo: " + syncs[0] + " IdentityHashCode not matched. Expected: " + hcode);
      }
      LockInfo li = info.getLockInfo();
      if (li == null) {
        throw new RuntimeException("Expected non-null LockInfo");
      }
    }
  /**
   * Associate the given object with the given key in this <tt>IdentityWeakHashMap</tt>, replacing
   * any existing mapping.
   *
   * @param key key to map to given object.
   * @param obj object to be associated with key.
   * @return the previous object for key or <tt>null</tt> if this <tt>IdentityWeakHashMap</tt> did
   *     not have one.
   * @throws <tt>NullPointerException</tt> if obj is null</tt>.
   */
  public V put(K key, V obj) {
    if (obj == null || key == null) {
      throw new IllegalArgumentException(
          ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap"));
    }
    cleanUp();
    WeakEntry[] copyOfEntries = entries;
    int hash = System.identityHashCode(key);
    int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
    for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) {
      if (e.key.get() == key) {
        EntryReference<V> old = e.value;
        if (key == obj) {
          e.value = e.key;
        } else {
          e.value = new HardEntryReference<V>(obj);
        }
        return old.get();
      }
    }

    modCount++;
    if (count >= threshold) {
      rehash();
      copyOfEntries = entries;
      index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
    }
    WeakEntry<K, V> e = new WeakEntry<K, V>(hash, key, obj, copyOfEntries[index], referenceQueue);
    copyOfEntries[index] = e;
    count++;
    return null;
  }
Exemplo n.º 3
0
 static void precheck(int n, Object[] key, Object[] abs) {
   int ck = 0;
   Map s = newMap();
   for (int i = 0; i < n; i++) {
     Object k = key[i];
     if (k == null) throw new Error("Null key at" + i);
     ck += System.identityHashCode(k);
     Object v = s.put(k, k);
     if (v != null) throw new Error("Duplicate " + k + " / " + v);
   }
   for (int i = 0; i < n; i++) {
     Object k = abs[i];
     if (k == null) throw new Error("Null key at" + i);
     ck += System.identityHashCode(k);
     Object v = s.put(k, k);
     if (v != null) throw new Error("Duplicate " + k + " / " + v);
   }
   checkSum += ck;
 }
 /**
  * Returns the value to which the given key is mapped in this <tt>IdentityWeakHashMap</tt>.
  * Returns <tt>null</tt> if this <tt>IdentityWeakHashMap</tt> contains no mapping for this key.
  *
  * @return the value to which this <tt>IdentityWeakHashMap</tt> maps the given key.
  * @param key key whose associated value is to be returned.
  */
 public V get(Object key) {
   if (key == null) return null;
   cleanUp();
   WeakEntry[] copyOfEntries = entries;
   int hash = System.identityHashCode(key);
   int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
   for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) {
     if (e.key.get() == key) {
       return (V) e.value.get();
     }
   }
   return null;
 }
Exemplo n.º 5
0
 protected Object replaceObject(Object obj) throws IOException {
   if (verbose) {
     System.out.println(
         "##replaceObject("
             + obj.toString()
             + ", System.idHashCode="
             + System.identityHashCode(obj)
             + ")");
   }
   Object subobj = super.replaceObject(obj);
   if (verbose && subobj != obj) {
     System.out.println("##replaced with " + subobj.toString());
   }
   return subobj;
 }
  public synchronized void close() {
    resetPoolManager();
    is_closed = true;

    C3P0Registry.markClosed(this);

    if (Debug.DEBUG && Debug.TRACE == Debug.TRACE_MAX && logger.isLoggable(MLevel.FINEST)) {
      logger.log(
          MLevel.FINEST,
          this.getClass().getName()
              + '@'
              + Integer.toHexString(System.identityHashCode(this))
              + " has been closed. ",
          new Exception("DEBUG STACK TRACE for PoolBackedDataSource.close()."));
    }
  }
 /**
  * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a mapping for the given
  * key. Equality is tested by reference.
  *
  * @param key object to be used as a key into this <tt>IdentityWeakHashMap</tt>.
  * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a mapping for key.
  */
 public boolean containsKey(Object key) {
   if (key == null) {
     throw new IllegalArgumentException(
         ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap"));
   }
   cleanUp();
   WeakEntry[] copyOfEntries = entries;
   int hash = System.identityHashCode(key);
   int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
   for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) {
     if (e.key.get() == key) {
       return true;
     }
   }
   return false;
 }
  @Override
  public String toString() {
    StringBuilder sb;

    sb = new StringBuilder("AgiReply[");
    sb.append("status=").append(getStatus()).append(",");
    if (status == SC_SUCCESS) {
      sb.append("result='").append(getResult()).append("',");
      sb.append("extra='").append(getExtra()).append("',");
      sb.append("attributes=").append(getAttributes()).append(",");
    }
    if (status == SC_INVALID_COMMAND_SYNTAX) {
      sb.append("synopsis='").append(getSynopsis()).append("',");
    }
    sb.append("systemHashcode=").append(System.identityHashCode(this));
    sb.append("]");

    return sb.toString();
  }
 /**
  * Removes the mapping (key and its corresponding value) from this <tt>IdentityWeakHashMap</tt>,
  * if present.
  *
  * @param key key whose mapping is to be removed from the map.
  * @return the previous object for key or <tt>null</tt> if this <tt>IdentityWeakHashMap</tt> did
  *     not have one.
  */
 public V remove(Object key) {
   if (key == null) return null;
   cleanUp();
   WeakEntry[] copyOfEntries = entries;
   int hash = System.identityHashCode(key);
   int index = (hash & 0x7FFFFFFF) % copyOfEntries.length;
   for (WeakEntry e = copyOfEntries[index], prev = null; e != null; prev = e, e = e.next) {
     if (e.key.get() == key) {
       if (prev != null) {
         prev.next = e.next;
       } else {
         copyOfEntries[index] = e.next;
       }
       count--;
       return (V) e.value.get();
     }
   }
   return null;
 }
 @Override
 public String toString() {
   String ret =
       "PartitionRegionConfig@"
           + System.identityHashCode(this)
           + ";prId="
           + this.prId
           + ";fullPath="
           + this.fullPath
           + ";scope="
           + this.scope
           + ";partition attributes="
           + this.pAttrs
           + ";partitionResolver="
           + this.partitionResolver
           + ";colocatedWith="
           + this.colocatedWith
           + ";eviction attributes="
           + this.ea
           + ";regionIdleTimeout= "
           + this.regionIdleTimeout
           + ";regionTimeToLive= "
           + this.regionTimeToLive
           + ";entryIdleTimeout= "
           + this.entryIdleTimeout
           + ";entryTimeToLive= "
           + this.entryTimeToLive
           + "'elderFPAs="******"'gatewaySenderIds="
           + gatewaySenderIds
           + ";nodes=";
   if (this.nodes != null) {
     return ret + nodes;
   } else {
     return ret + "null";
   }
 }
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    SpecialMethod specialMethod = _specialMethods.get(method);

    if (specialMethod != null) {
      switch (specialMethod) {
        case TO_STRING:
          return "PortProxyHandler[]";
        case EQUALS:
          return false;
        case HASH_CODE:
          return System.identityHashCode(this);

        case GET_BINDING:
          return _binding;

        case GET_REQUEST_CONTEXT:
          return _requestContext;

        case GET_RESPONSE_CONTEXT:
          return _responseContext;
      }
    }

    Object url = _requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);

    if (url == null) throw new ProtocolException("No service endpoint address specified");

    if (!(url instanceof String))
      throw new IllegalArgumentException("Invalid service endpoint address specified");

    // XXX cache this and the HandlerChainInvoker
    List<Handler> chain = _binding.getHandlerChain();

    if (chain == null || chain.size() == 0) return _skeleton.invoke(method, (String) url, args);
    else return _skeleton.invoke(method, (String) url, args, new HandlerChainInvoker(chain, this));
  }
Exemplo n.º 12
0
 @Override
 public int compareTo(Object o) {
   // return this.toString().compareTo(o.toString());
   return Integer.valueOf(System.identityHashCode(this)).compareTo(System.identityHashCode(o));
 }
  /** Creates a <code>BridgeServerResponse</code> in response to the given request. */
  static BridgeServerResponse create(DistributionManager dm, BridgeServerRequest request) {
    BridgeServerResponse m = new BridgeServerResponse();
    m.setRecipient(request.getSender());

    try {
      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getInstanceCloseOk(dm.getSystem());

      if (request.getCacheId() != System.identityHashCode(cache)) {
        m.bridgeInfo = null;

      } else {
        int operation = request.getOperation();
        switch (operation) {
          case BridgeServerRequest.ADD_OPERATION:
            {
              BridgeServerImpl bridge = (BridgeServerImpl) cache.addBridgeServer();
              m.bridgeInfo = new RemoteBridgeServer(bridge);
              break;
            }

          case BridgeServerRequest.INFO_OPERATION:
            {
              int id = request.getBridgeId();
              // Note that since this is only an informational request
              // it is not necessary to synchronize on allBridgeServersLock
              for (Iterator iter = cache.getBridgeServers().iterator(); iter.hasNext(); ) {
                BridgeServerImpl bridge = (BridgeServerImpl) iter.next();
                if (System.identityHashCode(bridge) == id) {
                  m.bridgeInfo = new RemoteBridgeServer(bridge);
                  break;

                } else {
                  m.bridgeInfo = null;
                }
              }
              break;
            }

          case BridgeServerRequest.START_OPERATION:
            {
              RemoteBridgeServer config = request.getBridgeInfo();
              for (Iterator iter = cache.getBridgeServers().iterator(); iter.hasNext(); ) {
                BridgeServerImpl bridge = (BridgeServerImpl) iter.next();
                if (System.identityHashCode(bridge) == config.getId()) {
                  bridge.configureFrom(config);
                  bridge.start();
                  m.bridgeInfo = new RemoteBridgeServer(bridge);
                  break;

                } else {
                  m.bridgeInfo = null;
                }
              }
              break;
            }

          case BridgeServerRequest.STOP_OPERATION:
            {
              RemoteBridgeServer config = request.getBridgeInfo();
              for (Iterator iter = cache.getBridgeServers().iterator(); iter.hasNext(); ) {
                BridgeServerImpl bridge = (BridgeServerImpl) iter.next();
                if (System.identityHashCode(bridge) == config.getId()) {
                  bridge.stop();
                  m.bridgeInfo = new RemoteBridgeServer(bridge);
                  break;

                } else {
                  m.bridgeInfo = null;
                }
              }
              break;
            }

          default:
            Assert.assertTrue(false, "Unknown bridge server operation: " + operation);
        }
      }

    } catch (CancelException ex) {
      m.bridgeInfo = null;

    } catch (Exception ex) {
      m.exception = ex;
      m.bridgeInfo = null;
    }
    return m;
  }
Exemplo n.º 14
0
 public int hashCode() {
   return System.identityHashCode(this);
 }