Exemplo n.º 1
0
  private boolean isInstanceSetup() {
    if (_instanceType == InstanceType.PARTICIPANT
        || _instanceType == InstanceType.CONTROLLER_PARTICIPANT) {
      boolean isValid =
          _store.exists(
                  PropertyPathConfig.getPath(
                      PropertyType.CONFIGS,
                      _clusterName,
                      ConfigScopeProperty.PARTICIPANT.toString(),
                      _instanceName))
              && _store.exists(
                  PropertyPathConfig.getPath(PropertyType.MESSAGES, _clusterName, _instanceName))
              && _store.exists(
                  PropertyPathConfig.getPath(
                      PropertyType.CURRENTSTATES, _clusterName, _instanceName))
              && _store.exists(
                  PropertyPathConfig.getPath(
                      PropertyType.STATUSUPDATES, _clusterName, _instanceName))
              && _store.exists(
                  PropertyPathConfig.getPath(PropertyType.ERRORS, _clusterName, _instanceName));

      return isValid;
    }
    return true;
  }
Exemplo n.º 2
0
  @Test
  public void testNullReplica() throws Exception {
    // Logger.getRootLogger().setLevel(Level.INFO);
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;

    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));

    MockParticipant[] participants = new MockParticipant[5];

    TestHelper.setupCluster(
        clusterName,
        ZK_ADDR,
        12918, // participant port
        "localhost", // participant name prefix
        "TestDB", // resource name prefix
        1, // resources
        10, // partitions per resource
        5, // number of nodes
        3, // replicas
        "MasterSlave",
        true); // do rebalance
    // set replica in ideal state to null
    String idealStatePath =
        PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, "TestDB0");
    ZNRecord idealState = _gZkClient.readData(idealStatePath);
    idealState.getSimpleFields().remove(IdealState.IdealStateProperty.REPLICAS.toString());
    _gZkClient.writeData(idealStatePath, idealState);

    ClusterController controller = new ClusterController(clusterName, "controller_0", ZK_ADDR);
    controller.syncStart();

    // start participants
    for (int i = 0; i < 5; i++) {
      String instanceName = "localhost_" + (12918 + i);

      participants[i] = new MockParticipant(clusterName, instanceName, ZK_ADDR, null);
      participants[i].syncStart();
    }

    boolean result =
        ClusterStateVerifier.verifyByZkCallback(
            new BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
    Assert.assertTrue(result);

    // clean up
    for (int i = 0; i < 5; i++) {
      participants[i].syncStop();
    }

    Thread.sleep(2000);
    controller.syncStop();

    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
  }
Exemplo n.º 3
0
  @Override
  public PropertyStore<ZNRecord> getPropertyStore() {
    checkConnected();

    if (_propertyStore == null) {
      String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, _clusterName);

      String propertyStoreRoot = _store.getPropertyRootNamespace() + path;
      _propertyStore =
          new FilePropertyStore<ZNRecord>(
              new PropertyJsonSerializer<ZNRecord>(ZNRecord.class),
              propertyStoreRoot,
              new PropertyJsonComparator<ZNRecord>(ZNRecord.class));
    }
    return _propertyStore;
  }
Exemplo n.º 4
0
  private boolean isClusterSetup(String clusterName) {
    if (clusterName == null || _store == null) {
      return false;
    }

    boolean isValid =
        _store.exists(PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName))
            && _store.exists(
                PropertyPathConfig.getPath(
                    PropertyType.CONFIGS, clusterName, ConfigScopeProperty.CLUSTER.toString()))
            && _store.exists(
                PropertyPathConfig.getPath(
                    PropertyType.CONFIGS, clusterName, ConfigScopeProperty.PARTICIPANT.toString()))
            && _store.exists(
                PropertyPathConfig.getPath(
                    PropertyType.CONFIGS, clusterName, ConfigScopeProperty.RESOURCE.toString()))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.LIVEINSTANCES, clusterName))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.INSTANCES, clusterName))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.EXTERNALVIEW, clusterName))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.CONTROLLER, clusterName))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.STATEMODELDEFS, clusterName))
            && _store.exists(
                PropertyPathConfig.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName))
            && _store.exists(
                PropertyPathConfig.getPath(PropertyType.ERRORS_CONTROLLER, clusterName))
            && _store.exists(
                PropertyPathConfig.getPath(PropertyType.STATUSUPDATES_CONTROLLER, clusterName))
            && _store.exists(PropertyPathConfig.getPath(PropertyType.HISTORY, clusterName));

    return isValid;
  }