Package org.apache.helix.model

Examples of org.apache.helix.model.StatusUpdate


              keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), originalMessage
                  .getMessageId().stringify())).getRecord();

      statusUpdate.getMapFields().putAll(_resultSummaryMap);
      accessor.setProperty(keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(),
          originalMessage.getMessageId().stringify()), new StatusUpdate(statusUpdate));

    }
View Full Code Here


              keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), _message
                  .getMessageId().stringify())).getRecord();

      statusUpdate.getMapFields().put("SentMessageCount", sendSummary);
      accessor.updateProperty(keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(),
          _message.getMessageId().stringify()), new StatusUpdate(statusUpdate));
    }
View Full Code Here

                  .getMessageId().stringify())).getRecord();

      statusUpdate.getMapFields().put("SentMessageCount", sendSummary);

      accessor.setProperty(keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(),
          _message.getMessageId().stringify()), new StatusUpdate(statusUpdate));

      result.getTaskResultMap().put("ControllerResult",
          "msg " + _message.getMessageId() + " from " + _message.getMsgSrc() + " processed");
      result.getTaskResultMap().put(SCHEDULER_MSG_ID, _message.getMessageId().stringify());
      result.setSuccess(true);
View Full Code Here

    if (controllerMsgUpdates.size() > 0) {
      for (String controllerMsgId : controllerMsgUpdates.keySet()) {
        PropertyKey controllerStatusUpdateKey =
            keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), controllerMsgId);
        StatusUpdate controllerStatusUpdate = accessor.getProperty(controllerStatusUpdateKey);
        for (String taskPartitionName : controllerMsgUpdates.get(controllerMsgId).keySet()) {
          Message innerMessage =
              schedulerTaskConfig.getInnerMessage(PartitionId.from(taskPartitionName));

          Map<String, String> result = new HashMap<String, String>();
          result.put("Result", controllerMsgUpdates.get(controllerMsgId).get(taskPartitionName));
          controllerStatusUpdate.getRecord().setMapField(
              "MessageResult " + innerMessage.getTgtName() + " " + taskPartitionName + " "
                  + innerMessage.getMessageId(), result);
        }

        // All done for the scheduled tasks that came from controllerMsgId, add summary for it
        if (controllerMsgUpdates.get(controllerMsgId).size() == controllerMsgIdCountMap.get(
            controllerMsgId).intValue()) {
          int finishedTasksNum = 0;
          int completedTasksNum = 0;
          for (String key : controllerStatusUpdate.getRecord().getMapFields().keySet()) {
            if (key.startsWith("MessageResult ")) {
              finishedTasksNum++;
            }
            if (controllerStatusUpdate.getRecord().getMapField(key).get("Result") != null) {
              if (controllerStatusUpdate.getRecord().getMapField(key).get("Result")
                  .equalsIgnoreCase("COMPLETED")) {
                completedTasksNum++;
              }
            }
          }
          Map<String, String> summary = new TreeMap<String, String>();
          summary.put("TotalMessages:", "" + finishedTasksNum);
          summary.put("CompletedMessages", "" + completedTasksNum);

          controllerStatusUpdate.getRecord().setMapField("Summary", summary);
        }
        // Update the statusUpdate of controllerMsgId
        accessor.updateProperty(controllerStatusUpdateKey, controllerStatusUpdate);
      }
    }
View Full Code Here

    Assert.assertEquals(0, factory._results.size());
    PropertyKey controllerTaskStatus =
        keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(),
            schedulerMessage.getMsgId());
    for (int i = 0; i < 10; i++) {
      StatusUpdate update = helixDataAccessor.getProperty(controllerTaskStatus);
      if (update == null || update.getRecord().getMapField("SentMessageCount") == null) {
        Thread.sleep(1000);
      }
    }
    ZNRecord statusUpdate = helixDataAccessor.getProperty(controllerTaskStatus).getRecord();
    Assert.assertTrue(statusUpdate.getMapField("SentMessageCount").get("MessageCount").equals("0"));
