Esempio n. 1
0
 private boolean isCodecG729Installed() {
   List<Location> locations = getLocationsManager().getLocationsForService(this);
   String serviceUri = null;
   FreeswitchApi api = null;
   String result = null;
   for (Location location : locations) {
     if (getSipxServiceManager().isServiceInstalled(location.getId(), BEAN_ID)) {
       serviceUri = getServiceUri(location);
       api = m_freeswitchApiProvider.getApi(serviceUri);
       try {
         result = api.g729_status();
         if (StringUtils.contains(result, G729_STATUS)) {
           return true;
         }
         // try also new FS detection algorithm
         result = api.g729_available();
         if (StringUtils.contains(result, "true")) {
           return true;
         }
       } catch (XmlRpcRemoteException xrre) {
         LOG.error(xrre);
         return false;
       }
     }
   }
   return false;
 }
Esempio n. 2
0
  private void reloadXmlWithRetries(Location location) {
    boolean success = false;
    int maxRetries = 3;
    int retry = 0;
    if (!isRunning(location)) {
      // no need to reloadXml if the service is not running at the moment
      return;
    }

    Serializable jobId = m_jobContext.schedule(RELOAD_XML_JOB_TITLE);
    m_jobContext.start(jobId);
    String serviceUri = getServiceUri(location);
    FreeswitchApi api = m_freeswitchApiProvider.getApi(serviceUri);

    while ((retry <= maxRetries) && !success) {
      LOG.debug("reloadXmlWithRetries() while loop retry:" + retry);
      try {
        api.reloadxml();
        success = true;
      } catch (Exception ex) {
        LOG.debug("reloadXmlWithRetries() caught Exception:" + ex);
      } finally {
        if (success) {
          m_jobContext.success(jobId);
        } else {
          LOG.debug("reloadXmlWithRetries() failed at retry " + retry);
          if (retry == maxRetries) { // failed after retry maxRetries so just give up
            LOG.error("reloadXmlWithRetries() gives up after retry " + retry);
            m_jobContext.failure(jobId, null, null);
          } else {
            retry++;
            // retry but sleep for a while
            try {
              Thread.sleep(2000);
            } catch (InterruptedException e) {
              continue;
            }
          }
        }
      }
    }

    LOG.debug("reloadXmlWithRetries() return success at retry " + retry);
  }
Esempio n. 3
0
 private void reloadXml(Location location) {
   if (!isRunning(location)) {
     // no need to reloadXml if the service is not running at the moment
     return;
   }
   boolean success = false;
   Serializable jobId = m_jobContext.schedule(RELOAD_XML_JOB_TITLE);
   try {
     m_jobContext.start(jobId);
     String serviceUri = getServiceUri(location);
     FreeswitchApi api = m_freeswitchApiProvider.getApi(serviceUri);
     api.reloadxml();
     success = true;
   } finally {
     if (success) {
       m_jobContext.success(jobId);
     } else {
       m_jobContext.failure(jobId, null, null);
     }
   }
 }
  /** @see org.sipfoundry.sipxconfig.admin.commserver.RegistrationContext#getRegistrations() */
  public List<RegistrationItem> getRegistrations() {
    try {
      Location primaryProxyLocation =
          m_locationsManager.getLocationByBundle("primarySipRouterBundle");
      if (primaryProxyLocation == null) {
        LOG.error("No primary proxy found.");
        return Collections.emptyList();
      }
      ImdbApi imdb = m_imdbApiProvider.getApi(primaryProxyLocation.getProcessMonitorUrl());

      Location managementLocation = m_locationsManager.getLocationByBundle("managementBundle");
      if (managementLocation == null) {
        LOG.error("No management bundle found");
        return Collections.emptyList();
      }
      List<Map<String, ?>> registrations = imdb.read(managementLocation.getFqdn(), "registration");
      return getRegistrations(registrations);
    } catch (XmlRpcRemoteException e) {
      // we are handling this separately - server returns FileNotFound even if everything is
      // OK but we have no registrations present
      LOG.warn("Cannot retrieve registrations.", e);
      return Collections.emptyList();
    }
  }