Search in sources :

Example 1 with SerializedObjectException

use of es.bsc.compss.nio.exceptions.SerializedObjectException in project compss by bsc-wdc.

the class Invoker method processParameter.

private void processParameter(NIOParam np, int i) throws JobExecutionException {
    // We need to use wrapper classes for basic types, reflection will unwrap automatically
    this.streams[i] = np.getStream();
    this.prefixes[i] = np.getPrefix();
    switch(np.getType()) {
        case BOOLEAN_T:
            this.types[i] = boolean.class;
            this.values[i] = np.getValue();
            break;
        case CHAR_T:
            this.types[i] = char.class;
            this.values[i] = np.getValue();
            break;
        case BYTE_T:
            this.types[i] = byte.class;
            this.values[i] = np.getValue();
            break;
        case SHORT_T:
            this.types[i] = short.class;
            this.values[i] = np.getValue();
            break;
        case INT_T:
            this.types[i] = int.class;
            this.values[i] = np.getValue();
            break;
        case LONG_T:
            this.types[i] = long.class;
            this.values[i] = np.getValue();
            break;
        case FLOAT_T:
            this.types[i] = float.class;
            this.values[i] = np.getValue();
            break;
        case DOUBLE_T:
            this.types[i] = double.class;
            this.values[i] = np.getValue();
            break;
        case STRING_T:
            this.types[i] = String.class;
            this.values[i] = np.getValue();
            break;
        case FILE_T:
            this.types[i] = String.class;
            this.values[i] = np.getOriginalName();
            this.writeFinalValue[i] = np.isWriteFinalValue();
            break;
        case OBJECT_T:
            this.renamings[i] = np.getValue().toString();
            this.writeFinalValue[i] = np.isWriteFinalValue();
            // Get object
            Object obj;
            try {
                obj = this.nw.getObject(this.renamings[i]);
            } catch (SerializedObjectException soe) {
                throw new JobExecutionException(ERROR_SERIALIZED_OBJ, soe);
            }
            // Check if object is null
            if (obj == null) {
                // This happens when 2 tasks have an INOUT PSCO that is persisted within the 1st task
                try {
                    obj = this.nw.getPersistentObject(renamings[i]);
                } catch (StorageException se) {
                    throw new JobExecutionException(ERROR_SERIALIZED_OBJ, se);
                }
            }
            // Check if object is still null
            if (obj == null) {
                StringBuilder sb = new StringBuilder();
                if (this.hasTarget && i == this.numParams - 1) {
                    sb.append("Target object");
                } else {
                    sb.append("Object parameter ").append(i);
                }
                sb.append(" with renaming ").append(this.renamings[i]);
                sb.append(" in MethodDefinition ").append(this.impl.getMethodDefinition());
                sb.append(" is null!").append("\n");
                throw new JobExecutionException(sb.toString());
            }
            // Store information as target or as normal parameter
            if (this.hasTarget && i == this.numParams - 1) {
                // Last parameter is the target object
                this.target.setValue(obj);
            } else {
                // Any other parameter
                this.types[i] = obj.getClass();
                this.values[i] = obj;
            }
            break;
        case PSCO_T:
            this.renamings[i] = np.getValue().toString();
            this.writeFinalValue[i] = np.isWriteFinalValue();
            // Get ID
            String id = this.renamings[i];
            // Get Object
            try {
                obj = this.nw.getPersistentObject(id);
            } catch (StorageException e) {
                throw new JobExecutionException(ERROR_PERSISTENT_OBJ + " with id " + id, e);
            }
            // Check if object is null
            if (obj == null) {
                StringBuilder sb = new StringBuilder();
                if (this.hasTarget && i == this.numParams - 1) {
                    sb.append("Target PSCO");
                } else {
                    sb.append("PSCO parameter ").append(i);
                }
                sb.append(" with renaming ").append(this.renamings[i]);
                sb.append(" in MethodDefinition ").append(this.impl.getMethodDefinition());
                sb.append(" is null!").append("\n");
                throw new JobExecutionException(sb.toString());
            }
            // Store information as target or as normal parameter
            if (this.hasTarget && i == this.numParams - 1) {
                // Last parameter is the target object
                this.target.setValue(obj);
            } else {
                // Any other parameter
                this.types[i] = obj.getClass();
                this.values[i] = obj;
            }
            break;
        case EXTERNAL_OBJECT_T:
            this.types[i] = String.class;
            this.values[i] = np.getValue();
            this.writeFinalValue[i] = np.isWriteFinalValue();
            break;
    }
    this.isFile[i] = (np.getType().equals(DataType.FILE_T));
    this.canBePSCO[i] = (np.getType().equals(DataType.OBJECT_T)) || (np.getType().equals(DataType.PSCO_T));
}
Also used : JobExecutionException(es.bsc.compss.nio.exceptions.JobExecutionException) SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException) StorageException(storage.StorageException)

