Changeset 4 for protocol


Ignore:
Timestamp:
09/18/19 10:00:22 (5 years ago)
Author:
bart
Message:

Faster example parties

Location:
protocol/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocol/src/main/java/geniusweb/protocol/ProtocolException.java

    r1 r4  
    1313
    1414        /**
    15          *
    1615         * @param message the error message
    1716         * @param party   offending party, either the {@link PartyId} or a
     
    1918         */
    2019        public ProtocolException(String message, String party) {
    21                 super(party + ":" + message);
    22                 this.party = party;
     20                this(message, party, null);
    2321        }
    2422
    2523        /**
     24         * ProtocolException is special, in that it does not auto-fill the
     25         * stacktrace. This is needed because usually a ProtocolException is caused
     26         * by a party doing a bad action. Creating a stacktrace pointing to the
     27         * class reporting the protocol exception (usually, the protocol handler)
     28         * makes no sense as the protocol handler is doing the correct job there.
     29         *
    2630         *
    2731         * @param message the error message
     
    3135         */
    3236        public ProtocolException(String message, String party, Throwable e) {
    33                 super(party + ":" + message, e);
     37                super(party + ":" + message, e, true, false);
    3438                this.party = party;
    3539        }
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOP.java

    r1 r4  
    22
    33import java.io.IOException;
     4import java.sql.Date;
     5import java.text.SimpleDateFormat;
    46import java.util.List;
    57import java.util.Timer;
     
    190192                                                        "BUG. Deadline timer has triggered but state is not final");
    191193                                }
     194                                log.log(Level.WARNING,
     195                                                "SAOP deadline reached. Terminating session.");
    192196                                finish();
    193197                        }
     
    196200                // early
    197201                deadlinetimer.schedule(task, deadline.getDuration() + TIME_MARGIN);
     202                log.log(Level.INFO, "SAOP deadline set to "
     203                                + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")
     204                                                .format(new Date(System.currentTimeMillis()
     205                                                                + deadline.getDuration() + TIME_MARGIN)));
    198206        }
    199207
     
    251259                        final ConnectionWithParty partyconn, final Action action) {
    252260                if (action == null) {
    253                         handleError("Received null from " + partyconn + ". Closing session",
     261                        handleError(partyconn
     262                                        + " did null action, breaching the protocol. Closing session",
    254263                                        partyconn.getParty().getName(), null);
    255264                        return;
     
    259268                        if (!partyconn.getParty().equals(state.getNextActor())) {
    260269                                // party does not have the turn.
    261                                 throw new ProtocolException(" act without having the turn",
     270                                throw new ProtocolException(
     271                                                "Party acts without having the turn",
    262272                                                partyconn.getParty().getName());
    263273                        }
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOPState.java

    r1 r4  
    189189                }
    190190                if (!actor.equals(getNextActor())) {
    191                         throw new ProtocolException("actor does not have the turn ",
     191                        throw new ProtocolException("Party does not have the turn ",
    192192                                        actor.getName());
    193193
     
    211211                        if (!bid.equals(((Accept) action).getBid())) {
    212212                                throw new ProtocolException(
    213                                                 "Accepts a bid that was not offered (last offer =" + bid
    214                                                                 + ", action=" + action + ")",
     213                                                "Party accepts a bid differing from the last offer ="
     214                                                                + bid + ", action=" + action + ")",
    215215                                                actor.getName());
    216216                        }
  • protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java

    r1 r4  
    284284                assertTrue(state.isFinal(NOW));
    285285                assertEquals(
    286                                 "geniusweb.protocol.ProtocolException: party1:actor does not have the turn ",
     286                                "geniusweb.protocol.ProtocolException: party1:Party does not have the turn ",
    287287                                state.getError().toString());
    288288        }
     
    297297                state = state.with(party2, nullaccept);
    298298                assertTrue(state.isFinal(NOW));
    299                 assertTrue(state.getError().toString()
    300                                 .matches(".*party2.*Accepts a bid that was not offered.*"));
     299                assertTrue(state.getError().toString().matches(
     300                                ".*party2.*Party accepts a bid differing from the last offer.*"));
    301301        }
    302302
Note: See TracChangeset for help on using the changeset viewer.