Exemplo n.º 1
0
 public static StatisticsType findTheStatisticType(EventingConfigData eventingConfigData) {
   StatisticsType statisticsType = null;
   if (!eventingConfigData.isServiceStatsEnable() && eventingConfigData.isMsgDumpingEnable()) {
     statisticsType = StatisticsType.ACTIVITY_STATS;
   } else if (eventingConfigData.isServiceStatsEnable()
       && !eventingConfigData.isMsgDumpingEnable()) {
     statisticsType = StatisticsType.SERVICE_STATS;
   } else if (eventingConfigData.isMsgDumpingEnable()
       && eventingConfigData.isServiceStatsEnable()) {
     statisticsType = StatisticsType.ACTIVITY_SERVICE_STATS;
   }
   return statisticsType;
 }
  /**
   * This method updates the stat publishing status in gateway domain
   *
   * @param receiverUrl event receiver url
   * @param user username for the event receiver
   * @param password password for the event receiver
   * @param statUpdateStatus status of the stat publishing state
   * @throws APIManagementException if an error occurs while adding BAMServerProfile
   * @throws ClusteringFault if it fails to send cluster message to Gateway domain and update stats
   *     publishing status
   * @throws Exception if an error occurs while updating EventingConfiguration
   */
  public void updateStatPublishGateway(
      String receiverUrl, String user, String password, Boolean statUpdateStatus)
      throws APIManagementException, ClusteringFault, Exception {

    if (log.isDebugEnabled()) {
      log.debug("Updating stats publishing status in Gateway.");
    }

    // updating stat publishing at the receiver node, self update
    APIManagerAnalyticsConfiguration analyticsConfiguration =
        APIManagerAnalyticsConfiguration.getInstance();
    analyticsConfiguration.setAnalyticsEnabled(statUpdateStatus);

    if (log.isDebugEnabled()) {
      log.debug("Updated stats publishing status in Gateway to : " + statUpdateStatus);
    }

    ServiceDataPublisherAdmin serviceDataPublisherAdmin =
        APIManagerComponent.getDataPublisherAdminService();
    EventingConfigData eventingConfigData = null;
    if (serviceDataPublisherAdmin != null) {
      eventingConfigData = serviceDataPublisherAdmin.getEventingConfigData();
    }

    if (eventingConfigData != null) {
      // config values must be updated if the stats publishing is true
      if (statUpdateStatus) {
        if (log.isDebugEnabled()) {
          log.debug("Updating values related to stats publishing status.");
        }
        // values related to stats publishing status are only updated if all of them are non-empty
        if (!(receiverUrl.isEmpty()) && !(user.isEmpty()) && !(password.isEmpty())) {
          analyticsConfiguration.setBamServerUrlGroups(receiverUrl);
          analyticsConfiguration.setBamServerUser(user);
          analyticsConfiguration.setBamServerPassword(password);

          eventingConfigData.setUrl(receiverUrl);
          eventingConfigData.setUserName(user);
          eventingConfigData.setPassword(password);
          if (log.isDebugEnabled()) {
            log.debug(
                "BAMServerURL : "
                    + receiverUrl
                    + " , BAMServerUserName : "******" , "
                    + "BAMServerPassword : "******"Sending cluster message to Gateway domain to update stats publishing status.");
      }
      clusteringAgent.sendMessage(
          new StatUpdateClusterMessage(statUpdateStatus, receiverUrl, user, password), true);
    }
  }