/** * 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 * <p/> * http://www.apache.org/licenses/LICENSE-2.0 * <p/> * 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.ic.topology; import eu.europeana.cloud.service.dps.examples.StaticDpsTaskSpout; import eu.europeana.cloud.service.dps.examples.util.DpsTaskUtil; import eu.europeana.cloud.service.dps.storm.AbstractDpsBolt; import eu.europeana.cloud.service.dps.storm.NotificationBolt; import eu.europeana.cloud.service.dps.storm.NotificationTuple; 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.topologies.ic.topology.bolt.IcBolt; 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.tuple.Fields; import org.apache.storm.utils.Utils; /** * Example ecloud topology: * <p/> * - Creates a DpsTask using {@link StaticDpsTaskSpout} * <p/> * - Reads a File from eCloud * <p/> * - Writes a File to eCloud */ public class StaticICTopology { private static String ecloudMcsAddress = "http://iks-kbase.synat.pcss.pl:9090/mcs"; public static void main(String[] args) throws Exception { TopologyBuilder builder = new TopologyBuilder(); StaticDpsTaskSpout taskSpout = new StaticDpsTaskSpout(DpsTaskUtil.generateDPsTaskForIC()); ReadFileBolt retrieveFileBolt = new ReadFileBolt(ecloudMcsAddress); WriteRecordBolt writeRecordBolt = new WriteRecordBolt(ecloudMcsAddress); builder.setSpout("taskSpout", taskSpout, 1); builder.setBolt("retrieveFileBolt", retrieveFileBolt, 1).shuffleGrouping( "taskSpout"); builder.setBolt("imageConversionBolt", new IcBolt(), 1).shuffleGrouping( "retrieveFileBolt"); builder.setBolt("writeRecordBolt", writeRecordBolt, 1).shuffleGrouping( "imageConversionBolt"); builder.setBolt("notificationBolt", new NotificationBolt("iks-kbase.synat.pcss.pl", 9042, "ecloud_dps", "cassandra", "cassandra"), 1) .fieldsGrouping("retrieveFileBolt", AbstractDpsBolt.NOTIFICATION_STREAM_NAME, new Fields(NotificationTuple.taskIdFieldName)) .fieldsGrouping("imageConversionBolt", AbstractDpsBolt.NOTIFICATION_STREAM_NAME, new Fields(NotificationTuple.taskIdFieldName)) .fieldsGrouping("writeRecordBolt", AbstractDpsBolt.NOTIFICATION_STREAM_NAME, new Fields(NotificationTuple.taskIdFieldName)); 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(); } } }