Beispiel #1
0
 public ErrorMessage(short?messageId, short?askId, ErrorType type, string additionalExceptionInformation)
 {
     this.MessageId = messageId;
     this.AskId     = askId;
     ErrorType      = type;
     Exception      = RemoteException.Create(type, additionalExceptionInformation, messageId, askId);
 }
Beispiel #2
0
        public async Task SendMessage(string id, [FromQueryAttribute] string message)
        {
            RemoteException ex = new RemoteException(1, "Unknown");
            await _notificationsMessageHandler.InvokeClientMethodToAllAsync("receiveMessage", ex, ex);

            await _notificationsMessageHandler.InvokeClientMethodToAllAsync("receiveMessage", message, ex);

            await _notificationsMessageHandler.InvokeClientMethodToAllAsync("receiveMessage", message);

            await _notificationsMessageHandler.InvokeClientMethodToAllAsync("receiveMessage", ex);

            await _notificationsMessageHandler.InvokeClientMethodOnlyAsync(id, "receiveMessage", message, ex);

            await _notificationsMessageHandler.SendClientResultAsync(id, "receiveResult", ex);

            await _notificationsMessageHandler.SendClientErrorAsync(id, "receiveError", ex);

            await _notificationsMessageHandler.SendClientNotifyAsync(id, "receiveNotify", ex);

            await _notificationsMessageHandler.SendAllNotifyAsync("receiveAllNotify", ex);

            //object[] objs = new object[1];
            //objs[0] = ex;
            //var t =  _notificationsMessageHandler.InvokeClientMethodAsync<RemoteException>(id, "waitMessage", objs);
        }
