Beispiel #1
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }

    StageGroup g = (StageGroup) obj;
    if (g.getStages().size() == stages.size()) {
      for (Stage s : g.getStages()) {
        if (!hasStage(s.getName()) || !getStage(s.getName()).equals(s)) {
          return false;
        }
      }
      if ((getPropertiesModifiedDate() == null) != (g.getPropertiesModifiedDate() == null)) {
        return false;
      } else if (getPropertiesModifiedDate() == null && g.getPropertiesModifiedDate() == null) {
        return true;
      }
      return getPropertiesModifiedDate().equals(g.getPropertiesModifiedDate());
    }
    return false;
  }
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("CoAP Explorer");
    Group root = new Group();
    Scene scene = new Scene(root, 800, 600);

    TextArea hexArea = new TextArea();
    TextArea binArea = new TextArea();

    CoapPacket packet = new CoapPacket();
    packet.setPayload("PAYLOAD");
    packetProp.setValue(packet);

    binArea.textProperty().bindBidirectional(packetProp, new AsciiConverter());

    hexArea.textProperty().bindBidirectional(packetProp, new HexConverter());
    hexArea.setEditable(false);
    hexArea.setFont(javafx.scene.text.Font.font(Font.MONOSPACED));

    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10));
    vbox.setSpacing(8);

    VBox.setMargin(hexArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(hexArea);
    VBox.setMargin(binArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(binArea);

    root.getChildren().add(vbox);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  private static void createTask(
      ActionDBAccessor db, long requestId, long stageId, String hostName, String clusterName)
      throws AmbariException {

    Stage s =
        new Stage(
            requestId,
            "/var/log",
            clusterName,
            1L,
            "execution command wrapper test",
            "clusterHostInfo",
            "commandParamsStage",
            "hostParamsStage");
    s.setStageId(stageId);
    s.addHostRoleExecutionCommand(
        hostName,
        Role.NAMENODE,
        RoleCommand.START,
        new ServiceComponentHostStartEvent(
            Role.NAMENODE.toString(), hostName, System.currentTimeMillis()),
        clusterName,
        "HDFS",
        false);
    List<Stage> stages = new ArrayList<Stage>();
    stages.add(s);
    Request request = new Request(stages, clusters);
    db.persistActions(request);
  }
Beispiel #4
0
 public Set<String> getStageNames() {
   HashSet<String> names = new HashSet<String>();
   for (Stage stage : stages) {
     names.add(stage.getName());
   }
   return names;
 }
  public void start(Stage stage) {
    stage.setTitle("ListView demo");
    FlowPane rootNode = new FlowPane(10, 10);
    rootNode.setAlignment(Pos.CENTER);
    Scene scene = new Scene(rootNode, 200, 120);
    stage.setScene(scene);

    responseLabel = new Label("Select Transport Type");

    ObservableList<String> transportTypes =
        FXCollections.observableArrayList("Train", "Car", "Airplane");
    ListView<String> transportListView = new ListView(transportTypes);
    transportListView.setPrefSize(80, 80);
    MultipleSelectionModel<String> listViewSelectionModel = transportListView.getSelectionModel();

    listViewSelectionModel
        .selectedItemProperty()
        .addListener(
            new ChangeListener<String>() {
              public void changed(
                  ObservableValue<? extends String> changed, String oldValue, String newValue) {
                responseLabel.setText("Transport selected is " + newValue);
              }
            });

    rootNode.getChildren().addAll(transportListView, responseLabel);
    stage.show();
  }
  /**
   * Populates and return pipelines for the supplied pipeline prototype with the current status.
   *
   * @param noOfPipelines number of pipeline instances
   */
  public List<Pipeline> createPipelineLatest(int noOfPipelines, ItemGroup context) {
    List<Pipeline> result = new ArrayList<Pipeline>();

    Iterator it = firstProject.getBuilds().iterator();
    for (int i = 0; i < noOfPipelines && it.hasNext(); i++) {
      AbstractBuild firstBuild = (AbstractBuild) it.next();
      List<Change> pipelineChanges = Change.getChanges(firstBuild);
      String pipeLineTimestamp = PipelineUtils.formatTimestamp(firstBuild.getTimeInMillis());
      List<Stage> pipelineStages = new ArrayList<Stage>();
      for (Stage stage : getStages()) {
        pipelineStages.add(stage.createLatestStage(context, firstBuild));
      }
      Pipeline pipelineLatest =
          new Pipeline(
              getName(),
              firstProject,
              firstBuild.getDisplayName(),
              pipeLineTimestamp,
              Trigger.getTriggeredBy(firstBuild),
              UserInfo.getContributors(firstBuild),
              pipelineStages,
              false);
      pipelineLatest.setChanges(pipelineChanges);
      result.add(pipelineLatest);
    }
    return result;
  }
 public Pipeline createPipelineAggregated(ItemGroup context) {
   List<Stage> pipelineStages = new ArrayList<Stage>();
   for (Stage stage : getStages()) {
     pipelineStages.add(stage.createAggregatedStage(context, firstProject));
   }
   return new Pipeline(getName(), firstProject, null, null, null, null, pipelineStages, true);
 }
 public void buildingBuildInstance(Stage stage) {
   if (!stage.getJobInstances().isEmpty()) {
     JobInstance jobInstance = stage.getJobInstances().get(0);
     jobInstance.setAgentUuid(AGENT_UUID);
     jobInstance.changeState(JobState.Building);
     jobInstanceDao.updateAssignedInfo(jobInstance);
   }
 }
Beispiel #9
0
 public void nextStage() {
   if (s != null) {
     s = s.nextStage(this);
     if (s != null) {
       s.apply(this);
     }
   }
 }
 public Stage saveBuildingStage(String pipelineName, String stageName) throws SQLException {
   Pipeline pipeline = saveTestPipeline(pipelineName, stageName);
   Stage stage = saveBuildingStage(pipeline.getStages().byName(stageName));
   for (JobInstance job : stage.getJobInstances()) {
     job.setIdentifier(new JobIdentifier(pipeline, stage, job));
   }
   return stage;
 }
Beispiel #11
0
 public Stage getStage(String name) {
   for (Stage stage : stages) {
     if (stage.getName().equals(name)) {
       return stage;
     }
   }
   return null;
 }
 private MaterialRevision materialRevisionForDownstream(
     DependencyMaterial material, Stage upstreamStage) {
   StageIdentifier identifier = upstreamStage.getIdentifier();
   String rev = identifier.getStageLocator();
   String pipelineLabel = identifier.getPipelineLabel();
   return new MaterialRevision(
       material, new Modification(new Date(), rev, pipelineLabel, upstreamStage.getPipelineId()));
 }
Beispiel #13
0
 /**
  * Link the given next leaf after the given leaf.
  *
  * @param <T> The value type of the b+tree objects.
  * @param <A> The address type used to identify an inner or leaf tier.
  * @param mutation The mutation state container.
  * @param leaf The leaf.
  * @param nextLeaf The next leaf.
  */
 public static <T, A> void link(Mutation<T, A> mutation, Tier<T, A> leaf, Tier<T, A> nextLeaf) {
   Structure<T, A> structure = mutation.getStructure();
   Stage<T, A> writer = structure.getStage();
   writer.dirty(mutation.getStash(), leaf);
   writer.dirty(mutation.getStash(), nextLeaf);
   nextLeaf.setNext(leaf.getNext());
   leaf.setNext(nextLeaf.getAddress());
 }
 public void cancelStage(Stage stage) {
   for (JobInstance job : stage.getJobInstances()) {
     job.cancel();
     jobInstanceDao.updateStateAndResult(job);
   }
   stage.calculateResult();
   updateResultInTransaction(stage, StageResult.Cancelled);
 }
Beispiel #15
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setVgap(10);
    grid.setHgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Scene sc = new Scene(grid, 500, 500);

    String css = Main.class.getResource("Login.css").toExternalForm();
    //        System.out.println(css);
    sc.getStylesheets().add(css);

    Text scenetitle = new Text("Welcome");
    //        scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 0, 0, 1, 1);

    Label userName = new Label("User Name:");
    grid.add(userName, 0, 1);

    TextField userTextField = new TextField("Мудак");
    grid.add(userTextField, 1, 1);

    Label pw = new Label("Password:"******"Sign in");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 1, 4);

    final Text actiontarget = new Text();
    grid.add(actiontarget, 1, 6);

    btn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            //                actiontarget.setFill(Color.FIREBRICK);
            actiontarget.setText("Pressed");
          }
        });

    //        grid.setGridLinesVisible(true);

    scenetitle.setId("welc");
    actiontarget.setId("act");

    primaryStage.setScene(sc);
    primaryStage.setTitle("Hello World");
    primaryStage.show();
  }
