Ejemplo n.º 1
0
 static void SourceDaemonListen(object para)
 {
     System.Net.Sockets.TcpListener TL = (System.Net.Sockets.TcpListener)para;
     System.Net.Sockets.Socket      sock;
     while ((sock = TL.AcceptSocket()) != null)
     {
         System.Net.Sockets.NetworkStream NS = new System.Net.Sockets.NetworkStream(sock);
         BD2.Daemon.StreamHandler         SH = new BD2.Daemon.StreamHandler(NS);
         BD2.Daemon.ObjectBus             OB = new BD2.Daemon.ObjectBus(SH);
         BD2.Daemon.ServiceManager        SM = new BD2.Daemon.ServiceManager(OB);
         Guid serviceType_SQL = Guid.Parse("57ce8883-1010-41ec-96da-41d36c64d65d");
         SM.AnnounceService(new BD2.Daemon.ServiceAnnounceMessage(Guid.NewGuid(), serviceType_SQL, "Source"), BD2.Conv.Daemon.MSSQL.ServiceAgent.CreateAgent);
         SM.AnounceReady();
     }
 }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            System.Threading.ThreadPool.SetMinThreads(64, 16);
            if (args.Length == 1)
            {
                foreach (string str in System.IO.File.ReadAllLines(args[0]))
                {
                    initial.Enqueue(str);
                }
            }
            SortedDictionary <int, System.Threading.Thread> jobs = new SortedDictionary <int, System.Threading.Thread> ();

            repositories = new SortedDictionary <string, ChunkRepository> ();
            Modifiers.Add("async");
            //BD2.Core.Database DB = new BD2.Core.Database ();
            string command;

            do
            {
                command = Query("Command>");
                if (command == null)
                {
                    return;
                }
                OffsetedArray <string> commandparts = command.Split(' ');
                string[] CommandParts = (string[])((string[])commandparts).Clone();
                commandparts.Offset = ExtractModifiers(CommandParts);
                SortedSet <string> CommandModifiers = new SortedSet <string> (commandparts.GetStrippedPart());
                switch (CommandParts [0])
                {
                case "Run":
                    if (CommandParts.Length < 2)
                    {
                        Console.Error.WriteLine("Run requires at least two parameter: [async] Run <Type>");
                        continue;
                    }
                    switch (CommandParts [1])
                    {
                    case "Daemon":
                        if (CommandParts.Length < 3)
                        {
                            Console.Error.WriteLine("Run Daemon requires at least one parameter: [async] Run Daemon <Daemon Type>");
                            continue;
                        }
                        switch (CommandParts [2])
                        {
                        case "SQL":
                            if (CommandModifiers.Contains("async"))
                            {
                                System.Threading.Thread t_runSourceDaemon = new System.Threading.Thread(RunSourceDaemon);
                                jobs.Add(t_runSourceDaemon.ManagedThreadId, t_runSourceDaemon);
                                t_runSourceDaemon.Start();
                            }
                            else
                            {
                                RunSourceDaemon();
                            }
                            break;                            //source

                        default:
                            Console.Error.WriteLine("Invalid Daemon Type.");
                            break;
                        }
                        break;
                    }
                    break;                    //daemon

                case "Open":
                    if (CommandParts.Length < 2)
                    {
                        Console.Error.WriteLine("Open requires at least one parameter: [async] Open <Repository Type>");
                        continue;
                    }
                    switch (CommandParts [1])
                    {
                    case "LevelDB":
                        if (CommandParts.Length < 4)
                        {
                            Console.Error.WriteLine("LevelDB repository requires at least two parameter: [async] Open File <Repository Nick> <Repository> <Path>");
                            continue;
                        }
                        if (CommandModifiers.Contains("async"))
                        {
                            System.Threading.Thread t_addrepo = new System.Threading.Thread(() => {
                                OpenLevelDBRepository(CommandParts);
                            });
                            t_addrepo.Start();
                            Console.WriteLine("[{0}]", t_addrepo.ManagedThreadId);
                        }
                        else
                        {
                            OpenLevelDBRepository(CommandParts);
                        }
                        break;                        //file

                    case "Network":
                        if (CommandParts.Length < 5)
                        {
                            Console.Error.WriteLine("Network repository requires at least three parameter: [async] Open File <Repository Nick> <Repository> <IPAddress> <Port>");
                            continue;
                        }
                        if (CommandModifiers.Contains("async"))
                        {
                            System.Threading.Thread t_addrepo = new System.Threading.Thread(() => {
                                OpenNetworkRepository(CommandParts);
                            });
                            t_addrepo.Start();
                            Console.WriteLine("[{0}]", t_addrepo.ManagedThreadId);
                        }
                        else
                        {
                            OpenNetworkRepository(CommandParts);
                        }

                        break;

                    case "Socket":
                        break;
                    }
                    break;

                case "Close":
                    break;

                case "Execute":

                    break;

                case "Convert":
                    if (CommandParts.Length < 2)
                    {
                        Console.Error.WriteLine("Open requires at least one parameter: [async] Open <Repository Type> [Parameters]");
                        continue;
                    }
                    switch (CommandParts [1])
                    {
                    case "Table":
                        string daemonIPAddress            = Query("Daemon IP Address");
                        string DaemonPort                 = Query("Daemon Port");
                        System.Net.IPAddress         IPA  = System.Net.IPAddress.Parse(daemonIPAddress);
                        System.Net.IPEndPoint        IPEP = new System.Net.IPEndPoint(IPA, int.Parse(DaemonPort));
                        System.Net.Sockets.TcpClient TC   = new  System.Net.Sockets.TcpClient();
                        TC.Connect(IPEP);
                        System.Net.Sockets.NetworkStream NS = TC.GetStream();
                        BD2.Daemon.StreamHandler         SH = new BD2.Daemon.StreamHandler(NS);
                        BD2.Daemon.ObjectBus             OB = new BD2.Daemon.ObjectBus(SH);
                        BD2.Daemon.ServiceManager        SM = new BD2.Daemon.ServiceManager(OB);
                        SM.AnounceReady();
                        SM.WaitForRemoteReady();

                        Guid serviceType_SQL = Guid.Parse("57ce8883-1010-41ec-96da-41d36c64d65d");
                        var  RS = SM.EnumerateRemoteServices();
                        BD2.Daemon.ServiceAnnounceMessage TSA = null;
                        foreach (var SA in RS)
                        {
                            if (SA.Type == serviceType_SQL)
                            {
                                TSA = SA;
                            }
                        }
                        if (TSA == null)
                        {
                            Console.WriteLine("Required services for Table Conversion not found on remote host.");
                        }
                        BD2.Daemon.TransparentAgent agent =
                            (BD2.Daemon.TransparentAgent)
                            SM.RequestService(TSA, (new BD2.Conv.Daemon.MSSQL.ServiceParameters(Query("Connection String"))).Serialize(),
                                              BD2.Daemon.TransparentAgent.CreateAgent, null);
                        Client CL = new Client(agent, repositories [Query("Repository Name")], Query("Database Name"));
                        CL.Convert();
                        break;
                    }
                    break;

                case "await":
                    string jobID    = commandparts [1];
                    int    intJobID = int.Parse(jobID);
                    jobs [intJobID].Join();
                    break;

                case "Exit":
                    return;

                default:
                    Console.Error.WriteLine(string.Format("{0} is not a valid command.", CommandParts [0]));
                    break;
                }
            } while(true);
        }