Beispiel #3
0
        public static void ShowRemoteException(RemoteException exception)
        {
            var remote = exception.Remote;

            ConsoleUtils.Error("Remote error " + exception.ToMessageWithType());
            ShowRemoteExceptionData(remote, 2);
        }
        public void Constructors()
        {
            _ = new RemoteException();
            _ = new RemoteException("exception");
            _ = new RemoteException("exception", new Exception("bang"));
            _ = new RemoteException(RemoteError.Undefined, true);
            _ = new RemoteException(RemoteError.Undefined, "exception");
            _ = new RemoteException(RemoteError.Undefined, "exception", true);
            _ = new RemoteException(RemoteError.Undefined, new Exception("bang"));
            _ = new RemoteException(RemoteError.Undefined, "exception", new Exception("bang"));
            _ = new RemoteException(RemoteError.Undefined, new Exception("bang"), true);
            var e = new RemoteException(RemoteError.AccessControl, "exception", new Exception("bang"), true);

            Assert.That(e.Message, Is.EqualTo("exception"));
            Assert.That(e.InnerException, Is.Not.Null);
            Assert.That(e.InnerException.Message, Is.EqualTo("bang"));
            Assert.That(e.Retryable, Is.True);
            Assert.That(e.Error, Is.EqualTo(RemoteError.AccessControl));

            e = e.SerializeAndDeSerialize();

            Assert.That(e.Message, Is.EqualTo("exception"));
            Assert.That(e.InnerException, Is.Not.Null);
            Assert.That(e.InnerException.Message, Is.EqualTo("bang"));
            Assert.That(e.Retryable, Is.True);
            Assert.That(e.Error, Is.EqualTo(RemoteError.AccessControl));

            Assert.Throws <ArgumentNullException>(() => e.GetObjectData(default !, default));
Beispiel #5
0
        private ErrorRecord GetErrorFromRemoteCommand(string commandName, RuntimeException runtimeException)
        {
            string       str;
            ErrorDetails errorDetails;

            if (string.IsNullOrEmpty(commandName))
            {
                throw PSTraceSource.NewArgumentNullException("commandName");
            }
            if (runtimeException == null)
            {
                throw PSTraceSource.NewArgumentNullException("runtimeException");
            }
            RemoteException exception = runtimeException as RemoteException;

            if (((exception != null) && (exception.SerializedRemoteException != null)) && Deserializer.IsInstanceOfType(exception.SerializedRemoteException, typeof(CommandNotFoundException)))
            {
                str          = "ErrorRequiredRemoteCommandNotFound";
                errorDetails = this.GetErrorDetails(str, new object[] { base.MyInvocation.MyCommand.Name });
                return(new ErrorRecord(new RuntimeException(errorDetails.Message, runtimeException), str, ErrorCategory.ObjectNotFound, null)
                {
                    ErrorDetails = errorDetails
                });
            }
            str          = "ErrorFromRemoteCommand";
            errorDetails = this.GetErrorDetails(str, new object[] { "Get-Command", runtimeException.Message });
            return(new ErrorRecord(new RuntimeException(errorDetails.Message, runtimeException), str, ErrorCategory.InvalidResult, null)
            {
                ErrorDetails = errorDetails
            });
        }
Beispiel #6
0
        public byte[] Compile(string sourceCode)
        {
            using (var peStream = new MemoryStream())
            {
                var result = GenerateCode(sourceCode, this.name, this.references).Emit(peStream);

                if (!result.Success)
                {
                    StringBuilder stringBuilder = new StringBuilder("Compilation errors: ");
                    var           failures      = result.Diagnostics.Where(diagnostic => diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error);
                    foreach (var diagnostic in failures)
                    {
                        //Console.Error.WriteLine("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
                        stringBuilder.AppendLine(diagnostic.Id.ToString() + ". " + diagnostic.GetMessage());
                    }

                    var ex = new RemoteException(stringBuilder.ToString());
                    ex.Code = "COMPILATION_ERROR";
                    throw ex;
                }

                //Console.WriteConsole.WriteLine("Compilation done without any error.");
                peStream.Seek(0, SeekOrigin.Begin);
                return(peStream.ToArray());
            }
        }
Beispiel #7
0
        public async Task <IServiceRemotingResponseMessage> RequestResponseAsync(
            IServiceRemotingRequestMessage remotingRequestRequestMessage)
        {
            var interfaceId      = remotingRequestRequestMessage.GetHeader().InterfaceId;
            var serializedHeader = this.serializersManager.GetHeaderSerializer()
                                   .SerializeRequestHeader(remotingRequestRequestMessage.GetHeader());
            var msgBodySeriaizer           = this.serializersManager.GetRequestBodySerializer(interfaceId);
            var serializedMsgBody          = msgBodySeriaizer.Serialize(remotingRequestRequestMessage.GetBody());
            var fabricTransportRequestBody = serializedMsgBody != null
                ? new FabricTransportRequestBody(serializedMsgBody.GetSendBuffers(),
                                                 serializedMsgBody.Dispose)
                : new FabricTransportRequestBody(new List <ArraySegment <byte> >(), null);


            //Send Request
            using (var retval = await this.fabricTransportClient.RequestResponseAsync(
                       new FabricTransportMessage(
                           new FabricTransportRequestHeader(serializedHeader.GetSendBuffer(), serializedHeader.Dispose),
                           fabricTransportRequestBody),
                       this.fabricTransportClient.Settings.OperationTimeout))
            {
                var incomingHeader = (retval != null && retval.GetHeader() != null)
                    ? new IncomingMessageHeader(retval.GetHeader().GetRecievedStream())
                    : null;

                ////DeSerialize Response
                var header =
                    this.serializersManager.GetHeaderSerializer()
                    .DeserializeResponseHeaders(
                        incomingHeader);

                byte[] headerValue;
                if (header != null && header.TryGetHeaderValue("HasRemoteException", out headerValue))
                {
                    Exception e;
                    var       isDeserialzied =
                        RemoteException.ToException(retval.GetBody().GetRecievedStream(),
                                                    out e);
                    if (isDeserialzied)
                    {
                        throw new AggregateException(e);
                    }
                    else
                    {
                        throw new ServiceException(e.GetType().FullName, string.Format(
                                                       CultureInfo.InvariantCulture,
                                                       Remoting.SR.ErrorDeserializationFailure,
                                                       e.ToString()));
                    }
                }
                var responseSerializer = this.serializersManager.GetResponseBodySerializer(interfaceId);
                var incomingMsgBody    = (retval != null && retval.GetBody() != null)
                    ? new IncomingMessageBody(retval.GetBody().GetRecievedStream())
                    : null;
                var msgBody =
                    responseSerializer.Deserialize(incomingMsgBody);
                return((IServiceRemotingResponseMessage) new ServiceRemotingResponseMessage(header, msgBody));
            }
        }
Beispiel #8
0
        public void RemoteException_Constructor_MessageArgument_Valid()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing the constructor with no custom logic.
            var ex = new RemoteException("test");

            Assert.AreEqual("test", ex.Message);
            Assert.IsNull(ex.InnerException);
        }