Beispiel #16
0
 public Stage removeStage(String stageName) {
   for (Stage stage : stages) {
     if (stage.getName().equals(stageName)) {
       stages.remove(stage);
       return stage;
     }
   }
   return null;
 }
 public void failStage(Stage stage, Date completionDate) {
   for (JobInstance job : stage.getJobInstances()) {
     job.completing(Failed, completionDate);
     job.completed(completionDate);
     jobInstanceDao.updateStateAndResult(job);
   }
   stage.calculateResult();
   updateResultInTransaction(stage, StageResult.Failed);
 }
 private void assertPipelineScheduled(PipelineConfig config) {
   Stage evolveStage =
       stageDao.mostRecentWithBuilds(
           CaseInsensitiveString.str(config.name()),
           config.findBy(new CaseInsensitiveString("dev")));
   assertThat(evolveStage.getName(), is("dev"));
   assertThat(evolveStage.getJobInstances().size(), is(1));
   assertThat(evolveStage.getJobInstances().first().getState(), is(JobState.Scheduled));
 }
Beispiel #19
0
 public void init(Control control) {
   super.backGround = new BaseSprite();
   super.backGround.Load("assets/title", 1, 1f, true);
   super.addChild(super.backGround);
   this.soundControl = new SoundControl();
   this.soundControl.Pos.x = LSystem.viewSize.width - this.soundControl.getWidth();
   this.soundControl.Pos.y = 0f;
   this.soundControl.setup();
   super.addChild(this.soundControl);
 }
