| /* |
| * 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 org.apache.eagle.correlation.example; |
| |
| import backtype.storm.Config; |
| import backtype.storm.LocalCluster; |
| import backtype.storm.StormSubmitter; |
| import backtype.storm.generated.StormTopology; |
| import backtype.storm.topology.BoltDeclarer; |
| import backtype.storm.topology.TopologyBuilder; |
| import backtype.storm.tuple.Fields; |
| import backtype.storm.utils.Utils; |
| import org.apache.eagle.correlation.topology.CorrelationSpout; |
| |
| /** |
| * Created on 2/17/16. |
| * this example demostrate how Correlation topology works |
| */ |
| public class CorrelationTestTopology { |
| public static void main(String[] args) throws Exception{ |
| TopologyBuilder builder = new TopologyBuilder(); |
| CorrelationSpout spout = new CorrelationSpout(1); |
| builder.setSpout("testSpout", spout); |
| BoltDeclarer declarer = builder.setBolt("testBolt", new TestBolt()); |
| declarer.fieldsGrouping("testSpout", new Fields("f1")); |
| StormTopology topology = builder.createTopology(); |
| boolean localMode = true; |
| Config conf = new Config(); |
| if(!localMode){ |
| StormSubmitter.submitTopologyWithProgressBar("testTopology", conf, topology); |
| }else{ |
| LocalCluster cluster = new LocalCluster(); |
| cluster.submitTopology("testTopology", conf, topology); |
| while(true) { |
| try { |
| Utils.sleep(Integer.MAX_VALUE); |
| } catch(Exception ex) { |
| } |
| } |
| } |
| } |
| } |