/** * @return the currently managed Connection */ protected final Connection connection() { return stateData().getConnection(); }
/** * @return the currently managed Connection */ protected final Connection connection() { return stateData().getConnection(); }
/** * Starts the {@link MessageMappingProcessorActor} responsible for payload transformation/mapping as child actor * behind a (cluster node local) RoundRobin pool and a dynamic resizer from the current mapping context. */ protected Either<DittoRuntimeException, ActorRef> startMessageMappingProcessor() { final MappingContext mappingContext = stateData().getConnection().getMappingContext().orElse(null); return startMessageMappingProcessor(mappingContext); }
/** * Starts the {@link MessageMappingProcessorActor} responsible for payload transformation/mapping as child actor * behind a (cluster node local) RoundRobin pool and a dynamic resizer from the current mapping context. */ protected Either<DittoRuntimeException, ActorRef> startMessageMappingProcessor() { final MappingContext mappingContext = stateData().getConnection().getMappingContext().orElse(null); return startMessageMappingProcessor(mappingContext); }
private FSM.State<BaseClientState, BaseClientData> closeConnection(final CloseConnection closeConnection, final BaseClientData data) { final ActorRef sender = getSender(); doDisconnectClient(data.getConnection(), sender); return goTo(DISCONNECTING).using(setSession(data, sender, closeConnection.getDittoHeaders()) .setDesiredConnectionStatus(ConnectionStatus.CLOSED) .setConnectionStatusDetails("closing or deleting connection at " + Instant.now())); }
private FSM.State<BaseClientState, BaseClientData> closeConnection(final CloseConnection closeConnection, final BaseClientData data) { final ActorRef sender = getSender(); doDisconnectClient(data.getConnection(), sender); return goTo(DISCONNECTING).using(setSession(data, sender, closeConnection.getDittoHeaders()) .setDesiredConnectionStatus(ConnectionStatus.CLOSED) .setConnectionStatusDetails("closing or deleting connection at " + Instant.now())); }
private State<BaseClientState, BaseClientData> clientConnected(final ClientConnected clientConnected, final BaseClientData data) { return ifEventUpToDate(clientConnected, () -> { LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); startMessageMappingProcessor(data.getConnection().getMappingContext().orElse(null)); allocateResourcesOnConnection(clientConnected); data.getSessionSender().ifPresent(origin -> origin.tell(new Status.Success(CONNECTED), getSelf())); return goTo(CONNECTED).using(data.resetSession() .setConnectionStatus(ConnectionStatus.OPEN) .setConnectionStatusDetails("Connected at " + Instant.now())); }); }
private State<BaseClientState, BaseClientData> clientConnected(final ClientConnected clientConnected, final BaseClientData data) { return ifEventUpToDate(clientConnected, () -> { LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); startMessageMappingProcessor(data.getConnection().getMappingContext().orElse(null)); allocateResourcesOnConnection(clientConnected); data.getSessionSender().ifPresent(origin -> origin.tell(new Status.Success(CONNECTED), getSelf())); return goTo(CONNECTED).using(data.resetSession() .setConnectionStatus(ConnectionStatus.OPEN) .setConnectionStatusDetails("Connected at " + Instant.now())); }); }
private FSM.State<BaseClientState, BaseClientData> openConnection(final OpenConnection openConnection, final BaseClientData data) { final ActorRef sender = getSender(); final Connection connection = data.getConnection(); final DittoHeaders dittoHeaders = openConnection.getDittoHeaders(); if (canConnectViaSocket(connection)) { doConnectClient(connection, sender); return goTo(CONNECTING).using(setSession(data, sender, dittoHeaders)); } else { cleanupResourcesForConnection(); final DittoRuntimeException error = newConnectionFailedException(data.getConnection(), dittoHeaders); sender.tell(new Status.Failure(error), getSelf()); return goTo(UNKNOWN).using(data.resetSession()); } }
private FSM.State<BaseClientState, BaseClientData> openConnection(final OpenConnection openConnection, final BaseClientData data) { final ActorRef sender = getSender(); final Connection connection = data.getConnection(); final DittoHeaders dittoHeaders = openConnection.getDittoHeaders(); if (canConnectViaSocket(connection)) { doConnectClient(connection, sender); return goTo(CONNECTING).using(setSession(data, sender, dittoHeaders)); } else { cleanupResourcesForConnection(); final DittoRuntimeException error = newConnectionFailedException(data.getConnection(), dittoHeaders); sender.tell(new Status.Failure(error), getSelf()); return goTo(UNKNOWN).using(data.resetSession()); } }
@Override protected FSMStateFunctionBuilder<BaseClientState, BaseClientData> inTestingState() { return super.inTestingState() .event(Status.Status.class, (e, d) -> !Objects.equals(getSender(), getSelf()), this::handleStatusReportFromChildren) .event(ClientConnected.class, BaseClientData.class, (event, data) -> { final String url = data.getConnection().getUri(); final String message = "mqtt connection to " + url + " established successfully"; completeTestConnectionFuture(new Status.Success(message), data); return stay(); }) .event(ConnectionFailure.class, BaseClientData.class, (event, data) -> { completeTestConnectionFuture(new Status.Failure(event.getFailure().cause()), data); return stay(); }); }
@Override protected FSMStateFunctionBuilder<BaseClientState, BaseClientData> inTestingState() { return super.inTestingState() .event(Status.Status.class, (e, d) -> !Objects.equals(getSender(), getSelf()), this::handleStatusReportFromChildren) .event(ClientConnected.class, BaseClientData.class, (event, data) -> { final String url = data.getConnection().getUri(); final String message = "mqtt connection to " + url + " established successfully"; completeTestConnectionFuture(new Status.Success(message), data); return stay(); }) .event(ConnectionFailure.class, BaseClientData.class, (event, data) -> { completeTestConnectionFuture(new Status.Failure(event.getFailure().cause()), data); return stay(); }); }