Beispiel #20
0
 public void start(Stage primaryStage) {
   d3 = new Draw3D();
   Scene scene = d3.buildScene();
   preambleCommands();
   drawingCommands();
   d3.setStart();
   primaryStage.setScene(scene);
   primaryStage.setTitle(title);
   primaryStage.show();
 }
 public void onefailAndOnePassedBuildInstances(Stage instance) {
   final JobInstance first = instance.getJobInstances().get(0);
   final JobInstance second = instance.getJobInstances().get(1);
   first.completing(Failed);
   second.completing(Failed);
   first.completed(new Date());
   second.completed(new Date());
   jobInstanceDao.updateStateAndResult(first);
   jobInstanceDao.updateStateAndResult(second);
 }
Beispiel #22
0
 @Override
 public void start(Stage stage) throws Exception {
   stage.setTitle("Tetris");
   Group root = new Group();
   Scene scene = new Scene(root, 800, 400);
   stage.setScene(scene);
   stage.show();
   SceneManager scmanager = new SceneManager(stage, scene, root);
   stage.setOnCloseRequest(scmanager.getOnCloseWindow());
   scmanager.launch();
 }
    public void dispose() {
      for (Stage stage : mStages) {
        stage.dispose();
      }

      mStages.clear();
      mDecimator.dispose();
      mDecimator = null;
      mFirstStage = null;
      mStages = null;
    }
 public void buildInstanceWithDiscontinuedState(Stage instance) {
   final JobInstance first = instance.getJobInstances().get(0);
   final JobInstance second = instance.getJobInstances().get(1);
   first.completing(JobResult.Passed);
   second.changeState(JobState.Discontinued);
   second.setResult(JobResult.Passed);
   first.completed(new Date());
   jobInstanceDao.updateStateAndResult(first);
   jobInstanceDao.updateStateAndResult(second);
   updateResultInTransaction(instance, StageResult.Passed);
 }
