Search in sources :

Example 1 with IJobSerializerDeserializer

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);
    }
}
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 IJobSerializerDeserializer

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));
}
Also used : IJobSerializerDeserializer(org.apache.hyracks.api.job.IJobSerializerDeserializer)

Example 3 with IJobSerializerDeserializer

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();
}
Also used : IJobSerializerDeserializerContainer(org.apache.hyracks.api.job.IJobSerializerDeserializerContainer) IJobSerializerDeserializer(org.apache.hyracks.api.job.IJobSerializerDeserializer)

Example 4 with IJobSerializerDeserializer

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);
    }
}
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)4 IJobSerializerDeserializerContainer (org.apache.hyracks.api.job.IJobSerializerDeserializerContainer)3 IOException (java.io.IOException)2 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)2