Beispiel #9
0
        public void DemoException_Constructor_MessageArgument_Null()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing the constructor with no custom logic.
            var ex = new RemoteException(null);

            Assert.AreEqual("Exception of type 'Rightpoint.UnitTesting.Demo.Mvc.Exceptions.RemoteException' was thrown.", ex.Message);
            Assert.IsNull(ex.InnerException);
        }
 public object Run()
 {
     try
     {
         try
         {
             byte[] tmppw = TestDelegationTokensWithHA.dtSecretManager.RetrievePassword(identifier
                                                                                        );
             NUnit.Framework.Assert.Fail("InvalidToken with cause StandbyException is expected"
                                         + " since nn0 is standby");
             return(tmppw);
         }
         catch (IOException e)
         {
             // Mimic the UserProvider class logic (server side) by throwing
             // SecurityException here
             throw new SecurityException(SecurityUtil.FailedToGetUgiMsgHeader + " " + e, e);
         }
     }
     catch (Exception oe)
     {
         //
         // The exception oe caught here is
         //     java.lang.SecurityException: Failed to obtain user group
         //     information: org.apache.hadoop.security.token.
         //     SecretManager$InvalidToken: StandbyException
         //
         HttpServletResponse response = Org.Mockito.Mockito.Mock <HttpServletResponse>();
         ExceptionHandler    eh       = new ExceptionHandler();
         eh.InitResponse(response);
         // The Response (resp) below is what the server will send to client
         //
         // BEFORE HDFS-6475 fix, the resp.entity is
         //     {"RemoteException":{"exception":"SecurityException",
         //      "javaClassName":"java.lang.SecurityException",
         //      "message":"Failed to obtain user group information:
         //      org.apache.hadoop.security.token.SecretManager$InvalidToken:
         //        StandbyException"}}
         // AFTER the fix, the resp.entity is
         //     {"RemoteException":{"exception":"StandbyException",
         //      "javaClassName":"org.apache.hadoop.ipc.StandbyException",
         //      "message":"Operation category READ is not supported in
         //       state standby"}}
         //
         Response resp = eh.ToResponse(oe);
         // Mimic the client side logic by parsing the response from server
         //
         IDictionary <object, object> m = (IDictionary <object, object>)JSON.Parse(resp.GetEntity
                                                                                       ().ToString());
         RemoteException re        = JsonUtil.ToRemoteException(m);
         Exception       unwrapped = ((RemoteException)re).UnwrapRemoteException(typeof(StandbyException
                                                                                        ));
         NUnit.Framework.Assert.IsTrue(unwrapped is StandbyException);
         return(null);
     }
 }
