public void AsyncCallBackOperator(IAsyncResult ar) { try { RemoteAsyncDelegateTuple del = (RemoteAsyncDelegateTuple)((AsyncResult)ar).AsyncDelegate; del.EndInvoke(ar); }catch { buildWorkingOps(); if (workingOutputSources != null) { TrySend: Console.WriteLine("FALLBACK"); if (this.workingOutputSources.Count > 0) { string nextOp = workingOutputSources[0]; try { RemoteOperator outputOperator = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), nextOp); RemoteAsyncDelegateTuple RemoteDel = new RemoteAsyncDelegateTuple(outputOperator.receiveInput); Console.WriteLine("SENDING CALLBACK - Result: " + result); IAsyncResult RemAr = RemoteDel.BeginInvoke(this.result, null, null); RemoteDel.EndInvoke(RemAr); writeLog(this.op_id, this.type, this.op_url, "RESULT <" + result.ToString() + ">"); } catch (Exception e1) { this.workingOutputSources.RemoveAt(0); goto TrySend; } } } } return; }
public void unfreezeOperator(string op_url) { RemoteOperator rm_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), op_url); RemoteAsyncDelegate RemoteDel = new RemoteAsyncDelegate(rm_op.unfreeze); IAsyncResult RemAr = RemoteDel.BeginInvoke(null, null); }
public void startOperator(string op_url, string op_id, string semantic) { RemoteOperator rm_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), op_url); RemoteAsyncDelegateStart RemoteDel = new RemoteAsyncDelegateStart(rm_op.startWorking); IAsyncResult RemAr = RemoteDel.BeginInvoke(op_id, op_url, semantic, null, null); }
public void sendResult() { if (this.result == null) { return; } // Writing on log throgh the output operator if (String.Compare(this.op_url, this.output_op[0]) == 0) { writeLog(this.op_id, this.type, this.op_url, "RESULT <" + result.ToString() + ">"); } else { RemoteOperator output_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), this.output_op[0]); RemoteAsyncDelegateLog RemoteDelOutput = new RemoteAsyncDelegateLog(output_op.writeLog); IAsyncResult RemArOutput = RemoteDelOutput.BeginInvoke(this.op_id, this.type, this.op_url, "RESULT <" + result.ToString() + ">", null, null); } Console.WriteLine("RESULT <" + result.ToString() + ">;\r\n"); if (this.outputSources == null) { return; } IDictionary options = new Hashtable(); options["name"] = this.type + "output" + (new Random()).Next(0, 10000);; TcpChannel channel = new TcpChannel(options, null, null); ChannelServices.RegisterChannel(channel, true); String firstOp = this.getRoutingOperator(); RemoteOperator outputOperator = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), firstOp); RemoteAsyncDelegateTuple RemoteDel = new RemoteAsyncDelegateTuple(outputOperator.receiveInput); if (!semantic.Equals("at-most-once")) // semantic at-least-once, exactly-once { IAsyncResult RemAr = RemoteDel.BeginInvoke(this.result, AsyncCallBackOperator, this.result); } else // semantic at-most-once { IAsyncResult RemAr = RemoteDel.BeginInvoke(this.result, null, null); } //RemoteDel.EndInvoke(RemAr); if (isFullLog) // Is full log, must send result to PuppetMaster { RemotePM pm = (RemotePM)Activator.GetObject(typeof(RemotePM), "tcp://localhost:10001/RemotePM"); string[] resultArray = { op_id, type, result.ToString() }; pm.receiveResult(resultArray); } ChannelServices.UnregisterChannel(channel); }
public void intervalOperator(string op_url, int miliseconds) { try { RemoteOperator rm_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), op_url); RemoteAsyncDelegateInt RemoteDel = new RemoteAsyncDelegateInt(rm_op.setInterval); IAsyncResult RemAr = RemoteDel.BeginInvoke(miliseconds, null, null); } catch (Exception e) {} }
public void crashOperator(string op_url) { try { RemoteOperator rm_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), op_url); RemoteAsyncDelegate RemoteDel = new RemoteAsyncDelegate(rm_op.crashOperator); IAsyncResult RemAr = RemoteDel.BeginInvoke(null, null); } catch { } }
public string statusOperator(string op_url) { RemoteOperator rm_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), op_url); try { return(rm_op.operatorState()); } catch (Exception e) { return("UNKNOWN"); } }
public void receiveInput(Tuple input) { inputList.Add(input); Console.WriteLine("RECEIVED <" + input.ToString() + ">;\r\n"); // Writing on log throgh the output operator if (String.Compare(this.op_url, this.output_op[0]) == 0) { writeLog(this.op_id, this.type, this.op_url, "RECEIVED <" + input.ToString() + ">"); } else { RemoteOperator output_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), this.output_op[0]); RemoteAsyncDelegateLog RemoteDelOutput = new RemoteAsyncDelegateLog(output_op.writeLog); IAsyncResult RemArOutput = RemoteDelOutput.BeginInvoke(this.op_id, this.type, this.op_url, "RECEIVED <" + input.ToString() + ">", null, null); } }
public void freeze() { isFreezed = true; state = Constants.STATE_FREEZED; // Writing on log throgh the output operator if (String.Compare(this.op_url, this.output_op[0]) == 0) { writeLog(this.op_id, this.type, this.op_url, "FREZZED"); } else { RemoteOperator output_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), this.output_op[0]); RemoteAsyncDelegateLog RemoteDelOutput = new RemoteAsyncDelegateLog(output_op.writeLog); IAsyncResult RemArOutput = RemoteDelOutput.BeginInvoke(this.op_id, this.type, this.op_url, "FREZZED", null, null); } Console.WriteLine("FREZZED;\r\n"); }
public void startWorking(string op_id, string op_url, string semantic) { this.op_id = op_id; this.semantic = semantic; this.op_url = op_url; state = Constants.STATE_RUNNING; doWork = true; start(); // Writing on log throgh the output operator if (String.Compare(this.op_url, this.output_op[0]) == 0) { writeLog(this.op_id, this.type, this.op_url, "STARTED"); } else { RemoteOperator output_op = (RemoteOperator)Activator.GetObject(typeof(RemoteOperator), this.output_op[0]); RemoteAsyncDelegateLog RemoteDelOutput = new RemoteAsyncDelegateLog(output_op.writeLog); IAsyncResult RemArOutput = RemoteDelOutput.BeginInvoke(this.op_id, this.type, this.op_url, "STARTED", null, null); } Console.WriteLine("STARTED;\r\n"); }