private void processMyQueryRequest(QueryRequest request) { int ret = sendMessage(tcpClient, request); NetworkResponse response = (NetworkResponse)receiveMessage(tcpClient); //add response to eventQueue lock (_lock) { eventQueue.Enqueue(response); } }
// Send indexes to all trusted nodes that are online // For use after a backup and associated index insertion have occurred public void sendIndexes() { IndexDatabase idd = new IndexDatabase(); if (!idd.TablesEmpty()) //if there are indexes to send { DistributionDatabase ddb = new DistributionDatabase(); List <string> guidList = new List <string>(); NodeDatabase ndb = new NodeDatabase(); string online = "online"; string indexDBCopy = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\indexes_" + (Properties.Settings.Default.guid).ToString() + ".s3db"; if (System.IO.File.Exists(idd.GetPathFileName())) { try { System.IO.File.Copy(idd.GetPathFileName(), indexDBCopy, true); } catch (System.IO.IOException e) { Debug.Print(e.Message); } } guidList = ndb.SelectGUID(); foreach (string currentGUID in guidList) { if (Node.GetGuid() != Guid.Parse(currentGUID) && ddb.GetStatus(currentGUID) == online && ndb.SelectNodeTrusted(Guid.Parse(currentGUID)) == "yes") { Guid myGuid = Node.GetGuid(); TcpClient tcpClient = new TcpClient((ndb.SelectNodeIp(Guid.Parse(currentGUID))).ToString(), 7890); ClientThread ct = new ClientThread(tcpClient, false, myGuid); PushIndexRequest pir = new PushIndexRequest(indexDBCopy, new FileInfo(indexDBCopy).Length); ct.EnqueueWork(pir); NetworkResponse response = (NetworkResponse)ct.DequeueEvent(); while (ct.IsWorking()) { Thread.Sleep(1000); } ct.RequestStop(); while (ct.IsAlive()) { Thread.Sleep(1000); } } } } }
private void processMyPullRequest(PullRequest request) { int ret = sendMessage(tcpClient, request); NetworkResponse response = (NetworkResponse)receiveMessage(tcpClient); if (response.Type == Backend.ResponseType.Yes) { ret = readFileToDisk(((PullRequest)request).FileSize, ((PullRequest)request).Path); //todo: add result to event queue } else { //other node said willnot, cannot, or notimplemented //add result to event queue lock (_lock) { eventQueue.Enqueue(response); } } }
private void processMyPushRequest(PushRequest request) { Logger.Debug("ClientThread:processMyPushRequest"); int ret = sendMessage(tcpClient, request); NetworkResponse response = (NetworkResponse)receiveMessage(tcpClient); if (response.Type == Backend.ResponseType.Yes) { ret = writeFileToNetwork(((PushRequest)request).Path); //todo: add result to event queue } else { //other node said willnot, cannot, or notimplemented //add result to event queue lock (_lock) { eventQueue.Enqueue(response); } } }
// Send indexes to a specific node // Use after a node comes online public void sendIndexes(string guid) { NodeDatabase ndb = new NodeDatabase(); IndexDatabase idd = new IndexDatabase(); if (!idd.TablesEmpty()) //if there are indexes to send { string indexDBCopy = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\indexes_" + (Properties.Settings.Default.guid).ToString() + ".s3db"; if (System.IO.File.Exists(idd.GetPathFileName())) { try { System.IO.File.Copy(idd.GetPathFileName(), indexDBCopy, true); } catch (System.IO.IOException e) { Debug.Print(e.Message); } } Guid myGuid = Node.GetGuid(); TcpClient tcpClient = new TcpClient((ndb.SelectNodeIp(Guid.Parse(guid))).ToString(), 7890); ClientThread ct = new ClientThread(tcpClient, false, myGuid); PushIndexRequest pir = new PushIndexRequest(indexDBCopy, new FileInfo(indexDBCopy).Length); ct.EnqueueWork(pir); NetworkResponse response = (NetworkResponse)ct.DequeueEvent(); while (ct.IsWorking()) { Thread.Sleep(1000); } ct.RequestStop(); while (ct.IsAlive()) { Thread.Sleep(1000); } } }
protected void processNetworkResponse(ClientThread ct, NetworkResponse response) { Logger.Debug("EchoBackupService:processNetworkResponse doing nothing"); //todo }