예제 #1
0
        /// <summary>
        /// Init the Component
        /// </summary>
        public static void InitComponent(ref Config config, ref TopologyContext context)
        {
            string message = ReadMsg();

            JContainer container = JsonConvert.DeserializeObject(message) as JContainer;

            var _pidDir = container["pidDir"];
            if (_pidDir != null && _pidDir.GetType() == typeof(JValue))
            {
                string pidDir = (_pidDir as JValue).Value.ToString();
                SendPid(pidDir);
            }

            var _conf = container["conf"];
            if (_conf != null && _conf.GetType().BaseType == typeof(JContainer))
            {
                config = GetConfig(_conf as JContainer);
            }

            var _context = container["context"];
            if (_context != null && _context.GetType().BaseType == typeof(JContainer))
            {
                context = GetContext(_context as JContainer);
            }
        }
예제 #2
0
 public void Prepare(Config stormConf, TopologyContext context)
 {
     return;
 }
예제 #3
0
        public static void LaunchPlugin(newPlugin createDelegate)
        {
            TopologyContext context = null;
            Config          config  = new Config();

            Context.pluginType = PluginType.UNKNOW;
#if NETFRAMEWORK4
            Type classType = createDelegate.Method.ReturnType;
#else
            Type classType = createDelegate.GetMethodInfo().ReturnType;
#endif
            Type[] interfaces = classType.GetInterfaces();

            foreach (Type eachType in interfaces)
            {
                if (eachType == typeof(ISpout))
                {
                    Context.pluginType = PluginType.SPOUT;
                    break;
                }
                else if (eachType == typeof(IBolt))
                {
                    Context.pluginType = PluginType.BOLT;
                    break;
                }
                else if (eachType == typeof(IBasicBolt))
                {
                    Context.pluginType = PluginType.BASICBOLT;
                    break;
                }
            }

            InitComponent(ref config, ref context);
            Context.Config          = config;
            Context.TopologyContext = context;

            PluginType pluginType = Context.pluginType;
            Context.Logger.Info("LaunchPlugin, pluginType: {0}", new object[]
            {
                pluginType
            });

            switch (pluginType)
            {
            case PluginType.SPOUT:
            {
                Spout spout = new Spout(createDelegate);
                spout.Launch();
                return;
            }

            case PluginType.BOLT:
            {
                Bolt bolt = new Bolt(createDelegate);
                bolt.Launch();
                return;
            }

            case PluginType.BASICBOLT:
            {
                BasicBolt basicBolt = new BasicBolt(createDelegate);
                basicBolt.Launch();
                return;
            }

            default:
            {
                Context.Logger.Error("unexpected pluginType: {0}!", new object[]
                    {
                        pluginType
                    });
                return;
            }
            }
        }
예제 #4
0
 /// <summary>
 /// Called when a task for this component is initialized within a worker on the cluster.
 /// It provides the spout with the environment in which the spout executes.
 /// </summary>
 /// <param name="config">The Storm configuration for this spout. This is the configuration provided to the topology merged in with cluster configuration on this machine.</param>
 /// <param name="topologyContext">This object can be used to get information about this task's place within the topology, including the task id and component id of this task, input and output information, etc.</param>
 public void Open(Config config, TopologyContext topologyContext)
 {
     return;
 }
예제 #5
0
        /// <summary>
        /// Init the Component
        /// </summary>
        public static void InitComponent(ref Config config, ref TopologyContext context)
        {
            string message = ReadMsg();

            StormConfigure configure = JsonConvert.DeserializeObject<StormConfigure>(message);

            if(!string.IsNullOrEmpty(configure.pidDir))
                SendPid(configure.pidDir);

            config.StormConf = configure.conf;

            //Todo: ignore the context?
            //string topologyId = "";
            //if (configure.context.ContainsKey("componentid"))
            //    topologyId = configure.context["componentid"].ToString();

            //context = new TopologyContext(Convert.ToInt32(configure.context["taskid"]), topologyId, null);
        }