Ejemplo n.º 1
0
        public void Can_get_db_and_server_from_oracle_connection_string()
        {
            var(db, server) = SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString("Oracle.ManagedDataAccess.Client",
                                                                                                 "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.82)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=xe)));  User Id=system;Password=oracle;");

            Assert.Equal("xe", db);
            Assert.Equal("192.168.2.82:1521", server);

            // values are missing, should not throw
            SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString("Oracle.ManagedDataAccess.Client",
                                                                               "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(PORT=1521)));  User Id=system;Password=oracle;");


            (db, server) = SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString("Oracle.ManagedDataAccess.Client",
                                                                                              " Data Source=MyOracleDB;Integrated Security=yes;");

            Assert.Null(db);
            Assert.Equal("MyOracleDB", server);

            (db, server) = SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString("Oracle.ManagedDataAccess.Client",
                                                                                              "Data Source=username/password@myserver/myservice:dedicated/instancename;");

            Assert.Null(db);
            Assert.Equal("myserver/myservice:dedicated/instancename", server);
        }
Ejemplo n.º 2
0
        public override string GetDestination()
        {
            if (_name != null)
            {
                return(_name);
            }

            var(database, server) = SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString(FactoryName, Connection.ConnectionString);

            return(_name = $"{database}@{server}");
        }
Ejemplo n.º 3
0
        private IEnumerable <OngoingTask> CollectEtlTasks(DatabaseRecord databaseRecord, DatabaseTopology dbTopology, ClusterTopology clusterTopology)
        {
            if (dbTopology == null)
            {
                yield break;
            }

            if (databaseRecord.RavenEtls != null)
            {
                foreach (var ravenEtl in databaseRecord.RavenEtls)
                {
                    var tag = dbTopology.WhoseTaskIsIt(ravenEtl, ServerStore.Engine.CurrentState);

                    var taskState = GetEtlTaskState(ravenEtl);

                    if (databaseRecord.RavenConnectionStrings.TryGetValue(ravenEtl.ConnectionStringName, out var connection) == false)
                    {
                        throw new InvalidOperationException(
                                  $"Could not find connection string named '{ravenEtl.ConnectionStringName}' in the database record for '{ravenEtl.Name}' ETL");
                    }


                    (string Url, OngoingTaskConnectionStatus Status)res = (null, OngoingTaskConnectionStatus.None);
                    string error = null;
                    if (tag == ServerStore.NodeTag)
                    {
                        foreach (var process in Database.EtlLoader.Processes)
                        {
                            if (process is RavenEtl etlProcess)
                            {
                                if (etlProcess.Name == ravenEtl.Name)
                                {
                                    res.Url    = etlProcess.Url;
                                    res.Status = OngoingTaskConnectionStatus.Active;
                                    break;
                                }
                            }
                        }
                        if (res.Status == OngoingTaskConnectionStatus.None)
                        {
                            error = $"The raven etl process'{ravenEtl.Name}' was not found.";
                        }
                    }
                    else
                    {
                        res.Status = OngoingTaskConnectionStatus.NotOnThisNode;
                    }

                    yield return(new OngoingTaskRavenEtlListView()
                    {
                        TaskId = ravenEtl.TaskId,
                        TaskName = ravenEtl.Name,
                        // TODO arek TaskConnectionStatus =
                        TaskState = taskState,
                        ResponsibleNode = new NodeId
                        {
                            NodeTag = tag,
                            NodeUrl = clusterTopology.GetUrlFromTag(tag)
                        },
                        DestinationUrl = res.Url,
                        TaskConnectionStatus = res.Status,
                        DestinationDatabase = connection.Database,
                        ConnectionStringName = ravenEtl.ConnectionStringName,
                        Error = error
                    });
                }
            }

            if (databaseRecord.SqlEtls != null)
            {
                foreach (var sqlEtl in databaseRecord.SqlEtls)
                {
                    var tag = dbTopology.WhoseTaskIsIt(sqlEtl, ServerStore.Engine.CurrentState);

                    var taskState = GetEtlTaskState(sqlEtl);

                    if (databaseRecord.SqlConnectionStrings.TryGetValue(sqlEtl.ConnectionStringName, out var sqlConnection) == false)
                    {
                        throw new InvalidOperationException(
                                  $"Could not find connection string named '{sqlEtl.ConnectionStringName}' in the database record for '{sqlEtl.Name}' ETL");
                    }

                    var(database, server) =
                        SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString(sqlEtl.FactoryName, sqlConnection.ConnectionString);

                    yield return(new OngoingTaskSqlEtlListView()
                    {
                        TaskId = sqlEtl.TaskId,
                        TaskName = sqlEtl.Name,
                        // TODO arek TaskConnectionStatus =
                        TaskState = taskState,
                        ResponsibleNode = new NodeId
                        {
                            NodeTag = tag,
                            NodeUrl = clusterTopology.GetUrlFromTag(tag)
                        },
                        DestinationServer = server,
                        DestinationDatabase = database,
                        ConnectionStringName = sqlEtl.ConnectionStringName
                    });
                }
            }
        }
