Package com.findwise.hydra.mongodb

Examples of com.findwise.hydra.mongodb.MongoDocument


    MongoTailableIterator inactiveIterator = mongoConnector.getDocumentReader().getInactiveIterator(new MongoQuery());

    Set<String> finishedDocumentIds = new HashSet<String>();
    while(!finishedDocumentIds.equals(externalDocumentIds)) {
      if(inactiveIterator.hasNext()) {
        MongoDocument finishedDocument = inactiveIterator.next();
        logger.info("Found finished document " + finishedDocument);
        // Assert that the document was successfully processed
        assertThat(finishedDocument.getStatus(), equalTo(Document.Status.PROCESSED));
        // Here we assert that we indeed have passed through the staticField stage
        assertThat((String) finishedDocument.getContentField("testField"), equalTo("Set by SetStaticFieldStage"));
        finishedDocumentIds.add((String) finishedDocument.getContentField("externalDocId"));
      } else {
        // Wait for a little while before polling again.
        Thread.sleep(100);
      }
    }
View Full Code Here


  public void setUp() throws Exception {
    if(!nm.isAlive()) {
      fail("NodeMaster is not running (TEST FAILIURE)");
    }
   
    test = new MongoDocument();
    test.setAction(Action.ADD);
    test.putContentField("name", "test");
    test.putContentField("type", "awesome");
    test.putContentField("unique", true);
   
    test2 = new MongoDocument();
    test2.setAction(Action.ADD);
    test2.putContentField("name", "test2");
    test2.putContentField("type", "fabulous");
   
    dbc.getDocumentWriter().deleteAll();
View Full Code Here

    }
  }
 
  @Test
  public void testSaveFile() throws Exception {
    MongoDocument testDoc = new MongoDocument();
    dbc.getDocumentWriter().insert(testDoc);
   
    RemotePipeline rp = new HttpRemotePipeline("localhost", server.getPort(), "stage");
   
    String content = "xäöåx";

    String fileName = "test.txt";
    DocumentFile<Local> df = new DocumentFile<Local>(new LocalDocument(testDoc.toJson()).getID(), fileName, IOUtils.toInputStream(content, "UTF-8"));
    df.setEncoding("UTF-8");
   
    if(!rp.saveFile(df)) {
      fail("RemotePipeline.saveFile() returned false");
    }
View Full Code Here

  private Set<String> createDocuments(int numDocs) throws UnknownHostException {
    MongoDocumentIO mongoDocumentIO = buildMongoDocumentIO(mongoConfiguration);
    Set<String> externalDocumentIds = new HashSet<String>();
    for(int i = 0; i < numDocs; i++) {
      String externalDocId = UUID.randomUUID().toString();
      MongoDocument mongoDocument = new MongoDocument();
      mongoDocument.putContentField("externalDocId", externalDocId);
      mongoDocumentIO.insert(mongoDocument);
      externalDocumentIds.add(externalDocId);
    }
    return externalDocumentIds;
  }
View Full Code Here

  }
 
  @Test
  public void testRemoveField() throws Exception {
    dbc.getDocumentWriter().deleteAll();
    MongoDocument testDoc = new MongoDocument();
    testDoc.putContentField("field", "value");
    dbc.getDocumentWriter().insert(testDoc);
    RemotePipeline rp = new HttpRemotePipeline("localhost", server.getPort(), "stage");
   
    LocalDocument ld = rp.getDocument(new LocalQuery());
    assertTrue(ld.hasContentField("field"));
View Full Code Here

    MongoDocumentIO io = new MongoDocumentIO(db, concern, documentsToKeep,
        oldDocsMaxSizeMB, updater, documentFs);
    io.prepare();

    MongoDocument document = new MongoDocument(args[args.length-1]);
    io.insert(document);
    System.out.println("Added document");
  }
View Full Code Here

TOP

Related Classes of com.findwise.hydra.mongodb.MongoDocument

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.