Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/no connection serial #983

Merged
merged 81 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
fe52c3f
Implemented connectionRecoveryKey
sacOO7 Nov 24, 2023
c3e7576
Renamed file to recoverykeycontext
sacOO7 Nov 24, 2023
2549547
Added a test to check for encoded recovery key
sacOO7 Nov 27, 2023
c767de2
Added test for encoding and decoding recovery key
sacOO7 Nov 27, 2023
25b9cdc
Added channel serial to channel properties
sacOO7 Nov 27, 2023
a7938e3
Added method to set channelSerials from recover option
sacOO7 Nov 27, 2023
2a8bbbd
Added method for getting channel serials to Channels class
sacOO7 Nov 27, 2023
6461967
Marked recoveryKey field as deprecated
sacOO7 Nov 28, 2023
1897227
Merge branch 'feature/no-connection-serial' into feature/no-connectio…
sacOO7 Nov 28, 2023
180d68f
Added explicit method for creating a recovery key
sacOO7 Nov 28, 2023
1509938
Simplified recoveryKeyContext class
sacOO7 Nov 28, 2023
169392e
Setting recovery key and serials from clientOption
sacOO7 Nov 28, 2023
c6af891
Refactored recoverykey to use createRecoveryKey method
sacOO7 Nov 28, 2023
e7dc410
Removed all connection serial references from the code
sacOO7 Nov 28, 2023
130305b
Added explicit null checks for recoveryKey
sacOO7 Nov 28, 2023
3c04523
Implemented channel serial for message reeived
sacOO7 Nov 29, 2023
0efffdf
Added missing implementation for channel detach when attached msg rec…
sacOO7 Nov 29, 2023
3ebeed7
Updated code to send explicit detach message when attached received in
sacOO7 Nov 29, 2023
21661c4
Created internal presencemap for internal presence
sacOO7 Nov 29, 2023
d465489
Clearing channel serial as per RTP5a1
sacOO7 Nov 30, 2023
b42ff87
resetting message serial on failed connection resume or recover
sacOO7 Dec 1, 2023
5b8ab5e
Fixed AblyRealtime as class imports
sacOO7 Dec 1, 2023
bb42aea
refactored ably protocol and agent headers in accordance with version id
sacOO7 Dec 1, 2023
5b8e5b7
Updated test for protocol version
sacOO7 Dec 1, 2023
232d87b
Added suspended state as per RTL13a for server initiated detached
sacOO7 Dec 1, 2023
47862f4
Merge pull request #980 from ably/feature/no-connection-serial-recove…
sacOO7 Dec 1, 2023
aedc320
Merge branch 'feature/no-connection-serial' of https://github.com/abl…
sacOO7 Dec 4, 2023
2a47f48
Added waitForSync unblocking mechanism when channel is attached
sacOO7 Dec 4, 2023
d003348
refactored presence file, removed unnecessary spec for RTP5c2
sacOO7 Dec 5, 2023
0cab20f
Refactored/simplified onSync and onPresence implementation for presence
sacOO7 Dec 5, 2023
6fb8686
Refactored presence file for handling on Presence
sacOO7 Dec 5, 2023
834738b
Refactored presence file, removed unnecessary flag
sacOO7 Dec 6, 2023
941230f
Refactored presence.java, added code to enter internal members
sacOO7 Dec 7, 2023
77e06fa
Added explicit call for entering presence members
sacOO7 Dec 7, 2023
da26dab
updated setAttached implementation for channelbase
sacOO7 Dec 7, 2023
19fe085
Refactored presence code for channel detached and failed state
sacOO7 Dec 8, 2023
768762d
Refactored endSync and onAttached channel method
sacOO7 Dec 8, 2023
da67abc
Added a method for reattaching channels in AblyRealtime class
sacOO7 Dec 8, 2023
68a9f0a
Refactored attach channels with right spec
sacOO7 Dec 8, 2023
249b40e
Removed unnecessary explicit code to reattach channels
sacOO7 Dec 11, 2023
e69884c
Refactored code to attach channels on reconnection
sacOO7 Dec 11, 2023
e4ebfb2
Simplified channel iteration loop
sacOO7 Dec 11, 2023
11d1994
refactored connection manager for connected message
sacOO7 Dec 11, 2023
ae1f5ba
Merge branch 'feature/no-connection-serial' into feature/no-connectio…
sacOO7 Dec 11, 2023
943f757
Updated protocol version for ably-java
sacOO7 Dec 11, 2023
4a72ad6
Updated connection id and key to be cleared as per connection states
sacOO7 Dec 11, 2023
b704dfb
Annotated implementation with no-connection-serial spec
sacOO7 Dec 12, 2023
088f96b
Refactored code to transfer queued messages
sacOO7 Dec 19, 2023
dcc93ac
Annotated missing spec implementation for the presence code
sacOO7 Dec 20, 2023
2f252eb
Fixed checkstyle import issues for ITransport
sacOO7 Dec 20, 2023
32e0687
Fixed failing tests for recovery key
sacOO7 Dec 20, 2023
6ea5c2b
Refactored test file for no connection serial
sacOO7 Jan 8, 2024
4d68663
Merge pull request #982 from ably/feature/no-connection-serial-presen…
sacOO7 Jan 23, 2024
cf567ec
Getting channel serial only when channel state is attached for recove…
sacOO7 Jan 23, 2024
564a96a
refactored presence impl for entering internal members
sacOO7 Jan 23, 2024
cfc7cb3
Merge branch 'feature/no-connection-serial' into fix/no-connection-se…
sacOO7 Jan 23, 2024
75a8032
updated realtime channel test for resume flag
sacOO7 Jan 23, 2024
ea65bff
Added todo that checks for exact error
sacOO7 Jan 24, 2024
cd355b6
Fixed test for server injected attach
sacOO7 Jan 25, 2024
969d1d5
Refactored helper method to wait channel event
sacOO7 Jan 26, 2024
f84e07a
Added test for server initiated detached
sacOO7 Jan 26, 2024
da74762
Fixed connect reauth failure test
sacOO7 Jan 26, 2024
5297b40
Added a test for valid/invalid resume channel attach
sacOO7 Jan 26, 2024
e9790c0
Simplified channel attach/detach assertions
sacOO7 Jan 26, 2024
f7c5437
Added channelStateChange specific helpers with recorders
sacOO7 Jan 29, 2024
a72e990
Fixed tests for re-attaching channels on connection resume success/fa…
sacOO7 Jan 29, 2024
f92ab59
Merge branch 'main' into fix/no-connection-serial-tests
sacOO7 Jan 29, 2024
d13051f
Fixed deltadecode failure recovery test
sacOO7 Jan 30, 2024
5449a9b
Fixed test for resume publish reenter with right message size
sacOO7 Jan 30, 2024
98e1e8f
refactored test for resume publish re-enter
sacOO7 Jan 30, 2024
4fded69
refactored code, added a separate class for updating connectionmanage…
sacOO7 Jan 30, 2024
c93f89d
Fixed checkstyle issues for integration tests
sacOO7 Jan 31, 2024
e93f0ca
Moved mutableConnection manager under helpers
sacOO7 Jan 31, 2024
2436f67
Updating complex tests where reflection is used
sacOO7 Jan 31, 2024
e791f8f
refactored tests with easier test helper implementation
sacOO7 Jan 31, 2024
68a0944
Refactored ably-java tests, removed unnecessary callbacks
sacOO7 Feb 4, 2024
8e7b272
Refactored channel resume tests
sacOO7 Feb 6, 2024
ada8758
Merge pull request #984 from ably/fix/no-connection-serial-tests
sacOO7 Feb 6, 2024
c0fd61f
Fixed realtime channel flaky test using conditional waiter
sacOO7 Feb 6, 2024
ca35a08
Refactored realtime channel and presence tests
sacOO7 Feb 7, 2024
7e7485e
Added back unused sync method, marked as deprecated
sacOO7 Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/main/java/io/ably/lib/http/HttpCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <T> T httpExecute(HttpURLConnection conn, String method, Param[] headers, Reques
if(!acceptSet) { conn.setRequestProperty(HttpConstants.Headers.ACCEPT, HttpConstants.ContentTypes.JSON); }

/* pass required headers */
conn.setRequestProperty(Defaults.ABLY_VERSION_HEADER, Defaults.ABLY_VERSION);
conn.setRequestProperty(Defaults.ABLY_PROTOCOL_VERSION_HEADER, Defaults.ABLY_PROTOCOL_VERSION); // RSC7a
conn.setRequestProperty(Defaults.ABLY_AGENT_HEADER, AgentHeaderCreator.create(options.agents, platformAgentProvider));

/* prepare request body */
Expand Down
49 changes: 36 additions & 13 deletions lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

Expand All @@ -15,8 +14,10 @@
import io.ably.lib.types.ErrorInfo;
import io.ably.lib.types.ProtocolMessage;
import io.ably.lib.types.ReadOnlyMap;
import io.ably.lib.types.RecoveryKeyContext;
import io.ably.lib.util.InternalMap;
import io.ably.lib.util.Log;
import io.ably.lib.util.StringUtils;

/**
* A client that extends the functionality of the {@link AblyRest} and provides additional realtime-specific features.
Expand Down Expand Up @@ -71,6 +72,14 @@ public void onConnectionStateChanged(ConnectionStateListener.ConnectionStateChan
}
});

if (!StringUtils.isNullOrEmpty(options.recover)) {
RecoveryKeyContext recoveryKeyContext = RecoveryKeyContext.decode(options.recover);
if (recoveryKeyContext != null) {
setChannelSerialsFromRecoverOption(recoveryKeyContext.getChannelSerials()); // RTN16j
connection.connectionManager.msgSerial = recoveryKeyContext.getMsgSerial(); //RTN16f
}
}

if(options.autoConnect) connection.connect();
}

Expand Down Expand Up @@ -233,9 +242,8 @@ public void onMessage(ProtocolMessage msg) {

@Override
public void suspendAll(ErrorInfo error, boolean notifyStateChange) {
for(Iterator<Map.Entry<String, Channel>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, Channel> entry = it.next();
entry.getValue().setSuspended(error, notifyStateChange);
for (Channel channel : map.values()) {
channel.setSuspended(error, notifyStateChange);
}
}

Expand All @@ -245,7 +253,7 @@ public void suspendAll(ErrorInfo error, boolean notifyStateChange) {
* @param queuedMessages Queued messages transferred from ConnectionManager
*/
@Override
public void transferToChannels(List<ConnectionManager.QueuedMessage> queuedMessages) {
public void transferToChannelQueue(List<ConnectionManager.QueuedMessage> queuedMessages) {
final Map<String, List<ConnectionManager.QueuedMessage>> channelQueueMap = new HashMap<>();
for (ConnectionManager.QueuedMessage queuedMessage : queuedMessages) {
final String channelName = queuedMessage.msg.channel;
Expand All @@ -255,16 +263,10 @@ public void transferToChannels(List<ConnectionManager.QueuedMessage> queuedMessa
channelQueueMap.get(channelName).add(queuedMessage);
}

for (Map.Entry<String, Channel> channelEntry : map.entrySet()) {
Channel channel = channelEntry.getValue();
for (Channel channel : map.values()) {
if (channel.state.isReattachable()) {
Log.d(TAG, "reAttach(); channel = " + channel.name);

if (channelQueueMap.containsKey(channel.name)){
channel.transferQueuedPresenceMessages(channelQueueMap.get(channel.name));
}else {
channel.transferQueuedPresenceMessages(null);
}
channel.transferQueuedPresenceMessages(channelQueueMap.getOrDefault(channel.name, null));
}
}
}
Expand All @@ -274,6 +276,27 @@ private void clear() {
}
}

protected void setChannelSerialsFromRecoverOption(Map<String, String> serials) {
for (Map.Entry<String, String> entry : serials.entrySet()) {
String channelName = entry.getKey();
String channelSerial = entry.getValue();
Channel channel = this.channels.get(channelName);
if (channel != null) {
channel.properties.channelSerial = channelSerial;
}
}
}

protected Map<String, String> getChannelSerials() {
Map<String, String> channelSerials = new HashMap<>();
for (Channel channel : this.channels.values()) {
if (channel.state == ChannelState.attached) {
channelSerials.put(channel.name, channel.properties.channelSerial);
}
}
return channelSerials;
}

/********************
* internal
********************/
Expand Down
Loading
Loading