Package com.findwise.hydra

Examples of com.findwise.hydra.Pipeline


            MongoDBConnectionConfig conf = new MongoDBConnectionConfig(pipelineConfig.getPipelineName(), cmd.getHost(), "", "");
            MongoConnector mdc =new MongoConnector(conf.getConfiguration());
            mdc.connect();

            Pipeline pipeline = mdc.getPipelineReader().getPipeline();
            for (Stage stage : stages) {
                if (cmd.getStageNames() != null) {
                    if (cmd.getStageNames().contains(stage.getName())) {
                        log.info("Preparing to upload stage, " + stage.getName());
                        StageGroup g = new StageGroup(stage.getName());
                        g.addStage(stage);
                        pipeline.addGroup(g);
                    }
                } else {
                    log.info("Preparing to upload stage, " + stage.getName());
                    StageGroup g = new StageGroup(stage.getName());
                    g.addStage(stage);
                    pipeline.addGroup(g);
                }
            }
            log.info("Uploading stages");
            log.info(pipeline.toString());
            mdc.getPipelineWriter().write(pipeline);
        }
    }
View Full Code Here


    private void getStages(HttpRequest request, HttpResponse response,
                           HttpContext context) {
        logger.trace("handleGetStages()");
        String group = RESTTools.getParam(request, GroupStarter.GROUP_PARAM);

        Pipeline p = reader.getPipeline();
        if(!p.hasGroup(group)) {
            p = reader.getDebugPipeline();
        }
        if(p.hasGroup(group)) {
            HttpResponseWriter.printJson(response, p.getGroup(group).getStageNames());
            return;
        }

        response.setStatusCode(HttpStatus.SC_NOT_FOUND);
        response.setEntity(new NStringEntity("", HttpResponseWriter.CONTENT_TYPE));
View Full Code Here

  @Override
  public void prepare() {}

  @Override
  public void write(Pipeline p) throws IOException {
    Pipeline old = reader.getPipeline();
    for(Stage s : old.getStages()) {
      inactivate(s);
    }
   
    for(StageGroup g : p.getStageGroups()) {
      write(g);
View Full Code Here

  public Pipeline getDebugPipeline() {
    return getPipeline(Stage.Mode.DEBUG);
  }

  private Pipeline getPipeline(Stage.Mode mode) {
    Pipeline p = new Pipeline();
    DBCursor cursor = stages.find(new BasicDBObject(ACTIVE_KEY, mode.toString()));
   
    while(cursor.hasNext()) {
      DBObject obj = cursor.next();
      if(!obj.containsField(TYPE_KEY) || STAGE_TYPE.equals(obj.get(TYPE_KEY))) {
        Stage s = getStage(obj);
        if(!p.hasGroup(getGroupName(obj))) {
          p.addGroup(new StageGroup(getGroupName(obj)));
        }
        p.getGroup(getGroupName(obj)).addStage(s);
      } else {
        addGroup(p, getGroup(obj));
      }
    }
   
View Full Code Here

    addStage(s, groupName);
  }

  public void addStage(Stage stage, String groupName) throws IOException {

    Pipeline pipeline = connector.getPipelineReader().getPipeline();
    if(!pipeline.hasGroup(groupName)) {
      pipeline.addGroup(new StageGroup(groupName));
    }
    pipeline.getGroup(groupName).addStage(stage);
    connector.getPipelineWriter().write(pipeline);
  }
View Full Code Here

    Stage stageToDelete = getStageInfo(stageName);
    Map<String, Object> ret = new HashMap<String, Object>();
    if (stageToDelete == null) {
      ret.put("stageStatus", "Could not find stage " + stageName);
    } else {
      Pipeline pipeline = connector.getPipelineReader().getPipeline();
      if(groupName == null) {
        groupName = getStageGroupForStage(stageToDelete);
      }
      if(!pipeline.hasGroup(groupName)) {
        pipeline.addGroup(new StageGroup(groupName));
      }
      pipeline.getGroup(groupName).removeStage(stageName);
      connector.getPipelineWriter().write(pipeline);
   
      ret.put("stageStatus", "Deleted stage " + stageName);
    }
    return ret;
View Full Code Here

  }
 
  @Test
  public void testGetStageGroups() throws Exception {
    MongoConnector mdc = mongoConnectorResource.getConnector();
    Pipeline p = new Pipeline();
    StageGroup singleGroup = new StageGroup("singleStage");
    StageGroup multiGroup = new StageGroup("multi");
    Stage single = new Stage("singleStage", new DatabaseFile());
    Stage multi1 = new Stage("multi1", new DatabaseFile());
    Stage multi2 = new Stage("multi2", new DatabaseFile());
    multiGroup.addStage(multi1);
    multiGroup.addStage(multi2);
    singleGroup.addStage(single);
   
    p.addGroup(multiGroup);
    p.addGroup(singleGroup);
   
    assertEquals(2, p.getStageGroups().size());
    assertTrue(p.hasGroup("multi"));
    assertTrue(p.hasGroup("singleStage"));
   
    mongoConnectorResource.reset();
    mdc = mongoConnectorResource.getConnector();
    MongoPipelineReader reader = new MongoPipelineReader(mdc.getDB());
    MongoPipelineWriter writer = new MongoPipelineWriter(reader, WriteConcern.SAFE);
View Full Code Here

  }
 
  @Test
  public void testStageGroupProperties() throws Exception {
    MongoConnector mdc = mongoConnectorResource.getConnector();
    Pipeline p = new Pipeline();
    StageGroup singleGroup = new StageGroup("singleStage");
    StageGroup multiGroup = new StageGroup("multi");
    Stage single = new Stage("singleStage", new DatabaseFile());
    Stage multi1 = new Stage("multi1", new DatabaseFile());
    Stage multi2 = new Stage("multi2", new DatabaseFile());
    multiGroup.addStage(multi1);
    multiGroup.addStage(multi2);
    singleGroup.addStage(single);
   
    p.addGroup(multiGroup);
    p.addGroup(singleGroup);
   
    multiGroup.setJvmParameters("jvm");
    multiGroup.setRetries(3);
    multiGroup.setLogging(false);
    multiGroup.setCmdlineArgs("cmd");
View Full Code Here

   
    ShutdownHandler shutdownHandler = Mockito.mock(ShutdownHandler.class);
   
    Mockito.when(shutdownHandler.isShuttingDown()).thenReturn(false);
   
    nm = new NodeMaster<MongoType>(conf, new CachingDocumentNIO<MongoType>(dbc, new NoopCache<MongoType>(), false), new Pipeline(), shutdownHandler);
    if(!nm.isAlive()) {
      nm.blockingStart();
   
      dbc.waitForWrites(true);
      dbc.connect();
View Full Code Here

    server = RESTServer.getNewStartedRESTServer(14000, new HttpRESTHandler<DatabaseType>(dbc));
  }
 
  @Test
  public void testGetStages() throws Exception {
    Pipeline p = new Pipeline();
    StageGroup g = new StageGroup("1");
    g.addStage(new Stage("stage", Mockito.mock(DatabaseFile.class)));
    g.addStage(new Stage("stage2", Mockito.mock(DatabaseFile.class)));
    p.addGroup(g);
   
    Mockito.when(reader.getPipeline()).thenReturn(p);
   
    List<String> stages = GroupStarter.getStages("localhost", server.getPort(), "1");

    assertTrue(stages.contains("stage"));
    assertTrue(stages.contains("stage2"));
    assertFalse(stages.contains("notingroup"));

    StageGroup g2 = new StageGroup("2");
    g2.addStage(new Stage("debug", Mockito.mock(DatabaseFile.class)));
    Pipeline p2 = new Pipeline();
    p2.addGroup(g2);
   
    Mockito.when(reader.getDebugPipeline()).thenReturn(p2);
    stages = GroupStarter.getStages("localhost", server.getPort(), "2");

    assertTrue(stages.contains("debug"));
View Full Code Here

TOP

Related Classes of com.findwise.hydra.Pipeline

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.