Search in sources :

Example 41 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class ZookeeperClient method delete.

/**
   * Deletes the given node residing at the given path
   *
   * @param path  target path to delete
   */
public void delete(final String path) {
    Preconditions.checkNotNull(path, "path is required");
    final String target = PathUtils.join(root, path);
    try {
        curator.delete().forPath(target);
        getCache().rebuildNode(target);
    } catch (final Exception e) {
        throw new DrillRuntimeException(String.format("unable to delete node at %s", target), e);
    }
}
Also used : DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) KeeperException(org.apache.zookeeper.KeeperException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) VersionMismatchException(org.apache.drill.exec.exception.VersionMismatchException) NodeExistsException(org.apache.zookeeper.KeeperException.NodeExistsException)

Example 42 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class ClassGenerator method createNestedClass.

/**
   * Creates {@link #innerClassGenerator} with inner class
   * if {@link #hasMaxIndexValue()} returns {@code true}.
   *
   * @return true if splitting happened.
   */
private boolean createNestedClass() {
    if (hasMaxIndexValue()) {
        // all new fields will be declared in the class from innerClassGenerator
        if (innerClassGenerator == null) {
            try {
                JDefinedClass innerClazz = clazz._class(JMod.PRIVATE, clazz.name() + "0");
                innerClassGenerator = new ClassGenerator<>(codeGenerator, mappings, sig, evaluationVisitor, innerClazz, model, optionManager);
            } catch (JClassAlreadyExistsException e) {
                throw new DrillRuntimeException(e);
            }
            oldBlocks = blocks;
            innerClassGenerator.index = index;
            innerClassGenerator.maxIndex += index;
            // blocks from the inner class should be used
            setupInnerClassBlocks();
            return true;
        }
        return innerClassGenerator.createNestedClass();
    }
    return false;
}
Also used : JClassAlreadyExistsException(com.sun.codemodel.JClassAlreadyExistsException) JDefinedClass(com.sun.codemodel.JDefinedClass) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException)

Example 43 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class ZookeeperClient method hasPath.

/**
   * Checks if the given path exists.
   * If the flag consistent is set, the check is consistent as it is made against Zookeeper directly.
   * Otherwise, the check is eventually consistent.
   *
   * If consistency flag is set to true and version holder is not null, passes version holder to get data change version.
   * Data change version is retrieved from {@link Stat} object, it increases each time znode data change is performed.
   * Link to Zookeeper documentation - https://zookeeper.apache.org/doc/r3.2.2/zookeeperProgrammers.html#sc_zkDataModel_znodes
   *
   * @param path path to check
   * @param consistent whether the check should be consistent
   * @param version version holder
   * @return true if path exists, false otherwise
   */
public boolean hasPath(final String path, final boolean consistent, final DataChangeVersion version) {
    Preconditions.checkNotNull(path, "path is required");
    final String target = PathUtils.join(root, path);
    try {
        if (consistent) {
            Stat stat = curator.checkExists().forPath(target);
            if (version != null && stat != null) {
                version.setVersion(stat.getVersion());
            }
            return stat != null;
        } else {
            return getCache().getCurrentData(target) != null;
        }
    } catch (final Exception e) {
        throw new DrillRuntimeException("error while checking path on zookeeper", e);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) KeeperException(org.apache.zookeeper.KeeperException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) VersionMismatchException(org.apache.drill.exec.exception.VersionMismatchException) NodeExistsException(org.apache.zookeeper.KeeperException.NodeExistsException)

Example 44 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class ZookeeperClient method create.

/**
   * Creates the given path without placing any data in.
   *
   * @param path  target path
   */
public void create(final String path) {
    Preconditions.checkNotNull(path, "path is required");
    final String target = PathUtils.join(root, path);
    try {
        curator.create().withMode(mode).forPath(target);
        getCache().rebuildNode(target);
    } catch (final Exception e) {
        throw new DrillRuntimeException("unable to put ", e);
    }
}
Also used : DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) KeeperException(org.apache.zookeeper.KeeperException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) VersionMismatchException(org.apache.drill.exec.exception.VersionMismatchException) NodeExistsException(org.apache.zookeeper.KeeperException.NodeExistsException)

Example 45 with DrillRuntimeException

use of org.apache.drill.common.exceptions.DrillRuntimeException in project drill by apache.

the class DrillFuncHolder method declareWorkspaceVariables.

protected JVar[] declareWorkspaceVariables(ClassGenerator<?> g) {
    JVar[] workspaceJVars = new JVar[attributes.getWorkspaceVars().length];
    for (int i = 0; i < attributes.getWorkspaceVars().length; i++) {
        WorkspaceReference ref = attributes.getWorkspaceVars()[i];
        JType jtype = g.getModel()._ref(ref.getType());
        if (ScalarReplacementTypes.CLASSES.contains(ref.getType())) {
            workspaceJVars[i] = g.declareClassField("work", jtype);
            JBlock b = g.getBlock(SignatureHolder.DRILL_INIT_METHOD);
            b.assign(workspaceJVars[i], JExpr._new(jtype));
        } else {
            workspaceJVars[i] = g.declareClassField("work", jtype);
        }
        if (ref.isInject()) {
            if (UdfUtilities.INJECTABLE_GETTER_METHODS.get(ref.getType()) != null) {
                g.getBlock(BlockType.SETUP).assign(workspaceJVars[i], g.getMappingSet().getIncoming().invoke("getContext").invoke(UdfUtilities.INJECTABLE_GETTER_METHODS.get(ref.getType())));
            } else {
                // Invalid injectable type provided, this should have been caught in FunctionConverter
                throw new DrillRuntimeException("Invalid injectable type requested in UDF: " + ref.getType().getSimpleName());
            }
        } else {
        //g.getBlock(BlockType.SETUP).assign(workspaceJVars[i], JExpr._new(jtype));
        }
    }
    return workspaceJVars;
}
Also used : JBlock(com.sun.codemodel.JBlock) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) JType(com.sun.codemodel.JType) JVar(com.sun.codemodel.JVar)

Aggregations

DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)69 IOException (java.io.IOException)32 VersionMismatchException (org.apache.drill.exec.exception.VersionMismatchException)9 Stopwatch (com.google.common.base.Stopwatch)7 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)7 UserException (org.apache.drill.common.exceptions.UserException)6 KeeperException (org.apache.zookeeper.KeeperException)6 NodeExistsException (org.apache.zookeeper.KeeperException.NodeExistsException)6 NoSuchElementException (java.util.NoSuchElementException)5 Path (org.apache.hadoop.fs.Path)5 Bson (org.bson.conversions.Bson)4 Registry (org.apache.drill.exec.proto.UserBitShared.Registry)3 ValueVector (org.apache.drill.exec.vector.ValueVector)3 Admin (org.apache.hadoop.hbase.client.Admin)3 Document (org.bson.Document)3 File (java.io.File)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URI (java.net.URI)2 RexNode (org.apache.calcite.rex.RexNode)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2