예제 #1
0
  protected void initialize() {
    if (m_clusterName != null) {
      Cluster cluster = getClusterManager().getCluster(m_clusterName);
      if (cluster == null) {
        throw new IllegalArgumentException("Can't resolve cluster name " + m_clusterName);
      }
      m_clusterID = cluster.getID();
    }

    IConfiguration config = getConfiguration();
    if (m_proxyId != null) {
      readInstanceSettings(config);
    }

    if (m_clusterID == 0) {
      throw new IllegalArgumentException("Cluster not configured: use --cluster or --proxy option");
    }

    readGlobalSettings(config);

    m_proxyStats.setClusterID(m_clusterID);
    m_workerSemaphore = new Semaphore(m_threadCount);
    m_quota = new Quota(m_memoryQuota);
    m_quota.setShouldBlock(false);
    m_quota.setTimeout(m_quotaTimeout);
  }
예제 #2
0
 /**
  * Get an ESP content manager based on a collection name and a cluster location
  *
  * @param collectionName collection to get manager for
  * @param loc cluster location
  * @param callbackHandler for handling ESP callbacks
  * @return content manager
  * @throws ContentManagerException if an error occurs
  */
 private IContentManager getContentManager(
     String collectionName, ClusterLocation loc, ESPCallbackHandler callbackHandler)
     throws ContentManagerException {
   Cluster cluster = m_clusterManager.getCluster(loc.getClusterId());
   try {
     IContentManagerFactory contentManagerFactory =
         ContentManagerFactory.newInstance(cluster.getProperties());
     return contentManagerFactory.create(
         collectionName, cluster.getProperties(), callbackHandler, 0, false);
   } catch (FactoryException e) {
     throw new ContentManagerException("FactoryException", e);
   }
 }
예제 #3
0
  /**
   * @param loc ClusterLocation
   * @param keysToRemove content ids to remove
   * @return ids that failed to purge
   * @throws IndexException if an error occurs
   */
  public Set<String> purgeIndexData(
      final String collectionName, final ClusterLocation loc, final Set<String> keysToRemove)
      throws IndexException {
    if (s_logCategory.isDebugEnabled()) {
      s_logCategory.debug(
          "purgeIndexData("
              + collectionName
              + ","
              + loc.getName()
              + ",...) # items = "
              + keysToRemove.size());
    }
    // if not thing to do, just return empty list
    if (CollectionsUtils.isNullOrEmpty(keysToRemove)) {
      return Collections.emptySet();
    }

    Cluster cluster = m_clusterManager.getCluster(loc.getClusterId());
    if (!cluster.isPurgeEnabled() || !loc.isPurgeEnabled()) {
      s_logCategory.warn(
          "Not processing "
              + keysToRemove.size()
              + " items because purge is disabled on "
              + cluster
              + " and "
              + loc);
      return keysToRemove; // fail all
    }

    try {
      final RoutingAttributes ra = new RoutingAttributes();
      ra.addElement("column", String.valueOf(loc.getColumnId()));

      final List<RoutingAttributes> routingAttributes =
          new ArrayList<RoutingAttributes>(
              Itertools.map(
                  new UnaryFunction<String, RoutingAttributes>() {
                    public RoutingAttributes execute(String key) {
                      return ra;
                    }
                  },
                  keysToRemove));

      Set<String> results =
          new HashSet<String>(
              (new FASTExecuteFunction(collectionName, loc, "purge", keysToRemove) {
                    public String executeWithFAST(IContentManager fast)
                        throws ContentManagerException {
                      // s_logCategory.debug("Calling fast.removeContents() with keys, subsystems
                      // and routing attributes (sz=" + routingAttributes.size() + ")");
                      return fast.removeContents(
                          keysToRemove, Arrays.asList(DOC_PROC, INDEXING), routingAttributes);
                    }
                  })
                  .execute(getBatchTimeoutMillis())
                  .keySet());

      if (!CollectionsUtils.isNullOrEmpty(results)) {
        s_logCategory.info("There were " + results.size() + " failed items at location " + loc);
      }

      if (s_logCategory.isDebugEnabled()) {
        s_logCategory.debug("Failed items at location " + loc.getName() + ": " + results);
      }

      return results;
    } catch (ContentManagerException e) {
      throw new IndexException("ContentManagerException", e);
    }
  }