Search in sources :

Example 1 with JsConsumer

use of io.deephaven.web.shared.fu.JsConsumer in project deephaven-core by deephaven.

the class WorkerConnection method flush.

private void flush() {
    // LATER: instead of running a bunch of serial operations,
    // condense these all into a single batch operation.
    // All three server calls made by this method are _only_ called by this method,
    // so we can reasonably merge all three into a single batched operation.
    ArrayList<ClientTableState> statesToFlush = new ArrayList<>(flushable);
    flushable.clear();
    for (ClientTableState state : statesToFlush) {
        if (state.hasNoSubscriptions()) {
            // yet completed (we leave orphaned nodes paused until a request completes).
            if (state.isSubscribed()) {
                state.setSubscribed(false);
                if (state.getHandle().isConnected()) {
                    BiDiStream<FlightData, FlightData> stream = subscriptionStreams.remove(state);
                    if (stream != null) {
                        stream.end();
                        stream.cancel();
                    }
                }
            }
            if (state.isEmpty()) {
                // completely empty; perform release
                final ClientTableState.ResolutionState previousState = state.getResolution();
                state.setResolution(ClientTableState.ResolutionState.RELEASED);
                state.setSubscribed(false);
                if (previousState != ClientTableState.ResolutionState.RELEASED) {
                    cache.release(state);
                    JsLog.debug("Releasing state", state, LazyString.of(state.getHandle()));
                    // don't send a release message to the server if the table isn't really there
                    if (state.getHandle().isConnected()) {
                        releaseHandle(state.getHandle());
                    }
                }
            }
        } else {
            List<TableSubscriptionRequest> vps = new ArrayList<>();
            state.forActiveSubscriptions((table, subscription) -> {
                assert table.isActive(state) : "Inactive table has a viewport still attached";
                vps.add(new TableSubscriptionRequest(table.getSubscriptionId(), subscription.getRows(), subscription.getColumns()));
            });
            boolean isViewport = vps.stream().allMatch(req -> req.getRows() != null);
            assert isViewport || vps.stream().noneMatch(req -> req.getRows() != null) : "All subscriptions to a given handle must be consistently viewport or non-viewport";
            BitSet includedColumns = vps.stream().map(TableSubscriptionRequest::getColumns).reduce((bs1, bs2) -> {
                BitSet result = new BitSet();
                result.or(bs1);
                result.or(bs2);
                return result;
            }).orElseThrow(() -> new IllegalStateException("Cannot call subscribe with zero subscriptions"));
            String[] columnTypes = Arrays.stream(state.getTableDef().getColumns()).map(ColumnDefinition::getType).toArray(String[]::new);
            state.setSubscribed(true);
            Builder subscriptionReq = new Builder(1024);
            double columnsOffset = BarrageSubscriptionRequest.createColumnsVector(subscriptionReq, makeUint8ArrayFromBitset(includedColumns));
            double viewportOffset = 0;
            if (isViewport) {
                viewportOffset = BarrageSubscriptionRequest.createViewportVector(subscriptionReq, serializeRanges(vps.stream().map(TableSubscriptionRequest::getRows).collect(Collectors.toSet())));
            }
            // TODO #188 support minUpdateIntervalMs
            double serializationOptionsOffset = BarrageSubscriptionOptions.createBarrageSubscriptionOptions(subscriptionReq, ColumnConversionMode.Stringify, true, 1000, 0);
            double tableTicketOffset = BarrageSubscriptionRequest.createTicketVector(subscriptionReq, state.getHandle().getTicket());
            BarrageSubscriptionRequest.startBarrageSubscriptionRequest(subscriptionReq);
            BarrageSubscriptionRequest.addColumns(subscriptionReq, columnsOffset);
            BarrageSubscriptionRequest.addSubscriptionOptions(subscriptionReq, serializationOptionsOffset);
            BarrageSubscriptionRequest.addViewport(subscriptionReq, viewportOffset);
            BarrageSubscriptionRequest.addTicket(subscriptionReq, tableTicketOffset);
            subscriptionReq.finish(BarrageSubscriptionRequest.endBarrageSubscriptionRequest(subscriptionReq));
            FlightData request = new FlightData();
            request.setAppMetadata(BarrageUtils.wrapMessage(subscriptionReq, BarrageMessageType.BarrageSubscriptionRequest));
            BiDiStream<FlightData, FlightData> stream = this.<FlightData, FlightData>streamFactory().create(headers -> flightServiceClient.doExchange(headers), (first, headers) -> browserFlightServiceClient.openDoExchange(first, headers), (next, headers, c) -> browserFlightServiceClient.nextDoExchange(next, headers, c::apply), new FlightData());
            stream.send(request);
            stream.onData(new JsConsumer<FlightData>() {

                @Override
                public void apply(FlightData data) {
                    ByteBuffer body = typedArrayToLittleEndianByteBuffer(data.getDataBody_asU8());
                    Message headerMessage = Message.getRootAsMessage(new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer(data.getDataHeader_asU8()));
                    if (body.limit() == 0 && headerMessage.headerType() != MessageHeader.RecordBatch) {
                        // TODO hang on to the schema to better handle the now-Utf8 columns
                        return;
                    }
                    RecordBatch header = headerMessage.header(new RecordBatch());
                    BarrageMessageWrapper barrageMessageWrapper = BarrageMessageWrapper.getRootAsBarrageMessageWrapper(new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer(data.getAppMetadata_asU8()));
                    if (barrageMessageWrapper.msgType() == BarrageMessageType.None) {
                        // continue previous message, just read RecordBatch
                        appendAndMaybeFlush(header, body);
                    } else {
                        assert barrageMessageWrapper.msgType() == BarrageMessageType.BarrageUpdateMetadata;
                        BarrageUpdateMetadata barrageUpdate = BarrageUpdateMetadata.getRootAsBarrageUpdateMetadata(new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer(new Uint8Array(barrageMessageWrapper.msgPayloadArray())));
                        startAndMaybeFlush(barrageUpdate.isSnapshot(), header, body, barrageUpdate, isViewport, columnTypes);
                    }
                }

                private DeltaUpdatesBuilder nextDeltaUpdates;

                private void appendAndMaybeFlush(RecordBatch header, ByteBuffer body) {
                    // using existing barrageUpdate, append to the current snapshot/delta
                    assert nextDeltaUpdates != null;
                    boolean shouldFlush = nextDeltaUpdates.appendRecordBatch(header, body);
                    if (shouldFlush) {
                        incrementalUpdates(state.getHandle(), nextDeltaUpdates.build());
                        nextDeltaUpdates = null;
                    }
                }

                private void startAndMaybeFlush(boolean isSnapshot, RecordBatch header, ByteBuffer body, BarrageUpdateMetadata barrageUpdate, boolean isViewport, String[] columnTypes) {
                    if (isSnapshot) {
                        TableSnapshot snapshot = createSnapshot(header, body, barrageUpdate, isViewport, columnTypes);
                        // for now we always expect snapshots to arrive in a single payload
                        initialSnapshot(state.getHandle(), snapshot);
                    } else {
                        nextDeltaUpdates = deltaUpdates(barrageUpdate, isViewport, columnTypes);
                        appendAndMaybeFlush(header, body);
                    }
                }
            });
            stream.onStatus(err -> {
                checkStatus(err);
                if (!err.isOk()) {
                    // TODO (core#1181): fix this hack that enables barrage errors to propagate to the UI widget
                    state.forActiveSubscriptions((table, subscription) -> {
                        table.failureHandled(err.getDetails());
                    });
                }
            });
            BiDiStream<FlightData, FlightData> oldStream = subscriptionStreams.put(state, stream);
            if (oldStream != null) {
                // cancel any old stream, we presently expect a fresh instance
                oldStream.end();
                oldStream.cancel();
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) InitialTableDefinition(io.deephaven.web.client.api.barrage.def.InitialTableDefinition) LogSubscriptionRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.console_pb.LogSubscriptionRequest) JsPropertyMap(jsinterop.base.JsPropertyMap) Buffer(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Buffer) HandshakeResponse(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.session_pb.HandshakeResponse) TypedTicket(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.TypedTicket) JsTimeZone(io.deephaven.web.client.api.i18n.JsTimeZone) ObjectServiceClient(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.object_pb_service.ObjectServiceClient) StackTrace(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.session_pb.terminationnotificationresponse.StackTrace) io.deephaven.web.shared.data(io.deephaven.web.shared.data) Map(java.util.Map) SessionServiceClient(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.session_pb_service.SessionServiceClient) FieldsChangeUpdate(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb.FieldsChangeUpdate) ListFieldsRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb.ListFieldsRequest) Set(java.util.Set) ClientTableState(io.deephaven.web.client.state.ClientTableState) ExportedTableCreationResponse(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableCreationResponse) JsArray(elemental2.core.JsArray) JsSet(elemental2.core.JsSet) Uint8Array(elemental2.core.Uint8Array) MetadataVersion(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.MetadataVersion) JsVariableDefinition(io.deephaven.web.client.api.console.JsVariableDefinition) KeyValue(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.KeyValue) ConsoleServiceClient(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.console_pb_service.ConsoleServiceClient) BarrageMessageWrapper(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper) JsRunnable(io.deephaven.web.shared.fu.JsRunnable) JsItr(io.deephaven.web.client.fu.JsItr) JsOptional(jsinterop.annotations.JsOptional) JsWidget(io.deephaven.web.client.api.widget.JsWidget) JsFigure(io.deephaven.web.client.api.widget.plot.JsFigure) Promise(elemental2.promise.Promise) BiDiStream(io.deephaven.web.client.api.barrage.stream.BiDiStream) Supplier(java.util.function.Supplier) RequestBatcher(io.deephaven.web.client.api.batch.RequestBatcher) ArrayList(java.util.ArrayList) Builder(io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder) ResponseStreamWrapper(io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper) BiConsumer(java.util.function.BiConsumer) TableReviver(io.deephaven.web.client.state.TableReviver) FetchObjectRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.object_pb.FetchObjectRequest) JsTreeTable(io.deephaven.web.client.api.tree.JsTreeTable) TableServiceClient(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb_service.TableServiceClient) LazyPromise(io.deephaven.web.client.fu.LazyPromise) Nullable(javax.annotation.Nullable) BrowserHeaders(io.deephaven.javascript.proto.dhinternal.browserheaders.BrowserHeaders) LogSubscriptionData(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.console_pb.LogSubscriptionData) Ticket(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket) ColumnDefinition(io.deephaven.web.client.api.barrage.def.ColumnDefinition) RecordBatch(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch) MergeTablesRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.MergeTablesRequest) ApplyPreviewColumnsRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ApplyPreviewColumnsRequest) InputTableServiceClient(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.inputtable_pb_service.InputTableServiceClient) BarrageSubscriptionOptions(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionOptions) ColumnConversionMode(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.ColumnConversionMode) EmptyTableRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.EmptyTableRequest) BarrageUpdateMetadata(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata) ByteBuffer(java.nio.ByteBuffer) TableConfig(io.deephaven.web.client.api.batch.TableConfig) TableReference(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.TableReference) JsVariableChanges(io.deephaven.web.client.api.console.JsVariableChanges) ReleaseRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.session_pb.ReleaseRequest) FlightData(io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData) ApplicationServiceClient(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb_service.ApplicationServiceClient) ExportedTableUpdatesRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableUpdatesRequest) JsLog(io.deephaven.web.client.fu.JsLog) Collectors(java.util.stream.Collectors) HasTableBinding(io.deephaven.web.client.state.HasTableBinding) List(java.util.List) FlightServiceClient(io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb_service.FlightServiceClient) HasLifecycle(io.deephaven.web.client.api.lifecycle.HasLifecycle) Message(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.Message) JsWeakMap(elemental2.core.JsWeakMap) BarrageSubscriptionRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionRequest) ExportedTableUpdateMessage(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableUpdateMessage) Optional(java.util.Optional) TimeTableRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.TimeTableRequest) HandshakeRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.session_pb.HandshakeRequest) Code(io.deephaven.javascript.proto.dhinternal.grpcweb.grpc.Code) Grpc(io.deephaven.javascript.proto.dhinternal.grpcweb.Grpc) BrowserFlightServiceClient(io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.browserflight_pb_service.BrowserFlightServiceClient) BarrageMessageType(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageType) JsMethod(jsinterop.annotations.JsMethod) HashMap(java.util.HashMap) StateCache(io.deephaven.web.client.api.state.StateCache) HashSet(java.util.HashSet) FetchTableRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.FetchTableRequest) Js(jsinterop.base.Js) FieldNode(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.FieldNode) Charset(java.nio.charset.Charset) Field(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Field) FetchObjectResponse(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.object_pb.FetchObjectResponse) Long(io.deephaven.javascript.proto.dhinternal.flatbuffers.Long) JsConsumer(io.deephaven.web.shared.fu.JsConsumer) DomGlobal(elemental2.dom.DomGlobal) Schema(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Schema) TerminationNotificationRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.session_pb.TerminationNotificationRequest) JsDataHandler(io.deephaven.web.client.api.parse.JsDataHandler) BarrageUtils(io.deephaven.web.client.api.barrage.BarrageUtils) FieldInfo(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb.FieldInfo) BitSet(java.util.BitSet) MessageHeader(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.MessageHeader) BarrageMessageWrapper(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper) Message(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.Message) ExportedTableUpdateMessage(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableUpdateMessage) RecordBatch(io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch) Builder(io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder) ArrayList(java.util.ArrayList) Uint8Array(elemental2.core.Uint8Array) BitSet(java.util.BitSet) ByteBuffer(java.nio.ByteBuffer) BarrageUpdateMetadata(io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata) FlightData(io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData) ClientTableState(io.deephaven.web.client.state.ClientTableState)