Beispiel #11
0
        // Token: 0x060010CA RID: 4298 RVA: 0x00033B8C File Offset: 0x00031D8C
        private ErrorRecord ResolveErrorRecord(ErrorRecord errorRecord)
        {
            RemoteException ex = errorRecord.Exception as RemoteException;

            if (ex != null)
            {
                return(new ErrorRecord(MonadCommand.DeserializeException(ex), errorRecord.FullyQualifiedErrorId, errorRecord.CategoryInfo.Category, errorRecord.TargetObject));
            }
            return(errorRecord);
        }
Beispiel #12
0
        internal static Exception DeserializeException(Exception ex)
        {
            RemoteException ex2 = ex as RemoteException;

            if (ex2 != null && MonadCommand.CanDeserialize(ex2.SerializedRemoteException))
            {
                return((MonadCommand.Deserialize(ex2.SerializedRemoteException) as Exception) ?? ex);
            }
            return(ex);
        }
        public void TC001_OnlyMessage()
        {
            //Arrange
            string message = "this is a message";

            //Act
            RemoteException remoteException = new RemoteException(message);

            //Assert
            Assert.IsFalse(string.IsNullOrEmpty(remoteException.Backtrace));
        }
Beispiel #14
0
        public void RemoteException_Constructor_MessageAndInnerExArgument_EmptyMessage()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing the constructor with no custom logic.
            var ex = new RemoteException(string.Empty, new Exception("Inner"));

            Assert.AreEqual(string.Empty, ex.Message);
            Assert.IsNotNull(ex.InnerException);
            Assert.AreEqual("Inner", ex.InnerException.Message);
            Assert.IsNull(ex.InnerException.InnerException);
        }
Beispiel #15
0
        private static void DefaultThrowIcfExceptionImplementation(Exception e, ErrorRecord error, string message)
        {
            LOG.Info(e, "DefaultThrowIcfExceptionImplementation dealing with Exception, message = {1}", message);


            if (error.CategoryInfo != null)
            {
                // TODO is this really correct? It is not sure that the object in question is really missing (although it's quite probable).
                String reason = error.CategoryInfo.Reason;
                if ("ManagementObjectNotFoundException".Equals(reason))
                {
                    throw new ObjectNotFoundException(message);
                }
                else if ("DuplicateAcceptedDomainException".Equals(reason) ||
                         "ADObjectAlreadyExistsException".Equals(reason))
                {
                    throw new AlreadyExistsException(message, e);
                }
                else if ("ProxyAddressExistsException".Equals(reason))
                {
                    throw new ProxyAddressExistsException(message, e);
                }
            }

            if (e == null)
            {
                throw new ConnectorException(message);
            }
            if (e is RemoteException)
            {
                RemoteException remote     = (RemoteException)e;
                PSObject        serialized = remote.SerializedRemoteException;
                if (serialized != null && serialized.BaseObject is Exception)
                {
                    DefaultThrowIcfExceptionImplementation((Exception)serialized.BaseObject, error, message);
                }
                else
                {
                    throw new ConnectorException("Remote exception: " + message, e);
                }
            }
            string name = e.GetType().Name;

            switch (name)
            {
            // not sure if these cases are covered by reason checking above ... to be sure, include them also here (for now)
            case "DuplicateAcceptedDomainException":
            case "ADObjectAlreadyExistsException":
                throw new AlreadyExistsException(message, e);

            default:
                throw new ConnectorException(message, e);
            }
        }
