Exemplo n.º 1
0
        public static async Task <bool> DeploySubscribeTask(CRAClientLibrary client, SubscribeTask task, OperatorsToplogy topology)
        {
            try
            {
                if (!_isSubscribeOperatorDefined)
                {
                    await client.DefineVertexAsync(typeof(ShardedSubscribeOperator).Name.ToLower(), () => new ShardedSubscribeOperator());

                    _isSubscribeOperatorDefined = true;
                }

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

                if (status == CRAErrorCode.Success)
                {
                    foreach (string fromInputId in task.EndpointsDescriptor.FromInputs.Keys)
                    {
                        var fromToConnection = task.VerticesConnectionsMap[fromInputId + task.OutputId][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 Subscribe task. Please, double check your task configurations: " + e.ToString());
                return(false);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var client = new CRAClientLibrary(new FileDataProvider());

            int chunkSize = 10 * 1024 * 1024;

            Console.ReadLine();

            client.DefineVertexAsync("bandwidthtestvertex", () => new BandwidthTestVertex()).Wait();
            client.InstantiateVertexAsync("crainst01", "bwvertex1", "bandwidthtestvertex", chunkSize).Wait();
            client.InstantiateVertexAsync("crainst02", "bwvertex2", "bandwidthtestvertex", chunkSize).Wait();
            // client.InstantiateVertexAsync("crainst03", "bwvertex3", "bandwidthtestvertex", chunkSize).Wait();

            client.ConnectAsync("bwvertex1", "output1", "bwvertex2", "input1").Wait();
            client.ConnectAsync("bwvertex1", "output2", "bwvertex2", "input2").Wait();
            client.ConnectAsync("bwvertex1", "output3", "bwvertex2", "input3").Wait();
            client.ConnectAsync("bwvertex1", "output4", "bwvertex2", "input4").Wait();
            client.ConnectAsync("bwvertex1", "output5", "bwvertex2", "input5").Wait();
            client.ConnectAsync("bwvertex1", "output6", "bwvertex2", "input6").Wait();
            client.ConnectAsync("bwvertex1", "output7", "bwvertex2", "input7").Wait();
            client.ConnectAsync("bwvertex1", "output8", "bwvertex2", "input8").Wait();
            client.ConnectAsync("bwvertex2", "output9", "bwvertex1", "input9").Wait();
            client.ConnectAsync("bwvertex2", "output10", "bwvertex1", "input10").Wait();
            client.ConnectAsync("bwvertex2", "output11", "bwvertex1", "input11").Wait();
            client.ConnectAsync("bwvertex2", "output12", "bwvertex1", "input12").Wait();
            client.ConnectAsync("bwvertex2", "output13", "bwvertex1", "input13").Wait();
            client.ConnectAsync("bwvertex2", "output14", "bwvertex1", "input14").Wait();
            client.ConnectAsync("bwvertex2", "output15", "bwvertex1", "input15").Wait();
            client.ConnectAsync("bwvertex2", "output16", "bwvertex1", "input16").Wait();

            Console.ReadLine();
            client.ResetAsync().Wait();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var client = new CRAClientLibrary();

            client.ResetAsync().Wait();

            client.DefineVertexAsync("fusableconnectionpairvertex", () => new FusableConnectionPairVertex()).Wait();

            client.InstantiateVertexAsync("crainst01", "fvertex1", "fusableconnectionpairvertex", null).Wait();
            client.InstantiateVertexAsync("crainst01", "fvertex2", "fusableconnectionpairvertex", null).Wait();

            client.ConnectAsync("fvertex1", "output", "fvertex2", "input").Wait();

            Console.ReadLine();
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var client = new CRAClientLibrary();

            client.DefineVertexAsync("connectionpairvertex", () => new ConnectionPairVertex()).Wait();

            client.InstantiateVertexAsync("crainst01", "vertex1", "connectionpairvertex", new MyParam {
                field1 = 33, field2 = "foo"
            }).Wait();


            client.InstantiateVertexAsync("crainst02", "vertex2", "connectionpairvertex", new MyParam {
                field1 = 34
            }).Wait();

            client.ConnectAsync("vertex1", "output", "vertex2", "input").Wait();
            client.ConnectAsync("vertex2", "output", "vertex1", "input").Wait();

            Console.ReadLine();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var client = new CRAClientLibrary();

            client.DefineVertexAsync("shardedconnectionpairvertex", (System.Linq.Expressions.Expression <Func <IVertex> >)(() => new ShardedConnectionPairVertex())).Wait();

            client.InstantiateVertexAsync(
                new[] { "crainst01", "crainst02" },
                "vertex1",
                "shardedconnectionpairvertex",
                null, 1, e => e % 2).Wait();

            client.InstantiateVertexAsync(
                new[] { "crainst01", "crainst02" },
                "vertex2",
                "shardedconnectionpairvertex",
                null, 1, e => e % 2).Wait();

            client.ConnectAsync("vertex1", "output", "vertex2", "input").Wait();
            client.ConnectAsync("vertex2", "output", "vertex1", "input").Wait();

            Console.ReadLine();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            GenericLogsInterface.SetToGenericLogs();
            ParseAndValidateOptions(args);

            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            switch (_runtimeMode)
            {
            case LocalAmbrosiaRuntimeModes.DebugInstance:
                var myRuntime = new AmbrosiaRuntime();
                myRuntime.InitializeRepro(_instanceName, _serviceLogPath, _checkpointToLoad, _currentVersion,
                                          _isTestingUpgrade, _serviceReceiveFromPort, _serviceSendToPort);
                return;

            case LocalAmbrosiaRuntimeModes.AddReplica:
            case LocalAmbrosiaRuntimeModes.RegisterInstance:
                if (_runtimeMode == LocalAmbrosiaRuntimeModes.AddReplica)
                {
                    _isActiveActive = true;
                }

                var dataProvider = new CRA.DataProvider.Azure.AzureDataProvider(Environment.GetEnvironmentVariable("AZURE_STORAGE_CONN_STRING"));
                var client       = new CRAClientLibrary(dataProvider);
                client.DisableArtifactUploading();

                var replicaName             = $"{_instanceName}{_replicaNumber}";
                AmbrosiaRuntimeParams param = new AmbrosiaRuntimeParams();
                param.createService = _recoveryMode == AmbrosiaRecoveryModes.A
                        ? (bool?)null
                        : (_recoveryMode != AmbrosiaRecoveryModes.N);
                param.pauseAtStart             = _isPauseAtStart;
                param.persistLogs              = _isPersistLogs;
                param.logTriggerSizeMB         = _logTriggerSizeMB;
                param.activeActive             = _isActiveActive;
                param.upgradeToVersion         = _upgradeVersion;
                param.currentVersion           = _currentVersion;
                param.serviceReceiveFromPort   = _serviceReceiveFromPort;
                param.serviceSendToPort        = _serviceSendToPort;
                param.serviceName              = _instanceName;
                param.serviceLogPath           = _serviceLogPath;
                param.AmbrosiaBinariesLocation = _binariesLocation;
                param.storageConnectionString  = Environment.GetEnvironmentVariable("AZURE_STORAGE_CONN_STRING");

                try
                {
                    if (client.DefineVertexAsync(param.AmbrosiaBinariesLocation, () => new AmbrosiaRuntime()).GetAwaiter().GetResult() != CRAErrorCode.Success)
                    {
                        throw new Exception();
                    }

                    // Workaround because of limitation in parameter serialization in CRA
                    XmlSerializer xmlSerializer = new XmlSerializer(param.GetType());
                    string        serializedParams;
                    using (StringWriter textWriter = new StringWriter())
                    {
                        xmlSerializer.Serialize(textWriter, param);
                        serializedParams = textWriter.ToString();
                    }

                    if (client.InstantiateVertexAsync(replicaName, param.serviceName, param.AmbrosiaBinariesLocation, serializedParams).GetAwaiter().GetResult() != CRAErrorCode.Success)
                    {
                        throw new Exception();
                    }
                    client.AddEndpointAsync(param.serviceName, AmbrosiaRuntime.AmbrosiaDataInputsName, true, true).Wait();
                    client.AddEndpointAsync(param.serviceName, AmbrosiaRuntime.AmbrosiaDataOutputsName, false, true).Wait();
                    client.AddEndpointAsync(param.serviceName, AmbrosiaRuntime.AmbrosiaControlInputsName, true, true).Wait();
                    client.AddEndpointAsync(param.serviceName, AmbrosiaRuntime.AmbrosiaControlOutputsName, false, true).Wait();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error trying to upload service. Exception: " + e.Message);
                }

                return;

            default:
                throw new NotSupportedException($"Runtime mode: {_runtimeMode} not supported.");
            }
        }