Пример #1
0
  @Override
  @Before
  public void setUp() throws Exception {
    if (!tablesCreated) {

      if (NODE1 == null) {
        NODE1 = CLUSTER.startNode(getNodeSettings());
      }
      if (NODE2 == null) {
        NODE2 = CLUSTER.startNode(getNodeSettings());
      }
      for (int i = 0; i < tablesAmount(); ++i) {
        execute(
            "create table setup_"
                + i
                + " ("
                + " countryName string,"
                + " population integer,"
                + " continent string"
                + ") clustered into 1 shards with (number_of_replicas=0)",
            new Object[0],
            false);
      }
    }
    tablesCreated = true;
  }
  /** Tests parsing valid strings */
  @Test
  public void parseValidString() {
    String[] validValues = {
      CLUSTER.getValue(),
      DC.getValue(),
      OTHER_DC.getValue(),
      CLUSTER.getValue() + "," + DC.getValue() + "," + OTHER_DC.getValue()
    };

    for (String invalidValue : validValues) {
      FenceProxySourceTypeHelper.parseFromString(invalidValue);
    }
  }
  @Override
  public void handleRebalanceCompleted(
      String cacheName, Address node, int topologyId, Throwable throwable, int viewId)
      throws Exception {
    if (throwable != null) {
      // TODO We could try to update the pending CH such that nodes reporting errors are not
      // considered to hold any state
      // For now we are just logging the error and proceeding as if the rebalance was successful
      // everywhere
      log.rebalanceError(cacheName, node, throwable);
    }

    CLUSTER.rebalanceCompleted(cacheName, node, topologyId);

    ClusterCacheStatus cacheStatus = cacheStatusMap.get(cacheName);
    if (cacheStatus == null || !cacheStatus.isRebalanceInProgress()) {
      log.debugf(
          "Ignoring rebalance confirmation from %s "
              + "for cache %s because it doesn't have a cache status entry",
          node, cacheName);
      return;
    }

    cacheStatus.doConfirmRebalance(node, topologyId);
  }
 @Override
 public void setRebalancingEnabled(boolean enabled) {
   if (enabled) {
     if (!globalRebalancingEnabled) {
       CLUSTER.rebalancingEnabled();
     }
   } else {
     if (globalRebalancingEnabled) {
       CLUSTER.rebalancingSuspended();
     }
   }
   globalRebalancingEnabled = enabled;
   for (ClusterCacheStatus cacheStatus : cacheStatusMap.values()) {
     cacheStatus.startQueuedRebalance();
   }
 }
 @Override
 public void broadcastRebalanceStart(
     String cacheName, CacheTopology cacheTopology, boolean totalOrder, boolean distributed) {
   CLUSTER.startRebalance(cacheName, cacheTopology);
   ReplicableCommand command =
       new CacheTopologyControlCommand(
           cacheName,
           CacheTopologyControlCommand.Type.REBALANCE_START,
           transport.getAddress(),
           cacheTopology,
           null,
           transport.getViewId());
   executeOnClusterAsync(command, getGlobalTimeout(), totalOrder, distributed);
 }