Skip to content

Commit 78cf964

Browse files
committed
XCOMMONS-3451: Realtime editing doesn't support clustering
1 parent d181581 commit 78cf964

File tree

12 files changed

+220
-13
lines changed

12 files changed

+220
-13
lines changed

xwiki-platform-core/xwiki-platform-netflux/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
<modules>
3535
<module>xwiki-platform-netflux-api</module>
3636
<module>xwiki-platform-netflux-rest</module>
37+
<module>xwiki-platform-netflux-remote</module>
3738
</modules>
3839
</project>

xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/main/java/org/xwiki/netflux/internal/DefaultEntityChannelStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private boolean hasRawChannel(EntityChannel channel)
101101
{
102102
Channel rawChannel = this.channelStore.get(channel.getKey());
103103
if (rawChannel != null) {
104-
channel.setUserCount(rawChannel.getConnectedUsers().size());
104+
channel.setUserCount(rawChannel.getUsers().size());
105105
return true;
106106
} else {
107107
return false;

xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/main/java/org/xwiki/netflux/internal/EntityChannelScriptAuthorBot.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.xwiki.component.annotation.Component;
3131
import org.xwiki.netflux.EntityChannel;
3232
import org.xwiki.netflux.EntityChannelStore;
33+
import org.xwiki.netflux.internal.user.local.LocalUser;
3334
import org.xwiki.user.CurrentUserReference;
3435
import org.xwiki.user.UserReference;
3536
import org.xwiki.user.UserReferenceResolver;

xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/DefaultEntityChannelStoreTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.mockito.Mock;
2828
import org.xwiki.model.reference.WikiReference;
2929
import org.xwiki.netflux.EntityChannel;
30+
import org.xwiki.netflux.internal.user.local.LocalUser;
3031
import org.xwiki.test.junit5.mockito.ComponentTest;
3132
import org.xwiki.test.junit5.mockito.InjectMockComponents;
3233
import org.xwiki.test.junit5.mockito.MockComponent;
@@ -77,18 +78,14 @@ void createAndGetChannel()
7778
assertSame(entityChannel, this.entityChannelStore.createChannel(this.entityReference, path));
7879

7980
// Add an user to the channel.
80-
User me = new User(this.session, "mflorea");
81+
User me = new LocalUser(this.session, "mflorea");
8182
channel.getUsers().put(me.getName(), me);
8283

8384
// Get should return the existing channel.
8485
assertSame(entityChannel, this.entityChannelStore.getChannel(this.entityReference, path).get());
8586
assertSame(entityChannel, this.entityChannelStore.getChannel(channel.getKey()).get());
8687
assertEquals(1, entityChannel.getUserCount());
8788

88-
// Disconnect the user and check again the user count.
89-
me.setConnected(false);
90-
assertEquals(0, this.entityChannelStore.getChannel(this.entityReference, path).get().getUserCount());
91-
9289
// Disconnect the raw channel and check the entity channel.
9390
when(this.channelStore.get(channel.getKey())).thenReturn(null);
9491
assertFalse(this.entityChannelStore.getChannel(this.entityReference, path).isPresent());

xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/EntityChannelScriptAuthorBotTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.xwiki.model.reference.DocumentReference;
2929
import org.xwiki.netflux.EntityChannel;
3030
import org.xwiki.netflux.EntityChannelStore;
31+
import org.xwiki.netflux.internal.user.local.LocalUser;
3132
import org.xwiki.test.junit5.mockito.ComponentTest;
3233
import org.xwiki.test.junit5.mockito.InjectMockComponents;
3334
import org.xwiki.test.junit5.mockito.MockComponent;
@@ -105,7 +106,7 @@ void onJoinChannel()
105106
@Test
106107
void onChannelMessage()
107108
{
108-
User sender = mock(User.class);
109+
LocalUser sender = mock(LocalUser.class);
109110
Session session = mock(Session.class);
110111
when(sender.getSession()).thenReturn(session);
111112

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
23+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.xwiki.platform</groupId>
27+
<artifactId>xwiki-platform-netflux</artifactId>
28+
<version>17.9.0-SNAPSHOT</version>
29+
</parent>
30+
<artifactId>xwiki-platform-netflux-remote</artifactId>
31+
<name>XWiki Platform - Netflux - Remote</name>
32+
<description>Clustering related real-time communication.</description>
33+
<packaging>jar</packaging>
34+
<properties>
35+
<!-- Name to display by the Extension Manager -->
36+
<xwiki.extension.name>Netflux Remote</xwiki.extension.name>
37+
<xwiki.jacoco.instructionRatio>1.00</xwiki.jacoco.instructionRatio>
38+
</properties>
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.xwiki.platform</groupId>
42+
<artifactId>xwiki-platform-netflux-api</artifactId>
43+
<version>${platform.version}</version>
44+
</dependency>
45+
46+
<!-- Test dependencies -->
47+
<dependency>
48+
<groupId>org.xwiki.commons</groupId>
49+
<artifactId>xwiki-commons-tool-test-component</artifactId>
50+
<version>${commons.version}</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>jakarta.servlet</groupId>
55+
<artifactId>jakarta.servlet-api</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>jakarta.websocket</groupId>
60+
<artifactId>jakarta.websocket-api</artifactId>
61+
<scope>test</scope>
62+
</dependency>
63+
</dependencies>
64+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.netflux.internal;
21+
22+
/**
23+
* A user accessing the current instance.
24+
*
25+
* @version $Id$
26+
* @since 17.10.0RC1
27+
*/
28+
public class RemoteUser extends User
29+
{
30+
private final String instance;
31+
32+
/**
33+
* Creates a new user with the specified name, using the given WebSocket session.
34+
*
35+
* @param instance the identifier of the instance on which the user is connected
36+
* @param name the user name
37+
*/
38+
public RemoteUser(String instance, String name)
39+
{
40+
super(name);
41+
42+
this.instance = instance;
43+
}
44+
45+
/**
46+
* @return the identifier of the instance on which the user is connected
47+
*/
48+
public String getInstance()
49+
{
50+
return instance;
51+
}
52+
53+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.xwiki.netflux.internal.RemoteUserHandler

xwiki-platform-core/xwiki-platform-observation/xwiki-platform-observation-remote/src/main/java/org/xwiki/observation/remote/RemoteObservationManager.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,41 @@
3535
public interface RemoteObservationManager
3636
{
3737
/**
38-
* Send a event in the different network channels.
38+
* @return the configured {@link NetworkAdapter}
39+
* @since 17.10.0RC1
40+
*/
41+
@Unstable
42+
NetworkAdapter getNetworkAdapter();
43+
44+
/**
45+
* Send an event in the different network channels.
3946
* <p>
4047
* This method is not supposed to be used directly for a new event unless the user specifically want to bypass or
4148
* emulate {@link org.xwiki.observation.ObservationManager}.
4249
*
43-
* @param event the event
50+
* @param localEvent the event to send
4451
*/
45-
void notify(LocalEventData event);
52+
void notify(LocalEventData localEvent);
53+
54+
/**
55+
* Send an event to the target channel members.
56+
*
57+
* @param localEvent the event to send
58+
* @param targets the members to send the event to
59+
* @since 17.10.0RC1
60+
*/
61+
@Unstable
62+
void notify(LocalEventData localEvent, List<NetworkMember> targets);
4663

4764
/**
48-
* Inject a remote event in the local {@link org.xwiki.observation.ObservationManager}.
65+
* Inject an remote event in the local {@link org.xwiki.observation.ObservationManager}.
4966
* <p>
5067
* This method is not supposed to be used directly for a new event unless the user specifically want to bypass or
5168
* emulate network.
5269
*
53-
* @param event the event
70+
* @param remoteEvent the event
5471
*/
55-
void notify(RemoteEventData event);
72+
void notify(RemoteEventData remoteEvent);
5673

5774
/**
5875
* Stop a running channel.

xwiki-platform-core/xwiki-platform-observation/xwiki-platform-observation-remote/src/main/java/org/xwiki/observation/remote/RemoteObservationManagerContext.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,24 @@ public interface RemoteObservationManagerContext
3232
{
3333
/**
3434
* Set the remote state to true.
35+
*
36+
* @deprecated use {@link #pushRemoteState(NetworkMember)} instead
3537
*/
38+
@Deprecated(since = "17.10.0RC1")
3639
void pushRemoteState();
3740

41+
/**
42+
* Store in the context metadata associated to the current event.
43+
*
44+
* @param sender the member who sent the event which triggered this thread, or it's not called in a remote event
45+
* thread
46+
* @since 17.10.0RC1
47+
*/
48+
default void pushRemoteState(NetworkMember sender)
49+
{
50+
pushRemoteState();
51+
}
52+
3853
/**
3954
* Set the remote state to false.
4055
*/
@@ -44,4 +59,10 @@ public interface RemoteObservationManagerContext
4459
* @return indicate if the event in the current thread is a remote event
4560
*/
4661
boolean isRemoteState();
62+
63+
/**
64+
* @return the member who sent the event which triggered this thread, or it's not called in a remote event thread
65+
* @since 17.10.0RC1
66+
*/
67+
NetworkMember getSender();
4768
}

0 commit comments

Comments
 (0)