Search in sources :

Example 1 with TransferObjectRequest

use of es.bsc.compss.types.request.ap.TransferObjectRequest in project compss by bsc-wdc.

the class AccessProcessor method obtainObject.

/**
 * Adds a request to obtain an object from a worker to the master
 *
 * @param oaId
 * @return
 */
private Object obtainObject(DataAccessId oaId) {
    LOGGER.debug("Obtain object with id " + oaId);
    // Ask for the object
    Semaphore sem = new Semaphore(0);
    TransferObjectRequest tor = new TransferObjectRequest(oaId, sem);
    if (!requestQueue.offer(tor)) {
        ErrorManager.error(ERROR_QUEUE_OFFER + "obtain object");
    }
    // Wait for response
    sem.acquireUninterruptibly();
    // Get response
    Object oUpdated = tor.getResponse();
    if (oUpdated == null) {
        /*
             * The Object didn't come from a WS but was transferred from a worker, we load it from its storage (file or
             * persistent)
             */
        LogicalData ld = tor.getLogicalDataTarget();
        try {
            ld.loadFromStorage();
            oUpdated = ld.getValue();
        } catch (CannotLoadException e) {
            LOGGER.fatal(ERROR_OBJECT_LOAD_FROM_STORAGE + ": " + ((ld == null) ? "null" : ld.getName()), e);
            ErrorManager.fatal(ERROR_OBJECT_LOAD_FROM_STORAGE + ": " + ((ld == null) ? "null" : ld.getName()), e);
        }
    }
    return oUpdated;
}
Also used : TransferObjectRequest(es.bsc.compss.types.request.ap.TransferObjectRequest) LogicalData(es.bsc.compss.types.data.LogicalData) CannotLoadException(es.bsc.compss.exceptions.CannotLoadException) Semaphore(java.util.concurrent.Semaphore)

Aggregations

CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 TransferObjectRequest (es.bsc.compss.types.request.ap.TransferObjectRequest)1 Semaphore (java.util.concurrent.Semaphore)1