Beispiel #25
0
  public void start(Stage stage) {
    Button button = new Button("Click me!");
    button.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            System.out.println("Thanks for clicking!");
          }
        });

    stage.setScene(new Scene(button));
    stage.show();
  }
  private void assertPipelinesScheduled() {
    Pipeline minglePipeline =
        pipelineDao.mostRecentPipeline(CaseInsensitiveString.str(mingleConfig.name()));
    Stage mingleStage = minglePipeline.getFirstStage();
    assertThat(mingleStage.getName(), is(STAGE_NAME));
    assertThat(mingleStage.getJobInstances().size(), is(2));
    JobInstance mingleJob = mingleStage.getJobInstances().first();
    assertThat(mingleJob.getState(), is(JobState.Scheduled));

    assertPipelineScheduled(evolveConfig);
    assertPipelineScheduled(goConfig);
  }
 private Pipeline passFirstStage(PipelineConfig pipelineConfig) {
   Stage completedMingleStage =
       stageDao.mostRecentWithBuilds(
           CaseInsensitiveString.str(pipelineConfig.name()),
           pipelineConfig.findBy(new CaseInsensitiveString("dev")));
   dbHelper.passStage(completedMingleStage);
   dbHelper.passStage(completedMingleStage);
   assertThat(completedMingleStage.getJobInstances().first().getState(), is(JobState.Completed));
   Pipeline pipeline =
       pipelineDao.mostRecentPipeline(CaseInsensitiveString.str(pipelineConfig.name()));
   return dbHelper.passPipeline(pipeline);
 }
  @Test
  public void shouldScheduleJobForAllAgentsWhenToBeRunOnAllAgents() throws Exception {
    configHelper.addAgent("localhost", "uuid1");
    configHelper.addAgent("localhost", "uuid2");
    configHelper.addAgent("localhost", "uuid3");
    configHelper.addAgentToEnvironment("dev", "uuid1");
    configHelper.setRunOnAllAgents(
        CaseInsensitiveString.str(evolveConfig.name()), STAGE_NAME, "unit", true);

    Material stubMaterial = new TestingMaterial();
    evolveConfig.setMaterialConfigs(new MaterialConfigs(stubMaterial.config()));
    MaterialRevisions revisions = new MaterialRevisions();
    revisions.addRevision(
        stubMaterial,
        ((TestingMaterial) stubMaterial)
            .modificationsSince(null, null, subprocessExecutionContext));
    BuildCause buildCause = BuildCause.createWithModifications(revisions, "");
    dbHelper.saveMaterials(buildCause.getMaterialRevisions());

    Pipeline pipeline =
        instanceFactory.createPipelineInstance(
            evolveConfig,
            buildCause,
            new DefaultSchedulingContext(
                DEFAULT_APPROVED_BY,
                environmentConfigService.agentsForPipeline(evolveConfig.name())),
            md5,
            new TimeProvider());
    pipelineService.save(pipeline);

    Stage instance =
        scheduleService.scheduleStage(
            pipeline,
            STAGE_NAME,
            "anyone",
            new ScheduleService.NewStageInstanceCreator(goConfigService),
            new ScheduleService.ExceptioningErrorHandler());
    JobInstances scheduledJobs = instance.getJobInstances();
    assertThat(
        scheduledJobs.toArray(),
        hasItemInArray(
            hasProperty(
                "name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("unit", 1)))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("agentUuid", is("uuid2"))));
    assertThat(
        scheduledJobs.toArray(),
        hasItemInArray(
            hasProperty(
                "name", is(RunOnAllAgents.CounterBasedJobNameGenerator.appendMarker("unit", 2)))));
    assertThat(scheduledJobs.toArray(), hasItemInArray(hasProperty("agentUuid", is("uuid3"))));
    assertThat(scheduledJobs.size(), is(2));
  }
Beispiel #29
0
  private int executeStage(Configuration configuration, Cluster cluster, int stageId) {
    Stage stage =
        masterConfig
            .getScenario()
            .getStage(
                stageId,
                state,
                getCurrentExtras(masterConfig, configuration, cluster),
                state.getReport());
    InitHelper.init(stage);
    StageResult result;
    try {
      if (stage instanceof MasterStage) {
        result = executeMasterStage((MasterStage) stage);
      } else if (stage instanceof DistStage) {
        result = executeDistStage(stageId, (DistStage) stage);
      } else {
        log.error("Stage '" + stage.getName() + "' is neither master nor distributed");
        return -1;
      }
    } finally {
      InitHelper.destroy(stage);
    }

    if (result == StageResult.SUCCESS) {
      return stageId + 1;
    } else if (result == StageResult.FAIL || result == StageResult.EXIT) {
      returnCode = masterConfig.getConfigurations().indexOf(configuration) + 1;
      if (result == StageResult.EXIT) {
        exitFlag = true;
      }
      return -1;
    } else if (result == StageResult.BREAK || result == StageResult.CONTINUE) {
      Stack<String> repeatNames = (Stack<String>) state.get(RepeatStage.REPEAT_NAMES);
      String nextLabel;
      if (repeatNames == null || repeatNames.isEmpty()) {
        log.warn("BREAK or CONTINUE used out of any repeat.");
        return -1;
      } else if (result == StageResult.BREAK) {
        nextLabel = Utils.concat(".", "repeat", repeatNames.peek(), "end");
      } else if (result == StageResult.CONTINUE) {
        nextLabel = Utils.concat(".", "repeat", repeatNames.peek(), "begin");
      } else throw new IllegalStateException();
      int nextStageId = masterConfig.getScenario().getLabel(nextLabel);
      if (nextStageId < 0) {
        log.error("No label '" + nextLabel + "' defined");
      }
      return nextStageId;
    } else {
      throw new IllegalStateException("Result does not match to any type.");
    }
  }
  private Pipeline scheduleJobInstancesAndSavePipeline(Pipeline pipeline) {
    assertNotInserted(pipeline.getId());
    for (Stage stage : pipeline.getStages()) {
      for (JobInstance jobInstance : stage.getJobInstances()) {
        jobInstance.schedule();
      }
    }
    this.savePipelineWithStagesAndMaterials(pipeline);

    long pipelineId = pipeline.getId();
    assertIsInserted(pipelineId);
    return pipeline;
  }