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;
  }
  @Override
  public void disconnect() {
    _store.stop();
    _messagingService.getExecutor().shutDown();

    _isConnected = false;
  }
 @Override
 public void connect() {
   if (!isClusterSetup(_clusterName)) {
     throw new HelixException(
         "Initial cluster structure is not set up for cluster:" + _clusterName);
   }
   _messagingService.onConnected();
   _store.start();
   _isConnected = true;
 }
  @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;
  }
  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;
  }