On Thu, Aug 30, 2012 at 8:45 AM, Andun Sameera <an...@wso2.com> wrote:

> Hi,
>
> I have tried int the way which Dushan explained. So I have change my proxy
> config like this,
>
> <proxy name="failoverEndPoint_Specific_Errors"
>           transports="http https"
>           startOnLoad="true">
>       <target>
>          <inSequence>
>             <send>
>                <endpoint>
>                   <failover>
>                      <endpoint name="9001 Server">
>                         <address uri="
> http://localhost:9001/services/LBService1";>
>                            <timeout>
>                               <duration>2000</duration>
>                            </timeout>
>                            <suspendOnFailure>
>                               <initialDuration>60000</initialDuration>
>                               <progressionFactor>2.0</progressionFactor>
>                            </suspendOnFailure>
>                            <markForSuspension>
>
> <errorCodes>101000,101500,101501,101503,101505,101506,101507,101509</errorCodes>
>
> <retriesBeforeSuspension>3</retriesBeforeSuspension>
>                            </markForSuspension>
>                          </address>
>                      </endpoint>
>                      <endpoint name="9002 Server">
>                         <address uri="
> http://localhost:9002/services/LBService1"/>
>                       </endpoint>
>                   </failover>
>                </endpoint>
>             </send>
>          </inSequence>
>          <outSequence>
>             <send/>
>          </outSequence>
>       </target>
>    </proxy>
>
> Here the endpoint "9001 Server" is marked for suspension for all the error
> codes but the 101504. Target of doing that is to verify that the endpoint
> will go to suspend state only if 101504 happens. But my argument is wrong.
> Because Let say if I generate 101505, then  "9001 Server" will be timeout.
> But Failover will retry same "9001 Server" for three times again. Because
> it is marked as timeout and eligible for send a message. After three
> retires "9001 Server" will be suspended. So my argument of "The endpoint
> will go to suspend state only if 101504 happens" is wrong.
>

Why don't you alter you test? If it fails immediately, then you know it's
due to a 101504 immediate suspension. If it takes >= 3 errors to fail then
it's some other error.

Thanks,
Hiranya