Ejemplo n.º 3
0
Archivo: Main.cs Proyecto: vebin/BD2
        public static void Main(string[] args)
        {
            System.Threading.ThreadPool.SetMinThreads (64, 16);
            if (args.Length == 1)
                foreach (string str in System.IO.File.ReadAllLines (args[0]))
                    initial.Enqueue (str);
            SortedDictionary<int, System.Threading.Thread> jobs = new SortedDictionary<int, System.Threading.Thread> ();
            repositories = new SortedDictionary<string, ChunkRepository> ();
            Modifiers.Add ("async");
            //BD2.Core.Database DB = new BD2.Core.Database ();
            string command;
            do {
                command = Query ("Command>");
                if (command == null)
                    return;
                OffsetedArray<string> commandparts = command.Split (' ');
                string[] CommandParts = (string[])((string[])commandparts).Clone ();
                commandparts.Offset = ExtractModifiers (CommandParts);
                SortedSet<string> CommandModifiers = new SortedSet<string> (commandparts.GetStrippedPart ());
                switch (CommandParts [0]) {
                case "Run":
                    if (CommandParts.Length < 2) {
                        Console.Error.WriteLine ("Run requires at least two parameter: [async] Run <Type>");
                        continue;
                    }
                    switch (CommandParts [1]) {
                    case "Daemon":
                        if (CommandParts.Length < 3) {
                            Console.Error.WriteLine ("Run Daemon requires at least one parameter: [async] Run Daemon <Daemon Type>");
                            continue;
                        }
                        switch (CommandParts [2]) {
                        case "SQL":
                            if (CommandModifiers.Contains ("async")) {
                                System.Threading.Thread t_runSourceDaemon = new System.Threading.Thread (RunSourceDaemon);
                                jobs.Add (t_runSourceDaemon.ManagedThreadId, t_runSourceDaemon);
                                t_runSourceDaemon.Start ();
                            } else
                                RunSourceDaemon ();
                            break;//source
                        default:
                            Console.Error.WriteLine ("Invalid Daemon Type.");
                            break;
                        }
                        break;
                    }
                    break;//daemon
                case "Open":
                    if (CommandParts.Length < 2) {
                        Console.Error.WriteLine ("Open requires at least one parameter: [async] Open <Repository Type>");
                        continue;
                    }
                    switch (CommandParts [1]) {
                    case "LevelDB":
                        if (CommandParts.Length < 4) {
                            Console.Error.WriteLine ("LevelDB repository requires at least two parameter: [async] Open File <Repository Nick> <Repository> <Path>");
                            continue;
                        }
                        if (CommandModifiers.Contains ("async")) {
                            System.Threading.Thread t_addrepo = new System.Threading.Thread (() => {
                                OpenLevelDBRepository (CommandParts);
                            });
                            t_addrepo.Start ();
                            Console.WriteLine ("[{0}]", t_addrepo.ManagedThreadId);
                        } else {
                            OpenLevelDBRepository (CommandParts);
                        }
                        break;//file
                    case "Network":
                        if (CommandParts.Length < 5) {
                            Console.Error.WriteLine ("Network repository requires at least three parameter: [async] Open File <Repository Nick> <Repository> <IPAddress> <Port>");
                            continue;
                        }
                        if (CommandModifiers.Contains ("async")) {
                            System.Threading.Thread t_addrepo = new System.Threading.Thread (() => {
                                OpenNetworkRepository (CommandParts);
                            });
                            t_addrepo.Start ();
                            Console.WriteLine ("[{0}]", t_addrepo.ManagedThreadId);
                        } else {
                            OpenNetworkRepository (CommandParts);
                        }

                        break;
                    case "Socket":
                        break;
                    }
                    break;
                case "Close":
                    break;
                case "Execute":

                    break;
                case "Convert":
                    if (CommandParts.Length < 2) {
                        Console.Error.WriteLine ("Open requires at least one parameter: [async] Open <Repository Type> [Parameters]");
                        continue;
                    }
                    switch (CommandParts [1]) {
                    case "Table":
                        string daemonIPAddress = Query ("Daemon IP Address");
                        string DaemonPort = Query ("Daemon Port");
                        System.Net.IPAddress IPA = System.Net.IPAddress.Parse (daemonIPAddress);
                        System.Net.IPEndPoint IPEP = new System.Net.IPEndPoint (IPA, int.Parse (DaemonPort));
                        System.Net.Sockets.TcpClient TC = new  System.Net.Sockets.TcpClient ();
                        TC.Connect (IPEP);
                        System.Net.Sockets.NetworkStream NS = TC.GetStream ();
                        BD2.Daemon.StreamHandler SH = new BD2.Daemon.StreamHandler (NS);
                        BD2.Daemon.ObjectBus OB = new BD2.Daemon.ObjectBus (SH);
                        BD2.Daemon.ServiceManager SM = new BD2.Daemon.ServiceManager (OB);
                        SM.AnounceReady ();
                        SM.WaitForRemoteReady ();

                        Guid serviceType_SQL = Guid.Parse ("57ce8883-1010-41ec-96da-41d36c64d65d");
                        var RS = SM.EnumerateRemoteServices ();
                        BD2.Daemon.ServiceAnnounceMessage TSA = null;
                        foreach (var SA in RS) {
                            if (SA.Type == serviceType_SQL) {
                                TSA = SA;
                            }
                        }
                        if (TSA == null) {
                            Console.WriteLine ("Required services for Table Conversion not found on remote host.");
                        }
                        BD2.Daemon.TransparentAgent agent =
                            (BD2.Daemon.TransparentAgent)
                                SM.RequestService (TSA, (new BD2.Conv.Daemon.MSSQL.ServiceParameters (Query ("Connection String"))).Serialize (),
                                BD2.Daemon.TransparentAgent.CreateAgent, null);
                        Client CL = new Client (agent, repositories [Query ("Repository Name")], Query ("Database Name"));
                        CL.Convert ();
                        break;
                    }
                    break;
                case "await":
                    string jobID = commandparts [1];
                    int intJobID = int.Parse (jobID);
                    jobs [intJobID].Join ();
                    break;
                case "Exit":
                    return;
                default:
                    Console.Error.WriteLine (string.Format ("{0} is not a valid command.", CommandParts [0]));
                    break;
                }
            } while(true);
        }
Ejemplo n.º 4
0
Archivo: Main.cs Proyecto: vebin/BD2
 static void SourceDaemonListen(object para)
 {
     System.Net.Sockets.TcpListener TL = (System.Net.Sockets.TcpListener)para;
     System.Net.Sockets.Socket sock;
     while ((sock = TL.AcceptSocket ()) != null) {
         System.Net.Sockets.NetworkStream NS = new System.Net.Sockets.NetworkStream (sock);
         BD2.Daemon.StreamHandler SH = new BD2.Daemon.StreamHandler (NS);
         BD2.Daemon.ObjectBus OB = new BD2.Daemon.ObjectBus (SH);
         BD2.Daemon.ServiceManager SM = new BD2.Daemon.ServiceManager (OB);
         Guid serviceType_SQL = Guid.Parse ("57ce8883-1010-41ec-96da-41d36c64d65d");
         SM.AnnounceService (new BD2.Daemon.ServiceAnnounceMessage (Guid.NewGuid (), serviceType_SQL, "Source"), BD2.Conv.Daemon.MSSQL.ServiceAgent.CreateAgent);
         SM.AnounceReady ();
     }
 }