.setConnectionStatusDetails("Connection restored at " + Instant.now()); failure.getFailure().cause(), failure.getFailureDescription()); data = data.setConnectionStatus(ConnectionStatus.FAILED) .setConnectionStatusDetails(message);
.setConnectionStatusDetails("Connection restored at " + Instant.now()); failure.getFailure().cause(), failure.getFailureDescription()); data = data.setConnectionStatus(ConnectionStatus.FAILED) .setConnectionStatusDetails(message);
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 State<BaseClientState, BaseClientData> clientDisconnected(final ClientDisconnected event, final BaseClientData data) { return ifEventUpToDate(event, () -> { LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); stopMessageMappingProcessorActor(); cleanupResourcesForConnection(); data.getSessionSender().ifPresent(sender -> sender.tell(new Status.Success(DISCONNECTED), getSelf())); return goTo(DISCONNECTED).using(data.resetSession() .setConnectionStatus(ConnectionStatus.CLOSED) .setConnectionStatusDetails("Disconnected at " + Instant.now())); }); }
private State<BaseClientState, BaseClientData> clientDisconnected(final ClientDisconnected event, final BaseClientData data) { return ifEventUpToDate(event, () -> { LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); stopMessageMappingProcessorActor(); cleanupResourcesForConnection(); data.getSessionSender().ifPresent(sender -> sender.tell(new Status.Success(DISCONNECTED), getSelf())); return goTo(DISCONNECTED).using(data.resetSession() .setConnectionStatus(ConnectionStatus.CLOSED) .setConnectionStatusDetails("Disconnected at " + Instant.now())); }); }
private FSM.State<BaseClientState, BaseClientData> connectionTimedOut(final Object event, final BaseClientData data) { data.getSessionSender().ifPresent(sender -> { final DittoRuntimeException error = ConnectionFailedException.newBuilder(connectionId()) .dittoHeaders(data.getSessionHeaders()) .build(); sender.tell(new Status.Failure(error), getSelf()); }); cleanupResourcesForConnection(); cleanupFurtherResourcesOnConnectionTimeout(stateName()); return goTo(UNKNOWN).using(data.resetSession() .setConnectionStatus(ConnectionStatus.FAILED) .setConnectionStatusDetails("Connection timed out at " + Instant.now() + " while " + stateName())); }
private FSM.State<BaseClientState, BaseClientData> connectionTimedOut(final Object event, final BaseClientData data) { data.getSessionSender().ifPresent(sender -> { final DittoRuntimeException error = ConnectionFailedException.newBuilder(connectionId()) .dittoHeaders(data.getSessionHeaders()) .build(); sender.tell(new Status.Failure(error), getSelf()); }); cleanupResourcesForConnection(); cleanupFurtherResourcesOnConnectionTimeout(stateName()); return goTo(UNKNOWN).using(data.resetSession() .setConnectionStatus(ConnectionStatus.FAILED) .setConnectionStatusDetails("Connection timed out at " + Instant.now() + " while " + stateName())); }
.using(setSession(data, sender, testConnection.getDittoHeaders()) .setConnection(connection) .setConnectionStatusDetails("Testing connection since " + Instant.now()));
private State<BaseClientState, BaseClientData> connectionFailure(final ConnectionFailure event, final BaseClientData data) { return ifEventUpToDate(event, () -> { LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); cleanupResourcesForConnection(); data.getSessionSender().ifPresent(sender -> sender.tell(getStatusToReport(event.getFailure()), getSelf())); return goTo(UNKNOWN).using(data.resetSession() .setConnectionStatus(ConnectionStatus.FAILED) .setConnectionStatusDetails(event.getFailureDescription()) .setSessionSender(getSender()) ); }); }
.using(setSession(data, sender, testConnection.getDittoHeaders()) .setConnection(connection) .setConnectionStatusDetails("Testing connection since " + Instant.now()));
private State<BaseClientState, BaseClientData> connectionFailure(final ConnectionFailure event, final BaseClientData data) { return ifEventUpToDate(event, () -> { LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); cleanupResourcesForConnection(); data.getSessionSender().ifPresent(sender -> sender.tell(getStatusToReport(event.getFailure()), getSelf())); return goTo(UNKNOWN).using(data.resetSession() .setConnectionStatus(ConnectionStatus.FAILED) .setConnectionStatusDetails(event.getFailureDescription()) .setSessionSender(getSender()) ); }); }