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); } }
private static List <ConnectionInfoWithLocality> PrepareFlatConnectionsMap(CRAClientLibrary client, int shardsCount, string fromVertex, OperatorEndpointsDescriptor fromVertexDescriptor, ConcurrentDictionary <string, int> fromVertexShards, string toVertex, OperatorEndpointsDescriptor toVertexDescriptor, ConcurrentDictionary <string, int> toVertexShards, bool isSecondaryInput) { List <ConnectionInfoWithLocality> fromToConnections = new List <ConnectionInfoWithLocality>(); string output = OperatorUtils.PrepareOutputEndpointIdForOperator(toVertex, fromVertexDescriptor); string input = OperatorUtils.PrepareInputEndpointIdForOperator(fromVertex, toVertexDescriptor, isSecondaryInput); bool hasSameCRAInstances = true; for (int i = 0; i < shardsCount; i++) { string currentFromVertex = fromVertex + "$" + i; string currentToVertex = toVertex + "$" + i; hasSameCRAInstances = hasSameCRAInstances & client.AreTwoVerticessOnSameCRAInstance(currentFromVertex, fromVertexShards, currentToVertex, toVertexShards); } fromToConnections.Add(new ConnectionInfoWithLocality(fromVertex, output, toVertex, input, hasSameCRAInstances, isSecondaryInput)); return(fromToConnections); }