Beispiel #16
0
            public async Task <ResponseMessage> RequestResponseAsync(ArraySegment <byte> messageHeaders,
                                                                     IEnumerable <ArraySegment <byte> > requestBody)
            {
                IMessageBody   outgoingMessageBody   = null;
                IMessageHeader outgoingMessageHeader = null;

                try
                {
                    var headerSerializer   = this.serializersManager.GetHeaderSerializer();
                    var deSerializedHeader =
                        headerSerializer.DeserializeRequestHeaders(
                            new IncomingMessageHeader(new SegmentedReadMemoryStream(messageHeaders)));

                    var msgBodySerializer =
                        this.serializersManager.GetRequestBodySerializer(deSerializedHeader.InterfaceId);
                    var deserializedMsg =
                        msgBodySerializer.Deserialize(
                            new IncomingMessageBody(new SegmentedReadMemoryStream(requestBody)));

                    var msg    = new ServiceRemotingRequestMessage(deSerializedHeader, deserializedMsg);
                    var retval = await
                                 this.messageHandler.HandleRequestResponseAsync(
                        this.requestContext,
                        msg);

                    if (retval == null)
                    {
                        return(new ResponseMessage());
                    }

                    outgoingMessageHeader = headerSerializer.SerializeResponseHeader(retval.GetHeader());

                    var responseSerializer =
                        this.serializersManager.GetResponseBodySerializer(deSerializedHeader.InterfaceId);

                    outgoingMessageBody = responseSerializer.Serialize(retval.GetBody());

                    var responseMessage = new ResponseMessage();
                    responseMessage.ResponseBody = outgoingMessageBody != null
                        ? outgoingMessageBody.GetSendBuffers()
                        : new List <ArraySegment <byte> >();

                    responseMessage.MessageHeaders = outgoingMessageHeader != null
                        ? outgoingMessageHeader.GetSendBuffer()
                        : new ArraySegment <byte>();

                    return(responseMessage);
                }
                catch (Exception e)
                {
                    ServiceTrace.Source.WriteInfo("WcfRemotingService", "Remote Exception occured {0}", e);
                    throw new FaultException <RemoteException>(RemoteException.FromException(e), e.Message);
                }
            }
        public void TC003_TestStatic()
        {
            //Arrange
            string    message   = "my special exception";
            Exception exception = new Exception(message);

            //Act
            RemoteException remoteException = RemoteException.CreateRemoteException(exception);

            //Assert
            Assert.AreEqual(message, remoteException.Message);
        }
Beispiel #18
0
 /// <summary>
 ///     Sends response to the remote application that invoked a service method.
 /// </summary>
 /// <param name="requestMessage">Request message</param>
 /// <param name="returnValue">Return value to send</param>
 /// <param name="exception">Exception to send</param>
 private void SendInvokeResponse(IMessage requestMessage, object returnValue, RemoteException exception)
 {
     try {
         _requestReplyMessenger.SendMessage(
             new RemoteInvokeReturnMessage {
             RepliedId       = requestMessage.Id,
             ReturnValue     = returnValue,
             RemoteException = exception
         });
     } catch {
     }
 }
Beispiel #19
0
 /// <exception cref="Org.Xml.Sax.SAXException"/>
 public override void StartElement(string ns, string localname, string qname, Attributes
                                   attrs)
 {
     if (!typeof(ContentSummary).FullName.Equals(qname))
     {
         if (typeof(RemoteException).Name.Equals(qname))
         {
             throw new SAXException(RemoteException.ValueOf(attrs));
         }
         throw new SAXException("Unrecognized entry: " + qname);
     }
     this.contentsummary = HftpFileSystem.ToContentSummary(attrs);
 }
Beispiel #20
0
 /// <exception cref="Org.Xml.Sax.SAXException"/>
 public override void StartElement(string ns, string localname, string qname, Attributes
                                   attrs)
 {
     if (!typeof(MD5MD5CRC32FileChecksum).FullName.Equals(qname))
     {
         if (typeof(RemoteException).Name.Equals(qname))
         {
             throw new SAXException(RemoteException.ValueOf(attrs));
         }
         throw new SAXException("Unrecognized entry: " + qname);
     }
     this.filechecksum = MD5MD5CRC32FileChecksum.ValueOf(attrs);
 }