View Full Code Here

    if (controllerMsgUpdates.size() > 0) {
      for (String controllerMsgId : controllerMsgUpdates.keySet()) {
        PropertyKey controllerStatusUpdateKey =
            keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), controllerMsgId);
        StatusUpdate controllerStatusUpdate = accessor.getProperty(controllerStatusUpdateKey);
        for (String taskPartitionName : controllerMsgUpdates.get(controllerMsgId).keySet()) {
          Map<String, String> result = new HashMap<String, String>();
          result.put("Result", controllerMsgUpdates.get(controllerMsgId).get(taskPartitionName));
          controllerStatusUpdate.getRecord().setMapField(
              "MessageResult "
                  + taskQueueIdealState.getRecord().getMapField(taskPartitionName)
                      .get(Message.Attributes.TGT_NAME.toString())
                  + " "
                  + taskPartitionName
                  + " "
                  + taskQueueIdealState.getRecord().getMapField(taskPartitionName)
                      .get(Message.Attributes.MSG_ID.toString()), result);
        }
        // All done for the scheduled tasks that came from controllerMsgId, add summary for it
        if (controllerMsgUpdates.get(controllerMsgId).size() == controllerMsgIdCountMap.get(
            controllerMsgId).intValue()) {
          int finishedTasksNum = 0;
          int completedTasksNum = 0;
          for (String key : controllerStatusUpdate.getRecord().getMapFields().keySet()) {
            if (key.startsWith("MessageResult ")) {
              finishedTasksNum++;
            }
            if (controllerStatusUpdate.getRecord().getMapField(key).get("Result") != null) {
              if (controllerStatusUpdate.getRecord().getMapField(key).get("Result")
                  .equalsIgnoreCase("COMPLETED")) {
                completedTasksNum++;
              }
            }
          }
          Map<String, String> summary = new TreeMap<String, String>();
          summary.put("TotalMessages:", "" + finishedTasksNum);
          summary.put("CompletedMessages", "" + completedTasksNum);

          controllerStatusUpdate.getRecord().setMapField("Summary", summary);
        }
        // Update the statusUpdate of controllerMsgId
        accessor.updateProperty(controllerStatusUpdateKey, controllerStatusUpdate);
      }
    }
View Full Code Here

    PropertyKey errorKey = keyBuilder.stateTransitionErrors("localhost_12918");

    // add participant status updates and errors
    statusUpdateKey =
        keyBuilder.stateTransitionStatus("localhost_12918", "session_0", "TestDB0", "TestDB0_0");
    accessor.setProperty(statusUpdateKey, new StatusUpdate(new ZNRecord("statusUpdate")));
    errorKey =
        keyBuilder.stateTransitionError("localhost_12918", "session_0", "TestDB0", "TestDB0_0");
    accessor.setProperty(errorKey, new Error(new ZNRecord("error")));

    // add controller status updates and errors
    controllerStatusUpdateKey = keyBuilder.controllerTaskStatus("session_0", "TestDB");
    accessor.setProperty(controllerStatusUpdateKey, new StatusUpdate(new ZNRecord(
        "controllerStatusUpdate")));
    controllerErrorKey = keyBuilder.controllerTaskError("TestDB_error");
    accessor.setProperty(controllerErrorKey, new Error(new ZNRecord("controllerError")));

    // run dump task, should remove existing statusUpdate/error paths
