public Client(BD2.Daemon.TransparentAgent agent, BD2.Chunk.ChunkRepository repo, string databaseName) { if (agent == null) throw new ArgumentNullException ("agent"); if (repo == null) throw new ArgumentNullException ("repo"); if (databaseName == null) throw new ArgumentNullException ("databaseName"); this.agent = agent; this.repo = repo; this.databaseName = databaseName; typeIDs = new Dictionary<Type, long> (); typeIDs.Add (typeof(bool), 1); typeIDs.Add (typeof(char), 2); typeIDs.Add (typeof(byte), 3); typeIDs.Add (typeof(byte[]), 4); typeIDs.Add (typeof(short), 5); typeIDs.Add (typeof(int), 6); typeIDs.Add (typeof(long), 7); typeIDs.Add (typeof(float), 8); typeIDs.Add (typeof(double), 9); typeIDs.Add (typeof(Guid), 10); typeIDs.Add (typeof(String), 11); typeIDs.Add (typeof(DateTime), 12); tableDataRequests = new SortedDictionary<Guid, Table> (); frontend = new BD2.Frontend.Table.Frontend (new BD2.Frontend.Table.GenericValueDeserializer ()); frontends = new BD2.Core.FrontendBase[] { frontend }; db = new BD2.Core.Database (new BD2.Chunk.ChunkRepository[] { repo }, frontends, new byte[]{ }, databaseName); ss = db.GetSnapshot ("Primary"); frontendInstance = (BD2.Frontend.Table.FrontendInstance)frontend.GetInstanse (ss); tableColumns = new System.Collections.Concurrent.ConcurrentDictionary<Table, System.Collections.Concurrent.BlockingCollection<Column>> (); tables = new SortedDictionary<Guid, Tuple<Table, List<Column>>> (); }
public Client(BD2.Daemon.TransparentAgent agent, BD2.Chunk.ChunkRepository repo, string databaseName) { if (agent == null) { throw new ArgumentNullException("agent"); } if (repo == null) { throw new ArgumentNullException("repo"); } if (databaseName == null) { throw new ArgumentNullException("databaseName"); } this.agent = agent; this.repo = repo; this.databaseName = databaseName; typeIDs = new Dictionary <Type, long> (); typeIDs.Add(typeof(bool), 1); typeIDs.Add(typeof(char), 2); typeIDs.Add(typeof(byte), 3); typeIDs.Add(typeof(byte[]), 4); typeIDs.Add(typeof(short), 5); typeIDs.Add(typeof(int), 6); typeIDs.Add(typeof(long), 7); typeIDs.Add(typeof(float), 8); typeIDs.Add(typeof(double), 9); typeIDs.Add(typeof(Guid), 10); typeIDs.Add(typeof(String), 11); typeIDs.Add(typeof(DateTime), 12); tableDataRequests = new SortedDictionary <Guid, Table> (); frontend = new BD2.Frontend.Table.Frontend(new BD2.Frontend.Table.GenericValueDeserializer()); frontends = new BD2.Core.FrontendBase[] { frontend }; db = new BD2.Core.Database(new BD2.Chunk.ChunkRepository[] { repo }, frontends, new byte[] { }, databaseName); ss = db.GetSnapshot("Primary"); frontendInstance = (BD2.Frontend.Table.FrontendInstance)frontend.GetInstanse(ss); tableColumns = new System.Collections.Concurrent.ConcurrentDictionary <Table, System.Collections.Concurrent.BlockingCollection <Column> > (); tables = new SortedDictionary <Guid, Tuple <Table, List <Column> > > (); }
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); }