Beispiel #21
0
        private FabricTransportMessage CreateFabricTransportExceptionMessage(Exception ex)
        {
            var header = new ServiceRemotingResponseMessageHeader();

            header.AddHeader("HasRemoteException", new byte[0]);
            var serializedHeader = this.serializersManager.GetHeaderSerializer().SerializeResponseHeader(header);
            var serializedMsg    = RemoteException.FromException(ex);
            var msg = new FabricTransportMessage(
                new FabricTransportRequestHeader(serializedHeader.GetSendBuffer(), serializedHeader.Dispose),
                new FabricTransportRequestBody(serializedMsg.Data, null));

            return(msg);
        }
        protected HttpWebResponse RequestGetResponse(NationBuilderWebRequest req)
        {
            HttpWebResponse response;

            try
            {
                response = (HttpWebResponse)req.GetResponse();
            }
            catch (WebException exc)
            {
                response = (HttpWebResponse)exc.Response;

                if (null == response)
                {
                    throw; // unrecognized exceptions back.
                }

                // Marshall Nation Builder exceptions back:
                switch (response.StatusCode)
                {
                case HttpStatusCode.BadRequest:
                case HttpStatusCode.NotFound:
                    RemoteException exceptionInformation;

                    try {
                        exceptionInformation = DeserializeNationBuilderObject <RemoteException>(response.GetResponseStream());
                    }
                    catch
                    {
                        Stream stream = response.GetResponseStream();

                        stream.Seek(0, SeekOrigin.Begin);
                        using (var reader = new StreamReader(stream, Encoding.UTF8)) {
                            exceptionInformation = new RemoteException()
                            {
                                message           = "Unknown error. See 'error_description' field for the unparsed server response.",
                                error_description = reader.ReadToEnd(),
                            };
                        }
                    }

                    throw new NationBuilderRemoteException(response.StatusCode, exceptionInformation, req, exc);
                }

                // Throw unrecognized exceptions back:
                throw;
            }

            return(response);
        }
Beispiel #23
0
        public async Task CallRpc(string id, string method, [FromBody] string message)
        {
            if (message.Length == 0)
            {
                message = "Unknown";
            }
            RemoteException ex = new RemoteException(1, message);

            object[] objs = new object[1];
            objs[0] = message;
            var t = await _notificationsMessageHandler.InvokeClientMethodAsync <RemoteException>(id, method, objs);

            await Task.CompletedTask;
        }
Beispiel #24
0
        /// <summary>
        /// Create a C# exception that represents an exception that was thrown remotely on a server.
        /// </summary>
        /// <param name="errorHolders">Server errors.</param>
        /// <returns>An exception representing the specified server errors.</returns>
        private static RemoteException CreateException(IEnumerator <ErrorHolder> errorHolders)
        {
            if (errorHolders == null)
            {
                throw new ArgumentNullException(nameof(errorHolders));
            }

            if (!errorHolders.MoveNext())
            {
                return(null);
            }

            var errorHolder = errorHolders.Current;

            if (errorHolder == null)
            {
                return(new RemoteException(RemoteError.Undefined));
            }

            var innerException = CreateException(errorHolders);

            var error = RemoteError.Undefined;

            if (Enum.IsDefined(typeof(RemoteError), errorHolder.ErrorCode))
            {
                error = (RemoteError)errorHolder.ErrorCode;
            }

            var retryable = RetryableExceptions.Contains(error);
            var exception = new RemoteException(error, errorHolder.Message, innerException, retryable);

            var sb    = new StringBuilder();
            var first = true;

            foreach (var stackTraceElement in errorHolder.StackTraceElements)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.AppendLine();
                }
                sb.Append("   ").Append(stackTraceElement);
            }

            exception.Data.Add("server", sb.ToString());
            return(exception);
        }
