class MetaStoreImpl implements MutableMetaStore {

  @Override
  public void deleteSource(final SourceName sourceName) {
    synchronized (referentialIntegrityLock) {
      dataSources.compute(sourceName, (ignored, source) -> {
        if (source == null) {
          throw new KsqlException(String.format("No data source with name %s exists.",
              sourceName.text()));
        }

        final String sourceForQueriesMessage = source.referentialIntegrity
            .getSourceForQueries()
            .stream()
            .collect(Collectors.joining(", "));

        final String sinkForQueriesMessage = source.referentialIntegrity
            .getSinkForQueries()
            .stream()
            .collect(Collectors.joining(", "));

        if (!sourceForQueriesMessage.isEmpty() || !sinkForQueriesMessage.isEmpty()) {
          throw new KsqlReferentialIntegrityException(
              String.format("Cannot drop %s.%n"
                      + "The following queries read from this source: [%s].%n"
                      + "The following queries write into this source: [%s].%n"
                      + "You need to terminate them before dropping %s.",
                  sourceName.toString(FormatOptions.noEscape()),
                  sourceForQueriesMessage,
                  sinkForQueriesMessage,
                  sourceName.toString(FormatOptions.noEscape())));
        }

        return null;
      });
    }
  }

  public  MetaStoreImpl(final FunctionRegistry functionRegistry);
  private  MetaStoreImpl(
      final Map<SourceName, SourceInfo> dataSources,
      final FunctionRegistry functionRegistry,
      final TypeRegistry typeRegistry
  );

}