use of org.apache.hyracks.api.job.IJobSerializerDeserializer 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.IJobSerializerDeserializer in project asterixdb by apache.
the class DeploymentUtils method deploy.
/**
* Deploying jars in NC or CC
*
* @param deploymentId
* the deployment id
* @param urls
* the jar URLs
* @param container
* the container of serailizer/deserializer
* @param ctx
* the ServerContext
* @param isNC
* true is NC/false is CC
* @throws HyracksException
*/
public static void deploy(DeploymentId deploymentId, List<URL> urls, IJobSerializerDeserializerContainer container, ServerContext ctx, boolean isNC) throws HyracksException {
IJobSerializerDeserializer jobSerDe = container.getJobSerializerDeserializer(deploymentId);
if (jobSerDe == null) {
jobSerDe = new ClassLoaderJobSerializerDeserializer();
container.addJobSerializerDeserializer(deploymentId, jobSerDe);
}
String rootDir = ctx.getBaseDir().toString();
String deploymentDir = rootDir.endsWith(File.separator) ? rootDir + DEPLOYMENT + File.separator + deploymentId : rootDir + File.separator + DEPLOYMENT + File.separator + deploymentId;
jobSerDe.addClassPathURLs(downloadURLs(urls, deploymentDir, isNC));
}
use of org.apache.hyracks.api.job.IJobSerializerDeserializer 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.IJobSerializerDeserializer 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