Example 2 with SerializedObjectException

use of es.bsc.compss.nio.exceptions.SerializedObjectException in project compss by bsc-wdc.

the class NIOAgent method sendData.

/**
 * Reply the data
 *
 * @param c
 * @param d
 * @param receiverID
 */
public void sendData(Connection c, Data d, int receiverID) {
    if (NIOTracer.isActivated()) {
        int tag = abs(d.getName().hashCode());
        CommandTracingID cmd = new CommandTracingID(tracingID, tag);
        c.sendCommand(cmd);
        NIOTracer.emitDataTransferEvent(d.getName());
        NIOTracer.emitCommEvent(true, receiverID, tag);
    }
    String path = d.getFirstURI().getPath();
    if (path.startsWith(File.separator)) {
        File f = new File(path);
        LOGGER.debug("INSIDE SENDATA");
        if (f.exists()) {
            LOGGER.debug("Connection " + c.hashCode() + " will transfer file " + path + " as data " + d.getName());
            c.sendDataFile(path);
        } else {
            ErrorManager.warn("Can't send file '" + path + "' via connection " + c.hashCode() + " because file doesn't exist.");
            handleDataToSendNotAvailable(c, d);
        }
    } else {
        try {
            Object o = getObject(path);
            LOGGER.debug("Connection " + c.hashCode() + " will transfer an object as data " + d.getName());
            c.sendDataObject(o);
        } catch (SerializedObjectException soe) {
            // Exception has been raised because object has been serialized
            String newLocation = getObjectAsFile(path);
            LOGGER.debug("Connection " + c.hashCode() + " will transfer an object-file " + newLocation + " as data " + d.getName());
            c.sendDataFile(newLocation);
        }
    }
    if (NIOTracer.isActivated()) {
        NIOTracer.emitDataTransferEvent(NIOTracer.TRANSFER_END);
    }
    c.finishConnection();
}
Also used : SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException) CommandTracingID(es.bsc.compss.nio.commands.CommandTracingID) File(java.io.File)

Example 3 with SerializedObjectException

use of es.bsc.compss.nio.exceptions.SerializedObjectException in project compss by bsc-wdc.

the class NIOAdaptor method getObject.

@Override
public Object getObject(String name) throws SerializedObjectException {
    LogicalData ld = Comm.getData(name);
    Object o = ld.getValue();
    // Check if the object has been serialized meanwhile
    if (o == null) {
        for (MultiURI loc : ld.getURIs()) {
            if (!loc.getProtocol().equals(Protocol.OBJECT_URI) && loc.getHost().equals(Comm.getAppHost())) {
                // The object is null because it has been serialized by the master, raise exception
                throw new SerializedObjectException(name);
            }
        }
    }
    // 2- The object is really null (no exception thrown)
    return o;
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) MultiURI(es.bsc.compss.types.uri.MultiURI) SerializedObjectException(es.bsc.compss.nio.exceptions.SerializedObjectException)

Aggregations

SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)3 CommandTracingID (es.bsc.compss.nio.commands.CommandTracingID)1 JobExecutionException (es.bsc.compss.nio.exceptions.JobExecutionException)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 MultiURI (es.bsc.compss.types.uri.MultiURI)1 File (java.io.File)1 StorageException (storage.StorageException)1