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