Changeset 9 for protocol/src/main


Ignore:
Timestamp:
11/28/19 14:40:48 (5 years ago)
Author:
bart
Message:

Release 1.1.0

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  
    1010import geniusweb.events.CurrentState;
    1111import geniusweb.events.ProtocolEvent;
    12 import geniusweb.protocol.partyconnection.ConnectionWithPartyFactory;
     12import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory;
    1313import geniusweb.protocol.session.SessionProtocol;
    1414import geniusweb.protocol.session.SessionSettings;
     
    7070         *
    7171         *
    72          * @param connectionfactory the {@link ConnectionWithPartyFactory} that allows
     72         * @param connectionfactory the {@link ProtocolToPartyConnFactory} that allows
    7373         *                          the protocol to connect with the {@link Reference}s
    7474         *                          in the settings
    7575         */
    76         void start(ConnectionWithPartyFactory connectionfactory);
     76        void start(ProtocolToPartyConnFactory connectionfactory);
    7777
    7878        /**
  • protocol/src/main/java/geniusweb/protocol/session/DefaultSessionState.java

    r1 r9  
    1010import geniusweb.progress.Progress;
    1111import geniusweb.protocol.ProtocolException;
    12 import geniusweb.protocol.partyconnection.ConnectionWithParties;
     12import geniusweb.protocol.partyconnection.ProtocolToPartyConnections;
    1313import geniusweb.references.PartyWithProfile;
    1414
     
    1919        private final List<Action> actions;
    2020
    21         private final transient ConnectionWithParties connections;
     21        private final transient ProtocolToPartyConnections connections;
    2222
    2323        private final Progress progress;
     
    6060         */
    6161        public DefaultSessionState(List<Action> actions,
    62                         ConnectionWithParties conns, Progress progr,
     62                        ProtocolToPartyConnections conns, Progress progr,
    6363                        SessionSettings settings,
    6464                        Map<PartyId, PartyWithProfile> partyprofiles, ProtocolException e) {
     
    6767                }
    6868                if (conns == null) {
    69                         this.connections = new ConnectionWithParties(
     69                        this.connections = new ProtocolToPartyConnections(
    7070                                        Collections.EMPTY_LIST);
    7171                } else {
     
    9292         * @return existing connections.
    9393         */
    94         public ConnectionWithParties getConnections() {
     94        public ProtocolToPartyConnections getConnections() {
    9595                return connections;
    9696        }
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOP.java

    r8 r9  
    2323import geniusweb.protocol.CurrentNegoState;
    2424import geniusweb.protocol.ProtocolException;
    25 import geniusweb.protocol.partyconnection.ConnectionWithParty;
    26 import geniusweb.protocol.partyconnection.ConnectionWithPartyFactory;
     25import geniusweb.protocol.partyconnection.ProtocolToPartyConn;
     26import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory;
    2727import geniusweb.protocol.session.SessionProtocol;
    2828import geniusweb.protocol.session.SessionSettings;
     
    9595        @Override
    9696        public synchronized void start(
    97                         ConnectionWithPartyFactory connectionfactory) {
     97                        ProtocolToPartyConnFactory connectionfactory) {
    9898
    9999                try {
     
    151151         */
    152152        protected synchronized void connect(
    153                         ConnectionWithPartyFactory connectionfactory)
     153                        ProtocolToPartyConnFactory connectionfactory)
    154154                        throws InterruptedException, IOException {
    155155                List<PartyWithProfile> participants = state.getSettings()
     
    158158                                .map(parti -> (parti.getParty().getPartyRef()))
    159159                                .collect(Collectors.toList());
    160                 List<ConnectionWithParty> connections = null;
     160                List<ProtocolToPartyConn> connections = null;
    161161                log.log(Level.INFO, "SAOP connect " + parties);
    162162                while (connections == null) {
     
    218218         */
    219219        protected synchronized void setupParties() throws ProtocolException {
    220                 for (ConnectionWithParty conn : state.getConnections()) {
     220                for (ProtocolToPartyConn conn : state.getConnections()) {
    221221                        conn.addListener(action -> actionRequest(conn, action));
    222222                }
    223223
    224                 for (ConnectionWithParty connection : state.getConnections()) {
     224                for (ProtocolToPartyConn connection : state.getConnections()) {
    225225                        try {
    226226                                sendSettings(connection);
     
    239239         * @throws IOException if party got disconnected
    240240         */
    241         private synchronized void sendSettings(ConnectionWithParty connection)
     241        private synchronized void sendSettings(ProtocolToPartyConn connection)
    242242                        throws IOException {
    243243                PartyId partyid = connection.getParty();
     
    261261         */
    262262        protected synchronized void actionRequest(
    263                         final ConnectionWithParty partyconn, final Action action) {
     263                        final ProtocolToPartyConn partyconn, final Action action) {
    264264                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);
    268272                        return;
    269273                }
     
    348352                        return;
    349353                Inform finished = new Finished(state.getAgreement());
    350                 for (ConnectionWithParty conn : state.getConnections()) {
     354                for (ProtocolToPartyConn conn : state.getConnections()) {
    351355                        sendFinish(conn, finished);
    352356                }
    353                 notifyChange(new CurrentNegoState(state));
    354         }
    355 
    356         private void sendFinish(ConnectionWithParty connection, Inform finished) {
     357                notifyListeners(new CurrentNegoState(state));
     358        }
     359
     360        private void sendFinish(ProtocolToPartyConn connection, Inform finished) {
    357361                try {
    358362                        connection.send(finished);
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOPState.java

    r4 r9  
    1616import geniusweb.progress.ProgressRounds;
    1717import geniusweb.protocol.ProtocolException;
    18 import geniusweb.protocol.partyconnection.ConnectionWithParties;
    19 import geniusweb.protocol.partyconnection.ConnectionWithParty;
     18import geniusweb.protocol.partyconnection.ProtocolToPartyConnections;
     19import geniusweb.protocol.partyconnection.ProtocolToPartyConn;
    2020import geniusweb.protocol.session.DefaultSessionState;
    2121import geniusweb.protocol.session.SessionSettings;
     
    4242         *                      occurred.
    4343         */
    44         public SAOPState(List<Action> actions, ConnectionWithParties conns,
     44        public SAOPState(List<Action> actions, ProtocolToPartyConnections conns,
    4545                        Progress progress, SessionSettings settings,
    4646                        Map<PartyId, PartyWithProfile> partyprofiles, ProtocolException e) {
     
    5555        public SAOPState(SAOPSettings settings) {
    5656                this(Collections.emptyList(),
    57                                 new ConnectionWithParties(Collections.emptyList()), null,
     57                                new ProtocolToPartyConnections(Collections.emptyList()), null,
    5858                                settings, null, null);
    5959
     
    8282        /**
    8383         *
    84          * @param connection   the new {@link ConnectionWithParty}
     84         * @param connection   the new {@link ProtocolToPartyConn}
    8585         * @param partyprofile the {@link PartyWithProfile} that is associated with
    8686         *                     this state
     
    9191         *         state currently indicate if that already happened or not.
    9292         */
    93         public SAOPState with(ConnectionWithParty connection,
     93        public SAOPState with(ProtocolToPartyConn connection,
    9494                        PartyWithProfile partyprofile) {
    9595                // Only called from the SAOP initialization phase.
    96                 ConnectionWithParties newconns = getConnections().with(connection);
     96                ProtocolToPartyConnections newconns = getConnections().with(connection);
    9797                Map<PartyId, PartyWithProfile> newprofiles = new HashMap<>(
    9898                                getPartyProfiles());
  • protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsProtocol.java

    r1 r9  
    77import geniusweb.protocol.CurrentNegoState;
    88import geniusweb.protocol.SessionResult;
    9 import geniusweb.protocol.partyconnection.ConnectionWithPartyFactory;
     9import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory;
    1010import geniusweb.protocol.session.SessionProtocol;
    1111import geniusweb.protocol.session.SessionSettings;
     
    2929        private final transient Reporter log;
    3030
    31         private ConnectionWithPartyFactory connectionFactory; // FINAL
     31        private ProtocolToPartyConnFactory connectionFactory; // FINAL
    3232        private AllPermutationsState state; // MUTABLE
    3333
     
    4545
    4646        @Override
    47         public void start(ConnectionWithPartyFactory connectionfactory) {
     47        public void start(ProtocolToPartyConnFactory connectionfactory) {
    4848                this.connectionFactory = connectionfactory;
    49                 notifyChange(new TournamentStarted(state.getSize().longValue()));
     49                notifyListeners(new TournamentStarted(state.getSize().longValue()));
    5050                startNextSession();
    5151        }
     
    8585                                                sessionstate.getAgreement(), sessionstate.getError());
    8686                                state = state.with(result);
    87                                 notifyChange(new CurrentNegoState(state));
     87                                notifyListeners(new CurrentNegoState(state));
    8888                                if (!state.isFinal(now)) {
    8989                                        startNextSession();
Note: See TracChangeset for help on using the changeset viewer.