26
|
1 using System;
|
20
|
2 using System.Collections.Concurrent;
|
|
3 using System.Threading;
|
26
|
4 using Christie_net.daemon;
|
20
|
5 using Christie_net.datagear;
|
26
|
6 using Christie_net.datagear.command;
|
20
|
7
|
|
8 namespace Christie_net.codegear {
|
|
9 public class CodeGearManager {
|
|
10 private ConcurrentDictionary<string, DataGearManager> dgmList = new ConcurrentDictionary<string, DataGearManager>();
|
|
11 private ConcurrentDictionary<int, CodeGearManager> cgmList = new ConcurrentDictionary<int, CodeGearManager>();
|
26
|
12 private ThreadPoolExecutors threadPoolExecutors;
|
20
|
13 private LocalDataGearManager localDgm = new LocalDataGearManager();
|
26
|
14 private ConcurrentDictionary<string, IncomingTcpConnection> acceptHash =
|
|
15 new ConcurrentDictionary<string, IncomingTcpConnection>();
|
20
|
16 public int cgmID;
|
26
|
17 public ChristieDaemon daemon;
|
20
|
18 public int localPort;
|
26
|
19
|
|
20 public CodeGearManager(int cgmID, ThreadPoolExecutors exe, ConcurrentDictionary<int, CodeGearManager> cgmList, int localPort) {
|
|
21 this.dgmList.TryAdd("local", localDgm);
|
|
22 this.cgmList = cgmList;
|
|
23 this.threadPoolExecutors = exe;
|
|
24 this.cgmID = cgmID;
|
|
25 this.localPort = localPort;
|
|
26 this.daemon = new ChristieDaemon(localPort, this);
|
|
27 this.daemon.Listen();
|
|
28 }
|
|
29
|
|
30 public LocalDataGearManager GetLocalDGM() {
|
|
31 return localDgm;
|
|
32 }
|
|
33
|
|
34 public DataGearManager GetDGM(string dgmName) {
|
|
35 if (dgmList.ContainsKey(dgmName)) {
|
|
36 return dgmList[dgmName];
|
|
37 } else {
|
|
38 throw new ArgumentNullException("DGM " + dgmName + " is not found");
|
|
39 }
|
|
40 }
|
|
41
|
|
42 public RemoteDataGearManager CreateRemoteDGM(string dgmName, string address, int port) {
|
|
43 RemoteDataGearManager remote = new RemoteDataGearManager(dgmName, address, port, this);
|
|
44 }
|
20
|
45 }
|
|
46 } |