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);
}
}
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();
}
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);
}
}
Aggregations