use of com.hortonworks.streamline.streams.catalog.UDF in project streamline by hortonworks.
the class StormTopologyDependenciesHandler method visit.
@Override
public void visit(RulesProcessor rulesProcessor) {
Set<UDF> udfsToShip = new HashSet<>();
for (Rule rule : rulesProcessor.getRules()) {
for (Udf udf : rule.getReferredUdfs()) {
List<QueryParam> qps = QueryParam.params(UDF.NAME, udf.getName());
// The null check for backward compatibility
if (udf.getClassName() != null) {
qps.add(new QueryParam(UDF.CLASSNAME, udf.getClassName()));
}
// The null check for backward compatibility
if (udf.getType() != null) {
qps.add(new QueryParam(UDF.TYPE, udf.getType().toString()));
}
Collection<UDF> udfs = catalogService.listUDFs(qps);
if (udfs.size() > 1) {
throw new IllegalStateException("Multiple UDF definitions for :" + udf);
} else if (udfs.size() == 1) {
udfsToShip.add(udfs.iterator().next());
} else {
throw new IllegalStateException("No catalog entity for udf: '" + udf + "'. " + "May be the UDF information is not bootstrapped or got deleted.");
}
}
for (UDF udf : udfsToShip) {
extraJars.add(udf.getJarStoragePath());
}
}
resourceNames.addAll(rulesProcessor.getExtraResources());
handleBundleForStreamlineComponent(rulesProcessor);
}
use of com.hortonworks.streamline.streams.catalog.UDF in project streamline by hortonworks.
the class UDFCatalogResourceTest method newTestUDF.
private UDF newTestUDF(String fnName, String className) {
// provide the same info the user would give the UI for a UDF upload
UDF udf = new UDF();
udf.setName(fnName);
udf.setDisplayName(fnName);
udf.setDescription("Test Function named " + fnName);
udf.setType(FUNCTION);
udf.setClassName(className);
udf.setJarStoragePath(CUSTOM_UDF_MICROTEST_PATH + File.separator + MICROTEST_JAR_NAME);
udf.setBuiltin(false);
return udf;
}
use of com.hortonworks.streamline.streams.catalog.UDF in project streamline by hortonworks.
the class UDFCatalogResourceTest method testProcessUdfWithSimpleClass.
@Test
public void testProcessUdfWithSimpleClass() throws Exception {
String fnName = "FooTriMultiplierUDF";
String className = getFullClassName(fnName);
UDF udf = newTestUDF(fnName, className);
InputStream inputStream = new FileInputStream(udf.getJarStoragePath());
catalogResource.processUdf(inputStream, udf, true, false);
}
use of com.hortonworks.streamline.streams.catalog.UDF in project streamline by hortonworks.
the class UDFCatalogResourceTest method testProcessUdfWithInnerClassFqdnName.
@Test
public void testProcessUdfWithInnerClassFqdnName() throws Exception {
String fnName = "FooPredicateGTZ";
String fqdnName = "FooInnerclassTestUDFs$FooPredicateGTZ";
String canonicalName = "FooInnerclassTestUDFs.FooPredicateGTZ.FooAdder";
String className = getFullClassName(fqdnName);
UDF udf = newTestUDF(fnName, className);
InputStream inputStream = new FileInputStream(udf.getJarStoragePath());
catalogResource.processUdf(inputStream, udf, true, false);
Assert.assertEquals(getFullClassName(fqdnName), udf.getClassName());
}
use of com.hortonworks.streamline.streams.catalog.UDF in project streamline by hortonworks.
the class UDFCatalogResourceTest method testProcessUdfWithInnerClassCanonicalName.
@Test
public void testProcessUdfWithInnerClassCanonicalName() throws Exception {
String fnName = "FooAdder";
String fqdnName = "FooInnerclassTestUDFs$FooAdder";
String canonicalName = "FooInnerclassTestUDFs.FooAdder";
String className = getFullClassName(canonicalName);
UDF udf = newTestUDF(fnName, className);
InputStream inputStream = new FileInputStream(udf.getJarStoragePath());
catalogResource.processUdf(inputStream, udf, true, false);
Assert.assertEquals(getFullClassName(fqdnName), udf.getClassName());
}
Aggregations