Esempio n. 1
0
        public void Launch()
        {
            Context.Logger.Info("[Bolt] Launch ...");
            ApacheStorm.ctx = new BoltContext();
            IPlugin iPlugin = this._createDelegate(ApacheStorm.ctx);

            if (!(iPlugin is IBolt))
            {
                Context.Logger.Error("[Bolt] newPlugin must return IBolt!");
            }
            this._bolt = (IBolt)iPlugin;

            try
            {
                //call Prepare method.
                this._bolt.Prepare(Context.Config, Context.TopologyContext);

                while (true)
                {
                    StormTuple tuple = ApacheStorm.ReadTuple();
                    if (tuple.IsHeartBeatTuple())
                    {
                        ApacheStorm.Sync();
                    }
                    else
                    {
                        this._bolt.Execute(tuple);
                    }
                }
            }
            catch (Exception ex)
            {
                Context.Logger.Error(ex.ToString());
            }
        }
Esempio n. 2
0
 public void Execute(StormTuple tuple)
 {
     Context.Logger.Info("SimpleDRPC Execute enter");
     
     string sentence = tuple.GetString(0) + "!";
     this.ctx.Emit("default", new List<StormTuple> { tuple }, new List<object> { sentence, tuple.GetValue(1) });
     Context.Logger.Info("SimpleDRPC Execute exit");
     ApacheStorm.Ack(tuple);
 }
Esempio n. 3
0
        /// <summary>
        /// The Execute() function will be called, when a new tuple is available.
        /// </summary>
        /// <param name="tuple"></param>
        public void Execute(StormTuple tuple)
        {
            Context.Logger.Info("Execute enter");

            string sentence = tuple.GetString(0);

            foreach (string word in sentence.Split(' '))
            {
                Context.Logger.Info("Splitter Emit: {0}", word);
                this.ctx.Emit("default", new List<StormTuple> { tuple }, new List<object> { word, word[0] });
            }

            Context.Logger.Info("Splitter Execute exit");
        }
Esempio n. 4
0
        /// <summary>
        /// The Execute() function will be called, when a new tuple is available.
        /// </summary>
        /// <param name="tuple"></param>
        public void Execute(StormTuple tuple)
        {
            Context.Logger.Info("Execute enter");

            string word = tuple.GetString(0);
            int count = counts.ContainsKey(word) ? counts[word] : 0;
            count++;
            counts[word] = count;

            Context.Logger.Info("Counter Emit: {0}, count: {1}", word, count);
            this.ctx.Emit("default", new List<StormTuple> { tuple }, new List<object> { word, count });

            Context.Logger.Info("Counter Execute exit");
        }
Esempio n. 5
0
 public abstract void Fail(StormTuple tuple);
Esempio n. 6
0
 public abstract void Ack(StormTuple tuple);
Esempio n. 7
0
 public override void Fail(StormTuple tuple)
 {
     Context.Logger.Error("[SpoutContext] Bolt can not call this function!");
 }
Esempio n. 8
0
 public static void Fail(StormTuple tuple)
 {
     SendMsgToParent("{\"command\": \"fail\", \"id\": \"" + tuple.GetTupleId() + "\"}");
 }
Esempio n. 9
0
 public abstract void Fail(StormTuple tuple);
Esempio n. 10
0
 public abstract void Ack(StormTuple tuple);
Esempio n. 11
0
 public static void Fail(StormTuple tuple)
 {
     SendMsgToParent("{\"command\": \"fail\", \"id\": \"" + tuple.GetTupleId() + "\"}");
 }
Esempio n. 12
0
 public override void Fail(StormTuple tuple)
 {
     Context.Logger.Error("[SpoutContext] Bolt can not call this function!");
 }
Esempio n. 13
0
 public override void Fail(StormTuple tuple)
 {
     ApacheStorm.Fail(tuple);
 }
Esempio n. 14
0
 public override void Ack(StormTuple tuple)
 {
     ApacheStorm.Ack(tuple);
 }
Esempio n. 15
0
 public override void Fail(StormTuple tuple)
 {
     ApacheStorm.Fail(tuple);
 }
Esempio n. 16
0
 public override void Ack(StormTuple tuple)
 {
     ApacheStorm.Ack(tuple);
 }