Beispiel #25
0
 private Task RespondError(IInboundMessageEvent <RmiRequestDto> e, Exception ex)
 {
     if (logger.IsDebugEnabled)
     {
         logger.Debug($"Threw when handling RMI {e.Body.InvocationId.ToString("n").Substring(0, 6)} Request on method {e.Body.MethodName} for service {e.Body.ServiceId.ToString("n").Substring(0, 6)}. Error: {ex}.");
     }
     return(messenger.SendReliableAsync(
                new RmiResponseDto {
         InvocationId = e.Body.InvocationId,
         Outs = new object[0],
         ReturnValue = null,
         Exception = RemoteException.Create(ex, e.Body)
     },
                e.Sender.Identity.Id));
 }
        /// <summary>
        /// 处理远返回的程异常
        /// </summary>
        /// <param name="package">数据包</param>
        private void ProcessRemoteException(JsonPacket package)
        {
            var taskSetter = this.taskSetterTable.Take(package.id);

            if (taskSetter == null)
            {
                return;
            }

            var body      = package.body;
            var message   = body == null ? null : body.ToString();
            var exception = new RemoteException(message);

            taskSetter.SetException(exception);
        }
Beispiel #27
0
        public async Task MissingCallback()
        {
            RemoteException exception = null;

            try
            {
                await _systemClient.MissingCallback(new SystemMessage());
            }
            catch (RemoteException ex)
            {
                exception = ex;
            }
            exception.Message.ShouldBe("Callback contract mismatch. Requested System.IDisposable, but it's UiPath.CoreIpc.Tests.ISystemCallback.");
            exception.Is <ArgumentException>().ShouldBeTrue();
        }
        public void TC002_TestException()
        {
            //Arrange
            string message    = "this is a message";
            string blob       = "blob";
            string stacktrace = "this is a stacktrace";

            //Act
            RemoteException remoteException = new RemoteException(message, stacktrace, blob);

            //Assert
            Assert.AreEqual(message, remoteException.Message);
            Assert.AreEqual(blob, remoteException.Blob);
            Assert.AreEqual(stacktrace, remoteException.Backtrace);
        }
        /// <summary>
        /// 处理远返回的程异常
        /// </summary>
        /// <param name="requestContext">请求上下文</param>
        private void ProcessRemoteException(RequestContext requestContext)
        {
            var taskSetter = this.TaskSetterTable.Take(requestContext.Packet.id);

            if (taskSetter == null)
            {
                return;
            }

            var body      = requestContext.Packet.body;
            var message   = body == null ? null : body.ToString();
            var exception = new RemoteException(message);

            taskSetter.SetException(exception);
        }
Beispiel #30
0
        /// <summary>
        /// 设置Api行为返回的任务异常
        /// </summary>
        /// <param name="taskSetActionTable">任务行为表</param>
        /// <param name="requestContext">请求上下文</param>
        /// <returns></returns>
        public static bool SetApiActionTaskException(TaskSetterTable <long> taskSetActionTable, RequestContext requestContext)
        {
            var taskSetAction = taskSetActionTable.Remove(requestContext.Packet.Id);

            if (taskSetAction == null)
            {
                return(true);
            }

            var exceptionBytes = requestContext.Packet.Body;
            var message        = exceptionBytes == null ? string.Empty : Encoding.UTF8.GetString(exceptionBytes);
            var exception      = new RemoteException(message);

            return(taskSetAction.SetException(exception));
        }
