예제 #1
0
  /**
   * Managing timeouts is trickier than putting all of them in a long list, like regular message
   * delivery. Timeouts are ordered and can be cancelled, so they need special treatment. Hence a
   * separate method for managing timeouts triggering.
   */
  private Pair<ClusterAction, ClusterState> performNextTimeoutFrom(ClusterInstance instance)
      throws Exception {
    ClusterState newState = snapshot();
    ClusterAction clusterAction = newState.instance(instance.uri().toASCIIString()).popTimeout();
    clusterAction.perform(newState);

    return Pair.of(clusterAction, newState);
  }
예제 #2
0
  public ClusterInstance instance(String to) throws URISyntaxException {
    URI uri = new URI(to);
    for (ClusterInstance clusterInstance : instances) {
      URI instanceUri = clusterInstance.uri();
      if (instanceUri.getHost().equals(uri.getHost()) && instanceUri.getPort() == uri.getPort()) {
        return clusterInstance;
      }
    }

    throw new IllegalArgumentException("No instance in cluster at address: " + to);
  }