Пример #1
0
        public void Deploy(ref TaskBase task, ref OperatorsToplogy operatorsTopology, ref OperatorTransforms operandTransforms)
        {
            GenerateProduceTask(ref operatorsTopology);

            var isRightOperandInput = task.IsRightOperandInput;

            if (isRightOperandInput)
            {
                task.InputIds.SetInputId2(_shardedDatasetId);
                task.NextInputIds.SetInputId2(_shardedDatasetId);
                task.OperationTypes.SetSecondaryKeyType(typeof(TKey));
                task.OperationTypes.SetSecondaryPayloadType(typeof(TPayload));
                task.OperationTypes.SetSecondaryDatasetType(typeof(TDataset));
            }
            else
            {
                task.InputIds.SetInputId1(_shardedDatasetId);
                task.NextInputIds.SetInputId1(_shardedDatasetId);
                task.OperationTypes.SetInputKeyType(typeof(TKey));
                task.OperationTypes.SetInputPayloadType(typeof(TPayload));
                task.OperationTypes.SetInputDatasetType(typeof(TDataset));
            }

            task.IsRightOperandInput = false;
        }
Пример #2
0
 public static bool DeployClientTerminal(CRAClientLibrary client, ClientTerminalTask task,
                                         ref DetachedVertex clientTerminal, OperatorsToplogy topology)
 {
     try
     {
         foreach (string fromInputId in task.EndpointsDescriptor.FromInputs.Keys)
         {
             string[] inputEndpoints  = OperatorUtils.PrepareInputEndpointsIdsForOperator(fromInputId, task.EndpointsDescriptor);
             string[] outputEndpoints = OperatorUtils.PrepareOutputEndpointsIdsForOperator(
                 task.OutputId, topology.OperatorsEndpointsDescriptors[fromInputId]);
             int shardsCount = client.CountVertexShards(task.DeployDescriptor.InstancesMap());
             for (int i = 0; i < shardsCount; i++)
             {
                 for (int j = 0; j < inputEndpoints.Length; j++)
                 {
                     clientTerminal.FromRemoteOutputEndpointStream(inputEndpoints[j] + i, fromInputId + "$" + i, outputEndpoints[j]);
                 }
             }
         }
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in deploying a CRA client terminal vertex. Please, double check your task configurations: " + e.ToString());
         return(false);
     }
 }
Пример #3
0
        private void DeployUnaryTransform(ref TaskBase task, ref OperatorsToplogy topology, ref OperatorTransforms parentTransforms)
        {
            var            isRightOperandInput = task.IsRightOperandInput;
            OperatorInputs temporaryInputs     = new OperatorInputs();

            // Prepare the transformation of the operation unary (left) operand
            task.IsRightOperandInput = false;
            OperatorTransforms unaryTransforms = new OperatorTransforms();

            (_input1 as IDeployable).Deploy(ref task, ref topology, ref unaryTransforms);
            temporaryInputs.InputId1 = task.NextInputIds.InputId1;

            // Update the inputs for the next operation
            if (isRightOperandInput)
            {
                task.NextInputIds.SetInputId2(temporaryInputs.InputId1);
            }
            else
            {
                task.NextInputIds.SetInputId1(temporaryInputs.InputId1);
            }

            // Add the transformations from this operand to the parent operand
            unaryTransforms.AddTransform(SerializationHelper.Serialize(_unaryTransformer),
                                         OperatorType.UnaryTransform.ToString(),
                                         TransformUtils.FillUnaryTransformTypes(typeof(TKeyI1), typeof(TPayloadI1), typeof(TDataSetI1),
                                                                                typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO)).ToString(), temporaryInputs);
            parentTransforms = unaryTransforms;
        }
Пример #4
0
        public static OperatorsToplogy GetInstance()
        {
            if (_instance == null)
            {
                _instance = new OperatorsToplogy();
            }

            return(_instance);
        }
