예제 #1
0
        private CommunicationGroupClient(
            [Parameter(typeof(GroupCommConfigurationOptions.CommunicationGroupName))] string groupName,
            [Parameter(typeof(GroupCommConfigurationOptions.SerializedOperatorConfigs))] ISet <string> operatorConfigs,
            IGroupCommNetworkObserver groupCommNetworkObserver,
            AvroConfigurationSerializer configSerializer,
            ICommunicationGroupNetworkObserver commGroupNetworkHandler,
            IInjector injector)
        {
            _operators = new Dictionary <string, object>();

            GroupName = groupName;
            groupCommNetworkObserver.Register(groupName, commGroupNetworkHandler);

            foreach (string operatorConfigStr in operatorConfigs)
            {
                IConfiguration operatorConfig = configSerializer.FromString(operatorConfigStr);

                IInjector operatorInjector = injector.ForkInjector(operatorConfig);
                string    operatorName     = operatorInjector.GetNamedInstance <GroupCommConfigurationOptions.OperatorName, string>(
                    GenericType <GroupCommConfigurationOptions.OperatorName> .Class);
                string msgType = operatorInjector.GetNamedInstance <GroupCommConfigurationOptions.MessageType, string>(
                    GenericType <GroupCommConfigurationOptions.MessageType> .Class);

                Type groupCommOperatorGenericInterface = typeof(IGroupCommOperator <>);
                Type groupCommOperatorInterface        = groupCommOperatorGenericInterface.MakeGenericType(Type.GetType(msgType));
                var  operatorObj = operatorInjector.GetInstance(groupCommOperatorInterface);
                _operators.Add(operatorName, operatorObj);
            }
        }
예제 #2
0
        private ReduceReceiver(
            [Parameter(typeof(GroupCommConfigurationOptions.OperatorName))] string operatorName,
            [Parameter(typeof(GroupCommConfigurationOptions.CommunicationGroupName))] string groupName,
            [Parameter(typeof(GroupCommConfigurationOptions.Initialize))] bool initialize,
            OperatorTopology <PipelineMessage <T> > topology,
            ICommunicationGroupNetworkObserver networkHandler,
            IReduceFunction <T> reduceFunction,
            IPipelineDataConverter <T> dataConverter)
        {
            OperatorName          = operatorName;
            GroupName             = groupName;
            Version               = PipelineVersion;
            ReduceFunction        = reduceFunction;
            PipelineDataConverter = dataConverter;

            _pipelinedReduceFunc = new PipelinedReduceFunction <T>(ReduceFunction);
            _topology            = topology;

            var msgHandler = Observer.Create <GeneralGroupCommunicationMessage>(message => topology.OnNext(message));

            networkHandler.Register(operatorName, msgHandler);

            if (initialize)
            {
                topology.Initialize();
            }
        }
예제 #3
0
        private ScatterReceiver(
            [Parameter(typeof(GroupCommConfigurationOptions.OperatorName))] string operatorName,
            [Parameter(typeof(GroupCommConfigurationOptions.CommunicationGroupName))] string groupName,
            [Parameter(typeof(GroupCommConfigurationOptions.Initialize))] bool initialize,
            OperatorTopology <T> topology,
            ICommunicationGroupNetworkObserver networkHandler)
        {
            OperatorName = operatorName;
            GroupName    = groupName;
            Version      = DefaultVersion;
            _topology    = topology;
            _initialize  = initialize;

            var msgHandler = Observer.Create <GeneralGroupCommunicationMessage>(message => topology.OnNext(message));

            networkHandler.Register(operatorName, msgHandler);
        }
예제 #4
0
        private BroadcastSender(
            [Parameter(typeof(GroupCommConfigurationOptions.OperatorName))] string operatorName,
            [Parameter(typeof(GroupCommConfigurationOptions.CommunicationGroupName))] string groupName,
            [Parameter(typeof(GroupCommConfigurationOptions.Initialize))] bool initialize,
            OperatorTopology <PipelineMessage <T> > topology,
            ICommunicationGroupNetworkObserver networkHandler,
            IPipelineDataConverter <T> dataConverter)
        {
            _topology             = topology;
            OperatorName          = operatorName;
            GroupName             = groupName;
            Version               = PipelineVersion;
            PipelineDataConverter = dataConverter;
            _initialize           = initialize;

            var msgHandler = Observer.Create <GeneralGroupCommunicationMessage>(message => topology.OnNext(message));

            networkHandler.Register(operatorName, msgHandler);
        }