Example usage for java.util.concurrent BlockingQueue hashCode

List of usage examples for java.util.concurrent BlockingQueue hashCode

Introduction

In this page you can find the example usage for java.util.concurrent BlockingQueue hashCode.

Prototype

int hashCode();

Source Link

Document

Returns the hash code value for this collection.

Usage

From source file:gridool.deployment.PeerClassLoader.java

@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
    BlockingQueue<GridTaskResult> resultQueue = new SynchronousQueue<GridTaskResult>();
    String jobId = "p2p-classloading_" + resultQueue.hashCode();
    responseQueue.addResponseQueue(jobId, resultQueue);

    if (LOG.isInfoEnabled()) {
        LOG.info("Loading a class '" + name + "' from " + remoteNode);
    }/*from   w  w w .j av  a 2 s.co m*/

    GridNode localNode = communicator.getLocalNode();
    final GridGetClassTask task = new GridGetClassTask(jobId, localNode, name);
    try {// send a class-loading request
        communicator.sendTaskRequest(task, remoteNode);
    } catch (GridException e) {
        throw new ClassNotFoundException("Failed sending a GridGetClassTask of the class: " + name, e);
    }

    // Receive a requested class
    final GridTaskResult result;
    try {
        result = resultQueue.take(); // TODO timeout
    } catch (InterruptedException e) {
        throw new ClassNotFoundException("An error caused while receiving a class: " + name, e);
    }
    final ClassData clazz = result.getResult();
    assert (clazz != null);
    byte[] clazzData = clazz.getClassData();
    long ts = clazz.getTimestamp();
    final Class<?> definedClazz = parentLdr.defineClassIfNeeded(name, clazzData, ts);

    // define enclosing classes
    ClassData enclosingClass = clazz.getEnclosingClass();
    while (enclosingClass != null) {
        defineClass(enclosingClass, parentLdr);
        enclosingClass = enclosingClass.getEnclosingClass();
    }

    return definedClazz;
}