Search in sources :

Example 1 with Relocator

use of org.apache.storm.hack.relocation.Relocator in project storm by apache.

the class DefaultShader method addJavaSource.

private void addJavaSource(Set<String> resources, JarOutputStream jos, String name, InputStream is, List<Relocator> relocators) throws IOException {
    jos.putNextEntry(new JarEntry(name));
    String sourceContent = IOUtil.toString(new InputStreamReader(is, "UTF-8"));
    for (Relocator relocator : relocators) {
        sourceContent = relocator.applyToSourceContent(sourceContent);
    }
    OutputStreamWriter writer = new OutputStreamWriter(jos, "UTF-8");
    writer.append(sourceContent);
    writer.flush();
    resources.add(name);
}
Also used : JarEntry(java.util.jar.JarEntry) Relocator(org.apache.storm.hack.relocation.Relocator)

Example 2 with Relocator

use of org.apache.storm.hack.relocation.Relocator in project storm by apache.

the class StormShadeRequest method makeRequest.

public static ShadeRequest makeRequest() {
    ShadeRequest request = new ShadeRequest();
    request.setRelocators(Arrays.asList((Relocator) new SimpleRelocator("backtype.storm", "org.apache.storm"), (Relocator) new SimpleRelocator("storm.trident", "org.apache.storm.trident"), (Relocator) new SimpleRelocator("org.apache.thrift7", "org.apache.storm.thrift")));
    request.setResourceTransformers(Arrays.asList((ResourceTransformer) new ClojureTransformer()));
    return request;
}
Also used : SimpleRelocator(org.apache.storm.hack.relocation.SimpleRelocator) ResourceTransformer(org.apache.storm.hack.resource.ResourceTransformer) Relocator(org.apache.storm.hack.relocation.Relocator) SimpleRelocator(org.apache.storm.hack.relocation.SimpleRelocator) ClojureTransformer(org.apache.storm.hack.resource.ClojureTransformer)

Example 3 with Relocator

use of org.apache.storm.hack.relocation.Relocator in project storm by apache.

the class ClojureTransformer method processResource.

@Override
public void processResource(String s, InputStream inputStream, List<Relocator> relocators) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int b;
    while ((b = inputStream.read()) != -1) {
        out.write(b);
    }
    String data = out.toString();
    for (Relocator rel : relocators) {
        data = rel.applyToSourceContent(data);
    }
    this.entries.put(s, data);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) Relocator(org.apache.storm.hack.relocation.Relocator)

Aggregations

Relocator (org.apache.storm.hack.relocation.Relocator)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 JarEntry (java.util.jar.JarEntry)1 SimpleRelocator (org.apache.storm.hack.relocation.SimpleRelocator)1 ClojureTransformer (org.apache.storm.hack.resource.ClojureTransformer)1 ResourceTransformer (org.apache.storm.hack.resource.ResourceTransformer)1