Пример #5
0
        public static async Task <bool> DeployOperators(CRAClientLibrary client, OperatorsToplogy topology)
        {
            topology.PrepareFinalOperatorsTasks();

            string[]   tasksIds = topology.OperatorsIds.ToArray();
            TaskBase[] tasks    = topology.OperatorsTasks.ToArray();

            for (int i = 0; i < tasks.Length; i++)
            {
                if (tasks[i].OperationType == OperatorType.Move)
                {
                    ShuffleTask shuffleTask = (ShuffleTask)tasks[i];
                    shuffleTask.SecondaryEndpointsDescriptor            = new OperatorEndpointsDescriptor();
                    shuffleTask.SecondaryEndpointsDescriptor.FromInputs = topology.OperatorsEndpointsDescriptors[shuffleTask.ReducerVertexName].FromInputs;
                    topology.OperatorsEndpointsDescriptors[shuffleTask.ReducerVertexName].FromInputs = new ConcurrentDictionary <string, int>();
                    int shardsCount = client.CountVertexShards(shuffleTask.DeployDescriptor.InstancesMap());
                    topology.UpdateShuffleInputs(shuffleTask.MapperVertexName, shuffleTask.ReducerVertexName, shardsCount);
                    topology.UpdateShuffleOperatorTask(shuffleTask.ReducerVertexName, shuffleTask);
                }
            }

            var tasksDictionary       = PrepareTasksDictionary(tasks);
            var connectionsMap        = PrepareVerticesConnectionsMap(client, tasks, tasksIds, tasksDictionary, topology);
            var tasksDeploymentStatus = new Dictionary <string, bool>();

            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i].EndpointsDescriptor    = topology.OperatorsEndpointsDescriptors[tasksIds[i]];
                tasks[i].VerticesConnectionsMap = connectionsMap;
                tasksDeploymentStatus.Add(tasksIds[i], false);
            }

            bool isSuccessful = true;

            for (int i = 0; i < tasks.Length; i++)
            {
                if (tasks[i].OperationType == OperatorType.Produce && tasks[i].EndpointsDescriptor.FromInputs.Count == 0 &&
                    tasks[i].EndpointsDescriptor.SecondaryFromInputs.Count == 0)
                {
                    isSuccessful = await DeployProduceTask(client, (ProduceTask)tasks[i], topology);

                    if (isSuccessful)
                    {
                        tasksDeploymentStatus[tasksIds[i]] = true;
                    }
                }
            }

            for (int i = 0; i < tasks.Length; i++)
            {
                isSuccessful = isSuccessful & await DeployTask(i, tasks, tasksIds, tasksDeploymentStatus, client, topology);
            }

            return(isSuccessful);
        }
Пример #6
0
        public static bool DeployOperators(CRAClientLibrary client, OperatorsToplogy topology)
        {
            topology.PrepareFinalOperatorsTasks();

            string[]   tasksIds = topology.OperatorsIds.ToArray();
            TaskBase[] tasks    = topology.OperatorsTasks.ToArray();

            for (int i = 0; i < tasks.Length; i++)
            {
                if (tasks[i].OperationType == OperatorType.Move)
                {
                    ShuffleTask shuffleTask = (ShuffleTask)tasks[i];
                    shuffleTask.SecondaryEndpointsDescriptor            = new OperatorEndpointsDescriptor();
                    shuffleTask.SecondaryEndpointsDescriptor.FromInputs = topology.OperatorsEndpointsDescriptors[shuffleTask.ReducerVertexName].FromInputs;
                    topology.OperatorsEndpointsDescriptors[shuffleTask.ReducerVertexName].FromInputs = new ConcurrentDictionary <string, int>();
                    int shardsCount = client.CountVertexShards(shuffleTask.DeployDescriptor.InstancesMap());
                    topology.UpdateShuffleInputs(shuffleTask.MapperVertexName, shuffleTask.ReducerVertexName, shardsCount);
                    topology.UpdateShuffleOperatorTask(shuffleTask.ReducerVertexName, shuffleTask);
                }
            }

            var tasksDictionary = PrepareTasksDictionary(tasks);
            var connectionsMap  = PrepareVerticesConnectionsMap(client, tasks, tasksIds, tasksDictionary, topology);

            bool isSuccessful = true;

            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i].EndpointsDescriptor    = topology.OperatorsEndpointsDescriptors[tasksIds[i]];
                tasks[i].VerticesConnectionsMap = connectionsMap;
                if (tasks[i].OperationType == OperatorType.Produce)
                {
                    isSuccessful = DeployProduceTask(client, (ProduceTask)tasks[i]);
                }
                else if (tasks[i].OperationType == OperatorType.Subscribe)
                {
                    isSuccessful = DeploySubscribeTask(client, (SubscribeTask)tasks[i], topology);
                }
                else if (tasks[i].OperationType == OperatorType.Move)
                {
                    isSuccessful = DeployShuffleReduceTask(client, (ShuffleTask)tasks[i], topology);
                }

                if (!isSuccessful)
                {
                    break;
                }
            }

            return(isSuccessful);
        }
