- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- protocol
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/pom.xml
r6 r9 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>protocol</artifactId> 8 <version>1. 0.0</version>8 <version>1.1.0</version> 9 9 <packaging>jar</packaging> 10 10 … … 16 16 <basedir>.</basedir> 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 <jackson-2-version>2.9. 6</jackson-2-version>18 <jackson-2-version>2.9.10</jackson-2-version> 19 19 </properties> 20 20 … … 31 31 <groupId>geniusweb</groupId> 32 32 <artifactId>profile</artifactId> 33 <version>1. 0.0</version>33 <version>1.1.0</version> 34 34 </dependency> 35 35 <dependency> 36 36 <groupId>geniusweb</groupId> 37 37 <artifactId>party</artifactId> 38 <version>1.0.0</version> 39 </dependency> 40 <dependency> 41 <groupId>tudelft.utilities</groupId> 42 <artifactId>listener</artifactId> 43 <version>1.0.0</version> 38 <version>1.1.0</version> 44 39 </dependency> 45 40 <dependency> 46 41 <groupId>geniusweb</groupId> 47 42 <artifactId>references</artifactId> 48 <version>1. 0.0</version>43 <version>1.1.0</version> 49 44 </dependency> 50 45 <dependency> 51 46 <groupId>geniusweb</groupId> 52 47 <artifactId>events</artifactId> 53 <version>1. 0.0</version>48 <version>1.1.0</version> 54 49 </dependency> 55 50 <dependency> … … 62 57 <artifactId>logging</artifactId> 63 58 <version>1.0.0</version> 59 </dependency> 60 <dependency> 61 <groupId>tudelft.utilities</groupId> 62 <artifactId>listener</artifactId> 63 <version>1.1.0</version> 64 64 </dependency> 65 65 … … 160 160 </configuration> 161 161 </plugin> 162 162 <plugin> 163 <groupId>org.apache.maven.plugins</groupId> 164 <artifactId>maven-enforcer-plugin</artifactId> 165 <version>3.0.0-M2</version> 166 <executions> 167 <execution> 168 <id>enforce</id> 169 <configuration> 170 <rules> 171 <dependencyConvergence /> 172 </rules> 173 </configuration> 174 <goals> 175 <goal>enforce</goal> 176 </goals> 177 </execution> 178 </executions> 179 </plugin> 163 180 <plugin> 164 181 <groupId>org.apache.maven.plugins</groupId> -
protocol/src/main/java/geniusweb/protocol/NegoProtocol.java
r1 r9 10 10 import geniusweb.events.CurrentState; 11 11 import geniusweb.events.ProtocolEvent; 12 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;12 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 13 13 import geniusweb.protocol.session.SessionProtocol; 14 14 import geniusweb.protocol.session.SessionSettings; … … 70 70 * 71 71 * 72 * @param connectionfactory the {@link ConnectionWithPartyFactory} that allows72 * @param connectionfactory the {@link ProtocolToPartyConnFactory} that allows 73 73 * the protocol to connect with the {@link Reference}s 74 74 * in the settings 75 75 */ 76 void start( ConnectionWithPartyFactory connectionfactory);76 void start(ProtocolToPartyConnFactory connectionfactory); 77 77 78 78 /** -
protocol/src/main/java/geniusweb/protocol/session/DefaultSessionState.java
r1 r9 10 10 import geniusweb.progress.Progress; 11 11 import geniusweb.protocol.ProtocolException; 12 import geniusweb.protocol.partyconnection. ConnectionWithParties;12 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 13 13 import geniusweb.references.PartyWithProfile; 14 14 … … 19 19 private final List<Action> actions; 20 20 21 private final transient ConnectionWithParties connections;21 private final transient ProtocolToPartyConnections connections; 22 22 23 23 private final Progress progress; … … 60 60 */ 61 61 public DefaultSessionState(List<Action> actions, 62 ConnectionWithParties conns, Progress progr,62 ProtocolToPartyConnections conns, Progress progr, 63 63 SessionSettings settings, 64 64 Map<PartyId, PartyWithProfile> partyprofiles, ProtocolException e) { … … 67 67 } 68 68 if (conns == null) { 69 this.connections = new ConnectionWithParties(69 this.connections = new ProtocolToPartyConnections( 70 70 Collections.EMPTY_LIST); 71 71 } else { … … 92 92 * @return existing connections. 93 93 */ 94 public ConnectionWithParties getConnections() {94 public ProtocolToPartyConnections getConnections() { 95 95 return connections; 96 96 } -
protocol/src/main/java/geniusweb/protocol/session/saop/SAOP.java
r8 r9 23 23 import geniusweb.protocol.CurrentNegoState; 24 24 import geniusweb.protocol.ProtocolException; 25 import geniusweb.protocol.partyconnection. ConnectionWithParty;26 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;25 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 26 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 27 27 import geniusweb.protocol.session.SessionProtocol; 28 28 import geniusweb.protocol.session.SessionSettings; … … 95 95 @Override 96 96 public synchronized void start( 97 ConnectionWithPartyFactory connectionfactory) {97 ProtocolToPartyConnFactory connectionfactory) { 98 98 99 99 try { … … 151 151 */ 152 152 protected synchronized void connect( 153 ConnectionWithPartyFactory connectionfactory)153 ProtocolToPartyConnFactory connectionfactory) 154 154 throws InterruptedException, IOException { 155 155 List<PartyWithProfile> participants = state.getSettings() … … 158 158 .map(parti -> (parti.getParty().getPartyRef())) 159 159 .collect(Collectors.toList()); 160 List< ConnectionWithParty> connections = null;160 List<ProtocolToPartyConn> connections = null; 161 161 log.log(Level.INFO, "SAOP connect " + parties); 162 162 while (connections == null) { … … 218 218 */ 219 219 protected synchronized void setupParties() throws ProtocolException { 220 for ( ConnectionWithPartyconn : state.getConnections()) {220 for (ProtocolToPartyConn conn : state.getConnections()) { 221 221 conn.addListener(action -> actionRequest(conn, action)); 222 222 } 223 223 224 for ( ConnectionWithPartyconnection : state.getConnections()) {224 for (ProtocolToPartyConn connection : state.getConnections()) { 225 225 try { 226 226 sendSettings(connection); … … 239 239 * @throws IOException if party got disconnected 240 240 */ 241 private synchronized void sendSettings( ConnectionWithPartyconnection)241 private synchronized void sendSettings(ProtocolToPartyConn connection) 242 242 throws IOException { 243 243 PartyId partyid = connection.getParty(); … … 261 261 */ 262 262 protected synchronized void actionRequest( 263 final ConnectionWithPartypartyconn, final Action action) {263 final ProtocolToPartyConn partyconn, final Action action) { 264 264 if (action == null) { 265 handleError(partyconn 266 + " did null action, breaching the protocol. Closing session", 267 partyconn.getParty().getName(), null); 265 Throwable err = partyconn.getError(); 266 if (err == null) { 267 err = new ProtocolException("Party sent a null action", 268 partyconn.getParty().getName()); 269 } 270 handleError(partyconn + "Protocol error", 271 partyconn.getParty().getName(), err); 268 272 return; 269 273 } … … 348 352 return; 349 353 Inform finished = new Finished(state.getAgreement()); 350 for ( ConnectionWithPartyconn : state.getConnections()) {354 for (ProtocolToPartyConn conn : state.getConnections()) { 351 355 sendFinish(conn, finished); 352 356 } 353 notify Change(new CurrentNegoState(state));354 } 355 356 private void sendFinish( ConnectionWithPartyconnection, Inform finished) {357 notifyListeners(new CurrentNegoState(state)); 358 } 359 360 private void sendFinish(ProtocolToPartyConn connection, Inform finished) { 357 361 try { 358 362 connection.send(finished); -
protocol/src/main/java/geniusweb/protocol/session/saop/SAOPState.java
r4 r9 16 16 import geniusweb.progress.ProgressRounds; 17 17 import geniusweb.protocol.ProtocolException; 18 import geniusweb.protocol.partyconnection. ConnectionWithParties;19 import geniusweb.protocol.partyconnection. ConnectionWithParty;18 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 19 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 20 20 import geniusweb.protocol.session.DefaultSessionState; 21 21 import geniusweb.protocol.session.SessionSettings; … … 42 42 * occurred. 43 43 */ 44 public SAOPState(List<Action> actions, ConnectionWithParties conns,44 public SAOPState(List<Action> actions, ProtocolToPartyConnections conns, 45 45 Progress progress, SessionSettings settings, 46 46 Map<PartyId, PartyWithProfile> partyprofiles, ProtocolException e) { … … 55 55 public SAOPState(SAOPSettings settings) { 56 56 this(Collections.emptyList(), 57 new ConnectionWithParties(Collections.emptyList()), null,57 new ProtocolToPartyConnections(Collections.emptyList()), null, 58 58 settings, null, null); 59 59 … … 82 82 /** 83 83 * 84 * @param connection the new {@link ConnectionWithParty}84 * @param connection the new {@link ProtocolToPartyConn} 85 85 * @param partyprofile the {@link PartyWithProfile} that is associated with 86 86 * this state … … 91 91 * state currently indicate if that already happened or not. 92 92 */ 93 public SAOPState with( ConnectionWithPartyconnection,93 public SAOPState with(ProtocolToPartyConn connection, 94 94 PartyWithProfile partyprofile) { 95 95 // Only called from the SAOP initialization phase. 96 ConnectionWithParties newconns = getConnections().with(connection);96 ProtocolToPartyConnections newconns = getConnections().with(connection); 97 97 Map<PartyId, PartyWithProfile> newprofiles = new HashMap<>( 98 98 getPartyProfiles()); -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsProtocol.java
r1 r9 7 7 import geniusweb.protocol.CurrentNegoState; 8 8 import geniusweb.protocol.SessionResult; 9 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;9 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 10 10 import geniusweb.protocol.session.SessionProtocol; 11 11 import geniusweb.protocol.session.SessionSettings; … … 29 29 private final transient Reporter log; 30 30 31 private ConnectionWithPartyFactory connectionFactory; // FINAL31 private ProtocolToPartyConnFactory connectionFactory; // FINAL 32 32 private AllPermutationsState state; // MUTABLE 33 33 … … 45 45 46 46 @Override 47 public void start( ConnectionWithPartyFactory connectionfactory) {47 public void start(ProtocolToPartyConnFactory connectionfactory) { 48 48 this.connectionFactory = connectionfactory; 49 notify Change(new TournamentStarted(state.getSize().longValue()));49 notifyListeners(new TournamentStarted(state.getSize().longValue())); 50 50 startNextSession(); 51 51 } … … 85 85 sessionstate.getAgreement(), sessionstate.getError()); 86 86 state = state.with(result); 87 notify Change(new CurrentNegoState(state));87 notifyListeners(new CurrentNegoState(state)); 88 88 if (!state.isFinal(now)) { 89 89 startNextSession(); -
protocol/src/test/java/geniusweb/protocol/session/ConnectionWithPartiesTest.java
r1 r9 14 14 15 15 import geniusweb.actions.PartyId; 16 import geniusweb.protocol.partyconnection. ConnectionWithParties;17 import geniusweb.protocol.partyconnection. ConnectionWithParty;16 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 17 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 18 18 import tudelft.utilities.junit.GeneralTests; 19 19 20 20 public class ConnectionWithPartiesTest 21 extends GeneralTests< ConnectionWithParties> {21 extends GeneralTests<ProtocolToPartyConnections> { 22 22 PartyId party1 = new PartyId("party1"); 23 23 PartyId party2 = new PartyId("party2"); 24 24 PartyId party3 = new PartyId("party3"); 25 25 26 private ConnectionWithParty con1 = mock(ConnectionWithParty.class);27 private ConnectionWithParty con2 = mock(ConnectionWithParty.class);28 private ConnectionWithParty con3 = mock(ConnectionWithParty.class);26 private ProtocolToPartyConn con1 = mock(ProtocolToPartyConn.class); 27 private ProtocolToPartyConn con2 = mock(ProtocolToPartyConn.class); 28 private ProtocolToPartyConn con3 = mock(ProtocolToPartyConn.class); 29 29 30 private ConnectionWithParties conns1 = new ConnectionWithParties(30 private ProtocolToPartyConnections conns1 = new ProtocolToPartyConnections( 31 31 Arrays.asList(con1, con2)); 32 private ConnectionWithParties conns1a = new ConnectionWithParties(32 private ProtocolToPartyConnections conns1a = new ProtocolToPartyConnections( 33 33 Arrays.asList(con1, con2)); 34 private ConnectionWithParties conns2 = new ConnectionWithParties(34 private ProtocolToPartyConnections conns2 = new ProtocolToPartyConnections( 35 35 Arrays.asList(con1, con3)); 36 private ConnectionWithParties conns3 = new ConnectionWithParties(36 private ProtocolToPartyConnections conns3 = new ProtocolToPartyConnections( 37 37 Arrays.asList(con2, con1)); 38 private ConnectionWithParties conns4 = new ConnectionWithParties(38 private ProtocolToPartyConnections conns4 = new ProtocolToPartyConnections( 39 39 Arrays.asList(con2, con1, con3)); 40 private ConnectionWithParties conns5 = new ConnectionWithParties(40 private ProtocolToPartyConnections conns5 = new ProtocolToPartyConnections( 41 41 Arrays.asList(con2, con1, con3, con1)); 42 42 … … 54 54 55 55 @Override 56 public List<List< ConnectionWithParties>> getGeneralTestData() {56 public List<List<ProtocolToPartyConnections>> getGeneralTestData() { 57 57 return Arrays.asList(Arrays.asList(conns1, conns1a), 58 58 Arrays.asList(conns2), Arrays.asList(conns3), … … 98 98 @Test 99 99 public void withPartyTest() { 100 ConnectionWithParties conns = conns3.with(con3);100 ProtocolToPartyConnections conns = conns3.with(con3); 101 101 assertEquals(2, conns3.size()); 102 102 assertEquals(3, conns.size()); -
protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java
r8 r9 27 27 import geniusweb.progress.ProgressTime; 28 28 import geniusweb.protocol.ProtocolException; 29 import geniusweb.protocol.partyconnection. ConnectionWithParties;29 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 30 30 import geniusweb.protocol.session.saop.SAOPSettings; 31 31 import geniusweb.references.Parameters; … … 48 48 PartyId party1 = new PartyId("party1"); 49 49 actions.add(new EndNegotiation(party1)); 50 ConnectionWithParties conns = new ConnectionWithParties(50 ProtocolToPartyConnections conns = new ProtocolToPartyConnections( 51 51 Collections.EMPTY_LIST); 52 52 DeadlineTime deadline = new DeadlineTime(1000); … … 126 126 127 127 public DefaultSessionState1(List<Action> actions, 128 ConnectionWithParties conns, Progress progr,128 ProtocolToPartyConnections conns, Progress progr, 129 129 SessionSettings settings, 130 130 Map<PartyId, PartyWithProfile> partyprofiles, ProtocolException e) { -
protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java
r4 r9 27 27 import geniusweb.progress.ProgressTime; 28 28 import geniusweb.protocol.ProtocolException; 29 import geniusweb.protocol.partyconnection. ConnectionWithParties;30 import geniusweb.protocol.partyconnection. ConnectionWithParty;29 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 30 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 31 31 import geniusweb.protocol.session.SessionSettings; 32 32 import tudelft.utilities.junit.GeneralTests; … … 42 42 private List<Action> actions2 = Arrays.asList(action); 43 43 44 private ConnectionWithParty party1conn = mock(ConnectionWithParty.class);45 private ConnectionWithParty party2conn = mock(ConnectionWithParty.class);46 private ConnectionWithParty party3conn = mock(ConnectionWithParty.class);47 48 private ConnectionWithParties connections = new ConnectionWithParties(44 private ProtocolToPartyConn party1conn = mock(ProtocolToPartyConn.class); 45 private ProtocolToPartyConn party2conn = mock(ProtocolToPartyConn.class); 46 private ProtocolToPartyConn party3conn = mock(ProtocolToPartyConn.class); 47 48 private ProtocolToPartyConnections connections = new ProtocolToPartyConnections( 49 49 Arrays.asList(party1conn, party2conn)); 50 private ConnectionWithParties connections2 = new ConnectionWithParties(50 private ProtocolToPartyConnections connections2 = new ProtocolToPartyConnections( 51 51 Arrays.asList(party1conn, party3conn)); 52 private ConnectionWithParties connections3 = new ConnectionWithParties(52 private ProtocolToPartyConnections connections3 = new ProtocolToPartyConnections( 53 53 Arrays.asList(party1conn, party2conn, party3conn)); 54 54 … … 114 114 @Test 115 115 public void constructWith0Connection() { 116 new SAOPState(actions, new ConnectionWithParties(Arrays.asList()),116 new SAOPState(actions, new ProtocolToPartyConnections(Arrays.asList()), 117 117 progresstime, settings, null, null); 118 118 } … … 132 132 @Test 133 133 public void testNextActor2() { 134 ConnectionWithParties conns = new ConnectionWithParties(134 ProtocolToPartyConnections conns = new ProtocolToPartyConnections( 135 135 Arrays.asList(party2conn, party3conn)); 136 136 SAOPState state = new SAOPState(actions, conns, progresstime, settings, -
protocol/src/test/java/geniusweb/protocol/session/saop/SAOPTest.java
r8 r9 39 39 import geniusweb.progress.Progress; 40 40 import geniusweb.protocol.ProtocolException; 41 import geniusweb.protocol.partyconnection. ConnectionWithParties;42 import geniusweb.protocol.partyconnection. ConnectionWithParty;43 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;41 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 42 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 43 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 44 44 import geniusweb.references.Parameters; 45 45 import geniusweb.references.PartyRef; … … 76 76 private final PartyWithProfile party2 = mock(PartyWithProfile.class); 77 77 private SAOP saop; 78 private ConnectionWithPartyFactory factory;78 private ProtocolToPartyConnFactory factory; 79 79 private List connections; 80 private ConnectionWithParty conn1 = mock(ConnectionWithParty.class),81 conn2 = mock( ConnectionWithParty.class);80 private ProtocolToPartyConn conn1 = mock(ProtocolToPartyConn.class), 81 conn2 = mock(ProtocolToPartyConn.class); 82 82 private Map<PartyId, PartyWithProfile> partyprofiles; 83 83 private Progress progress = mock(Progress.class); 84 84 private ProfileRef profile1; 85 85 private ProfileRef profile2; 86 private ConnectionWithParties connectionswithparties = mock(87 ConnectionWithParties.class);;86 private ProtocolToPartyConnections connectionswithparties = mock( 87 ProtocolToPartyConnections.class);; 88 88 @SuppressWarnings("unchecked") 89 89 private final Listener<ProtocolEvent> testlistener = mock(Listener.class); … … 116 116 when(settings.getDeadline()).thenReturn(deadlinetime); 117 117 118 factory = mock( ConnectionWithPartyFactory.class);118 factory = mock(ProtocolToPartyConnFactory.class); 119 119 connections = mock(List.class); 120 120 when(factory.connect(any(List.class))).thenReturn(connections); … … 159 159 when(state.getPartyProfiles()).thenReturn(partyprofiles); 160 160 when(state.getProgress()).thenReturn(progress); 161 when(state.with(any( ConnectionWithParty.class),161 when(state.with(any(ProtocolToPartyConn.class), 162 162 any(PartyWithProfile.class))).thenReturn(connectedstate); 163 163 when(state.getNextActor()).thenReturn(PARTY1ID); -
protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsProtocolTest.java
r1 r9 24 24 import geniusweb.protocol.NegoState; 25 25 import geniusweb.protocol.SessionResult; 26 import geniusweb.protocol.partyconnection. ConnectionWithPartyFactory;26 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 27 27 import geniusweb.protocol.session.SessionProtocol; 28 28 import geniusweb.protocol.session.SessionSettings; … … 42 42 private final AllPermutationsProtocol app = new AllPermutationsProtocol( 43 43 state, log); 44 private final ConnectionWithPartyFactory factory = mock(45 ConnectionWithPartyFactory.class);44 private final ProtocolToPartyConnFactory factory = mock( 45 ProtocolToPartyConnFactory.class); 46 46 private final SessionSettings settings = mock(SessionSettings.class); 47 47 private final SessionState finalsessionstate = mock(SessionState.class); … … 140 140 141 141 @Override 142 public void start( ConnectionWithPartyFactory connectionfactory) {142 public void start(ProtocolToPartyConnFactory connectionfactory) { 143 143 144 144 }
Note:
See TracChangeset
for help on using the changeset viewer.