Package org.apache.helix.api.id

Examples of org.apache.helix.api.id.PartitionId


  public void doTransition(Message message, NotificationContext context) {
    HelixManager manager = context.getManager();
    ZkHelixPropertyStore<ZNRecord> store = manager.getHelixPropertyStore();
    final String setPath = "/TEST_PERF/set";
    final String updatePath = "/TEST_PERF/update";
    final PartitionId key = message.getPartitionId();
    try {
      // get/set once
      ZNRecord record = null;
      try {
        record = store.get(setPath, null, 0);
      } catch (ZkNoNodeException e) {
        record = new ZNRecord(setPath);
      }
      record.setSimpleField("setTimestamp", "" + System.currentTimeMillis());
      store.set(setPath, record, AccessOption.PERSISTENT);

      // update once
      store.update(updatePath, new DataUpdater<ZNRecord>() {

        @Override
        public ZNRecord update(ZNRecord currentData) {
          if (currentData == null) {
            currentData = new ZNRecord(updatePath);
          }
          currentData.setSimpleField(key.stringify(), "" + System.currentTimeMillis());

          return currentData;
        }

      }, AccessOption.PERSISTENT);
View Full Code Here


  @Override
  public void doTransition(Message message, NotificationContext context) {
    State fromState = message.getTypedFromState();
    State toState = message.getTypedToState();
    PartitionId partition = message.getPartitionId();

    String key = (fromState + "-" + toState).toUpperCase();
    if (_errPartitions.containsKey(key) && _errPartitions.get(key).contains(partition.stringify())) {
      String errMsg =
          "IGNORABLE: test throw exception in msgId: " + message.getId() + " for " + partition
              + " transit from " + fromState + " to " + toState;
      throw new RuntimeException(errMsg);
    }
View Full Code Here

TOP

Related Classes of org.apache.helix.api.id.PartitionId

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.