feature_1341028.txt

来自「Software Testing Automation Framework (S」· 文本 代码 · 共 1,147 行 · 第 1/3 页

TXT
1,147
字号
Feature ID  : 1341028
Last Updated: 11/02/2005
Title       : Perform interface cycling when connecting to a machine


Description
-----------

Currently, in STAF V3, if an endpoint for a remote machine is 
specified without an interface, STAF attempts to connect to the
endpoint using only the default interface.  To connect to the
endpoint using a different interface, you must specify it.
This feature would add the ability to perform automatic interface
cycling so that if you have an interface configured on the
requesting machine that can be used to connect to the remote machine,
STAF will find it automatically for you.

Since this could significantly lengthen the time it takes to connect
to a remote machine, caching will be added.  That is, if an interface
has been found for an endpoint that works, it will be added to the
interface cycling cache so that next time it will try to connect
using the cached interface first.

This feature will also provide the ability to turn interface cycling
on or off (it will be on by default) and to be able to list the
interface cycling cache and to purge the contents of the cache.


Problem(s) Solved
-----------------

You may not know (or don't care) what interfaces/ports are 
configured for STAF on a remote machine.  You just want to submit
a STAF request to a remote machine and have it connect successfully
(and not get an RC 16).  This feature helps remove the amount of
information you need to have to connect to another STAF machine by
determining the interface to use automatically for you. 


Related Features
----------------

None


External Changes
----------------

1) New Operational Parameters:

SET INTERFACECYCLING <Enabled | Disabled>

INTERFACECYCLING specifies to whether to enable or disable automatic
interface cycling.  The default is to enable interface cycling so
that when an interface is not specified, all of the interfaces will
be used to try to connect to a remote machine instead of just trying
the default interface.  You may also enable or disable automatic
interface cycling dynamically using the MISC service.

2) Changes to the MISC Service:

a) Update the SET request to allow you to dynamically enable or
disable automatic interface cycling.

SET INTERFACECYCLING <Enabled | Disabled>

Requires trust level 5.

b) Update the LIST SETTINGS request to show whether automatic
interface cycling is enabled or disabled.

Add key "interfaceCycling" with description "Interface Cycling"
with possible values "Enabled" or "Disabled" to the
STAF/Service/Misc/Settings map.

c) Add the ability to list the cached endpoints and their
interfaces used for automatic interface cycling.

LIST  ENDPOINTCACHE 

Requires trust level 2 or higher.

The result buffer will contain a marshalled
<Map:/STAF/Service/Misc/EndpointCache> representing the
contents of the endpoint cache used when automatic interface
cycling is enabled.  The map is defined as follows:

Key Name         Display Name Type     Format/Value
---------------- ------------ -------- -------------------
endpoint         Endpoint     <String>
interface        Interface    <String>
createdTimestamp Date-Time    <String> <YYYYMMDD-HH:MM:SS>

Note:  The "Date-Time" value contains the timestamp for when
the entry was added to the endpoint cache.

For example:

Machine                 Interface Date-Time
----------------------- --------- -----------------
client1                 tcp       20051029-09:23:25
client1.austin.ibm.com  tcp       20051028-14:57:15
client2.austin.ibm.com  tcp2      20051028-14:14:32
client3.raleigh.ibm.com tcp       20051027-08:30:21

d) Add the ability to purge one or more (or all) of the endpoints
from the cache used for automatic interface cycling.

PURGE ENDPOINTCACHE <ENDPOINT <Endpoint>... | CONFIRM>

Requires trust level 5.

If successful, the result buffer will contain a marshalled
<Map:STAF/Service/Misc/PurgeStats>, representing the number
of endpoints that were purged and the number of endpoints
remaining in the endpoint cache. The map is defined as follows: 

Key Name     Display Name        Type     Format/Value
------------ ------------------- -------- ------------
numPurged    Purged Endpoints    <String>
numRemaining Remaining Endpoints <String>

For example:

Purged Endpoints   : 2
Remaining Endpoints: 8


Design Considerations
---------------------

