class TransportCreateViewAction extends TransportMasterNodeAction<CreateViewRequest, CreateViewResponse> {

    @Inject
    public TransportCreateViewAction(TransportService transportService,
                                     ClusterService clusterService,
                                     ThreadPool threadPool) {
        super(
            "internal:crate:sql/views/create",
            transportService,
            clusterService,
            threadPool,
            CreateViewRequest::new
        );
    }

    @Override
    protected String executor() {
        return ThreadPool.Names.GENERIC;
    }

    @Override
    protected CreateViewResponse read(StreamInput in) throws IOException {
        return new CreateViewResponse(in);
    }

    @Override
    protected void masterOperation(CreateViewRequest request,
                                   ClusterState state,
                                   ActionListener<CreateViewResponse> listener) {<FILL_FUNCTION_BODY>}

    @Override
    protected ClusterBlockException checkBlock(CreateViewRequest request, ClusterState state) {
        return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
    }
}


        if (!request.replaceExisting() && state.metadata().contains(request.name())) {
            listener.onResponse(new CreateViewResponse(true));
        } else {
            clusterService.submitStateUpdateTask("views/create [" + request.name() + "]",
                new AckedClusterStateUpdateTask<CreateViewResponse>(Priority.HIGH, request, listener) {

                    boolean alreadyExitsFailure = false;

                    @Override
                    public ClusterState execute(ClusterState currentState) {
                        ViewsMetadata views = currentState.metadata().custom(ViewsMetadata.TYPE);
                        if (currentState.metadata().contains(request.name())) {
                            boolean replacesView = request.replaceExisting() && views != null && views.contains(request.name());
                            if (!replacesView) {
                                alreadyExitsFailure = true;
                                return currentState;
                            }
                        }
                        return ClusterState.builder(currentState)
                            .metadata(
                                Metadata.builder(currentState.metadata())
                                    .putCustom(
                                        ViewsMetadata.TYPE,
                                        ViewsMetadata.addOrReplace(
                                            views,
                                            request.name(),
                                            request.query(),
                                            request.owner(),
                                            request.searchPath()))
                                    .build()
                            ).build();
                    }

                    @Override
                    protected CreateViewResponse newResponse(boolean acknowledged) {
                        return new CreateViewResponse(alreadyExitsFailure);
                    }
                });
        }
    
<methods><variables>protected final non-sealed org.elasticsearch.cluster.service.ClusterService clusterService,private final non-sealed java.lang.String executor,protected final non-sealed org.elasticsearch.threadpool.ThreadPool threadPool,protected final non-sealed org.elasticsearch.transport.TransportService transportService