Пример #7
0
        public static async Task <bool> DeployClientTerminal(
            CRAClientLibrary client,
            string workerName,
            ClientTerminalTask task,
            OperatorsToplogy topology)
        {
            try
            {
                bool result = true;

                client.DisableArtifactUploading();

                if (!_isSubscribeClientOperatorDefined)
                {
                    await client.DefineVertexAsync(typeof(ShardedSubscribeClientOperator).Name.ToLower(), () => new ShardedSubscribeClientOperator());

                    _isSubscribeClientOperatorDefined = true;
                }

                var status = await client.InstantiateVertexAsync(new string[] { workerName }, task.OutputId, typeof(ShardedSubscribeClientOperator).Name.ToLower(), task, 1);

                if (status == CRAErrorCode.Success)
                {
                    foreach (string fromInputId in task.EndpointsDescriptor.FromInputs.Keys)
                    {
                        string outputEndpoint = OperatorUtils.PrepareOutputEndpointIdForOperator(
                            task.OutputId, topology.OperatorsEndpointsDescriptors[fromInputId]);
                        string inputEndpoint = OperatorUtils.PrepareInputEndpointIdForOperator(fromInputId, task.EndpointsDescriptor, false);

                        await client.ConnectAsync(fromInputId, outputEndpoint, task.OutputId, inputEndpoint);
                    }
                    result = true;
                }
                else
                {
                    result = false;
                }

                client.EnableArtifactUploading();

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in deploying a CRA client terminal vertex. Please, double check your task configurations: " + e.ToString());
                return(false);
            }
        }
Пример #8
0
        public void Deploy(ref TaskBase task, ref OperatorsToplogy topology, ref OperatorTransforms parentTransforms)
        {
            switch (OperationType)
            {
            case OperatorType.Move:
                DeployMove(ref task, ref topology);
                break;

            case OperatorType.BinaryTransform:
                DeployBinaryTransform(ref task, ref topology, ref parentTransforms);
                break;

            default:
                DeployUnaryTransform(ref task, ref topology, ref parentTransforms);
                break;
            }
        }
Пример #9
0
        public override IShardedDataset <TKey, TPayload, TDataset> Deploy()
        {
            if (!_isDeployed)
            {
                OperatorsToplogy operatorsTopology = OperatorsToplogy.GetInstance();

                GenerateProduceTask(ref operatorsTopology);

                _craClient  = new CRAClientLibrary();
                _isDeployed = DeploymentUtils.DeployOperators(_craClient, operatorsTopology);
                if (!_isDeployed)
                {
                    return(null);
                }
            }

            return(this);
        }
Пример #10
0
        private static async Task <bool> DeployShuffleReduceTask(
            CRAClientLibrary client,
            ShuffleTask task,
            OperatorsToplogy topology)
        {
            try
            {
                if (!_isShuffleOperatorDefined)
                {
                    await client.DefineVertexAsync(typeof(ShardedShuffleOperator).Name.ToLower(), () => new ShardedShuffleOperator());

                    _isShuffleOperatorDefined = true;
                }

                var status = await client.InstantiateVertexAsync(CreateInstancesNames(task.DeployDescriptor.InstancesMap()), task.ReducerVertexName, typeof(ShardedShuffleOperator).Name.ToLower(), task, 1);

                if (status == CRAErrorCode.Success)
                {
                    foreach (string fromInputId in task.EndpointsDescriptor.FromInputs.Keys)
                    {
                        var fromToConnection = task.VerticesConnectionsMap[fromInputId + task.ReducerVertexName][0];
                        await client.ConnectAsync(fromToConnection.FromVertex, fromToConnection.FromEndpoint, fromToConnection.ToVertex, fromToConnection.ToEndpoint);
                    }

                    foreach (string fromSecondaryInputId in task.EndpointsDescriptor.SecondaryFromInputs.Keys)
                    {
                        var fromToConnection = task.VerticesConnectionsMap[fromSecondaryInputId + task.ReducerVertexName][0];
                        await client.ConnectAsync(fromToConnection.FromVertex, fromToConnection.FromEndpoint, fromToConnection.ToVertex, fromToConnection.ToEndpoint);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in deploying a sharded CRA shuffle mapper task. Please, double check your task configurations: " + e.ToString());
                return(false);
            }
        }
Пример #11
0
        private void GenerateProduceTask(ref OperatorsToplogy operatorsTopology)
        {
            _shardedDatasetId = typeof(ShardedProducerOperator).Name.ToLower() + Guid.NewGuid().ToString();

            TaskBase produceTask = new ProduceTask(SerializationHelper.Serialize(_producer));

            produceTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                typeof(TKey), typeof(TPayload), typeof(TDataset),
                typeof(TKey), typeof(TPayload), typeof(TDataset),
                typeof(TKey), typeof(TPayload), typeof(TDataset));
            produceTask.IsRightOperandInput = false;
            produceTask.InputIds.SetInputId1(_shardedDatasetId);
            produceTask.InputIds.SetInputId2(_shardedDatasetId);
            produceTask.OutputId = _shardedDatasetId;
            produceTask.NextInputIds.SetInputId1(_shardedDatasetId);
            produceTask.NextInputIds.SetInputId2(_shardedDatasetId);
            produceTask.PrepareTaskTransformations(new OperatorTransforms());

            operatorsTopology.AddOperatorBase(produceTask.OutputId, produceTask);
        }
Пример #12
0
        private void DeployBinaryTransform(ref TaskBase task, ref OperatorsToplogy topology, ref OperatorTransforms parentTransforms)
        {
            var            isRightOperandInput = task.IsRightOperandInput;
            OperatorInputs temporaryInputs     = new OperatorInputs();

            // Prepare the transformations of the operation left operand
            task.IsRightOperandInput = false;
            OperatorTransforms leftTransforms = new OperatorTransforms();

            (_input1 as IDeployable).Deploy(ref task, ref topology, ref leftTransforms);
            temporaryInputs.InputId1 = task.NextInputIds.InputId1;

            // Prepare the transformations of the operation right operand
            task.IsRightOperandInput = true;
            OperatorTransforms rightTransforms = new OperatorTransforms();

            (_input2 as IDeployable).Deploy(ref task, ref topology, ref rightTransforms);
            temporaryInputs.InputId2 = task.NextInputIds.InputId2;

            // Update the inputs for the next operation
            if (isRightOperandInput)
            {
                task.NextInputIds.SetInputId2(temporaryInputs.InputId1);
            }
            else
            {
                task.NextInputIds.SetInputId1(temporaryInputs.InputId1);
            }

            // Merge the tranformations from the two operands, and assign them to the parent operation
            parentTransforms = TransformUtils.MergeTwoSetsOfTransforms(leftTransforms, rightTransforms);
            parentTransforms.AddTransform(SerializationHelper.Serialize(_binaryTransformer),
                                          OperatorType.BinaryTransform.ToString(),
                                          TransformUtils.FillBinaryTransformTypes(typeof(TKeyI1), typeof(TPayloadI1), typeof(TDataSetI1),
                                                                                  typeof(TKeyI2), typeof(TPayloadI2), typeof(TDataSetI2),
                                                                                  typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO)).ToString(), temporaryInputs);
        }
