Package ca.carleton.gcrc.couch.client

Examples of ca.carleton.gcrc.couch.client.CouchQueryResults


       
        JSONArray keys = new JSONArray();
        keys.put(JSONObject.NULL);
        query.setKeys(keys);
   
        CouchQueryResults results = atlasDesign.performQuery(query);
        synchronized(this) { // protect docIdsToSkip
          for(JSONObject row : results.getRows()) {
            String id = row.optString("id");
            if( null != id
             && false == docIdsToSkip.contains(id) ) {
              // Found some work
              docIds.add(id);
            }
          }
        }
      }

      // Check for work: all legacy nodes
      {
        List<TreeNode> legacyNodes = clusterTree.getLegacyNodes();
        if( legacyNodes.size() > 0 ){
          JSONArray keys = new JSONArray();
          for(TreeNode legacyNode : legacyNodes){
            keys.put(legacyNode.getClusterId());
          }

          CouchQuery query = new CouchQuery();
          query.setViewName("date-index");
          query.setReduce(false);
          query.setReduce(false);
          query.setKeys(keys);
     
          CouchQueryResults results = atlasDesign.performQuery(query);
          synchronized(this) { // protect docIdsToSkip
            for(JSONObject row : results.getRows()) {
              String id = row.optString("id");
              if( null != id
               && false == docIdsToSkip.contains(id) ) {
                // Found some work
                docIds.add(id);
View Full Code Here


 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("submission-work");

    CouchQueryResults results;
    try {
      results = submissionDbDesignDocument.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing submission database",e);
      waitMillis(60 * 1000); // wait a minute
      return;
    }

    // Check for work
    String docId = null;
    for(JSONObject row : results.getRows()) {
      String id = row.optString("id");
      if( false == docIdsToSkip.contains(id) ) {
        // Found some work
        docId = id;
        break;
View Full Code Here

 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing server",e);
      waitMillis(60 * 1000); // wait a minute
      return;
    }
   
    // Check for work
    String docId = null;
    String state = null;
    for(JSONObject row : results.getRows()) {
      String id = row.optString("id");
      if( false == docIdsToSkip.contains(id) ) {
        // Found some work
        docId = id;
        state = row.optString("key");
View Full Code Here

      CouchQuery query = new CouchQuery();
      query.setViewName(viewName);
      query.setStartKey(serverName);
      query.setEndKey(serverName);
     
      CouchQueryResults results;
      try {
        results = dd.performQuery(query);
      } catch (Exception e) {
        throw new Exception("Error accessing view: "+viewName,e);
      }
     
      // Analyze configuration
      if( results.getRows().size() < 1 ) {
        throw new Exception("Configuration with id "+serverName+" not found.");
      }
      try {
        JSONObject row = results.getRows().get(0);
        JSONObject doc = row.getJSONObject("value");
        String rev = doc.getString("_rev");
        if( null == rev ) {
          throw new Exception("Unable to read attribute '_rev'");
         
View Full Code Here

      query.setViewName("emails");
      query.setStartKey(emailAddress);
      query.setEndKey(emailAddress);
      query.setIncludeDocs(true);

      CouchQueryResults results = nunaliitUserDesignDocument.performQuery(query);
      List<JSONObject> rows = results.getRows();
      for(JSONObject row : rows){
        JSONObject doc = row.optJSONObject("doc");
        if( null != doc ){
          JSONObject result = getPublicUserFromUser(doc);
          return result;
View Full Code Here

    CouchQuery query = new CouchQuery();
    query.setViewName(viewName);
    query.setStartKey(serverName);
    query.setEndKey(serverName);
   
    CouchQueryResults results;
    try {
      results = configDesign.performQuery(query);
    } catch (Exception e) {
      throw new Exception("Error accessing view: "+viewName,e);
    }
   
    // Analyze configuration
    if( results.getRows().size() < 1 ) {
      throw new Exception("Configuration with id "+serverName+" not found.");
    }
    CouchConfig config = null;
    try {
      JSONObject row = results.getRows().get(0);
      JSONObject doc = row.getJSONObject("value");

      config = parseJSON(doc);

    } catch(Exception e) {
View Full Code Here

 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("submission-work");

    CouchQueryResults results;
    try {
      results = submissionDbDesignDocument.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing submission database",e);
      waitMillis(DELAY_ERROR); // wait a minute
      return;
    }

    // Check for work
    String docId = null;
    synchronized(this){ // protect docIdsToSkip
      for(JSONObject row : results.getRows()) {
        String id = row.optString("id");
        if( false == docIdsToSkip.contains(id) ) {
          // Found some work
          docId = id;
          break;
View Full Code Here

 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing server",e);
      waitMillis(60 * 1000); // wait a minute
      return;
    }
   
    // Check for work
    String docId = null;
    String state = null;
    for(JSONObject row : results.getRows()) {
      String id = row.optString("id");
      if( false == docIdsToSkip.contains(id) ) {
        // Found some work
        docId = id;
        state = row.optString("key");
View Full Code Here

    query.setViewName("schemas");
    query.setStartKey(schemaName);
    query.setEndKey(schemaName);
    query.setIncludeDocs(true);
   
    CouchQueryResults results = dd.performQuery(query);
   
    List<JSONObject> rows = results.getRows();
    if( rows.size() < 1 ) {
      documentsFromSchemaName.put(schemaName, null);
      return null;
    }
   
View Full Code Here

 
  private void activity() {
    CouchQuery query = new CouchQuery();
    query.setViewName("server_work");
   
    CouchQueryResults results;
    try {
      results = dd.performQuery(query);
    } catch (Exception e) {
      logger.error("Error accessing server",e);
      waitMillis(60 * 1000); // wait a minute
      return;
    }
   
    // Check for work
    String docId = null;
    String state = null;
    for(JSONObject row : results.getRows()) {
      String id = row.optString("id");
      if( false == docIdsToSkip.contains(id) ) {
        // Found some work
        docId = id;
        state = row.optString("key");
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.couch.client.CouchQueryResults

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.