private void BatchRequests(int batchSize, BatchMonitor monitor, bool messageBatch) { lock (monitor) { if (monitor.Filled) { if (messageBatch) { this.localPushServerProxy.StartMessageBatch(); } else { this.localPushServerProxy.StartBatch(); } if (batchSize <= 0) { actionsLogger.Debug("Starting a new batch for unlimited requests in session " + this.localPushServerProxy.SessionId); } else { actionsLogger.Debug(string.Concat(new object[] { "Starting a new batch for ", batchSize, " requests in session ", this.localPushServerProxy.SessionId })); } } else if (batchSize <= 0) { actionsLogger.Debug("Extending the current batch with unlimited requests in session " + this.localPushServerProxy.SessionId); } else { actionsLogger.Debug(string.Concat(new object[] { "Extending the current batch with ", batchSize, " requests in session ", this.localPushServerProxy.SessionId })); } monitor.Expand(batchSize); } }
internal virtual void RequestSubscr(ITableManager table, Lightstreamer.DotNet.Client.SubscribedTableKey subscrKey, BatchMonitor batch) { string winCode = subscrKey.KeyValue.ToString(); this.Check(); try { this.serverTranslator.CallTableRequest(this.serverInfo, winCode, table, batch); } catch (IOException exception) { throw new PushConnException(exception); } catch (WebException exception2) { throw new PushConnException(exception2); } this.Check(); }
internal virtual void RequestItemsSubscr(VirtualTableManager table, Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys, BatchMonitor batch) { string[] winCodes = new string[subscrKeys.Length]; for (int i = 0; i < subscrKeys.Length; i++) { winCodes[i] = subscrKeys[i].KeyValue.ToString(); } this.Check(); try { this.serverTranslator.CallItemsRequest(this.serverInfo, winCodes, table, batch); } catch (IOException exception) { throw new PushConnException(exception); } catch (WebException exception2) { throw new PushConnException(exception2); } this.Check(); }
private void DoControlRequest(PushServerProxy.PushServerProxyInfo pushInfo, IDictionary parameters, BatchMonitor batch) { this.DoControlRequest(pushInfo, parameters, "/lightstreamer/control.txt", batch, this.batchManager); }
internal virtual void CallDelete(string userId, PushServerProxy.PushServerProxyInfo pushInfo, string[] winCodes, BatchMonitor batch) { Hashtable parameters = new Hashtable(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_op"] = "delete"; for (int i = 0; i < winCodes.Length; i++) { parameters["LS_window" + (i + 1)] = winCodes[i]; } this.DoControlRequest(pushInfo, parameters, batch); }
internal virtual void CallTableRequest(PushServerProxy.PushServerProxyInfo pushInfo, string tableCode, ITableManager table, BatchMonitor batch) { IDictionary parameters = new Dictionary<string, string>(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_op"] = "add"; parameters["LS_table"] = tableCode; parameters["LS_id"] = table.Group; parameters["LS_mode"] = table.Mode; parameters["LS_schema"] = table.Schema; if (table.DataAdapter != null) { parameters["LS_data_adapter"] = table.DataAdapter; } if (table.Selector != null) { parameters["LS_selector"] = table.Selector; } if (table.Snapshot) { if (table.DistinctSnapshotLength != -1) { parameters["LS_Snapshot"] = table.DistinctSnapshotLength.ToString(); } else { parameters["LS_Snapshot"] = "true"; } } if (table.Start != -1) { parameters["LS_start"] = table.Start.ToString(); } if (table.End != -1) { parameters["LS_end"] = table.End.ToString(); } if (table.Unfiltered) { parameters["LS_requested_max_frequency"] = "unfiltered"; } else if (!(table.MaxFrequency == -1.0)) { parameters["LS_requested_max_frequency"] = table.MaxFrequency.ToString(); } if (table.MaxBufferSize != -1) { parameters["LS_requested_buffer_size"] = table.MaxBufferSize.ToString(); } this.DoControlRequest(pushInfo, parameters, batch); }
internal virtual void CallDelete(string userId, PushServerProxy.PushServerProxyInfo pushInfo, string[] tableCodes, BatchMonitor batch) { IDictionary parameters = new Dictionary<string, string>(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_op"] = "delete"; for (int i = 0; i < tableCodes.Length; i++) { parameters["LS_table" + (i + 1)] = tableCodes[i]; } this.DoControlRequest(pushInfo, parameters, batch); }
internal virtual void CloseBatch(BatchMonitor monitor, bool messageBatch) { lock (monitor) { actionsLogger.Debug("Executing the current batch in session " + this.localPushServerProxy.SessionId); if (messageBatch) { this.localPushServerProxy.CloseMessageBatch(); } else { this.localPushServerProxy.CloseBatch(); } monitor.Clear(); } }
internal virtual void RequestSendMessage(MessageManager message, int prog, BatchMonitor batch) { this.Check(); try { this.serverTranslator.CallGuaranteedSendMessageRequest(this.serverInfo, Convert.ToString(prog), message, batch); } catch (IOException e) { throw new PushConnException(e); } this.Check(); }
private void DoControlRequest(PushServerProxy.PushServerProxyInfo pushInfo, Hashtable parameters, BatchMonitor batch) { string controlUrl = pushInfo.controlAddress + "/lightstreamer/control.txt"; StreamReader answer = this.batchManager.GetAnswer(controlUrl, parameters, batch); try { this.CheckAnswer(answer); } finally { try { if (!(answer is BatchingHttpProvider.MyReader)) { streamLogger.Debug("Closing connection"); } answer.Close(); } catch (IOException exception) { streamLogger.Debug("Error closing connection", exception); } } }
internal virtual void CallTableRequest(PushServerProxy.PushServerProxyInfo pushInfo, string winCode, ITableManager table, BatchMonitor batch) { Hashtable parameters = new Hashtable(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_op"] = "add"; parameters["LS_window"] = winCode; parameters["LS_id" + 1] = table.Group; parameters["LS_mode" + 1] = table.Mode; parameters["LS_schema" + 1] = table.Schema; if (table.DataAdapter != null) { parameters["LS_data_adapter" + 1] = table.DataAdapter; } if (table.Selector != null) { parameters["LS_selector" + 1] = table.Selector; } if (table.Snapshot) { if (table.DistinctSnapshotLength != -1) { parameters["LS_Snapshot" + 1] = table.DistinctSnapshotLength.ToString(); } else { parameters["LS_Snapshot" + 1] = "true"; } } if (table.Start != -1) { parameters["LS_start" + 1] = table.Start.ToString(); } if (table.End != -1) { parameters["LS_end" + 1] = table.End.ToString(); } if (table.Unfiltered) { parameters["LS_requested_max_frequency" + 1] = "unfiltered"; } else if (!(table.MaxFrequency == -1.0)) { parameters["LS_requested_max_frequency" + 1] = table.MaxFrequency.ToString(); } if (table.MaxBufferSize != -1) { parameters["LS_requested_buffer_size" + 1] = table.MaxBufferSize.ToString(); } this.DoControlRequest(pushInfo, parameters, batch); }
internal virtual void CallItemsRequest(PushServerProxy.PushServerProxyInfo pushInfo, string[] winCodes, VirtualTableManager table, BatchMonitor batch) { Hashtable parameters = new Hashtable(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_op"] = "add"; parameters["LS_mode"] = table.Mode; parameters["LS_schema"] = table.Schema; if (table.DataAdapter != null) { parameters["LS_data_adapter"] = table.DataAdapter; } for (int i = 0; i < table.NumItems; i++) { parameters["LS_window" + (i + 1)] = winCodes[i]; parameters["LS_id" + (i + 1)] = table.GetItemName(i); if (table.Selector != null) { parameters["LS_selector" + (i + 1)] = table.Selector; } if (table.Snapshot) { if (table.DistinctSnapshotLength != -1) { parameters["LS_Snapshot" + (i + 1)] = table.DistinctSnapshotLength.ToString(); } else { parameters["LS_Snapshot" + (i + 1)] = "true"; } } if (table.Unfiltered) { parameters["LS_requested_max_frequency" + (i + 1)] = "unfiltered"; } else if (!(table.MaxFrequency == -1.0)) { parameters["LS_requested_max_frequency" + (i + 1)] = table.MaxFrequency.ToString(); } if (table.MaxBufferSize != -1) { parameters["LS_requested_buffer_size" + (i + 1)] = table.MaxBufferSize.ToString(); } } this.DoControlRequest(pushInfo, parameters, batch); }
internal virtual void DelSubscrs(Lightstreamer.DotNet.Client.SubscribedTableKey[] subscrKeys, BatchMonitor batch) { string[] winCodes = new string[subscrKeys.Length]; for (int i = 0; i < subscrKeys.Length; i++) { winCodes[i] = subscrKeys[i].KeyValue.ToString(); } this.Check(); try { this.serverTranslator.CallDelete(this.userId, this.serverInfo, winCodes, batch); } catch (PushUserException exception) { protLogger.Debug("Refused delete request", exception); throw new PushServerException(7); } catch (IOException exception2) { throw new PushConnException(exception2); } catch (WebException exception3) { throw new PushConnException(exception3); } this.Check(); }
public MessageParallelizer(BatchMonitor monitor, ServerManager manager) { this.monitor = monitor; monitor.Listener = this; this.manager = manager; }
internal virtual StreamReader GetAnswer(string controlUrl, IDictionary parameters, BatchMonitor batch) { BatchingHttpProvider batchToClose = null; BatchingHttpProvider.BufferedReaderMonitor monitor = null; bool flag = false; lock (batch) { lock (this) { if (!batch.Filled) { batch.UseOne(); if (this.batchingProvider != null) { protLogger.Info("Batching control request"); if (protLogger.IsDebugEnabled) { protLogger.Debug("Control params: " + CollectionsSupport.ToString(parameters)); } monitor = this.batchingProvider.AddCall(parameters); if (monitor != null) { if (batch.Filled) { batchToClose = this.batchingProvider; this.batchingProvider = null; } } else if (this.batchingProvider.Empty) { protLogger.Info("Batching failed; trying without batch"); if (batch.Filled) { this.batchingProvider = null; } } else { protLogger.Info("Batching failed; trying a new batch"); batchToClose = this.batchingProvider; batch.Expand(1); this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit); flag = true; } } } else if (this.batchingProvider != null) { this.batchingProvider.Abort(new SubscrException("wrong requests batch")); this.batchingProvider = null; } } } if (batchToClose != null) { DoAsyncPost(batchToClose); } if (monitor != null) { return monitor.GetReader(); } if (flag) { return this.GetAnswer(controlUrl, parameters, batch); } return this.GetNotBatchedAnswer(controlUrl, parameters); }
internal virtual void CallItemsRequest(PushServerProxy.PushServerProxyInfo pushInfo, string[] tableCodes, VirtualTableManager table, BatchMonitor batch) { IDictionary parameters = new Dictionary<string, string>(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_op"] = "add"; parameters["LS_mode"] = table.Mode; parameters["LS_schema"] = table.Schema; if (table.DataAdapter != null) { parameters["LS_data_adapter"] = table.DataAdapter; } for (int i = 0; i < table.NumItems; i++) { parameters["LS_table" + (i + 1)] = tableCodes[i]; parameters["LS_id" + (i + 1)] = table.GetItemName(i); if (table.Selector != null) { parameters["LS_selector" + (i + 1)] = table.Selector; } if (table.Snapshot) { if (table.DistinctSnapshotLength != -1) { parameters["LS_Snapshot" + (i + 1)] = table.DistinctSnapshotLength.ToString(); } else { parameters["LS_Snapshot" + (i + 1)] = "true"; } } if (table.Unfiltered) { parameters["LS_requested_max_frequency" + (i + 1)] = "unfiltered"; } else if (!(table.MaxFrequency == -1.0)) { parameters["LS_requested_max_frequency" + (i + 1)] = table.MaxFrequency.ToString(); } if (table.MaxBufferSize != -1) { parameters["LS_requested_buffer_size" + (i + 1)] = table.MaxBufferSize.ToString(); } } this.DoControlRequest(pushInfo, parameters, batch); }
internal virtual void CallGuaranteedSendMessageRequest(PushServerProxy.PushServerProxyInfo pushInfo, string messageProg, MessageManager message, BatchMonitor batch) { IDictionary parameters = new Dictionary<string, string>(); parameters["LS_session"] = pushInfo.sessionId; parameters["LS_message"] = message.Message; parameters["LS_sequence"] = message.Sequence; parameters["LS_msg_prog"] = messageProg; if (message.DelayTimeout > -1) { parameters["LS_max_wait"] = Convert.ToString(message.DelayTimeout); } this.DoControlRequest(pushInfo, parameters, "/lightstreamer/send_message.txt", batch, this.mexBatchManager); }
private void DoControlRequest(PushServerProxy.PushServerProxyInfo pushInfo, IDictionary parameters, BatchMonitor batch) { string controlUrl = pushInfo.controlAddress + "/lightstreamer/control.txt"; StreamReader answer = this.batchManager.GetAnswer(controlUrl, parameters, batch); try { this.CheckAnswer(answer); } catch (PushEndException) { throw new PushServerException(7); } finally { try { if (!(answer is BatchingHttpProvider.MyReader)) { streamLogger.Debug("Closing control connection"); } answer.Close(); } catch (IOException exception) { streamLogger.Debug("Error closing control connection", exception); } } }
internal virtual StreamReader GetAnswer(string controlUrl, Hashtable parameters, BatchMonitor batch) { BatchingHttpProvider batchToClose = null; BatchingHttpProvider.BufferedReaderMonitor monitor = null; bool flag = false; lock (batch) { lock (this) { if (!batch.Filled) { batch.UseOne(); if (this.batchingProvider != null) { protLogger.Info("Batching control request"); if (protLogger.IsDebugEnabled) { protLogger.Debug("Control params: " + CollectionsSupport.ToString(parameters)); } monitor = this.batchingProvider.AddCall(parameters); if (monitor != null) { if (batch.Filled) { batchToClose = this.batchingProvider; this.batchingProvider = null; } } else if (this.batchingProvider.Empty) { protLogger.Info("Batching failed; trying without batch"); if (batch.Filled) { this.batchingProvider = null; } } else { protLogger.Info("Batching failed; trying a new batch"); batchToClose = this.batchingProvider; batch.Expand(1); this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit); flag = true; } } } else if (this.batchingProvider != null) { this.batchingProvider.Abort(new SubscrException("wrong requests batch")); this.batchingProvider = null; } } } if (batchToClose != null) { DoAsyncPost(batchToClose); } if (monitor != null) { return(monitor.GetReader()); } if (flag) { return(this.GetAnswer(controlUrl, parameters, batch)); } return(this.GetNotBatchedAnswer(controlUrl, parameters)); }