Пример #13
0
        public override async Task <IShardedDataset <TKeyO, TPayloadO, TDataSetO> > Deploy()
        {
            if (!_isDeployed)
            {
                OperatorsToplogy toplogy = OperatorsToplogy.GetInstance();

                TaskBase subscribeTask = new SubscribeTask();
                subscribeTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO));
                subscribeTask.IsRightOperandInput = false;
                OperatorTransforms subscribeInputTransforms = new OperatorTransforms();
                Deploy(ref subscribeTask, ref toplogy, ref subscribeInputTransforms);
                subscribeTask.InputIds.SetInputId1(subscribeTask.NextInputIds.InputId1);
                subscribeTask.InputIds.SetInputId2(subscribeTask.NextInputIds.InputId2);
                subscribeTask.OutputId = typeof(ShardedSubscribeOperator).Name.ToLower() + Guid.NewGuid().ToString();
                subscribeTask.PrepareTaskTransformations(subscribeInputTransforms);

                toplogy.AddOperatorBase(subscribeTask.OutputId, subscribeTask);
                toplogy.AddOperatorInput(subscribeTask.OutputId, subscribeTask.InputIds.InputId1);
                toplogy.AddOperatorSecondaryInput(subscribeTask.OutputId, subscribeTask.InputIds.InputId2);
                toplogy.AddOperatorOutput(subscribeTask.InputIds.InputId1, subscribeTask.OutputId);
                toplogy.AddOperatorOutput(subscribeTask.InputIds.InputId2, subscribeTask.OutputId);

                if (subscribeTask.Transforms != null)
                {
                    foreach (OperatorInputs inputs in subscribeTask.TransformsInputs)
                    {
                        toplogy.AddOperatorSecondaryInput(subscribeTask.OutputId, inputs.InputId2);
                        toplogy.AddOperatorOutput(inputs.InputId2, subscribeTask.OutputId);
                    }

                    foreach (OperatorInputs inputs in subscribeTask.TransformsInputs)
                    {
                        if (!toplogy.ContainsSecondaryOperatorInput(subscribeTask.OutputId, inputs.InputId1))
                        {
                            toplogy.AddOperatorInput(subscribeTask.OutputId, inputs.InputId1);
                            toplogy.AddOperatorOutput(inputs.InputId1, subscribeTask.OutputId);
                        }
                    }
                }

                _clientTerminalTask = new ClientTerminalTask();
                _clientTerminalTask.InputIds.SetInputId1(subscribeTask.OutputId);
                _clientTerminalTask.OutputId       = typeof(ShardedSubscribeClientOperator).Name.ToLower() + Guid.NewGuid().ToString();
                _clientTerminalTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO));

                _craClient = new CRAClientLibrary(_dataProvider);
                toplogy.AddOperatorBase(_clientTerminalTask.OutputId, _clientTerminalTask);
                toplogy.AddOperatorInput(_clientTerminalTask.OutputId, _clientTerminalTask.InputIds.InputId1);
                toplogy.AddOperatorInput(_clientTerminalTask.OutputId, _clientTerminalTask.InputIds.InputId2);
                toplogy.AddOperatorOutput(_clientTerminalTask.InputIds.InputId1, _clientTerminalTask.OutputId);
                toplogy.AddOperatorOutput(_clientTerminalTask.InputIds.InputId2, _clientTerminalTask.OutputId);

                _isDeployed = await DeploymentUtils.DeployOperators(_craClient, toplogy);

                if (_isDeployed)
                {
                    string craWorkerName = typeof(ShardedSubscribeClientOperator).Name.ToLower() + "worker" + Guid.NewGuid().ToString();
                    _craWorker = new CRAWorker(craWorkerName, "127.0.0.1", NetworkUtils.GetAvailablePort(), _craClient.DataProvider, null, 1000);
                    _craWorker.DisableDynamicLoading();
                    _craWorker.SideloadVertex(new ShardedSubscribeClientOperator(), typeof(ShardedSubscribeClientOperator).Name.ToLower());
                    new Thread(() => _craWorker.Start()).Start();
                    Thread.Sleep(1000);

                    _isDeployed = await DeploymentUtils.DeployClientTerminal(_craClient, craWorkerName, _clientTerminalTask, toplogy);
                }
                else
                {
                    return(null);
                }
            }

            return(this);
        }