Example 2 with JsConsumer

use of io.deephaven.web.shared.fu.JsConsumer in project deephaven-core by deephaven.

the class RequestBatcher method sendRequest.

public Promise<Void> sendRequest() {
    return new Promise<>((resolve, reject) -> {
        // calling buildRequest will change the state of each table, so we first check what the state was
        // of each table before we do that, in case we are actually not making a call to the server
        ClientTableState prevState = table.lastVisibleState();
        final BatchTableRequest request = buildRequest();
        // let callbacks peek at entire request about to be sent.
        for (JsConsumer<BatchTableRequest> send : onSend) {
            send.apply(request);
        }
        onSend.clear();
        sent = true;
        if (request.getOpsList().length == 0) {
            // This is like tableLoop below, except no failure is possible, since we already have the results
            if (table.isAlive()) {
                final ClientTableState active = table.state();
                assert active.isRunning() : active;
                boolean sortChanged = !prevState.getSorts().equals(active.getSorts());
                boolean filterChanged = !prevState.getFilters().equals(active.getFilters());
                boolean customColumnChanged = !prevState.getCustomColumns().equals(active.getCustomColumns());
                table.fireEvent(HasEventHandling.EVENT_REQUEST_SUCCEEDED);
                // TODO think more about the order of events, and what kinds of things one might bind to each
                if (sortChanged) {
                    table.fireEvent(JsTable.EVENT_SORTCHANGED);
                }
                if (filterChanged) {
                    table.fireEvent(JsTable.EVENT_FILTERCHANGED);
                }
                if (customColumnChanged) {
                    table.fireEvent(JsTable.EVENT_CUSTOMCOLUMNSCHANGED);
                }
            }
            orphans.forEach(ClientTableState::cleanup);
            resolve.onInvoke((Void) null);
            // if there's no outgoing operation, user may have removed an operation and wants to return to where
            // they left off
            table.maybeReviveSubscription();
            finished = true;
            return;
        }
        final BatchOp operationHead = builder.getFirstOp();
        assert operationHead != null : "A non-empty request must have a firstOp!";
        final ClientTableState source = operationHead.getAppendTo();
        assert source != null : "A non-empty request must have a source state!";
        JsLog.debug("Sending request", LazyString.of(request), request, " based on ", this);
        ResponseStreamWrapper<ExportedTableCreationResponse> batchStream = ResponseStreamWrapper.of(connection.tableServiceClient().batch(request, connection.metadata()));
        batchStream.onData(response -> {
            TableReference resultid = response.getResultId();
            if (!resultid.hasTicket()) {
                // thanks for telling us, but we don't at this time have a nice way to indicate this
                return;
            }
            Ticket ticket = resultid.getTicket();
            if (!response.getSuccess()) {
                String fail = response.getErrorInfo();
                // any table which has that state active should fire a failed event
                ClientTableState state = allStates().filter(cts -> cts.getHandle().makeTicket().getTicket_asB64().equals(ticket.getTicket_asB64())).first();
                if (state.isEmpty()) {
                    // nobody cares about this state anymore
                    JsLog.debug("Ignoring empty state", state);
                    return;
                }
                state.getHandle().setState(TableTicket.State.FAILED);
                for (JsTable table : allInterestedTables().filter(t -> t.state() == state)) {
                    // fire the failed event
                    failTable(table, fail);
                }
                // mark state as failed (his has to happen after table is marked as failed, it will trigger rollback
                state.setResolution(ClientTableState.ResolutionState.FAILED, fail);
                return;
            }
            // find the state that applies to this ticket
            ClientTableState state = allStates().filter(cts -> cts.getHandle().makeTicket().getTicket_asB64().equals(ticket.getTicket_asB64())).first();
            if (state.isEmpty()) {
                // response.
                return;
            }
            // Before we mark it as successfully running and give it its new schema, track the previous CTS
            // that each table was using. Identify which table to watch based on its current state, even if
            // not visible, but then track the last visible state, so we know which events to fire.
            Map<JsTable, ClientTableState> activeTablesAndStates = StreamSupport.stream(allInterestedTables().spliterator(), false).filter(JsTable::isAlive).filter(t -> t.state() == state).collect(Collectors.toMap(Function.identity(), JsTable::lastVisibleState));
            // Mark the table as ready to go
            state.applyTableCreationResponse(response);
            state.forActiveTables(t -> t.maybeRevive(state));
            state.setResolution(ClientTableState.ResolutionState.RUNNING);
            // Let each table know that what has changed since it has a previous state
            for (JsTable table : activeTablesAndStates.keySet()) {
                ClientTableState lastVisibleState = activeTablesAndStates.get(table);
                // fire any events that are necessary
                boolean sortChanged = !lastVisibleState.getSorts().equals(state.getSorts());
                boolean filterChanged = !lastVisibleState.getFilters().equals(state.getFilters());
                boolean customColumnChanged = !lastVisibleState.getCustomColumns().equals(state.getCustomColumns());
                table.fireEvent(HasEventHandling.EVENT_REQUEST_SUCCEEDED);
                // TODO think more about the order of events, and what kinds of things one might bind to each
                if (sortChanged) {
                    table.fireEvent(JsTable.EVENT_SORTCHANGED);
                }
                if (filterChanged) {
                    table.fireEvent(JsTable.EVENT_FILTERCHANGED);
                }
                if (customColumnChanged) {
                    table.fireEvent(JsTable.EVENT_CUSTOMCOLUMNSCHANGED);
                }
            }
        });
        batchStream.onEnd(status -> {
            // request is complete
            if (status.isOk()) {
                resolve.onInvoke((Void) null);
            } else {
                failed(reject, status.getDetails());
            }
            // Tell anybody who was orphaned to check if they should release their subscriptions / handles
            orphans.forEach(ClientTableState::cleanup);
        });
    });
}
Also used : BatchTableRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.BatchTableRequest) Arrays(java.util.Arrays) ActiveTableBinding(io.deephaven.web.client.state.ActiveTableBinding) JsMethod(jsinterop.annotations.JsMethod) RejectCallbackFn(elemental2.promise.Promise.PromiseExecutorCallbackFn.RejectCallbackFn) MappedIterable(io.deephaven.web.shared.fu.MappedIterable) Promise(elemental2.promise.Promise) JsPropertyMap(jsinterop.base.JsPropertyMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) CustomColumnDescriptor(io.deephaven.web.shared.data.CustomColumnDescriptor) TableReference(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.TableReference) Map(java.util.Map) ResponseStreamWrapper(io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper) io.deephaven.web.client.api(io.deephaven.web.client.api) StreamSupport(java.util.stream.StreamSupport) FilterCondition(io.deephaven.web.client.api.filter.FilterCondition) IdentityHashMap(java.util.IdentityHashMap) JsLog(io.deephaven.web.client.fu.JsLog) JsConsumer(io.deephaven.web.shared.fu.JsConsumer) Ticket(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket) ClientTableState(io.deephaven.web.client.state.ClientTableState) CustomEventInit(elemental2.dom.CustomEventInit) ExportedTableCreationResponse(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableCreationResponse) Collectors(java.util.stream.Collectors) List(java.util.List) BatchOp(io.deephaven.web.client.api.batch.BatchBuilder.BatchOp) Ticket(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket) BatchOp(io.deephaven.web.client.api.batch.BatchBuilder.BatchOp) Promise(elemental2.promise.Promise) TableReference(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.TableReference) BatchTableRequest(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.BatchTableRequest) ExportedTableCreationResponse(io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableCreationResponse) ClientTableState(io.deephaven.web.client.state.ClientTableState)

Aggregations

Promise (elemental2.promise.Promise)2 ExportedTableCreationResponse (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableCreationResponse)2 TableReference (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.TableReference)2 Ticket (io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket)2 ResponseStreamWrapper (io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper)2 JsLog (io.deephaven.web.client.fu.JsLog)2 ClientTableState (io.deephaven.web.client.state.ClientTableState)2 JsConsumer (io.deephaven.web.shared.fu.JsConsumer)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 JsMethod (jsinterop.annotations.JsMethod)2 JsPropertyMap (jsinterop.base.JsPropertyMap)2 JsArray (elemental2.core.JsArray)1 JsSet (elemental2.core.JsSet)1 JsWeakMap (elemental2.core.JsWeakMap)1 Uint8Array (elemental2.core.Uint8Array)1 CustomEventInit (elemental2.dom.CustomEventInit)1