Ejemplo n.º 4
0
        private static IEnumerable <OngoingTask> CollectEtlTasks(DatabaseRecord databaseRecord, DatabaseTopology dbTopology, ClusterTopology clusterTopology, ServerStore store)
        {
            if (dbTopology == null)
            {
                yield break;
            }

            if (databaseRecord.RavenEtls != null)
            {
                foreach (var ravenEtl in databaseRecord.RavenEtls)
                {
                    var tag = dbTopology.WhoseTaskIsIt(ravenEtl, store.IsPassive());

                    var taskState = OngoingTaskState.Enabled;

                    if (ravenEtl.Disabled || ravenEtl.Transforms.All(x => x.Disabled))
                    {
                        taskState = OngoingTaskState.Disabled;
                    }
                    else if (ravenEtl.Transforms.Any(x => x.Disabled))
                    {
                        taskState = OngoingTaskState.PartiallyEnabled;
                    }

                    if (databaseRecord.RavenConnectionStrings.TryGetValue(ravenEtl.ConnectionStringName, out var connection) == false)
                    {
                        throw new InvalidOperationException(
                                  $"Could not find connection string named '{ravenEtl.ConnectionStringName}' in the database record for '{ravenEtl.Name}' ETL");
                    }

                    yield return(new OngoingTaskRavenEtl
                    {
                        TaskId = ravenEtl.TaskId,
                        TaskName = ravenEtl.Name,
                        // TODO arek TaskConnectionStatus =
                        TaskState = taskState,
                        ResponsibleNode = new NodeId
                        {
                            NodeTag = tag,
                            NodeUrl = clusterTopology.GetUrlFromTag(tag)
                        },
                        DestinationUrl = connection.Url,
                        DestinationDatabase = connection.Database
                    });
                }
            }

            if (databaseRecord.SqlEtls != null)
            {
                foreach (var sqlEtl in databaseRecord.SqlEtls)
                {
                    var tag = dbTopology.WhoseTaskIsIt(sqlEtl, store.IsPassive());

                    var taskState = OngoingTaskState.Enabled;

                    if (sqlEtl.Disabled || sqlEtl.Transforms.All(x => x.Disabled))
                    {
                        taskState = OngoingTaskState.Disabled;
                    }
                    else if (sqlEtl.Transforms.Any(x => x.Disabled))
                    {
                        taskState = OngoingTaskState.PartiallyEnabled;
                    }

                    if (databaseRecord.SqlConnectionStrings.TryGetValue(sqlEtl.ConnectionStringName, out var sqlConnection) == false)
                    {
                        throw new InvalidOperationException(
                                  $"Could not find connection string named '{sqlEtl.ConnectionStringName}' in the database record for '{sqlEtl.Name}' ETL");
                    }

                    var(database, server) =
                        SqlConnectionStringParser.GetDatabaseAndServerFromConnectionString(sqlEtl.FactoryName, sqlConnection.ConnectionString);

                    yield return(new OngoingTaskSqlEtl
                    {
                        TaskId = sqlEtl.TaskId,
                        TaskName = sqlEtl.Name,
                        // TODO arek TaskConnectionStatus =
                        TaskState = taskState,
                        ResponsibleNode = new NodeId
                        {
                            NodeTag = tag,
                            NodeUrl = clusterTopology.GetUrlFromTag(tag)
                        },
                        DestinationServer = server,
                        DestinationDatabase = database
                    });
                }
            }
        }