Пример #14
0
        public static bool DeploySubscribeTask(CRAClientLibrary client, SubscribeTask task, OperatorsToplogy topology)
        {
            try
            {
                client.DefineVertex(typeof(SubscribeOperator).Name.ToLower(), () => new SubscribeOperator());
                CRAErrorCode status = client.InstantiateShardedVertex(task.OutputId, typeof(SubscribeOperator).Name.ToLower(),
                                                                      task, task.DeployDescriptor.InstancesMap());
                if (status == CRAErrorCode.Success)
                {
                    foreach (string fromInputId in task.EndpointsDescriptor.FromInputs.Keys)
                    {
                        client.ConnectShardedVertices(task.VerticesConnectionsMap[fromInputId + task.OutputId]);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in deploying a sharded CRA Subscribe task. Please, double check your task configurations: " + e.ToString());
                return(false);
            }
        }
Пример #15
0
        private static async Task <bool> DeployTask(int taskIndex, TaskBase[] tasks, string[] tasksIds, Dictionary <string, bool> tasksDeploymentStatus, CRAClientLibrary client, OperatorsToplogy topology)
        {
            if (!tasksDeploymentStatus[tasksIds[taskIndex]])
            {
                bool isSuccessful = true;
                foreach (var fromInput in tasks[taskIndex].EndpointsDescriptor.FromInputs.Keys)
                {
                    int fromInputIndex = RetrieveTaskIndexOfOperator(fromInput, tasksIds);
                    isSuccessful = isSuccessful & await DeployTask(fromInputIndex, tasks, tasksIds, tasksDeploymentStatus, client, topology);
                }
                foreach (var fromSecondaryInput in tasks[taskIndex].EndpointsDescriptor.SecondaryFromInputs.Keys)
                {
                    int fromSecondaryInputIndex = RetrieveTaskIndexOfOperator(fromSecondaryInput, tasksIds);
                    isSuccessful = isSuccessful & await DeployTask(fromSecondaryInputIndex, tasks, tasksIds, tasksDeploymentStatus, client, topology);
                }

                if (isSuccessful)
                {
                    if (tasks[taskIndex].OperationType == OperatorType.Produce)
                    {
                        isSuccessful = isSuccessful & await DeployProduceTask(client, (ProduceTask)tasks[taskIndex], topology);

                        if (isSuccessful)
                        {
                            tasksDeploymentStatus[tasksIds[taskIndex]] = true;
                        }
                    }
                    else if (tasks[taskIndex].OperationType == OperatorType.Subscribe)
                    {
                        isSuccessful = isSuccessful & await DeploySubscribeTask(client, (SubscribeTask)tasks[taskIndex], topology);

                        if (isSuccessful)
                        {
                            tasksDeploymentStatus[tasksIds[taskIndex]] = true;
                        }
                    }
                    else if (tasks[taskIndex].OperationType == OperatorType.Move)
                    {
                        isSuccessful = isSuccessful & await DeployShuffleReduceTask(client, (ShuffleTask)tasks[taskIndex], topology);

                        if (isSuccessful)
                        {
                            tasksDeploymentStatus[tasksIds[taskIndex]] = true;
                        }
                    }
                }
                return(isSuccessful);
            }
            else
            {
                return(true);
            }
        }
Пример #16
0
        private static bool DeployShuffleReduceTask(CRAClientLibrary client, ShuffleTask task, OperatorsToplogy topology)
        {
            try
            {
                client.DefineVertex(typeof(ShuffleOperator).Name.ToLower(), () => new ShuffleOperator());
                CRAErrorCode status = client.InstantiateShardedVertex(task.ReducerVertexName, typeof(ShuffleOperator).Name.ToLower(),
                                                                      task, task.DeployDescriptor.InstancesMap());
                if (status == CRAErrorCode.Success)
                {
                    foreach (string fromInputId in task.SecondaryEndpointsDescriptor.FromInputs.Keys)
                    {
                        client.ConnectShardedVertices(task.VerticesConnectionsMap[fromInputId + task.OutputId]);
                    }

                    var fromInput      = task.EndpointsDescriptor.FromInputs.First().Key;
                    var newFromInputId = fromInput.Substring(0, fromInput.Length - 1);
                    client.ConnectShardedVertices(task.VerticesConnectionsMap[newFromInputId + task.ReducerVertexName]);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error in deploying a sharded CRA shuffle mapper task. Please, double check your task configurations");
                return(false);
            }
        }
Пример #17
0
        public override IShardedDataset <TKeyO, TPayloadO, TDataSetO> Deploy()
        {
            if (!_isDeployed)
            {
                OperatorsToplogy toplogy = OperatorsToplogy.GetInstance();

                TaskBase subscribeTask = new SubscribeTask();
                subscribeTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO),
                    typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO));
                subscribeTask.IsRightOperandInput = false;
                OperatorTransforms subscribeInputTransforms = new OperatorTransforms();
                Deploy(ref subscribeTask, ref toplogy, ref subscribeInputTransforms);
                subscribeTask.InputIds.SetInputId1(subscribeTask.NextInputIds.InputId1);
                subscribeTask.InputIds.SetInputId2(subscribeTask.NextInputIds.InputId2);
                subscribeTask.OutputId = typeof(SubscribeOperator).Name.ToLower() + Guid.NewGuid().ToString();
                subscribeTask.PrepareTaskTransformations(subscribeInputTransforms);

                toplogy.AddOperatorBase(subscribeTask.OutputId, subscribeTask);
                toplogy.AddOperatorInput(subscribeTask.OutputId, subscribeTask.InputIds.InputId1);
                toplogy.AddOperatorSecondaryInput(subscribeTask.OutputId, subscribeTask.InputIds.InputId2);
                toplogy.AddOperatorOutput(subscribeTask.InputIds.InputId1, subscribeTask.OutputId);
                toplogy.AddOperatorOutput(subscribeTask.InputIds.InputId2, subscribeTask.OutputId);

                if (subscribeTask.Transforms != null)
                {
                    foreach (OperatorInputs inputs in subscribeTask.TransformsInputs)
                    {
                        toplogy.AddOperatorInput(subscribeTask.OutputId, inputs.InputId1);
                        toplogy.AddOperatorSecondaryInput(subscribeTask.OutputId, inputs.InputId2);
                        toplogy.AddOperatorOutput(inputs.InputId1, subscribeTask.OutputId);
                        toplogy.AddOperatorOutput(inputs.InputId2, subscribeTask.OutputId);
                    }
                }

                ClientTerminalTask clientTerminalTask = new ClientTerminalTask();
                clientTerminalTask.InputIds.SetInputId1(subscribeTask.OutputId);
                clientTerminalTask.OutputId = typeof(DetachedVertex).Name.ToLower() + Guid.NewGuid().ToString();

                _craClient      = new CRAClientLibrary();
                _clientTerminal = _craClient.RegisterAsVertex(clientTerminalTask.OutputId);
                toplogy.AddOperatorBase(clientTerminalTask.OutputId, clientTerminalTask);
                toplogy.AddOperatorInput(clientTerminalTask.OutputId, clientTerminalTask.InputIds.InputId1);
                toplogy.AddOperatorInput(clientTerminalTask.OutputId, clientTerminalTask.InputIds.InputId2);
                toplogy.AddOperatorOutput(clientTerminalTask.InputIds.InputId1, clientTerminalTask.OutputId);
                toplogy.AddOperatorOutput(clientTerminalTask.InputIds.InputId2, clientTerminalTask.OutputId);

                _isDeployed = DeploymentUtils.DeployOperators(_craClient, toplogy);
                if (_isDeployed)
                {
                    _isDeployed = DeploymentUtils.DeployClientTerminal(_craClient, clientTerminalTask, ref _clientTerminal, toplogy);
                }
                else
                {
                    return(null);
                }
            }

            return(this);
        }
