Example #1
0
        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;
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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) {}
        }
Example #6
0
        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 { }
        }
Example #7
0
        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");
            }
        }
Example #8
0
 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);
     }
 }
Example #9
0
 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");
 }
Example #10
0
 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");
 }