>
> So Is there a way to verify that the failover logic is working fine for
> specific error codes?
>
> Thanks
> AndunSLG
>
>
> On Wed, Aug 29, 2012 at 10:14 PM, Dushan Abeyruwan <dus...@wso2.com>wrote:
>
>> Hi
>>
>>  AFAIU, the failover logic is working as follows, In your endpoint if its
>> defines as
>>                                     <timeout>
>>                                         <duration>2000</duration>
>>                                     </timeout>
>>
>>                                     <markForSuspension>
>>
>> <errorCodes>101504,101508</errorCodes>
>>
>> <retriesBeforeSuspension>0</retriesBeforeSuspension>
>>                                         <retryDelay>0</retryDelay>
>>                                     </markForSuspension>
>>
>>             based on 101504,101508 errocodes always the endpoint will get
>> marked as TIMEOUT and it wont try  and IF the endpoints are failover then
>> the FAILOVER will be invoked the next NONSUSPENDED endpoint.. actually the
>> point you need to Note that the FAILOVER will be working only
>> for 101504,101508,(according to your current configuration) so In your case
>> let say need to invoke next NONSUSPNEDED endpoint when CONNECTION CLOSED.(
>> *101505)*. then you should include that in MarkForSuspence, so please
>> try with following
>>
>>                                 <markForSuspension>
>>                                         <errorCodes>101504,101508,*101505
>> *</errorCodes>
>>
>> <retriesBeforeSuspension>0</retriesBeforeSuspension>
>>                                         <retryDelay>0</retryDelay>
>>                                     </markForSuspension>
>>
>>          so what will happen now the IF BE is closed then the EP will be
>> marked as TIMEOUT for 101504,101508,*101505 then as I
>> explained earlier it will invoke next active NONSUSPNEDED endpoint,*
>> *                    *
>> *   *        Persoally i havent try this out but if looking
>> http://wso2.org/library/articles/wso2-enterprise-service-bus-endpoint-error-handling
>> the logic is clearly explained please give more attention to
>> the highlighted text
>>
>> e.g
>>
>> <endpoint name="SampleFailover">
>>     <failover>
>>         <endpoint name="Sample_First" statistics="enable" >
>>             <address uri="http://localhost/myendpoint"; statistics="enable" 
>> trace="disable">
>>                 <timeout>
>>                     <duration>60000</duration>
>>                 </timeout>
>>
>>                 <markForSuspension>
>>                     <errorCodes>101504, 101505, 101500</errorCodes>
>>                     <retriesBeforeSuspension>3</retriesBeforeSuspension>
>>                     <retryDelay>1</retryDelay>
>>                 </markForSuspension>
>>
>>                 <suspendOnFailure>
>>                     <initialDuration>1000</initialDuration>
>>                     <progressionFactor>2</progressionFactor>
>>                     <maximumDuration>64000</maximumDuration>
>>                 </suspendOnFailure>
>>
>>             </address>
>>         </endpoint>
>>     </failover>
>> </endpoint>
>>
>>
>> "Here the Sample_First endpoint is marked as *TIMEOUT if a connection runs 
>> out of time, a connection close or sends IO errors. For all the other 
>> errors*, it will be marked as suspended. *When this error occurs the fail 
>> over will retry using the first non SUSPENDED endpoint.* In this case, it is 
>> the same endpoint (Sample_First). It will retry until the retry count 
>> becomes 0. The retry happens in parrellel. Since messages do come to this 
>> endpoint using many threads, the same message may not be retired 3 times. 
>> Another message may fail and can reduce the retry count. So it is important 
>> to note that the retry count is not a per message based setting, it is a per 
>> endpoint based setting."
>>
>>
>>
>> cheers
>> Dushan
>>
>>
>>
>> On Wed, Aug 29, 2012 at 7:57 PM, Andun Sameera <an...@wso2.com> wrote:
>>
>>> Hi All,
>>>
>>> I am trying to check the functionality of the Fail Over Endpoint. I want
>>> to verify that the failover logic is happening to specific error codes. I
>>> used  proxy given below for that,
>>>
>>> According to 
>>> [1]<http://wso2.org/library/articles/wso2-enterprise-service-bus-endpoint-error-handling>,
>>> error code 101504,101508 for timeouts. So I used following test case
>>> to produce the scenario,
>>>
>>> My logic was this,
>>>
>>>    1. Send a request to proxy to check it is functioning.
>>>    2. Shutdown http://localhost:9001 server.
>>>    3. Then send Send a request to proxy again. So the first endpoint
>>>    should be failed. But it cant be suspend. Because it is only suspending 
>>> for
>>>    timeouts.
>>>    4. Response should come from second server.
>>>    5. Then Start the http://localhost:9001 server.
>>>    6. Then send Send a request to proxy again. Response should come
>>>    from server1. Because it is not suspended.( I am trying this with in the
>>>    suspend time period of 9001-server endpoint, so if is suspended, response
>>>    should come from server2)
>>>
>>> But when I tried this, in the 3rd step of the logic
>>> (Red Highlighted line of the code) it fails. The endpoint is suspending for
>>> connection refused created by shutting down the server. According to spec
>>> it cant be. Is this a bug or am I doing something wrong here? Please look
>>> at this ASAP we need this to wind up Test Automation Hackathon tomorrow.
>>>
>>> Thanks
>>> AndunSLG
>>>
>>> [1] -
>>> http://wso2.org/library/articles/wso2-enterprise-service-bus-endpoint-error-handling
>>>
>>> Proxy Service :
>>>
>>> <proxy name="failoverEndPoint_Specific_Errors" transports="http,https">
>>>         <target>
>>>             <inSequence>
>>>                 <send>
>>>                     <endpoint>
>>>                         <failover>
>>>                             <endpoint name="9001 Server">
>>>                                 <address uri="
>>> http://localhost:9001/services/LBService1";>
>>>                                     <timeout>
>>>                                         <duration>2000</duration>
>>>                                     </timeout>
>>>
>>>                                     <markForSuspension>
>>>
>>> <errorCodes>101504,101508</errorCodes>
>>>
>>> <retriesBeforeSuspension>0</retriesBeforeSuspension>
>>>                                         <retryDelay>0</retryDelay>
>>>                                     </markForSuspension>
>>>
>>>                                     <suspendOnFailure>
>>>
>>> <initialDuration>60000</initialDuration>
>>>
>>> <progressionFactor>2</progressionFactor>
>>>                                     </suspendOnFailure>
>>>                                 </address>
>>>                             </endpoint>
>>>                             <endpoint name="9002 Server">
>>>                                 <address uri="
>>> http://localhost:9002/services/LBService1";>
>>>                                     <timeout>
>>>                                         <duration>2000</duration>
>>>                                     </timeout>
>>>
>>>                                     <markForSuspension>
>>>                                         <errorCodes>101509</errorCodes>
>>>
>>> <retriesBeforeSuspension>0</retriesBeforeSuspension>
>>>                                         <retryDelay>0</retryDelay>
>>>                                     </markForSuspension>
>>>
>>>                                     <suspendOnFailure>
>>>
>>> <initialDuration>60000</initialDuration>
>>>
>>> <progressionFactor>2</progressionFactor>
>>>                                     </suspendOnFailure>
>>>                                 </address>
>>>                             </endpoint>
>>>                         </failover>
>>>                     </endpoint>
>>>                 </send>
>>>             </inSequence>
>>>             <outSequence>
>>>                 <send/>
>>>             </outSequence>
>>>         </target>
>>>     </proxy>
>>>
>>> Test Case :
>>>
>>> @Test(groups = "wso2.esb", description = "Test sending request to Fail
>>> Over Endpoint which Suspend Endpoints to Specific Errors")
>>>     public void testSendingFailOverEndpoint_With_Specific_Errors()
>>> throws IOException, InterruptedException {
>>>         //Check the fail over endpoint is functioning well
>>>         String response =
>>> lbClient.sendLoadBalanceRequest(getProxyServiceURL("failoverEndPoint_Specific_Errors"),
>>>                 null);
>>>         Assert.assertNotNull(response);
>>>         Assert.assertTrue(response.toString().contains("Response from
>>> server: Server_1"));
>>>
>>>         //Stop one server to generate a failure in one endpoint
>>>         //But the suspend cant be triggered here. because suspend the
>>> endpoint happen only for Timeouts 101504,101508
>>>         axis2Server1.stop();
>>>
>>>         response =
>>> lbClient.sendLoadBalanceRequest(getProxyServiceURL("failoverEndPoint_Specific_Errors"),
>>>                 null);
>>>         Assert.assertNotNull(response);
>>>         Assert.assertTrue(response.toString().contains("Response from
>>> server: Server_2"));
>>>
>>>         axis2Server1.start();
>>>
>>>         int counter=0;
>>>         while(!AxisServiceClientUtils.isServiceAvailable("
>>> http://localhost:9001/services/LBService1";)) {
>>>             if(counter>100){
>>>                 break;
>>>             }
>>>             counter++;
>>>         }
>>>
>>>         if(counter>100){
>>>             throw new AssertionError("Axis2 Server didn't started with
>>> in expected time period.") ;
>>>         }
>>>         else{
>>>             //Checaxiaxis2Server1.start()s2Server1.stop()k that the
>>> endpoint one is not suspended.
>>>             //If reply comes that means not suspended.
>>>             //Because suspend duration of the endpoint is 20 seconds. So
>>> reply cant come in this time.
>>>             response =
>>> lbClient.sendLoadBalanceRequest(getProxyServiceURL("failoverEndPoint_Specific_Errors"),
>>>                     null);
>>>             Assert.assertNotNull(response);
>>>             Assert.assertTrue(response.toString().contains("Response
>>> from server: Server_1"));
>>>
>>>             //Invoke a web service method which will invoke a time out
>>> and cause the endpoint to suspend.
>>>             response =
>>> lbClient.sendSleepRequest(getProxyServiceURL("failoverEndPoint_Specific_Errors"),"4000");
>>>             Assert.assertNotNull(response);
>>>             Assert.assertTrue(response.toString().contains("Response
>>> from server: Server_2"));
>>>
>>>             //Invoke a web service method which will invoke a time out
>>> and cause the endpoint to suspend.
>>>             response =
>>> lbClient.sendLoadBalanceRequest(getProxyServiceURL("failoverEndPoint_Specific_Errors"),
>>>                     null);
>>>             Assert.assertNotNull(response);
>>>             Assert.assertTrue(response.toString().contains("Response
>>> from server: Server_2"));
>>>
>>>         }
>>>     }
>>>
>>>
>>
>>
>> --
>> Dushan Abeyruwan
>> *Senior Software Engineer*
>> *Integration Technologies Team*
>> *WSO2 Inc. http://wso2.com/*
>> *Mobile:(+94)714408632*
>>
>>
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Hiranya Jayathilaka
Associate Technical Lead;
WSO2 Inc.;  http://wso2.org
E-mail: hira...@wso2.com;  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to