Changeset 9 for protocol/src/main/java
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- protocol/src/main/java/geniusweb/protocol
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note:
See TracChangeset
for help on using the changeset viewer.