@Override
  protected void masterOperation(
      final TypesExistsRequest request,
      final ClusterState state,
      final ActionListener<TypesExistsResponse> listener)
      throws ElasticSearchException {
    String[] concreteIndices =
        state.metaData().concreteIndices(request.indices(), request.ignoreIndices(), false);
    if (concreteIndices.length == 0) {
      listener.onResponse(new TypesExistsResponse(false));
      return;
    }

    for (String concreteIndex : concreteIndices) {
      if (!state.metaData().hasConcreteIndex(concreteIndex)) {
        listener.onResponse(new TypesExistsResponse(false));
        return;
      }

      ImmutableMap<String, MappingMetaData> mappings =
          state.metaData().getIndices().get(concreteIndex).mappings();
      if (mappings.isEmpty()) {
        listener.onResponse(new TypesExistsResponse(false));
        return;
      }

      for (String type : request.types()) {
        if (!mappings.containsKey(type)) {
          listener.onResponse(new TypesExistsResponse(false));
          return;
        }
      }
    }

    listener.onResponse(new TypesExistsResponse(true));
  }
  @Override
  protected void masterOperation(
      final TypesExistsRequest request,
      final ClusterState state,
      final ActionListener<TypesExistsResponse> listener) {
    String[] concreteIndices =
        indexNameExpressionResolver.concreteIndexNames(
            state, request.indicesOptions(), request.indices());
    if (concreteIndices.length == 0) {
      listener.onResponse(new TypesExistsResponse(false));
      return;
    }

    for (String concreteIndex : concreteIndices) {
      if (!state.metaData().hasConcreteIndex(concreteIndex)) {
        listener.onResponse(new TypesExistsResponse(false));
        return;
      }

      ImmutableOpenMap<String, MappingMetaData> mappings =
          state.metaData().getIndices().get(concreteIndex).getMappings();
      if (mappings.isEmpty()) {
        listener.onResponse(new TypesExistsResponse(false));
        return;
      }

      for (String type : request.types()) {
        if (!mappings.containsKey(type)) {
          listener.onResponse(new TypesExistsResponse(false));
          return;
        }
      }
    }

    listener.onResponse(new TypesExistsResponse(true));
  }
 @Override
 protected ClusterBlockException checkBlock(TypesExistsRequest request, ClusterState state) {
   return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA, request.indices());
 }