1) Would be better to attempt to connect to an interface once and then
   try the other interfaces, and then repeat this loop if still fails
   to connect up to ther maximum number of connection attempts.
   
   Loop up to maxmimum connection attempts with delay between attempts
   {
       Loop through the additional interfaces
       {
           Try to connect...
           return 0 if works
       }
   }

   Currently, the design does it the other way, e.g.:

   Loop through the additional interfaces
   {
       Loop up to maxmimum connection attempts with delay between attempts
       {
           Try to connect...
           return 0 if works
       }
    }

2) Automatic interface cycling can only connect to a remote machine
   if the requesting machine has an interface with a port that is
   configured on the remote machine.  In the future, we could add the
   ability to try connecting to the remote machine via a configurable
   set of ports (by default, port 6500 and 6501) event if interfaces
   for these ports are not configured on the requesting machine.


Backward Compatibility Issues
-----------------------------

- Since automatic interface cycling is enabled by default, a connection
  may now succeed that failed before.  In general this should be a
  "good" thing, but it's possible that it's not in some cases.


Internal Changes
----------------

1) STAFConnectionManager.cpp/h:

   a) Add new methods to enable and disable automatic interface cycling
      and to see if it's enabled or disabled.
   b) Update makeConnection method when the endpoint doesn't not
      specify an interface so that if automatic interface cycling
      is enabled, it will first check if the endpoint is already in
      the endpoint cache and, if so, first try to connect using the
      interface in the cache.  If the endpoint is not in the endpoint
      cache, first try to connect using the default interface.
      Call the new attemptConnection method to make the connection.
      If the connection attempt failed when using a cached interface,
      remove the entry for the endpoint from the cache.
      Return the rc if the connenction attempt worked or if an interface
      was specified in the endpoint, or if automatic interface cycling
      is disabled, since won't try additional interfaces in these cases.
      Otherwise, iterate through any other interfaces (using a list of
      the interfaces in the order they were configured in the STAF.cfg
      file), skipping the interface that was first unsuccessfully 
      attempted and skipping the local interface.  Call the
      attemptConnection method to make the connection.  If the
      connection attempt works, add the endpoint (and the interface
      that worked and the current timestamp) to the endpoint cache and
      return 0. 
   c) Add a new attemptConnection method that attempts to make
      a connection using the specified interface.  This method is
      just like the current makeConnection method except it doesn't
      verify that the connection provider exists (because that now
      being done in the updated makeConnection method.

   Here's a CVS DIFF of the changes:

Index: STAFConnectionManager.cpp
===================================================================
RCS file: /cvsroot/staf/src/staf/stafproc/STAFConnectionManager.cpp,v
retrieving revision 1.13
diff -r1.13 STAFConnectionManager.cpp
19c19
<     /* Do Nothing */
---
>     fAutoInterfaceCycling = true;   // Enable by default
118a119,141
> STAFRC_t STAFConnectionManager::enableAutoInterfaceCycling()
> {
>     STAFMutexSemLock lock(fAutoInterfaceCyclingSem);
>     fAutoInterfaceCycling = true;
>     return kSTAFOk;
> }
> 
> 
> STAFRC_t STAFConnectionManager::disableAutoInterfaceCycling()
> {
>     STAFMutexSemLock lock(fAutoInterfaceCyclingSem);
>     fAutoInterfaceCycling = false;
>     return kSTAFOk;
> }
> 
> 
> bool STAFConnectionManager::getAutoInterfaceCycling()
> {
>     STAFMutexSemLock lock(fAutoInterfaceCyclingSem);
>     return fAutoInterfaceCycling;
> }
> 
> 
143a167,171
>     bool interfaceSpecified = true;
>     bool useCachedEndpoint = false;
> 
>     // Check if an interface was specified in the 'where' value
> 
154a183,275
>     else if (fAutoInterfaceCycling)
>     {
>         interfaceSpecified = false;
> 
>         // If the endpoint is found in the Endpoint Cache Map, assign the
>         // connection provider (aka interface) name cached for the endpoint
> 
>         STAFString interface;
> 
>         if (getCachedInterface(endpoint, connProvName) == kSTAFOk)
>         {
>             useCachedEndpoint = true;
>         }
>     }
> 
>     // Make sure connection provider exists and get the connection provider
> 
>     ConnectionProviderMap::iterator cpIter = fConnProvMap.find(
>         connProvName.toLowerCase());
> 
>     if (cpIter == fConnProvMap.end())
>     {
>         errorBuffer = "No such interface: " + connProvName +
>             ", Endpoint: " + where;
>         return kSTAFNoPathToMachine;
>     }
> 
>     provider = cpIter->second;
> 
>     // Attempt to connect to the endpoint using this connection provider
> 
>     rc = attemptConnection(connProvName, endpoint, provider, connection,
>                            errorBuffer);
> 
>     if (rc == kSTAFOk && !interfaceSpecified && !useCachedEndpoint)
>     {
>         addToEndpointCache(endpoint, connProvName);
>     }
>     else if ((rc != kSTAFOk) && useCachedEndpoint)
>     {
>         removeFromEndpointCache(endpoint);
>     }
> 
>     if (rc == kSTAFOk || interfaceSpecified || !fAutoInterfaceCycling)
>     {
>         // Return because the connection worked or because the connection
>         // failed and an explicit interface was specified or automatic
>         // interface cycling is not enabled
> 
>         return rc;
>     }
> 
>     // Don't overwrite the error message from the first attempt, so that the
>     // rc and error message from the 1st connect attempt are returned if still
>     // can't connect using other connection providers.
> 
>     STAFString errorBuffer2 = "";
>     
>     // Iterate through the remaining connection providers and try to connect
>     // to the endpoint using another connection provider
> 
>     for (STAFConnectionManager::ConnectionProviderList::iterator
>          iter = fConnProvList.begin(); iter != fConnProvList.end(); ++iter)
>     {
>         STAFString interface = (*iter)->getName();
> 
>         if ((interface == connProvName) || (interface == sLocal))
>         {
>             // Skip the connProvName that already we tried and skip the local
>             // connection provider
>             continue;
>         }
>         
>         if (attemptConnection(interface, endpoint, *iter, connection, 
>                               errorBuffer2) == kSTAFOk)
>         {
>             // Connection worked - Add to the endpoint cache and exit
> 
>             addToEndpointCache(endpoint, interface);
>             return kSTAFOk;
>         }
>     }
> 
>     return rc;
> }
> 
> 
> STAFRC_t STAFConnectionManager::attemptConnection(
>     const STAFString &interface, const STAFString &endpoint,
>     STAFConnectionProviderPtr &provider, STAFConnectionPtr &connection,
>     STAFString &errorBuffer)
> {
>     STAFRC_t rc = kSTAFOk;
165,176c286
<             ConnectionProviderMap::iterator iter =
<                 fConnProvMap.find(connProvName.toLowerCase());
< 
<             if (iter == fConnProvMap.end())
<             {
<                 errorBuffer = "No such interface: " + connProvName +
<                     ", Endpoint: " + where;
<                 return kSTAFNoPathToMachine;
<             }
< 
<             provider = iter->second;
<             connection = iter->second->connect(endpoint);
---
>             connection = provider->connect(endpoint);
182c292,293
<                 STAFString(e.getErrorCode()) + ", Endpoint: " + where;
---
>                 STAFString(e.getErrorCode()) + ", Endpoint: " +
>                 interface + gSpecSeparator + endpoint;
216a328,419
> STAFRC_t STAFConnectionManager::addToEndpointCache(const STAFString &endpoint,
>                                                    const STAFString &interface)
> {
>     // Don't add to cache if using the default connection provider since that
>     // will be the first one tried anyway
> 
>     if (interface == fDefaultConnProv) return kSTAFOk;
> 
>     // Add the endpoint to the endpoint cache map
> 
>     STAFMutexSemLock cacheLock(fEndpointCacheMapSem);
> 
>     EndpointCacheData endpointData(interface);
>     fEndpointCacheMap[endpoint] = endpointData;
> 
>     return kSTAFOk;
> }
> 
> 
> STAFRC_t STAFConnectionManager::removeFromEndpointCache(
>     const STAFString &endpoint)
> {
>     // Remove endpoint from the endpoint cache map

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?