예제 #1
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);
        }
예제 #2
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);
     }
 }
예제 #3
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");
 }
예제 #4
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");
 }