/**
   * Handles the remote dispatch of a local event so that runners on other nodes can eventually
   * receive the data.
   */
  @Override
  public void newStateAdded(ITransition sourceTransition, IState newStateId) {
    if (sourceTransition == null) {
      return;
    }

    NewStateChange change =
        new NewStateChange(
            sourceTransition.getFiredFrom().getId(),
            sourceTransition.getId(),
            newStateId.getId(),
            convert(newStateId.getOutgoingTransitions()),
            "me");

    if (appliedRemoteChanges.contains(change)) {
      appliedRemoteChanges.remove(change);
      return;
    }

    List<IDesignSpaceChange> push = null;
    synchronized (hashSet) {
      hashSet.add(change);
      if (hashSet.size() > 0) {
        push = new ArrayList<IDesignSpaceChange>();
        push.addAll(hashSet);
        hashSet.clear();
      }
    }

    if (push != null) {
      remote.doUpdates(push, identifier);
      //			process(updates);
    }
  }
 private Map<Object, RemoteTransitionMetaData> convert(
     Collection<? extends ITransition> outgoing) {
   Map<Object, RemoteTransitionMetaData> trans = new HashMap<Object, RemoteTransitionMetaData>();
   for (ITransition transition : outgoing) {
     trans.put(transition.getId(), convertRemote(transition.getTransitionMetaData()));
   }
   return trans;
 }
  private boolean merge(IDesignSpaceChange change) {
    if (change instanceof NewRootChange) {
      NewRootChange newRootChange = (NewRootChange) change;

      local.addState(
          null,
          newRootChange.getRootId(),
          convertLocal(newRootChange.getOutgoingTransitions()),
          false);
      System.out.println("DS root is now: " + local.getRoot());
      return true;
    }
    if (change instanceof NewStateChange) {
      NewStateChange newStateChange = (NewStateChange) change;
      IState sourceState = local.getStateById(newStateChange.getSourceStateId());
      if (sourceState != null) {
        //				System.out.println("source state is id: " + newStateChange.getSourceStateId() + "
        // locally found id: "
        //						+ sourceState);
        ITransition sourceTransition = null;
        for (ITransition t : sourceState.getOutgoingTransitions()) {
          if (t.getId().equals(newStateChange.getTransitionId())) {
            sourceTransition = t;
          }
        }
        if (sourceTransition == null) {
          throw new Error();
        }

        appliedRemoteChanges.add(change);
        local.addState(
            sourceTransition,
            newStateChange.getNewStateId(),
            convertLocal(newStateChange.getOutgoingTransitions()),
            false);
        return true;
      } else {
        return false;
      }
    }
    throw new Error();
  }