Search in sources :

Example 1 with IJobSerializerDeserializerContainer

use of org.apache.hyracks.api.job.IJobSerializerDeserializerContainer in project asterixdb by apache.

the class DeploymentUtils method deserialize.

/**
     * Deserialize bytes to an object according to a specific deployment
     *
     * @param bytes
     *            the bytes to be deserialized
     * @param deploymentId
     *            the deployment id
     * @param serviceCtx
     * @return the deserialized object
     * @throws HyracksException
     */
public static Object deserialize(byte[] bytes, DeploymentId deploymentId, IServiceContext serviceCtx) throws HyracksException {
    try {
        IJobSerializerDeserializerContainer jobSerDeContainer = serviceCtx.getJobSerializerDeserializerContainer();
        IJobSerializerDeserializer jobSerDe = deploymentId == null ? null : jobSerDeContainer.getJobSerializerDeserializer(deploymentId);
        return jobSerDe == null ? JavaSerializationUtils.deserialize(bytes) : jobSerDe.deserialize(bytes);
    } catch (Exception e) {
        throw new HyracksException(e);
    }
}
Also used : HyracksException(org.apache.hyracks.api.exceptions.HyracksException) IJobSerializerDeserializerContainer(org.apache.hyracks.api.job.IJobSerializerDeserializerContainer) IJobSerializerDeserializer(org.apache.hyracks.api.job.IJobSerializerDeserializer) IOException(java.io.IOException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Example 2 with IJobSerializerDeserializerContainer

use of org.apache.hyracks.api.job.IJobSerializerDeserializerContainer in project asterixdb by apache.

the class DeploymentUtils method getClassLoader.

/**
     * Get the classloader of a specific deployment
     *
     * @param deploymentId
     * @param appCtx
     * @return
     * @throws HyracksException
     */
public static ClassLoader getClassLoader(DeploymentId deploymentId, IServiceContext appCtx) throws HyracksException {
    IJobSerializerDeserializerContainer jobSerDeContainer = appCtx.getJobSerializerDeserializerContainer();
    IJobSerializerDeserializer jobSerDe = deploymentId == null ? null : jobSerDeContainer.getJobSerializerDeserializer(deploymentId);
    return jobSerDe == null ? DeploymentUtils.class.getClassLoader() : jobSerDe.getClassLoader();
}
Also used : IJobSerializerDeserializerContainer(org.apache.hyracks.api.job.IJobSerializerDeserializerContainer) IJobSerializerDeserializer(org.apache.hyracks.api.job.IJobSerializerDeserializer)

Example 3 with IJobSerializerDeserializerContainer

use of org.apache.hyracks.api.job.IJobSerializerDeserializerContainer in project asterixdb by apache.

the class DeploymentUtils method loadClass.

/**
     * Load a class from its class name
     *
     * @param className
     * @param deploymentId
     * @param serviceCtx
     * @return the loaded class
     * @throws HyracksException
     */
public static Class<?> loadClass(String className, DeploymentId deploymentId, IServiceContext serviceCtx) throws HyracksException {
    try {
        IJobSerializerDeserializerContainer jobSerDeContainer = serviceCtx.getJobSerializerDeserializerContainer();
        IJobSerializerDeserializer jobSerDe = deploymentId == null ? null : jobSerDeContainer.getJobSerializerDeserializer(deploymentId);
        return jobSerDe == null ? JavaSerializationUtils.loadClass(className) : jobSerDe.loadClass(className);
    } catch (ClassNotFoundException | IOException e) {
        throw new HyracksException(e);
    }
}
Also used : HyracksException(org.apache.hyracks.api.exceptions.HyracksException) IOException(java.io.IOException) IJobSerializerDeserializerContainer(org.apache.hyracks.api.job.IJobSerializerDeserializerContainer) IJobSerializerDeserializer(org.apache.hyracks.api.job.IJobSerializerDeserializer)

Aggregations

IJobSerializerDeserializer (org.apache.hyracks.api.job.IJobSerializerDeserializer)3 IJobSerializerDeserializerContainer (org.apache.hyracks.api.job.IJobSerializerDeserializerContainer)3 IOException (java.io.IOException)2 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)2