public void OnNext(IContextMessage value)
 {
     LOGGER.Log(Level.Info, "Received ContextMessage: " + ByteUtilities.ByteArraysToString(value.Message));
 }
Пример #2
0
 public static T FromBytes(byte[] bytes)
 {
     return(FromString(ByteUtilities.ByteArraysToString(bytes)));
 }
Пример #3
0
 /// <summary>
 /// Sample code to print out a completed task's details.
 /// </summary>
 /// <param name="completedTask"></param>
 public void OnNext(ICompletedTask completedTask)
 {
     Console.WriteLine("Received CompletedTask: {0}, with message [{1}].", completedTask.Id, ByteUtilities.ByteArraysToString(completedTask.Message));
 }
Пример #4
0
        /// <summary>
        /// Convert bytes which contains Json string into AvroHttpRequest object
        /// </summary>
        /// <param name="serializedBytes">The serialized bytes.</param>
        /// <returns>AvroHttpRequest.</returns>
        public static AvroHttpRequest FromBytesWithJson(byte[] serializedBytes)
        {
            string s = ByteUtilities.ByteArraysToString(serializedBytes);

            return(FromJson(s));
        }
Пример #5
0
 public override string ToString()
 {
     return("DriverMessage [value=" + ByteUtilities.ByteArraysToString(_value.Value) + "]");
 }
Пример #6
0
 public void OnNext(byte[] value)
 {
     LOGGER.Log(Level.Info, "Received message: " + ByteUtilities.ByteArraysToString(value));
 }
Пример #7
0
 /// <summary>
 /// helper function mostly used for logging
 /// </summary>
 /// <returns>seralized string</returns>
 public override string ToString()
 {
     return(ByteUtilities.ByteArraysToString(new ProcessedResultsCodec().Encode(this)));
 }
Пример #8
0
        public void OnNext(IRemoteMessage <REEFMessage> value)
        {
            REEFMessage       remoteEvent = value.Message;
            IRemoteIdentifier id          = value.Identifier;

            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "receive a ReefMessage from {0} Driver at {1}.", remoteEvent, id));

            if (remoteEvent.evaluatorControl != null)
            {
                if (remoteEvent.evaluatorControl.context_control != null)
                {
                    string context_message = null;
                    string task_message    = null;

                    if (remoteEvent.evaluatorControl.context_control.context_message != null)
                    {
                        context_message = remoteEvent.evaluatorControl.context_control.context_message.ToString();
                    }
                    if (remoteEvent.evaluatorControl.context_control.task_message != null)
                    {
                        task_message = ByteUtilities.ByteArraysToString(remoteEvent.evaluatorControl.context_control.task_message);
                    }

                    if (!(string.IsNullOrEmpty(context_message) && string.IsNullOrEmpty(task_message)))
                    {
                        LOGGER.Log(Level.Info,
                                   string.Format(CultureInfo.InvariantCulture, "Control protobuf with context message [{0}] and task message [{1}]", context_message, task_message));
                    }
                    else if (remoteEvent.evaluatorControl.context_control.remove_context != null)
                    {
                        LOGGER.Log(Level.Info,
                                   string.Format(CultureInfo.InvariantCulture, "Control protobuf to remove context {0}", remoteEvent.evaluatorControl.context_control.remove_context.context_id));
                    }
                    else if (remoteEvent.evaluatorControl.context_control.add_context != null)
                    {
                        LOGGER.Log(Level.Info,
                                   string.Format(CultureInfo.InvariantCulture, "Control protobuf to add a context on top of {0}", remoteEvent.evaluatorControl.context_control.add_context.parent_context_id));
                    }
                    else if (remoteEvent.evaluatorControl.context_control.start_task != null)
                    {
                        LOGGER.Log(Level.Info,
                                   string.Format(CultureInfo.InvariantCulture, "Control protobuf to start an task in {0}", remoteEvent.evaluatorControl.context_control.start_task.context_id));
                    }
                    else if (remoteEvent.evaluatorControl.context_control.stop_task != null)
                    {
                        LOGGER.Log(Level.Info, "Control protobuf to stop task");
                    }
                    else if (remoteEvent.evaluatorControl.context_control.suspend_task != null)
                    {
                        LOGGER.Log(Level.Info, "Control protobuf to suspend task");
                    }
                }
            }
            if (_count == 0)
            {
                _begin     = DateTime.Now;
                _origBegin = _begin;
            }
            var count = Interlocked.Increment(ref _count);

            int printBatchSize = 100000;

            if (count % printBatchSize == 0)
            {
                DateTime end             = DateTime.Now;
                var      diff            = (end - _begin).TotalMilliseconds;
                double   seconds         = diff / 1000.0;
                long     eventsPerSecond = (long)(printBatchSize / seconds);
                _begin = DateTime.Now;
            }

            var observer = _observer;

            if (observer != null)
            {
                observer.OnNext(value);
            }
        }
Пример #9
0
 private void Check()
 {
     if (_result.IsPresent() && _lastException.IsPresent())
     {
         LOGGER.Log(Level.Warning, "Both task result and exception are present, the expcetion will take over. Thrown away result:" + ByteUtilities.ByteArraysToString(_result.Value));
         State   = TaskState.Failed;
         _result = Optional <byte[]> .Empty();
     }
 }