Search in sources :

Example 1 with AcsServiceToStart

use of alma.acs.commandcenter.serviceshelper.TMCDBServicesHelper.AcsServiceToStart in project ACS by ACS-Community.

the class StartServicesHelper method internalGetServicesDescription.

/**
	 * Return the the XML string describing the services to start by reading the services from the
	 * TMCDB.
	 *  
	 * @param daemon That services daemon
	 * @return The XML and the list of services describing the services to start
	 * @throws HibernateException In case of error reading the services from the TMCDB
	 * @throws DaemonException In case of error from the daemon
	 * @throws TMCDBException If the list of service read from the TMCDB is empty
	 */
private AlarmServicesDefinitionHolder internalGetServicesDescription(ServicesDaemon daemon) throws HibernateException, DaemonException, TMCDBException {
    if (daemon == null) {
        throw new IllegalArgumentException("The daemon can't be null");
    }
    // Get the service definition builder for the current instance
    ServiceDefinitionBuilder srvDefBuilder = null;
    try {
        srvDefBuilder = daemon.create_service_definition_builder((short) instance);
    } catch (Throwable t) {
        throw new DaemonException("Error getting the service definition builder", t);
    }
    logger.log(AcsLogLevel.DEBUG, "ServiceDefinitionBuilder got from the ACS services daemon");
    // Get the services from the TMCDB
    List<AcsServiceToStart> services = getServicesList();
    if (services.isEmpty()) {
        throw new TMCDBException("No services to start from TMCDB");
    }
    logger.log(AcsLogLevel.DEBUG, "Read " + services.size() + " to start from TMCDB");
    // Add the services to the service definition builder
    try {
        /*
			 * NOTE: some of the paremeters required to start the services are hardcoded
			 *       because the tables of the database do not allow to have them stored
			 *       in the TMCDB.
			 *       For this release it is good enough but if we want to have them available
			 *       in the TMCDB and the explorer then we have to change the table of
			 *       the database too.
			 */
        for (AcsServiceToStart svc : services) {
            if (svc.serviceName == null) {
                logger.log(AcsLogLevel.DEBUG, "Adding " + svc.serviceType + "@" + svc.hostName + " to the ServicesDefinitionBuilder");
            } else {
                logger.log(AcsLogLevel.DEBUG, "Adding " + svc.serviceType + "@" + svc.hostName + " with name " + svc.serviceName + " to the ServicesDefinitionBuilder");
            }
            switch(svc.serviceType) {
                case MANAGER:
                    {
                        srvDefBuilder.add_manager(svc.hostName, "", false);
                        break;
                    }
                case ALARM:
                    {
                        srvDefBuilder.add_alarm_service(svc.hostName);
                        break;
                    }
                case CDB:
                    {
                        srvDefBuilder.add_rdb_cdb(svc.hostName, false, configurationName);
                        break;
                    }
                case IFR:
                    {
                        srvDefBuilder.add_interface_repository(svc.hostName, true, false);
                        break;
                    }
                case LOGGING:
                    {
                        srvDefBuilder.add_logging_service(svc.hostName, "Log");
                        break;
                    }
                case LOGPROXY:
                    {
                        srvDefBuilder.add_acs_log(svc.hostName);
                        break;
                    }
                case NAMING:
                    {
                        srvDefBuilder.add_naming_service(svc.hostName);
                        break;
                    }
                case NOTIFICATION:
                    {
                        srvDefBuilder.add_notification_service(svc.serviceName, svc.hostName);
                        break;
                    }
                default:
                    {
                        throw new Exception("Unknown type of service to start: " + svc.serviceType + ", on " + svc.hostName);
                    }
            }
        }
    } catch (Throwable t) {
        throw new DaemonException("Error adding services to the daemon", t);
    }
    logger.log(AcsLogLevel.DEBUG, "All the services have been added to the ServiceDefinitionBuilder");
    String svcsXML = srvDefBuilder.get_services_definition();
    StringHolder errorStr = new StringHolder();
    if (!srvDefBuilder.is_valid(errorStr)) {
        // Error in the XML
        throw new DaemonException("Error in the services definition: " + errorStr.value);
    } else {
        logger.log(AcsLogLevel.DEBUG, "Services successfully validated by the ServicesDefinitionBuilder");
    }
    return new AlarmServicesDefinitionHolder(svcsXML, Collections.unmodifiableList(services));
}
Also used : StringHolder(org.omg.CORBA.StringHolder) ServiceDefinitionBuilder(alma.acsdaemon.ServiceDefinitionBuilder) AcsServiceToStart(alma.acs.commandcenter.serviceshelper.TMCDBServicesHelper.AcsServiceToStart) HibernateException(org.hibernate.HibernateException)

Aggregations

AcsServiceToStart (alma.acs.commandcenter.serviceshelper.TMCDBServicesHelper.AcsServiceToStart)1 ServiceDefinitionBuilder (alma.acsdaemon.ServiceDefinitionBuilder)1 HibernateException (org.hibernate.HibernateException)1 StringHolder (org.omg.CORBA.StringHolder)1