/** * Returns the default filter that should applies to all program type. By default * all hadoop classes and cdap-api classes (and dependencies) are allowed. */ public static Filter defaultFilter() { final Set<String> visibleResources = ProgramResources.getVisibleResources(); final Set<String> visiblePackages = new HashSet<>(); for (String resource : visibleResources) { if (resource.endsWith(".class")) { int idx = resource.lastIndexOf('/'); // Ignore empty package if (idx > 0) { visiblePackages.add(resource.substring(0, idx).replace('/', '.')); } } } return new Filter() { @Override public boolean acceptResource(String resource) { return visibleResources.contains(resource); } @Override public boolean acceptPackage(String packageName) { return visiblePackages.contains(packageName); } }; }
/** * Returns the default filter that should applies to all program type. By default * all hadoop classes and cdap-api classes (and dependencies) are allowed. */ public static Filter defaultFilter() { final Set<String> visibleResources = ProgramResources.getVisibleResources(); final Set<String> visiblePackages = new HashSet<>(); for (String resource : visibleResources) { if (resource.endsWith(".class")) { int idx = resource.lastIndexOf('/'); // Ignore empty package if (idx > 0) { visiblePackages.add(resource.substring(0, idx).replace('/', '.')); } } } return new Filter() { @Override public boolean acceptResource(String resource) { return visibleResources.contains(resource); } @Override public boolean acceptPackage(String packageName) { return visiblePackages.contains(packageName); } }; }
public static Location createDeploymentJar(LocationFactory locationFactory, Class<?> clz, Manifest manifest, File... bundleEmbeddedJars) throws IOException { return createDeploymentJar(locationFactory, clz, manifest, new ClassAcceptor() { final Set<String> visibleResources = ProgramResources.getVisibleResources(); @Override public boolean accept(String className, URL classUrl, URL classPathUrl) { if (visibleResources.contains(className.replace('.', '/') + ".class")) { return false; } // TODO: Fix it with CDAP-5800 if (className.startsWith("org.apache.spark.")) { return false; } return true; } }, bundleEmbeddedJars); }
public static Location createDeploymentJar(LocationFactory locationFactory, Class<?> clz, File... bundleEmbeddedJars) throws IOException { return AppJarHelper.createDeploymentJar(locationFactory, clz, new Manifest(), new ClassAcceptor() { final Set<String> visibleResources = ProgramResources.getVisibleResources(); @Override public boolean accept(String className, URL classUrl, URL classPathUrl) { if (visibleResources.contains(className.replace('.', '/') + ".class")) { return false; } // TODO: Fix it with CDAP-5800 if (className.startsWith("org.apache.spark.")) { return false; } // exclude a necessary dependency if (className.startsWith("com.google.")) { return false; } return true; } }, bundleEmbeddedJars); }