/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.europeana.cloud.service.dps.xslt.kafka.topologies;
import eu.europeana.cloud.service.dps.examples.StaticDpsTaskSpout;
import eu.europeana.cloud.service.dps.examples.util.DpsTaskUtil;
import eu.europeana.cloud.service.dps.storm.io.ReadFileBolt;
import eu.europeana.cloud.service.dps.storm.io.WriteRecordBolt;
import eu.europeana.cloud.service.dps.storm.xslt.XsltBolt;
import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.StormSubmitter;
import org.apache.storm.topology.TopologyBuilder;
import org.apache.storm.utils.Utils;
/**
* Example ecloud topology:
*
* - Creates a DpsTask using {@link StaticDpsTaskSpout}
*
* - Reads a File from eCloud
*
* - Writes a File to eCloud
*/
public class StaticXsltTopology {
private static String ecloudMcsAddress = "http://146.48.82.158:8080/ecloud-service-mcs-rest-0.3-SNAPSHOT";
private static String username = "Cristiano";
private static String password = "Ronaldo";
private static String zkAddress = "ecloud.eanadev.org:2181";
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
StaticDpsTaskSpout taskSpout = new StaticDpsTaskSpout(DpsTaskUtil.generateDpsTask());
ReadFileBolt retrieveFileBolt = new ReadFileBolt(ecloudMcsAddress);
WriteRecordBolt writeRecordBolt = new WriteRecordBolt(ecloudMcsAddress);
builder.setSpout("taskSpout", taskSpout, 1);
builder.setBolt("retrieveFileBolt", retrieveFileBolt, 1).shuffleGrouping(
"taskSpout");
builder.setBolt("xsltTransformationBolt", new XsltBolt(), 1).shuffleGrouping(
"retrieveFileBolt");
builder.setBolt("writeRecordBolt", writeRecordBolt, 1).shuffleGrouping(
"xsltTransformationBolt");
Config conf = new Config();
conf.put(Config.TOPOLOGY_DEBUG, false);
if (args != null && args.length > 0) {
conf.setNumWorkers(3);
StormSubmitter.submitTopologyWithProgressBar(args[0], conf,
builder.createTopology());
} else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(60000);
cluster.killTopology("test");
cluster.shutdown();
}
}
}