Solstice Enterprise Manager 4.1 Developing CORBA Applications | ![]() ![]() ![]() ![]() ![]() |
Programming Techniques
The SEM CORBA Gateway ToolKit provides you with the tools you need to build and deploy the SEM CORBA Gateway and also provides you with an environment for the development of client applications that interact with Solstice Enterprise Manager (Solstice EM) Management Information Server (MIS) via the SEM CORBA Gateway.
This appendix briefly describes with examples the various steps involved in developing a client application. It also describes steps to be followed for compiling, linking and troubleshooting.
This appendix describes the following topics:
B.1 Compiling and Linking Applications
To compile and link a sample CORBA program, write a UNIX script; example follows:
The individual lines of this script are explained as follows:
- Change your current directory to where your sample program resides
- The environment variable $EM_HOME is the EM install directory (e.g. /opt/SUNWconn/em )
- All CORBA sample programs reside in the $EM_HOME/src/corba_gateway directory
- Metadata Gateway sample programs reside in the
$EM_HOME/src/corba_gateway/metadata directory- Request Gateway sample programs reside in the
$EM_HOME/src/corba_gateway/requests directory- Event Gateway sample programs resides in the
$EM_HOME/src/corba_gateway/events directory
- Set EM environment variables, for example:
setenv EM_HOME /opt/SUNWconn/emsetenv EM_MIS_HOME /opt/SUNWconn/emsetenv EM_RUNTIME /var/opt/SUNWconn/em
- Set EM CORBA environment variables, for example:
setenv VB_INSTALL_DIR /net/mars/export/tools/inprise/vbrokersetenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${VB_INSTALL_DIR}/libsetenv OSAGENT_PORT 14567
- Remove object files, executable files and libraries in metadata, requests and events directories.
- The Makefile used is:
RM = /bin/rm -f$(EXEC):: $(LIBS) $(OBJS)$(CPLUS) $(CCFLAGS) $(OBJS) $(LIBS) $(LDIR) $(LDLB) -o$(EXEC)clean::$(RM) $(EXEC)
- make firstmake
- Generate C++ stubs in the idl_generated/cpp directory.
- Delete1 the generated *_c.cc and *_s.cc files in the idl_generated directory
- The Makefile used is:
# define sub-directoriesIDL_DIRS = cos jidm jidm_ext metadata_gwFDIRS= $(IDL_DIRS)firstmake include clobber Makefile:@for i in $(FDIRS); do \(echo "----- Creating cpp stubs in $$i";\cd idl_generated/cpp/$$i; pwd ;\/bin/rm -rf *.idl;\cp $(ROOT)/idl/$$i/*.idl ./;\make .idl.module); \done@echo DONE
- The Makefile used is:
CPLUS = CCCCFLAGS = -features=no%localfor,no%conststrings -library=iostream$($(MODE)FLAG) $($(INCLUDE_TNF_PROBES)TNF)$(INCL) $(DEFN) -DCPP_5_0_OR_HIGHER -o $@SRCS = \action_client.cc \action_linked_reply_handler_impl.ccOBJS = $(SRCS:%.cc=%.o) $(SRCS.c:%.c=%.o)LIBS = \$(LIBRARY)LDIR = \-L$(ROOT)/lib \$(LD_PATH)LDLB = \$(LD_LIBRARY) \$(MORE_LIBS)all:: $(EXEC)$(EXEC):: $(LIBS) $(OBJS)$(CPLUS) $(CCFLAGS) $(OBJS) $(LIBS) $(LDIR) $(LDLB) -o $(EXEC):
CODE EXAMPLE B-2 Getting Root Naming Context
CosNaming::NamingContext_ptr CORBAGatewayConnection::get_root_naming_context() throw() { if (CosNaming::NamingContext::_nil() != root_nc_) { return CosNaming::NamingContext::_duplicate(root_nc_); } try{ CORBA::Object_var object = orb_->resolve_initial_references("NameService"); root_nc_ = CosNaming::NamingContext::_narrow(object); if(CORBA::is_nil(root_nc_)) { cerr << "FAILED: Unable to obtain root naming context\n" << flush; exit(2); } } catch(const CORBA::Exception& e) { cerr << "FAILED: Unable to obtain root naming context:\n\t" << endl; exit(3); } cout << "PASSED: Obtained root naming context\n" << flush; return CosNaming::NamingContext::_duplicate(root_nc_); }
CODE EXAMPLE B-3 Getting ProxyAgentFinder
JIDM::ProxyAgentFinder_ptr CORBAGatewayConnection::get_proxy_agent_finder() throw() { try{ CosNaming::Name name; name.length(1); name[0].id = CORBA::string_dup("JIDM::ProxyAgentFinder"); name[0].kind = CORBA::string_dup(""); CORBA::Object_var object; object = root_nc_->resolve(name); proxy_agent_finder_ = JIDM::ProxyAgentFinder::_narrow(object); if (CORBA::is_nil(proxy_agent_finder_)) { cerr << "FAILED: Unable to obtain correct Proxy Agent Finder\n" << flush; exit(1); } if(proxy_agent_finder_->_non_existent()) { cerr << "FAILED: Proxy Agent Finder does not exist\n" << flush; exit(2); } } catch(const CORBA::Exception& e) { cerr << "FAILED: Unable to resolve JIDM::ProxyAgentFinder:\n\t" << endl; exit(3); } cout << "PASSED: Obtained JIDM::ProxyAgentFinder reference\n" << flush; return JIDM::ProxyAgentFinder::_duplicate(proxy_agent_finder_); }
CODE EXAMPLE B-4 Getting ProxyAgent
JIDM::ProxyAgent_ptr CORBAGatewayConnection::get_proxy_agent() throw() { JIDM::Key a_key; a_key.length(1); a_key[0].id = CORBA::string_dup(JIDM_OSI_KEY_ID); a_key[0].kind = CORBA::string_dup(JIDM_OSI_KEY_KIND); JIDM::Criteria a_criteria; a_criteria.length(2); a_criteria[0].name = CORBA::string_dup(JIDM_MANAGER_TITLE); a_criteria[0].value <<= (const char*)"SEM MIS"; a_criteria[1].name = CORBA::string_dup(JIDM_USER_PROFILE); AuthenticationClient* ac = new AuthenticationClientHandle("UNIX_CLEAR"); a_criteria[1].value = *(ac->get_user_profile(get_root_naming_context(), NULL)); if(CORBA::tk_null == a_criteria[1].value.type()->kind()) { cerr << "FAILED: Unable to obtain encrypted user profile\n" << flush; exit(1); } cout << "PASSED: Obtained criteria from encrypting user profile\n" << flush; try { proxy_agent_ = proxy_agent_finder_->access_domain(a_key, a_criteria); if (CORBA::is_nil(proxy_agent_)) { cerr << "FAILED: Unable to obtain correct Proxy Agent" << endl << flush; exit(1); } if(proxy_agent_->_non_existent()) { cerr << "FAILED: Proxy Agent does not exist" << endl << flush; exit(1); } cout << "PASSED: Created a new Proxy Agent\n" << flush; } catch(const JIDM::InvalidKey& ue) { cerr << "FAILED: Key is not recognized" << endl; exit(1); } catch (const JIDM::InvalidCriteria& ue) { cerr << "FAILED: Criteria is not recognized" << endl; exit(1); } catch (const JIDM::CannotMeetCriteria& ue) { cerr << "FAILED: Proxy Agent creation criteria is not met" << endl; exit(1); } catch (const JIDM::CannotAccess& e) { cerr << "FAILED: Access Denied to create proxy agent" << endl; exit(1); } catch (const CORBA::Exception& e) { cerr << "FAILED: Uncaught CORBA Exception - " << endl; exit(1); } try { criteria_ = proxy_agent_->access_criteria(); cout << "PASSED: Obtained access criteria\n" << flush; } catch (const CORBA::Exception& e) { cerr << "FAILED:Caught CORBA Exception " << endl; exit(1); } SampleShutdownCallback::set_proxy_agent(proxy_agent_); return JIDM::ProxyAgent::_duplicate(proxy_agent_);B.2 Troubleshooting Gateway Processes
You can troubleshoot SEM CORBA Gateway processes by:
- Checking the log files associated with SEM CORBA Gateway processes.
- Using em_debug to turn on dynamic debugging in a CORBA gateway.
B.2.1 Checking the Log Files
The first thing to do when troubleshooting SEM CORBA Gateway is to check the log files associated with the SEM CORBA Gateway processes. These files contain the error messages that are logged by the Gateway. TABLE B-1 describes the log files that are generated by default by the SEM CORBA Gateway. These files are located in /var/opt/SUNWconn/em/debug directory.
TABLE B-1 CORBA Gateway Log Files em_corba_epr.log Event Port Registry log file em_corba_rgw.log Request Gateway log file em_corba_mgw.log Metadata Gateway log file em_corba_eds1.log CORBA EDS 1 log file em_corba_eds2.log CORBA EDS 2 log file
You can specify different files to be used as log files by changing the values of the log file configuration variables.
CODE EXAMPLE B-5 Sample Log File Contents for RGW
rgw_debug: Started the thread safe PMI scheduler rgw_debug: Obtained initial name service reference rgw_trace: JIDM::ProxyAgentController - created rgw_debug: JIDM::ProxyAgentController is ready rgw_debug: JIDM::ProxyAgentFinder is ready rgw_debug: SEM::AuthenticationProxy is ready rgw_debug: Ready to accept client requests rgw_trace: ProxyAgentFinderImpl::access_domain() starts rgw_trace: JIDM::ProxyAgentFinder - validating key and access criteria rgw_trace: JIDM::ProxyAgentFinder - authenticating user profile in [faith MIS] rgw_trace: ProxyAgentFinderImpl::find_matching_proxy_agent() starts rgw_trace: JIDMProxyAgentImpl::JIDMProxyAgentImpl() start rgw_trace: JIDMProxyAgentImpl::JIDMProxyAgentImpl() end rgw_debug: OSIMgmtExt::ProxyAgent is ready rgw_trace: ProxyAgentFinderImpl::returning this - access_domain() ends rgw_trace: JIDMProxyAgentImpl::access_criteria() start rgw_trace: GetPendingRequest::translate_request() start rgw_debug: message type = get request rgw_debug: id = 0 rgw_debug: source = rgw_debug: aclass = PRIM, atag = 2 aval = "[0xff][0xff][0x2][0xe3][0xc4][0x1][0x4][0x81][0x9e][0xe6][0xa3]" rgw_debug: dest = rgw_debug: aclass = PRIM, atag = 2 aval = "[0xff][0xff][0x2][0x15][0xb3][0x1][0x4][0x81][0x9e][0xe6][0xa3]" rgw_debug: remote = rgw_debug: aclass = DEF, atag = 0 aval = Du: no data unit allocated rgw_debug: mode = CONFIRMED rgw_debug: app_context = Du: no data unit allocated rgw_debug: oc = rgw_debug: Tag Len ValueB.2.2 Using Dynamic Debugging
Occasionally, you may need to use em_debug to turn on dynamic debugging for a CORBA gateway. The output of em_debug is particularly useful if you have to file a bug against the SEM CORBA Gateway. TABLE B-2 describes the debug objects that you can enable:
TABLE B-2 CORBA Gateway Debugging Objects rgw_error rgw_debug Request Gateway mgw_error mgw_debug Metadata Gateway epr_error epr_debug Event Port Registry egw_error egw_debug CORBA Event Distribution Server
The debug objects2 print out extensive debug statements, which will involve printing the contents of a message going back and forth. The debug statements are much more than just trace, but are not the actual error indicators.
For example, to see the error messages from the Request Gateway, you can enter the following command:
em_debug -port 6666 -c 'on rgw_error'The em_debug command sends messages to the window in which the command is executed. If a large number of messages will be generated, it is recommended that the output of the command be redirected to a file which can be viewed using a text-editor or by executing the tail -f command.
1 Only *_c.hh and *_s.hh files are generated in the idl_generated directory. 2 Enabling debug objects degrades the performance of the system because of the large number of messages that get generated. It is recommended that you disable debug objects when you no longer need the debug information.
Sun Microsystems, Inc. Copyright information. All rights reserved. |
Doc Set | Contents | Previous | Next | Index |