Пример #18
0
        private static ConcurrentDictionary <string, List <ConnectionInfoWithLocality> > PrepareVerticesConnectionsMap(
            CRAClientLibrary client, TaskBase[] tasks, string[] tasksIds, Dictionary <string, TaskBase> tasksDictionary, OperatorsToplogy topology)
        {
            ConcurrentDictionary <string, List <ConnectionInfoWithLocality> > verticesConnectionsMap = new ConcurrentDictionary <string, List <ConnectionInfoWithLocality> >();

            for (int i = 0; i < tasks.Length; i++)
            {
                int shardsCount = client.CountVertexShards(tasks[i].DeployDescriptor.InstancesMap());

                tasks[i].EndpointsDescriptor = topology.OperatorsEndpointsDescriptors[tasksIds[i]];
                foreach (string fromInputId in tasks[i].EndpointsDescriptor.FromInputs.Keys)
                {
                    var flatFromToConnections = PrepareFlatConnectionsMap(client, shardsCount,
                                                                          fromInputId, topology.OperatorsEndpointsDescriptors[fromInputId], tasksDictionary[fromInputId].DeployDescriptor.InstancesMap(),
                                                                          tasks[i].OutputId, tasks[i].EndpointsDescriptor, tasks[i].DeployDescriptor.InstancesMap(), false);
                    verticesConnectionsMap.AddOrUpdate(fromInputId + tasks[i].OutputId,
                                                       flatFromToConnections, (key, value) => flatFromToConnections);
                }

                foreach (string secondaryFromInputId in tasks[i].EndpointsDescriptor.SecondaryFromInputs.Keys)
                {
                    var flatFromToConnections = PrepareFlatConnectionsMap(client, shardsCount,
                                                                          secondaryFromInputId, topology.OperatorsEndpointsDescriptors[secondaryFromInputId], tasksDictionary[secondaryFromInputId].DeployDescriptor.InstancesMap(),
                                                                          tasks[i].OutputId, tasks[i].EndpointsDescriptor, tasks[i].DeployDescriptor.InstancesMap(), true);
                    verticesConnectionsMap.AddOrUpdate(secondaryFromInputId + tasks[i].OutputId,
                                                       flatFromToConnections, (key, value) => flatFromToConnections);
                }
            }
            return(verticesConnectionsMap);
        }
