Package gc.base.task

Examples of gc.base.task.TaskContext


        try {
          List<Gptdb2SolrInstance> instances = Gptdb2SolrInstance.createInstancesFromConfig();
          for (Gptdb2SolrInstance instance: instances) {
            //System.err.println("???????????????????????????????");
            XmlTypes xmlTypes = XmlTypes.createFromConfig();
            TaskContext context = new TaskContext("Gptdb2SolrTask");
            context.getStats().setFeedbackMillis(60000);
            Gptdb2SolrTask task = new Gptdb2SolrTask(context,xmlTypes,instance);
            SingleTaskExecutor.executeTask(task);
          }
        } catch (Exception e) {
          e.printStackTrace();
View Full Code Here


    this.solrCollectionUrl = this.gptdb2SolrInstance.getSolrCollectionUrl();
  }

  @Override
  protected void executeTask() throws Exception {
    TaskContext context = this.getContext();
    Connection con = null;
    try {
      // TODO: dbconnection, gptinstance name, gcinstancename
      queryServer = new HttpSolrServer(solrCollectionUrl);
      docPublisher = new DocPublisher(context,solrCollectionUrl,5000,10,1);
View Full Code Here

     - store the XML? link to the XML?
     - gpt fields?
     - tags?
   */
   
    TaskContext context = getContext();
    DocBuilder builder = new DocBuilder();
    DocInfo info = new DocInfo();
    SolrInputDocument doc = new SolrInputDocument();
    String s;
   
View Full Code Here

 
  private void walkSolrDocs() throws SolrServerException, IOException {
    if (!checkForDeletes) return;
    if ((okIds == null) || (okIds.size() == 0)) return;
   
    TaskContext context = this.getContext();
    TaskStats stats = context.getStats();
    String tn = context.getTaskName()+".walkSolrDocs";
    stats.setString(tn,"...");
   
    String fl = FieldConstants.Id;
    String q = FieldConstants.Id_Table+":"+FieldConstants.Val_Id_Table_DocIndex;
    q += " AND "+FieldConstants.Sync_Type+":"+this.syncType;
    q += " AND "+FieldConstants.Sync_Foreign_InstanceId+":"+this.foreignInstanceId;
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("q",q);
    params.set("fl",fl);
    stats.setString(tn+".q",q);
   
    boolean bContinue = true;
    long nDeepTotal = 0;
    long nFetched = 0;
    long nHits = 0;
    int nDocs = 0;
    long nStart = 0;
    int nRows = 1000;
    long nNextStart = 0;
    while (bContinue) {
      bContinue = false;
      params.set("start",""+nStart);
      params.set("rows",""+nRows);
      QueryResponse response = queryServer.query(params);
      SolrDocumentList docs = response.getResults();
      if (docs != null) {
        nHits = docs.getNumFound();
        nDocs = docs.size();
        nNextStart = nStart+nDocs;
        if ((nDocs > 0) && (nNextStart < nHits)) {
          bContinue = true;
        }
        for (int i=0;i<nDocs;i++) {
          SolrDocument doc = docs.get(i);
          String id = (String)doc.getFieldValue(FieldConstants.Id);
          nFetched++;
          stats.incrementCount(tn+".fetched");
          if (okIds.get(id) != null) {
            stats.incrementCount(tn+".idOk");
          } else {
            stats.incrementCount(tn+".idRequiresDelete");
            if ((delIds != null) && (delIds.size() <= this.maxIdsInMap)) {
              delIds.add(id);
            } else if (delIds != null) {
              delIds = null;
              bContinue = false;
              break;
            }
          }
          if ((nDeepTotal > 0) && (nFetched >= nDeepTotal)) {
            bContinue = false;
            break;
          }
        }
        nStart = nNextStart;
      }
    }
   
    if ((delIds != null) && (delIds.size() > 0)) {
      stats.incrementCount(context.getTaskName()+".solr.sentForDelete",delIds.size());
      this.docPublisher.getUpdateServer().deleteById(delIds);
    }
   
  }
View Full Code Here

TOP

Related Classes of gc.base.task.TaskContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.