View Full Code Here

    Assert.assertTrue(baseAccessor.exists(errorKey.getPath(), 0));

    // add participant status updates and errors
    statusUpdateKey =
        keyBuilder.stateTransitionStatus("localhost_12918", "session_0", "TestDB0", "TestDB0_0");
    accessor.setProperty(statusUpdateKey, new StatusUpdate(new ZNRecord("statusUpdate")));
    errorKey =
        keyBuilder.stateTransitionError("localhost_12918", "session_0", "TestDB0", "TestDB0_0");
    accessor.setProperty(errorKey, new Error(new ZNRecord("error")));

    // add controller status updates and errors (one of each, should not trigger anything)
    controllerStatusUpdateKey = keyBuilder.controllerTaskStatus("session_0", "TestDB");
    accessor.setProperty(controllerStatusUpdateKey, new StatusUpdate(new ZNRecord(
        "controllerStatusUpdate")));
    controllerErrorKey = keyBuilder.controllerTaskError("TestDB_error");
    accessor.setProperty(controllerErrorKey, new Error(new ZNRecord("controllerError")));

    // run dump task, should not remove anything because the threshold is not exceeded
    task.run();
    Assert.assertTrue(baseAccessor.exists(controllerStatusUpdateKey.getPath(), 0));
    Assert.assertTrue(baseAccessor.exists(controllerErrorKey.getPath(), 0));
    Assert.assertTrue(baseAccessor.exists(statusUpdateKey.getPath(), 0));
    Assert.assertTrue(baseAccessor.exists(errorKey.getPath(), 0));

    // add a second set of all status updates and errors
    statusUpdateKey =
        keyBuilder.stateTransitionStatus("localhost_12918", "session_0", "TestDB0", "TestDB0_1");
    accessor.setProperty(statusUpdateKey, new StatusUpdate(new ZNRecord("statusUpdate")));
    errorKey =
        keyBuilder.stateTransitionError("localhost_12918", "session_0", "TestDB0", "TestDB0_1");
    accessor.setProperty(errorKey, new Error(new ZNRecord("error")));
    controllerStatusUpdateKey = keyBuilder.controllerTaskStatus("session_0", "TestDB1");
    accessor.setProperty(controllerStatusUpdateKey, new StatusUpdate(new ZNRecord(
        "controllerStatusUpdate")));
    controllerErrorKey = keyBuilder.controllerTaskError("TestDB1_error");
    accessor.setProperty(controllerErrorKey, new Error(new ZNRecord("controllerError")));

    // run dump task, should remove everything since capacities are exceeded
View Full Code Here

    Assert.assertEquals(0, factory._results.size());
    PropertyKey controllerTaskStatus = keyBuilder.controllerTaskStatus(
        MessageType.SCHEDULER_MSG.toString(), schedulerMessage.getMsgId());
    for(int i = 0; i< 10; i++)
    {
      StatusUpdate update = helixDataAccessor.getProperty(controllerTaskStatus);
      if(update == null || update.getRecord().getMapField("SentMessageCount") == null)
      {
        Thread.sleep(1000);
      }
    }
    ZNRecord statusUpdate = helixDataAccessor.getProperty(controllerTaskStatus)
View Full Code Here

    {
      for(String controllerMsgId : controllerMsgUpdates.keySet())
      {
        PropertyKey controllerStatusUpdateKey
          = keyBuilder.controllerTaskStatus(MessageType.SCHEDULER_MSG.toString(), controllerMsgId);
        StatusUpdate controllerStatusUpdate = accessor.getProperty(controllerStatusUpdateKey);
        for(String taskPartitionName : controllerMsgUpdates.get(controllerMsgId).keySet())
        {
          Map<String, String> result = new HashMap<String, String>();
          result.put("Result", controllerMsgUpdates.get(controllerMsgId).get(taskPartitionName));
          controllerStatusUpdate.getRecord().setMapField("MessageResult "  +
             taskQueueIdealState.getRecord().getMapField(taskPartitionName).get(Message.Attributes.TGT_NAME.toString()) + " " + taskPartitionName + " " +
             taskQueueIdealState.getRecord().getMapField(taskPartitionName).get(Message.Attributes.MSG_ID.toString())
             , result);
        }
        // All done for the scheduled tasks that came from controllerMsgId, add summary for it
        if(controllerMsgUpdates.get(controllerMsgId).size() == controllerMsgIdCountMap.get(controllerMsgId).intValue())
        {
          int finishedTasksNum = 0;
          int completedTasksNum = 0;
          for(String key : controllerStatusUpdate.getRecord().getMapFields().keySet())
          {
            if(key.startsWith("MessageResult "))
            {
              finishedTasksNum ++;
            }
            if(controllerStatusUpdate.getRecord().getMapField(key).get("Result") != null)
            {
              if(controllerStatusUpdate.getRecord().getMapField(key).get("Result").equalsIgnoreCase("COMPLETED"))
              {
                completedTasksNum++;
              }
            }
          }
          Map<String, String> summary = new TreeMap<String, String>();
          summary.put("TotalMessages:", "" + finishedTasksNum);
          summary.put("CompletedMessages", "" + completedTasksNum);
         
          controllerStatusUpdate.getRecord().setMapField("Summary", summary);
        }
        // Update the statusUpdate of controllerMsgId
        accessor.updateProperty(controllerStatusUpdateKey, controllerStatusUpdate);
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.helix.model.StatusUpdate

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.