Пример #19
0
        private void DeployMove(ref TaskBase task, ref OperatorsToplogy topology)
        {
            var            isRightOperandInput = task.IsRightOperandInput;
            OperatorInputs temporaryInputs     = new OperatorInputs();

            TaskBase shuffleTask = new ShuffleTask(_moveDescriptor);

            shuffleTask.OperationTypes = TransformUtils.FillBinaryTransformTypes(
                typeof(TKeyI1), typeof(TPayloadI1), typeof(TDataSetI1),
                typeof(TKeyI2), typeof(TPayloadI2), typeof(TDataSetI2),
                typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO));
            shuffleTask.IsRightOperandInput = false;
            OperatorTransforms shuffleInputTransforms = new OperatorTransforms();

            (_input1 as IDeployable).Deploy(ref shuffleTask, ref topology, ref shuffleInputTransforms);
            shuffleTask.PrepareTaskTransformations(shuffleInputTransforms);
            (shuffleTask as ShuffleTask).MapperVertexName  = "shufflemapper" + Guid.NewGuid().ToString();
            (shuffleTask as ShuffleTask).ReducerVertexName = typeof(ShuffleOperator).Name.ToLower() + Guid.NewGuid().ToString();
            shuffleTask.InputIds.SetInputId1(shuffleTask.NextInputIds.InputId1);
            shuffleTask.InputIds.SetInputId2(shuffleTask.NextInputIds.InputId2);
            shuffleTask.OutputId = (shuffleTask as ShuffleTask).ReducerVertexName;
            OperatorTransforms shuffleTransforms = new OperatorTransforms();

            shuffleTransforms.AddTransform(SerializationHelper.Serialize(_splitter),
                                           OperatorType.MoveSplit.ToString(),
                                           TransformUtils.FillBinaryTransformTypes(typeof(TKeyI1), typeof(TPayloadI1), typeof(TDataSetI1),
                                                                                   typeof(TKeyI2), typeof(TPayloadI2), typeof(TDataSetI2),
                                                                                   typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO)).ToString(),
                                           shuffleTask.InputIds);
            shuffleTransforms.AddTransform(SerializationHelper.Serialize(_merger),
                                           OperatorType.MoveMerge.ToString(),
                                           TransformUtils.FillBinaryTransformTypes(typeof(TKeyI1), typeof(TPayloadI1), typeof(TDataSetI1),
                                                                                   typeof(TKeyI2), typeof(TPayloadI2), typeof(TDataSetI2),
                                                                                   typeof(TKeyO), typeof(TPayloadO), typeof(TDataSetO)).ToString(),
                                           shuffleTask.InputIds);
            ((ShuffleTask)shuffleTask).PrepareShuffleTransformations(shuffleTransforms);

            topology.AddShuffleOperator((shuffleTask as ShuffleTask).MapperVertexName, (shuffleTask as ShuffleTask).ReducerVertexName, shuffleTask as ShuffleTask);
            topology.AddOperatorInput((shuffleTask as ShuffleTask).MapperVertexName, shuffleTask.InputIds.InputId1);
            topology.AddOperatorSecondaryInput((shuffleTask as ShuffleTask).MapperVertexName, shuffleTask.InputIds.InputId2);
            topology.AddOperatorOutput(shuffleTask.InputIds.InputId1, (shuffleTask as ShuffleTask).MapperVertexName);
            topology.AddOperatorOutput(shuffleTask.InputIds.InputId2, (shuffleTask as ShuffleTask).MapperVertexName);

            if (shuffleTask.Transforms != null)
            {
                foreach (OperatorInputs inputs in shuffleTask.TransformsInputs)
                {
                    topology.AddOperatorInput((shuffleTask as ShuffleTask).MapperVertexName, inputs.InputId1);
                    topology.AddOperatorSecondaryInput((shuffleTask as ShuffleTask).MapperVertexName, inputs.InputId2);
                    topology.AddOperatorOutput(inputs.InputId1, (shuffleTask as ShuffleTask).MapperVertexName);
                    topology.AddOperatorOutput(inputs.InputId2, (shuffleTask as ShuffleTask).MapperVertexName);
                }
            }

            // Update the inputs and types for the next operation
            task.InputIds.SetInputId1(shuffleTask.OutputId);
            task.OperationTypes.SetInputKeyType(typeof(TKeyO));
            task.OperationTypes.SetInputPayloadType(typeof(TPayloadO));
            task.OperationTypes.SetInputDatasetType(typeof(TDataSetO));
            if (isRightOperandInput)
            {
                temporaryInputs.InputId2 = shuffleTask.OutputId;
            }
            else
            {
                temporaryInputs.InputId1 = shuffleTask.OutputId;
            }
            task.NextInputIds = temporaryInputs;
        }