Beispiel #31
0
        /// <summary>
        /// Gets the exception that occured when the given thread was executing.
        /// </summary>
        /// <param name="sc">security credentials to verify if the owner has permission to perform this operation 
        /// (i.e get failed thread exception, which is associated with the ManageOwnApp / ManageAllApps permission)</param>
        /// <param name="ti">ThreadIdentifier of the failed thread</param>
        /// <returns></returns>
        public Exception Owner_GetFailedThreadException(SecurityCredentials sc, ThreadIdentifier ti)
        {
            AuthenticateUser(sc);
            ApplicationAuthorizationCheck(sc, ti.ApplicationId);

            logger.Debug("Getting exception for thread:" + ti.ThreadId);
            Exception newEx = _Applications[ti.ApplicationId][ti.ThreadId].FailedThreadException;

            //wrap the exception
            if ( newEx != null && !(newEx is RemoteException))
                newEx = new RemoteException(newEx.Message, newEx);

            if (newEx != null)
                return new RemoteException(newEx.Message, newEx);
            else
                return null;
            //return _Applications[ti.ApplicationId][ti.ThreadId].FailedThreadException;
        }
        /// <summary>
        /// 处理远返回的程异常
        /// </summary>
        /// <param name="requestContext">请求上下文</param>     
        private void ProcessRemoteException(RequestContext requestContext)
        {
            var taskSetAction = this.TaskSetActionTable.Take(requestContext.Packet.id);
            if (taskSetAction == null)
            {
                return;
            }

            var body = requestContext.Packet.body;
            var message = body == null ? null : body.ToString();
            var exception = new RemoteException(message);
            taskSetAction.SetException(exception);
        }
Beispiel #33
0
        /// <summary>
        /// Connect to an executor which is in dedicated mode.
        /// This method is called by the remote executor using its reference to this manager.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e connect dedicated, which is associated with the ExecuteThread permission)</param>
        /// <param name="executorId">executor id</param>
        /// <param name="executorEP">end point of the executor</param>
        /// <returns>Returns the exception that ocured.</returns>
        public Exception Executor_ConnectDedicatedExecutor(SecurityCredentials sc, string executorId, EndPoint executorEP)
        {
            Exception ret = null;
            try
            {
                logger.Debug("Executor called: ConnectDedicated: Authenticate,EnsurePermission,Connect,Set DedicatedScheduler");
                AuthenticateUser(sc);
                EnsurePermission(sc, Permission.ExecuteThread);

                try
                {
                    _Executors[executorId].ConnectDedicated(executorEP);
                    InternalShared.Instance.DedicatedSchedulerActive.Set();
                }
                catch (ExecutorCommException ece)
                {
                    logger.Error("Couldnt connect back to the supplied executor", ece);
                    throw new ConnectBackException("Couldn't connect back to the supplied Executor", ece);
                }
            }
            catch (Exception ex)
            {
                ret = new RemoteException(ex.Message, ex);
            }

            return ret;
        }
Beispiel #34
0
        /// <summary>
        /// Connect to an executor which is in non-dedicated mode.
        /// This is called by a non-dedicated executor using its reference to this manager.
        /// </summary>
        /// <param name="sc">security credentials to verify if the executor has permission to perform this operation 
        /// (i.e connect non-dedicated, which is associated with the ExecuteThread permission)</param>
        /// <param name="executorId">executor id</param>
        /// Returns the exception that ocured.
        public Exception Executor_ConnectNonDedicatedExecutor(SecurityCredentials sc, string executorId, EndPoint executorEP)
        {
            Exception ret = null;

            try
            {
                logger.Debug("Executor called: ConnectNonDedicated");
                AuthenticateUser(sc);
                EnsurePermission(sc, Permission.ExecuteThread);

                _Executors[executorId].ConnectNonDedicated(executorEP);

                logger.Debug("Connected to executor non-dedicated: " + executorId);
                _Executors[executorId].HeartbeatUpdate(new HeartbeatInfo(0, 0, 0));
            }
            catch (Exception ex)
            {
                ret = new RemoteException(ex.Message, ex);
            }

            return ret;
        }
 protected internal override void OnRemoteException(RemoteException e)
 {
     base.OnRemoteException(e);
     Security.RemoveNonce(mNonce);
 }
 /// <summary>
 /// Called when a remote exception occurs while trying to execute the
 /// <seealso cref="#run()"/> method.  The derived class can override this to
 /// execute exception-handling code. </summary>
 /// <param name="e"> the exception </param>
 protected internal virtual void OnRemoteException(RemoteException e)
 {
     Log.Warn(TAG, "remote billing service crashed");
     mService = null;
 }