Пример #20
0
        private static ConcurrentDictionary <string, List <ConnectionInfoWithLocality> > PrepareVerticesConnectionsMap(
            CRAClientLibrary client, TaskBase[] tasks, string[] tasksIds, Dictionary <string, TaskBase> tasksDictionary, OperatorsToplogy topology)
        {
            ConcurrentDictionary <string, List <ConnectionInfoWithLocality> > verticesConnectionsMap = new ConcurrentDictionary <string, List <ConnectionInfoWithLocality> >();

            for (int i = 0; i < tasks.Length; i++)
            {
                int shardsCount = client.CountVertexShards(tasks[i].DeployDescriptor.InstancesMap());

                tasks[i].EndpointsDescriptor = topology.OperatorsEndpointsDescriptors[tasksIds[i]];
                if (tasks[i].OperationType == OperatorType.Move)
                {
                    var shuffleTask = (ShuffleTask)tasks[i];
                    foreach (string fromInputId in shuffleTask.SecondaryEndpointsDescriptor.FromInputs.Keys)
                    {
                        var flatFromToConnections = PrepareFlatConnectionsMap(client, shardsCount,
                                                                              fromInputId, topology.OperatorsEndpointsDescriptors[fromInputId], tasksDictionary[fromInputId].DeployDescriptor.InstancesMap(),
                                                                              shuffleTask.ReducerVertexName, shuffleTask.EndpointsDescriptor, shuffleTask.DeployDescriptor.InstancesMap());
                        verticesConnectionsMap.AddOrUpdate(fromInputId + shuffleTask.OutputId,
                                                           flatFromToConnections, (key, value) => flatFromToConnections);
                    }

                    var fromInput                = shuffleTask.EndpointsDescriptor.FromInputs.First().Key;
                    var newFromInputId           = fromInput.Substring(0, fromInput.Length - 1);
                    var shuffleFromToConnections = PrepareShuffleConnectionsMap(client, shardsCount,
                                                                                newFromInputId, topology.OperatorsEndpointsDescriptors[newFromInputId], tasksDictionary[newFromInputId].DeployDescriptor.InstancesMap(),
                                                                                shuffleTask.ReducerVertexName, shuffleTask.EndpointsDescriptor, shuffleTask.DeployDescriptor.InstancesMap());
                    verticesConnectionsMap.AddOrUpdate(newFromInputId + shuffleTask.ReducerVertexName,
                                                       shuffleFromToConnections, (key, value) => shuffleFromToConnections);
                }
                else
                {
                    foreach (string fromInputId in tasks[i].EndpointsDescriptor.FromInputs.Keys)
                    {
                        var flatFromToConnections = PrepareFlatConnectionsMap(client, shardsCount,
                                                                              fromInputId, topology.OperatorsEndpointsDescriptors[fromInputId], tasksDictionary[fromInputId].DeployDescriptor.InstancesMap(),
                                                                              tasks[i].OutputId, tasks[i].EndpointsDescriptor, tasks[i].DeployDescriptor.InstancesMap());
                        verticesConnectionsMap.AddOrUpdate(fromInputId + tasks[i].OutputId,
                                                           flatFromToConnections, (key, value) => flatFromToConnections);
                    }
                }
            }
            return(verticesConnectionsMap);
        }