lobby-svn Mailing List for Lobby (Page 3)
Brought to you by:
yuranet
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
(3) |
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(8) |
Mar
(10) |
Apr
(2) |
May
(96) |
Jun
(33) |
Jul
(113) |
Aug
(24) |
Sep
(35) |
Oct
(17) |
Nov
(36) |
Dec
(1) |
2008 |
Jan
(10) |
Feb
|
Mar
(35) |
Apr
(14) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(6) |
Aug
(23) |
Sep
(19) |
Oct
(13) |
Nov
(59) |
Dec
(42) |
2013 |
Jan
(7) |
Feb
(10) |
Mar
(29) |
Apr
(10) |
May
(28) |
Jun
(3) |
Jul
(7) |
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2014 |
Jan
(7) |
Feb
(1) |
Mar
(11) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(3) |
Sep
|
Oct
|
Nov
(1) |
Dec
(3) |
2015 |
Jan
(10) |
Feb
|
Mar
(5) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(3) |
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(3) |
Sep
(7) |
Oct
(4) |
Nov
|
Dec
(16) |
2019 |
Jan
(2) |
Feb
(3) |
Mar
(4) |
Apr
|
May
|
Jun
(2) |
Jul
(2) |
Aug
|
Sep
(3) |
Oct
(8) |
Nov
(3) |
Dec
(6) |
2020 |
Jan
|
Feb
|
Mar
(4) |
Apr
(11) |
May
(12) |
Jun
(12) |
Jul
(8) |
Aug
(10) |
Sep
(3) |
Oct
(11) |
Nov
(7) |
Dec
|
2021 |
Jan
|
Feb
|
Mar
(5) |
Apr
(7) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(19) |
Dec
(15) |
2022 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
|
May
(3) |
Jun
(2) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(3) |
2023 |
Jan
(1) |
Feb
|
Mar
|
Apr
(5) |
May
(4) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(3) |
May
(7) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yu...@us...> - 2021-12-12 13:35:49
|
Revision: 1009 http://sourceforge.net/p/lobby/code/1009 Author: yuranet Date: 2021-12-12 13:35:46 +0000 (Sun, 12 Dec 2021) Log Message: ----------- info about why we cant move to new DataNucleus added Modified Paths: -------------- trunk/build.xml trunk/src_server/net/yura/lobby/server/GameLobby.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2021-12-11 13:24:51 UTC (rev 1008) +++ trunk/build.xml 2021-12-12 13:35:46 UTC (rev 1009) @@ -101,8 +101,25 @@ <mkdir dir="${dir.build.server.classes}"/> <!-- TARGET NEEDS TO BE 1.8 for DataNucleus to work -if it is newer the DataNucleus enhancer will fail +if it is newer (or older) the DataNucleus enhancer will fail +currently we are unable to upgrade to anything newer then DataNucleus 5.0.2 +as newer version use a new connection pool (DBCP2) and this does not work. +We get errors after running the net.yura.lobby.loadtest.TestRunner such as: + - getStatistics().getConnectionActiveCurrent() being stuck on positive number + - getStatistics().getConnectionActiveCurrent() getting stuck on negative number +and this causes the live server to fail after 10 to 20 hours of use with: + - endTransaction close error + - at net.yura.lobby.server.GameLobby$5.needInputFrom(GameLobby.java:1548) + - Caused by: com.mysql.cj.exceptions.CJCommunicationsException: The last packet successfully received from the server was 47,125,605 milliseconds ago. + The last packet sent successfully to the server was 47,125,605 milliseconds ago. + is longer than the server configured value of 'wait_timeout'. + You should consider either expiring and/or testing connection validity before use in your application, + increasing the server configured values for client timeouts, + or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. + - Caused by: java.net.SocketException: Broken pipe (Write failed) +and then all DB reads (JPAEntityManager.find) and writes will start failing with the same error message + firebase-admin from: https://repo1.maven.org/maven2/com/google/firebase/firebase-admin/6.8.1/firebase-admin-6.8.1.jar --> Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-11 13:24:51 UTC (rev 1008) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-12 13:35:46 UTC (rev 1009) @@ -273,6 +273,9 @@ database.startTransaction(); GameRoom gameRoom = getGame(id); + // TODO if we can not read from the DB, we wont be able to save + // can we attempt a save without a read? should we try save somewhere else? + ServerGame serverGame = runningGames.get(id); if (serverGame!=null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-11 13:24:53
|
Revision: 1008 http://sourceforge.net/p/lobby/code/1008 Author: yuranet Date: 2021-12-11 13:24:51 +0000 (Sat, 11 Dec 2021) Log Message: ----------- show status when logging in Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/Database.java trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java trunk/src_server/net/yura/lobby/server/GameLobby.java Modified: trunk/src_server/net/yura/lobby/database/Database.java =================================================================== --- trunk/src_server/net/yura/lobby/database/Database.java 2021-12-09 22:50:53 UTC (rev 1007) +++ trunk/src_server/net/yura/lobby/database/Database.java 2021-12-11 13:24:51 UTC (rev 1008) @@ -34,5 +34,7 @@ User getUserByPushToken(String token); void saveUser(User user); - public void logGameMove(String gameID, String user, String move); + void logGameMove(String gameID, String user, String move); + + String getStatus(); } Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-09 22:50:53 UTC (rev 1007) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-11 13:24:51 UTC (rev 1008) @@ -369,6 +369,18 @@ public boolean isHasLevel2Cache() { return getContext().hasLevel2Cache(); } + + @Override + public String getStatus() { + int errors = getErrorCount(); + int interactions = getInteractionsCount(); + int connections = getStatistics().getConnectionActiveCurrent(); + if (errors == 0 && interactions >= 0 && connections >= 0) { + return "all ok"; + } + return "ERR=" + errors + " i=" + interactions + " c=" + connections; + } + /* @Override public boolean isFederated() { Modified: trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java 2021-12-09 22:50:53 UTC (rev 1007) +++ trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java 2021-12-11 13:24:51 UTC (rev 1008) @@ -270,4 +270,9 @@ checkTransaction(); //TODO: Implement ? Do we even want to? } + + @Override + public String getStatus() { + return "MEM DB"; + } } Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-09 22:50:53 UTC (rev 1007) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-11 13:24:51 UTC (rev 1008) @@ -403,6 +403,12 @@ Map responce = loginResponce(user); send(session, ProtoAccess.COMMAND_LOGIN_OK, responce, LobbyLogger.NO_GAME_ID); + + if (checkIAm(session, Player.PLAYER_MODERATOR)) { + Map map = new HashMap(); + map.put("message", "DB Status: " + database.getStatus()); + send(session, ProtoAccess.COMMAND_CHAT_MESSAGE, map, LobbyLogger.NO_GAME_ID); + } } finally { database.endTransaction(); @@ -521,6 +527,9 @@ send(session, ProtoLobby.COMMAND_PUSH_REGISTER_DONE, null, LobbyLogger.NO_GAME_ID); } + /** + * called for oauth login + */ private void loginAndUpdateUser(User user, LobbySession session, String uuid, String email, String oauthId, String pushToken) { boolean changed = false; @@ -709,6 +718,7 @@ } /** + * called when user name or type changes on the server * @see net.yura.lobby.client.LobbyCom#messageFromServer(net.yura.lobby.model.Message) */ private void updateSessions(Collection<LobbySession> sessions, User user) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-09 22:50:56
|
Revision: 1007 http://sourceforge.net/p/lobby/code/1007 Author: yuranet Date: 2021-12-09 22:50:53 +0000 (Thu, 09 Dec 2021) Log Message: ----------- datanucleus 5.0.2 test Modified Paths: -------------- trunk/build.xml trunk/lobby.proto trunk/resources/runLobbyServer.sh trunk/src/net/yura/lobby/client/LobbyClient.java trunk/src/net/yura/lobby/client/TcpClient.java trunk/src/net/yura/lobby/model/Game.java trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java trunk/src_server/META-INF/MANIFEST.MF trunk/src_server/META-INF/persistence.xml trunk/src_server/net/yura/lobby/database/GameRoom.java trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/server/GameLobby.java trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java trunk/test/net/yura/lobby/server/ServerTest.java Added Paths: ----------- trunk/lib/datanucleus-api-jpa-5.0.2.jar trunk/lib/datanucleus-core-5.0.2.jar trunk/lib/datanucleus-rdbms-5.0.2.jar trunk/test/net/yura/lobby/loadtest/ trunk/test/net/yura/lobby/loadtest/TestRunner.java trunk/test/net/yura/lobby/util/LobbyConnection.java Removed Paths: ------------- trunk/test/net/yura/lobby/server/LobbyConnection.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/build.xml 2021-12-09 22:50:53 UTC (rev 1007) @@ -110,9 +110,9 @@ <javac debug="on" srcdir="${dir.source}:src_server" destdir="${dir.build.server.classes}" - source="1.6" target="1.6" + source="1.8" target="1.8" - classpath="${basedir}/lib/UtilME.jar:${basedir}/lib/QuickServer.jar:${basedir}/lib/javax.persistence-2.2.4.jar:${basedir}/lib/datanucleus-core-3.1.3.jar:${basedir}/lib/datanucleus-api-jpa-3.1.3.jar:${basedir}/lib/Grasshopper.jar:${basedir}/lib/gcm-server.jar:${basedir}/lib/netty-all-4.1.Final.jar:${basedir}/lib/google-api-client-1.24.1.jar:${basedir}/lib/google-http-client-1.24.1.jar:${basedir}/lib/google-http-client-gson-1.24.1.jar:${basedir}/lib/google-oauth-client-1.24.1.jar:${basedir}/lib/google-auth-library-oauth2-http-0.17.1.jar:${basedir}/lib/google-auth-library-credentials-0.18.0.jar:${basedir}/lib/firebase-admin-6.13.0.jar:${basedir}/lib/guava-26.0-android.jar" + classpath="${basedir}/lib/UtilME.jar:${basedir}/lib/QuickServer.jar:${basedir}/lib/javax.persistence-2.2.4.jar:${basedir}/lib/datanucleus-core-5.0.2.jar:${basedir}/lib/datanucleus-api-jpa-5.0.2.jar:${basedir}/lib/Grasshopper.jar:${basedir}/lib/gcm-server.jar:${basedir}/lib/netty-all-4.1.Final.jar:${basedir}/lib/google-api-client-1.24.1.jar:${basedir}/lib/google-http-client-1.24.1.jar:${basedir}/lib/google-http-client-gson-1.24.1.jar:${basedir}/lib/google-oauth-client-1.24.1.jar:${basedir}/lib/google-auth-library-oauth2-http-0.17.1.jar:${basedir}/lib/google-auth-library-credentials-0.18.0.jar:${basedir}/lib/firebase-admin-6.13.0.jar:${basedir}/lib/guava-26.0-android.jar" /> Added: trunk/lib/datanucleus-api-jpa-5.0.2.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-api-jpa-5.0.2.jar =================================================================== --- trunk/lib/datanucleus-api-jpa-5.0.2.jar 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/lib/datanucleus-api-jpa-5.0.2.jar 2021-12-09 22:50:53 UTC (rev 1007) Property changes on: trunk/lib/datanucleus-api-jpa-5.0.2.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/datanucleus-core-5.0.2.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-core-5.0.2.jar =================================================================== --- trunk/lib/datanucleus-core-5.0.2.jar 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/lib/datanucleus-core-5.0.2.jar 2021-12-09 22:50:53 UTC (rev 1007) Property changes on: trunk/lib/datanucleus-core-5.0.2.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/datanucleus-rdbms-5.0.2.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-rdbms-5.0.2.jar =================================================================== --- trunk/lib/datanucleus-rdbms-5.0.2.jar 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/lib/datanucleus-rdbms-5.0.2.jar 2021-12-09 22:50:53 UTC (rev 1007) Property changes on: trunk/lib/datanucleus-rdbms-5.0.2.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/lobby.proto =================================================================== --- trunk/lobby.proto 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/lobby.proto 2021-12-09 22:50:53 UTC (rev 1007) @@ -77,6 +77,8 @@ REQUEST_CREATE_NEW_GAME = 18; // Game REQUEST_JOIN_GAME = 19; // {game_id=id,magic_word=String} REQUEST_LEAVE_GAME = 20; // {game_id=id} + + // @deprecated (was used for GooglePlay private games COMMAND_GAME_STARTED = 27; // {game_id=id} // play a game Modified: trunk/resources/runLobbyServer.sh =================================================================== --- trunk/resources/runLobbyServer.sh 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/resources/runLobbyServer.sh 2021-12-09 22:50:53 UTC (rev 1007) @@ -1,6 +1,6 @@ #!/bin/sh cd "`dirname "$0"`" -exec java -server -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=4567 -Dcom.sun.management.jmxremote.rmi.port=4567 -javaagent:lib/datanucleus-enhancer-3.1.3.jar=-api=JPA,net.yura.lobby.database -jar LobbyServer.jar "$@" +exec java -server -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=4567 -Dcom.sun.management.jmxremote.rmi.port=4567 -javaagent:lib/datanucleus-core-5.0.2.jar=-api=JPA,net.yura.lobby.database -jar LobbyServer.jar "$@" # The exec here is important, it makes the started java process replace the script process, so that a) the process id doesn't change and b) we don't get an additional process because of the script. # http://www.ralfebert.de/blog/java/debian_daemon/ # may need to add -Djava.rmi.server.hostname=lobby.yura.net Modified: trunk/src/net/yura/lobby/client/LobbyClient.java =================================================================== --- trunk/src/net/yura/lobby/client/LobbyClient.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src/net/yura/lobby/client/LobbyClient.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -60,6 +60,10 @@ void addOrUpdateGame(Game game); void removeGame(int gameid); + /** + * signals that the PlayGames game YOU CREATED has started so you can now open it + * @deprecated + */ void gameStarted(int gameId); /** Modified: trunk/src/net/yura/lobby/client/TcpClient.java =================================================================== --- trunk/src/net/yura/lobby/client/TcpClient.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src/net/yura/lobby/client/TcpClient.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -144,16 +144,14 @@ * @param buf */ protected abstract void onRead(ByteBuffer buf) throws Exception; - + /** * Override with something meaningful - * @param buf */ protected abstract void onConnected() throws Exception; /** * Override with something meaningful - * @param buf */ protected abstract void onDisconnected(); @@ -194,7 +192,7 @@ LOG.log(Level.WARNING,"exception", e); } finally { connected.set(false); - onDisconnected(); + onDisconnected(); // TODO this can accedently throw/clear the InterruptedException ((Buffer)writeBuf).clear(); ((Buffer)readBuf).clear(); close(channel); Modified: trunk/src/net/yura/lobby/model/Game.java =================================================================== --- trunk/src/net/yura/lobby/model/Game.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src/net/yura/lobby/model/Game.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -92,12 +92,18 @@ return options; } + /** + * @return timeout in seconds + */ public int getTimeout() { return timeout; } - public void setTimeout(int timeout) { - this.timeout = timeout; + /** + * @param seconds timeout in seconds + */ + public void setTimeout(int seconds) { + this.timeout = seconds; } public String getWhosTurn() { Modified: trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java =================================================================== --- trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -125,6 +125,8 @@ private static final String NOTLOGGEDIN_PANEL = "notlogged"; private static final String LOGGEDIN_PANEL = "logged"; + public static final int DEFAULT_PORT = 1964; + private CardLayout cardlayout; private JPanel playersactions; private JButton adminButton; @@ -231,7 +233,7 @@ config = new Properties(); - config.setProperty("default.port","1964"); + config.setProperty("default.port",String.valueOf(DEFAULT_PORT)); config.setProperty("default.host","lobby.yura.net"); config.setProperty("default.mode","debug"); Modified: trunk/src_server/META-INF/MANIFEST.MF =================================================================== --- trunk/src_server/META-INF/MANIFEST.MF 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_server/META-INF/MANIFEST.MF 2021-12-09 22:50:53 UTC (rev 1007) @@ -1,5 +1,5 @@ Manifest-Version: 1.0 Created-By: Yura Mamyrin (yu...@yu...) Main-Class: net.yura.lobby.netty.Server -Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.26.jar lib/datanucleus-core-3.1.3.jar lib/datanucleus-rdbms-3.1.3.jar lib/datanucleus-api-jpa-3.1.3.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar +Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.26.jar lib/datanucleus-core-5.0.2.jar lib/datanucleus-rdbms-5.0.2.jar lib/datanucleus-api-jpa-5.0.2.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar lib/firebase-admin-6.13.0.jar lib/google-http-client-jackson2-1.33.0.jar lib/jackson-core-2.10.0.jar lib/slf4j-api-1.7.25.jar lib/google-auth-library-oauth2-http-0.17.1.jar lib/google-auth-library-credentials-0.18.0.jar lib/guava-26.0-android.jar lib/api-common-1.8.1.jar Modified: trunk/src_server/META-INF/persistence.xml =================================================================== --- trunk/src_server/META-INF/persistence.xml 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_server/META-INF/persistence.xml 2021-12-09 22:50:53 UTC (rev 1007) @@ -41,7 +41,7 @@ <property name="datanucleus.cache.level2.type" value="none"/> <property name="datanucleus.enableStatistics" value="true"/> - <!-- <property name="datanucleus.jmxType" value="default"/> --> + <property name="datanucleus.jmxType" value="default"/> </properties> </persistence-unit> </persistence> Modified: trunk/src_server/net/yura/lobby/database/GameRoom.java =================================================================== --- trunk/src_server/net/yura/lobby/database/GameRoom.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_server/net/yura/lobby/database/GameRoom.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -138,12 +138,19 @@ return false; } + /** + * @return timeout in seconds + */ @Column(name="timeout", nullable=true) public int getTimeout() { return game.getTimeout(); } - public void setTimeout(int timeout) { - game.setTimeout(timeout); + + /** + * @param seconds timeout in seconds + */ + public void setTimeout(int seconds) { + game.setTimeout(seconds); } // this is a waste of memory to load this every time we get a list of games Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -4,12 +4,10 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.persistence.EntityManager; @@ -23,8 +21,7 @@ import net.yura.lobby.database.GameTypeRoom; import net.yura.lobby.database.User; import net.yura.lobby.service.Alert; -import org.datanucleus.NucleusContext; -import org.datanucleus.api.jpa.JPAEntityManagerFactory; +import org.datanucleus.PersistenceNucleusContext; import org.datanucleus.api.jpa.NucleusJPAHelper; import org.datanucleus.management.FactoryStatistics; @@ -336,11 +333,12 @@ return errorCount.get(); } - private NucleusContext getContext() { - //return emf.unwrap(PersistenceNucleusContext.class); // v 5+ - - JPAEntityManagerFactory dnemf = (JPAEntityManagerFactory)emf; - return dnemf.getNucleusContext(); + private PersistenceNucleusContext getContext() { + // datanucleus v3 (in case we need to rollback again) + //JPAEntityManagerFactory dnemf = (JPAEntityManagerFactory)emf; + //return dnemf.getNucleusContext(); + + return emf.unwrap(PersistenceNucleusContext.class); // v 5+ } /* private ExecutionContext getContext(EntityManager em) { @@ -362,6 +360,11 @@ return emf.isOpen(); } + /** + * this is the object cache that's shared between all Interaction/EntityManager + * we disable this or direct changes to the DB do not get picked up by the app + * @return should always return false + */ @Override public boolean isHasLevel2Cache() { return getContext().hasLevel2Cache(); Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -1663,4 +1663,12 @@ public boolean checkIAm(LobbySession session, int playerType) { return session.getPlayerType() >= playerType; } + + /** + * to test that alerts are actually working from the main server + */ + @Override + public void sendAlert(String subject, String message) { + Alert.sendAlert(subject, message); + } } Modified: trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -65,4 +65,6 @@ // Hacks for removing broken games, should not be needed. int removeCurrentPlayerNotInGameGames(); int removeRunningGameNotFoundGames(); + + void sendAlert(String subject, String message); } Added: trunk/test/net/yura/lobby/loadtest/TestRunner.java =================================================================== --- trunk/test/net/yura/lobby/loadtest/TestRunner.java (rev 0) +++ trunk/test/net/yura/lobby/loadtest/TestRunner.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -0,0 +1,114 @@ +package net.yura.lobby.loadtest; + +import net.yura.lobby.util.LobbyConnection; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import net.yura.lobby.client.LobbyClientGUI; +import net.yura.lobby.model.Game; +import net.yura.lobby.model.GameType; + +public class TestRunner { + + public static void main(String[] args) { + int numClients = 20; + + for (int c = 0; c < numClients; c++) { + new Client(c); + } + } + + static class Client { + + int name; + + LobbyConnection com = new LobbyConnection(UUID.randomUUID().toString()); + + int targetGames = 4; + + List<Game> myGames = new ArrayList<>(); // TODO something thread safe + + public Client(int name) { + this.name = name; + com.connect("localhost", LobbyClientGUI.DEFAULT_PORT).thenAccept(player -> { + System.out.println("we are in " + player); + + com.getGameTypes().thenAccept(games -> { + System.out.println("we got gametypes " + games); + + Optional<GameType> domGame = games.stream().filter(type -> "Domination".equals(type.getName())).findFirst(); + + testGame(domGame.get(), player.getName()); + }); + }); + } + + public void testGame(GameType type, String myUsername) { +System.out.println("TEST GAME " + type); + com.getGames(type, game -> { + System.out.println("GOT GAME " + game); + + int state = game.getState(myUsername); + + if (myGames.size() < targetGames && game.getMagicWord() == null && state == Game.STATE_CAN_JOIN) { + System.out.println("join " + game); + + com.joinGame(game.getId(), null); + } + else if (game.hasPlayer(myUsername) && state == Game.STATE_CAN_PLAY && !myGames.contains(game)) { + System.out.println("play " + game); + + // yay we managed to join + myGames.add(game); + + com.playGame(game.getId()).thenAccept(data -> { + // TODO do something with game data + System.out.println("got game data " + data); + }); + + } + else if (myUsername.equals(game.getWhosTurn()) && myGames.contains(game)) { + System.out.println("turn " + game); + + //com.sendGameMessage(game.getId(), "autoplace"); + com.leaveGame(game.getId()); + com.closeGame(game.getId()); + } + + + }, gameId -> { + System.out.println("remove game " + gameId); + + for (int c = 0; c < myGames.size(); c++) { + if (myGames.get(c).getId() == gameId) { + myGames.remove(c); + break; + } + } + + if (myGames.isEmpty()) { + makeNewGame(type); + } + }); + + makeNewGame(type); + + } + + public void makeNewGame(GameType type) { + Game newGame = new Game(); + newGame.setType(type); + newGame.setMaxPlayers(2); + newGame.setName("TestRunner game " + name); + newGame.setTimeout(5); + newGame.setOptions("0\n" + + "0\n" + + "4\n" + + "choosemap luca.map\n" + + "startgame mission increasing recycle"); + com.createNewGame(newGame); + } + + } +} Deleted: trunk/test/net/yura/lobby/server/LobbyConnection.java =================================================================== --- trunk/test/net/yura/lobby/server/LobbyConnection.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/test/net/yura/lobby/server/LobbyConnection.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -1,280 +0,0 @@ -package net.yura.lobby.server; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Future; -import net.yura.lobby.client.Connection; -import net.yura.lobby.client.LobbyClient; -import net.yura.lobby.client.LobbyCom; -import net.yura.lobby.gen.ProtoLobby; -import net.yura.lobby.model.Game; -import net.yura.lobby.model.GameType; -import net.yura.lobby.model.Player; -import net.yura.lobby.model.PlayerInfo; -import net.yura.lobby.client.PushLobbyClient; - -public class LobbyConnection { - Connection mycom; - LoggingClient client; - - public LobbyConnection(String clientId) { - client = new LoggingClient(); - mycom = new LobbyCom(clientId, "JUnit-Test", "2"); - mycom.addEventListener(client); - mycom.addPushEventListener(client); - } - - public Future<Player> connect(String server, int port) { - CompletableFuture<Player> connected = new CompletableFuture(); - client.loginFuture = connected; - mycom.connect(server, port); - return connected; - } - - public void disconnect() { - mycom.disconnect(); - } - - public Future<List<GameType>> getGameTypes() { - CompletableFuture<List<GameType>> getTypes = new CompletableFuture(); - client.gametypesFuture = getTypes; - mycom.getGameTypes(); - return getTypes; - } - - public Future<Game> createNewGame(Game game) { - CompletableFuture<Game> newGame = new CompletableFuture(); - client.gameFuture = newGame; - mycom.createNewGame(game); - return newGame; - } - - /** - * sets the gametype on the server, can return nothing if no games - */ - public Future<Game> getGames(GameType type) { - CompletableFuture<Game> newGame = new CompletableFuture(); - client.gameFuture = newGame; - mycom.getGames(type); - return newGame; - } - - public Future<Game> joinGame(int gameId, String magicWord) { - CompletableFuture<Game> newGame = new CompletableFuture(); - client.gameFuture = newGame; - mycom.joinGame(gameId, magicWord); - return newGame; - } - - public Future<List<PlayerInfo>> getPlayerInfo(String username) { - CompletableFuture<List<PlayerInfo>> playerInfo = new CompletableFuture(); - client.playerInfoFuture = playerInfo; - mycom.getPlayerInfo(username); - return playerInfo; - } - - public Future<Integer> removedGame() { - return client.removeGame; - } - - public Future<Object> playGame(int gameId) { - CompletableFuture<Object> playGame = new CompletableFuture(); - client.playGameFuture = playGame; - mycom.playGame(gameId); - return playGame; - } - - public Future<String> getChatMessage() { - CompletableFuture<String> chatFuture = new CompletableFuture(); - client.chatFuture = chatFuture; - return chatFuture; - } - - public void sendChat(int id, String message) { - mycom.sendChat(id, message); - } - public void sendChat(String toWho, String message) { - mycom.sendPrivateChat(toWho, message); - } - - public void flagUser(String name) { - Map request = new HashMap(); - request.put("username", name); - mycom.sendAdminCommand(ProtoLobby.REQUEST_FLAG_USER, request); - } - - static class LoggingClient implements LobbyClient, PushLobbyClient { - - List gametypes; - String username; - int playerType; - boolean regDone; - - public CompletableFuture<Integer> removeGame = new CompletableFuture(); - public CompletableFuture<List<GameType>> gametypesFuture; - public CompletableFuture<Player> loginFuture; - public CompletableFuture<Game> gameFuture; - public CompletableFuture<List<PlayerInfo>> playerInfoFuture; - public CompletableFuture<Object> playGameFuture; - public CompletableFuture<String> chatFuture; - - @Override - public void connected() { - System.out.println("connected"); - } - - @Override - public void disconnected() { - System.out.println("disconnected"); - } - - @Override - public void connecting(String message) { - System.out.println("connecting " + message); - } - - @Override - public void error(String error) { - System.out.println("error " + error); - - if (gametypesFuture != null && !gametypesFuture.isDone()) { - gametypesFuture.completeExceptionally(new Exception(error)); - } - if (loginFuture != null && !loginFuture.isDone()) { - loginFuture.completeExceptionally(new Exception(error)); - } - if (gameFuture != null && !gameFuture.isDone()) { - gameFuture.completeExceptionally(new Exception(error)); - } - if (playerInfoFuture != null && !playerInfoFuture.isDone()) { - playerInfoFuture.completeExceptionally(new Exception(error)); - } - } - - @Override - public void setUsername(String name, int type) { - username = name; - playerType = type; - System.out.println("setUsername " + name + " " + type); - if (loginFuture != null) { - loginFuture.complete(new Player(name, type)); - } - } - - public String getUsername() { - return username; - } - public int getPlayerType() { - return playerType; - } - - @Override - public void addGameType(List gametypes) { - System.out.println("addGameType " + gametypes); - this.gametypes = gametypes; - if (gametypesFuture != null) { - gametypesFuture.complete(gametypes); - } - } - - @Override - public void addOrUpdateGame(Game game) { - System.out.println("addOrUpdateGame " + game); - if (gameFuture != null) { - gameFuture.complete(game); - } - } - - @Override - public void removeGame(int gameid) { - System.out.println("removeGame " + gameid); - - removeGame.complete(gameid); - } - - @Override - public void gameStarted(int gameId) { - System.out.println("gameStarted " + gameId); - } - - @Override - public void messageForGame(int gameid, Object object) { - System.out.println("messageForGame " + gameid + " " + object); - if (playGameFuture != null) { - playGameFuture.complete(object); - } - } - - @Override - public ClassLoader getClassLoader(GameType gameType) { - return null; - } - - @Override - public void renamePlayer(String oldname, String newname, int newtype) { - System.out.println("renamePlayer " + oldname + " " + newname + " " + newtype); - } - - @Override - public void addPlayer(Player player) { - System.out.println("addPlayer " + player); - } - - @Override - public void removePlayer(String player) { - System.out.println("removePlayer " + player); - } - - @Override - public void addPlayer(int roomid, Player player) { - System.out.println("addPlayer " + roomid + " " + player); - } - - @Override - public void removePlayer(int roomid, String player) { - System.out.println("removePlayer " + roomid + " " + player); - } - - @Override - public void incomingChat(String fromwho, String message) { - System.out.println("incomingChat " + fromwho + " " + message); - if (chatFuture != null) { - chatFuture.complete(message); - } - } - - @Override - public void incomingChat(int roomid, String fromWho, String message) { - System.out.println("incomingChat " + roomid + " " + fromWho + " " + message); - if (chatFuture != null && fromWho != null) { - chatFuture.complete(message); - } - } - - @Override - public void privateMessage(String fromwho, String message) { - System.out.println("privateMessage " + fromwho + " " + message); - } - - @Override - public void setUserInfo(String user, List info) { - System.out.println("setUserInfo " + user + " " + info); - if (playerInfoFuture != null) { - playerInfoFuture.complete(info); - } - } - - @Override - public void registerDone() { - System.out.println("registerDone"); - regDone = true; - } - - @Override - public void ping(long time) { - System.out.println("ping " + time); - } - } -} Modified: trunk/test/net/yura/lobby/server/ServerTest.java =================================================================== --- trunk/test/net/yura/lobby/server/ServerTest.java 2021-12-07 21:17:13 UTC (rev 1006) +++ trunk/test/net/yura/lobby/server/ServerTest.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -1,5 +1,6 @@ package net.yura.lobby.server; +import net.yura.lobby.util.LobbyConnection; import java.lang.management.ManagementFactory; import java.util.List; import java.util.concurrent.ExecutionException; @@ -16,7 +17,7 @@ import net.yura.lobby.model.Player; import net.yura.lobby.model.PlayerInfo; import net.yura.lobby.netty.Server; -import net.yura.lobby.server.LobbyConnection.LoggingClient; +import net.yura.lobby.util.LobbyConnection.LoggingClient; import net.yura.lobby.service.SphericalLabsMXBean; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; @@ -76,7 +77,7 @@ sleep(1000); mycom.disconnect(); String username1 = client.getUsername(); - Assert.assertEquals(true, client.regDone); + Assert.assertEquals(true, client.pushRegDone); System.out.println("-----------------------------------"); @@ -87,7 +88,7 @@ sleep(1000); mycom.disconnect(); Assert.assertEquals(username1, client.getUsername()); - Assert.assertEquals(true, client.regDone); + Assert.assertEquals(true, client.pushRegDone); } @Test @@ -103,7 +104,7 @@ sleep(1000); mycom.disconnect(); String username1 = client.getUsername(); - Assert.assertEquals(true, client.regDone); + Assert.assertEquals(true, client.pushRegDone); System.out.println("-----------------------------------"); @@ -115,7 +116,7 @@ sleep(1000); mycom.disconnect(); Assert.assertFalse(username1.equals(client.getUsername())); - Assert.assertEquals(true, client.regDone); + Assert.assertEquals(true, client.pushRegDone); } @Test @@ -205,7 +206,7 @@ LobbyConnection mycom1 = new LobbyConnection("test-flagged-uuid"); Player player = mycom1.connect(server, port).get(); Assert.assertEquals("test-flagged", player.getName()); - GameType type = getMockGame(mycom1.getGameTypes().get()); + GameType type = getMockGameType(mycom1.getGameTypes().get()); mycom1.getGames(type); // do not call get, as no games are returned Game game = new Game("my game name", BLACKJACK_OPTIONS, 2, 1000); game.setType(type); @@ -218,7 +219,7 @@ LobbyConnection mycom1 = new LobbyConnection(id1); Player user1 = mycom1.connect(server, port).get(); - GameType type1 = getMockGame(mycom1.getGameTypes().get()); + GameType type1 = getMockGameType(mycom1.getGameTypes().get()); mycom1.getGames(type1); // do not call get, as no games are returned Game game1 = new Game("my game name", BLACKJACK_OPTIONS, 2, 1000); game1.setType(type1); @@ -226,8 +227,8 @@ LobbyConnection mycom2 = new LobbyConnection(id2); Player user2 = mycom2.connect(server, port).get(); - GameType type2 = getMockGame(mycom2.getGameTypes().get()); - Game game2 = mycom2.getGames(type2).get(); + GameType type2 = getMockGameType(mycom2.getGameTypes().get()); + Game game2 = mycom2.getGames(type2).take(); game2 = mycom2.joinGame(game2.getId(), null).get(); // both players go into the game @@ -267,7 +268,7 @@ LobbyConnection mycom1 = new LobbyConnection(id1); mycom1.connect(server, port).get(); List<GameType> gameTypes1 = mycom1.getGameTypes().get(); - GameType type = getMockGame(gameTypes1); + GameType type = getMockGameType(gameTypes1); mycom1.getGames(type); // do not call get, as no games are returned Game game1 = new Game("my game name", "1 1 1 1 1", 2, 1000); game1.setType(type); @@ -280,7 +281,7 @@ LobbyConnection mycom2 = new LobbyConnection(id2); mycom2.connect(server, port).get(); List<GameType> gameTypes2 = mycom2.getGameTypes().get(); - Game game2 = mycom2.getGames(getMockGame(gameTypes2)).get(); + Game game2 = mycom2.getGames(getMockGameType(gameTypes2)).take(); Game newGame2 = mycom2.joinGame(game2.getId(), null).get(); Assert.assertEquals(2, newGame2.getPlayers().size()); @@ -297,7 +298,7 @@ LobbyConnection mycom1 = new LobbyConnection(id1); mycom1.connect(server, port).get(); - GameType type = getMockGame(mycom1.getGameTypes().get()); + GameType type = getMockGameType(mycom1.getGameTypes().get()); mycom1.getGames(type); // do not call get, as no games are returned Game game1 = new Game("my game name", BLACKJACK_OPTIONS, 2, 1000); game1.setType(type); @@ -311,7 +312,7 @@ LobbyConnection mycom2 = new LobbyConnection(id2); mycom2.connect(server, port).get(); try { - mycom2.joinGame(mycom2.getGames(getMockGame(mycom2.getGameTypes().get())).get().getId(), "abracadabra").get(); + mycom2.joinGame(mycom2.getGames(getMockGameType(mycom2.getGameTypes().get())).take().getId(), "abracadabra").get(); Assert.fail("should not allow join"); } catch (ExecutionException ex) { @@ -345,7 +346,7 @@ LobbyConnection mycom1 = new LobbyConnection(id1); mycom1.connect(server, port).get(); List<GameType> gameTypes1 = mycom1.getGameTypes().get(); - GameType type = getMockGame(gameTypes1); + GameType type = getMockGameType(gameTypes1); mycom1.getGames(type); // do not call get, as no games are returned Game game1 = new Game("my game name", "bad game options", 1, 1000); game1.setType(type); @@ -358,7 +359,7 @@ System.out.println("expected error: " + ex); } - int removedGame = mycom1.removedGame().get(); + int removedGame = mycom1.removedGame().take(); Assert.assertEquals(1, removedGame); mycom1.disconnect(); @@ -378,7 +379,7 @@ // ############################## Helper methods ############################## - private GameType getMockGame(List<GameType> types) { + private GameType getMockGameType(List<GameType> types) { for (GameType type : types) { if (type.getName().equals("Blackjack")) { return type; @@ -400,7 +401,7 @@ client.playerType = 0; client.username = null; client.gametypes = null; - client.regDone = false; + client.pushRegDone = false; Connection mycom = new LobbyCom(id, "JUnit-Test", "1"); mycom.addEventListener(client); Copied: trunk/test/net/yura/lobby/util/LobbyConnection.java (from rev 1006, trunk/test/net/yura/lobby/server/LobbyConnection.java) =================================================================== --- trunk/test/net/yura/lobby/util/LobbyConnection.java (rev 0) +++ trunk/test/net/yura/lobby/util/LobbyConnection.java 2021-12-09 22:50:53 UTC (rev 1007) @@ -0,0 +1,333 @@ +package net.yura.lobby.util; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.SubmissionPublisher; +import java.util.function.Consumer; +import net.yura.lobby.client.Connection; +import net.yura.lobby.client.LobbyClient; +import net.yura.lobby.client.LobbyCom; +import net.yura.lobby.gen.ProtoLobby; +import net.yura.lobby.model.Game; +import net.yura.lobby.model.GameType; +import net.yura.lobby.model.Player; +import net.yura.lobby.model.PlayerInfo; +import net.yura.lobby.client.PushLobbyClient; + +public class LobbyConnection { + + private Connection mycom; + private LoggingClient client; + + private BlockingQueue<Integer> removedGames = new LinkedBlockingQueue<>(); + + public LobbyConnection(String clientId) { + client = new LoggingClient(); + mycom = new LobbyCom(clientId, "JUnit-Test", "3"); + mycom.addEventListener(client); + mycom.addPushEventListener(client); + } + + public CompletableFuture<Player> connect(String server, int port) { + CompletableFuture<Player> connected = new CompletableFuture(); + client.loginFuture = connected; + mycom.connect(server, port); + return connected; + } + + public CompletableFuture<Void> disconnect() { + CompletableFuture<Void> disconnectFuture = new CompletableFuture<>(); + client.disconnectFuture = disconnectFuture; + mycom.disconnect(); + return disconnectFuture; + } + + public CompletableFuture<List<GameType>> getGameTypes() { + CompletableFuture<List<GameType>> getTypes = new CompletableFuture(); + client.gametypesFuture = getTypes; + mycom.getGameTypes(); + return getTypes; + } + + /** + * sets the gametype on the server, can return nothing if no games + */ + public BlockingQueue<Game> getGames(GameType type) { + LinkedBlockingQueue<Game> queue = new LinkedBlockingQueue(); + getGames(type, queue::add, removedGames::add); + return queue; + } + + /** + * for use with tests, makes check for remove commands easy + */ + public BlockingQueue<Integer> removedGame() { + return removedGames; + } + + public CompletableFuture<Void> getGames(GameType type, Consumer<Game> consumer, Consumer<Integer> removedConsumer) { + client.gameQueue = new SubmissionPublisher<>(); + client.delQueue = new SubmissionPublisher<>(); + CompletableFuture<Void> future1 = client.gameQueue.consume(consumer); + CompletableFuture<Void> future2 = client.delQueue.consume(removedConsumer); + + mycom.getGames(type); + return CompletableFuture.allOf(future1, future2); + } + + public CompletableFuture<Game> createNewGame(Game game) { + CompletableFuture<Game> newGame = new CompletableFuture(); + client.gameFuture = newGame; + mycom.createNewGame(game); + return newGame; + } + + public CompletableFuture<Game> joinGame(int gameId, String magicWord) { + CompletableFuture<Game> newGame = new CompletableFuture(); + client.gameFuture = newGame; + mycom.joinGame(gameId, magicWord); + return newGame; + } + + public void leaveGame(int gameId) { + mycom.leaveGame(gameId); + } + + public void closeGame(int gameId) { + mycom.closeGame(gameId); + } + + public CompletableFuture<List<PlayerInfo>> getPlayerInfo(String username) { + CompletableFuture<List<PlayerInfo>> playerInfo = new CompletableFuture(); + client.playerInfoFuture = playerInfo; + mycom.getPlayerInfo(username); + return playerInfo; + } + + public CompletableFuture<Object> playGame(int gameId) { + CompletableFuture<Object> playGame = new CompletableFuture(); + client.playGameFuture = playGame; + mycom.playGame(gameId); + return playGame; + } + + public CompletableFuture<String> getChatMessage() { + CompletableFuture<String> chatFuture = new CompletableFuture(); + client.chatFuture = chatFuture; + return chatFuture; + } + + public void sendChat(int id, String message) { + mycom.sendChat(id, message); + } + public void sendChat(String toWho, String message) { + mycom.sendPrivateChat(toWho, message); + } + + public void sendGameMessage(int id, Object obj) { + mycom.sendGameMessage(id, obj); + } + + public void flagUser(String name) { + Map request = new HashMap(); + request.put("username", name); + mycom.sendAdminCommand(ProtoLobby.REQUEST_FLAG_USER, request); + } + + public static class LoggingClient implements LobbyClient, PushLobbyClient { + + public String username; + public int playerType; + public List gametypes; + public boolean pushRegDone; + + SubmissionPublisher<Game> gameQueue; + SubmissionPublisher<Integer> delQueue; + + CompletableFuture<List<GameType>> gametypesFuture; + CompletableFuture<Player> loginFuture; + CompletableFuture<Game> gameFuture; // used for newGame or joinGame + CompletableFuture<List<PlayerInfo>> playerInfoFuture; + CompletableFuture<Object> playGameFuture; + CompletableFuture<String> chatFuture; + CompletableFuture<Void> disconnectFuture; + + @Override + public void connected() { + System.out.println("connected"); + } + + @Override + public void disconnected() { + System.out.println("disconnected"); + + if (gameQueue !=null) gameQueue.close(); + if (delQueue !=null) delQueue.close(); + + if (disconnectFuture != null) { + disconnectFuture.complete(null); + } + } + + @Override + public void connecting(String message) { + System.out.println("connecting " + message); + } + + @Override + public void error(String error) { + System.out.println("error " + error); + + if (gametypesFuture != null && !gametypesFuture.isDone()) { + gametypesFuture.completeExceptionally(new Exception(error)); + } + if (loginFuture != null && !loginFuture.isDone()) { + loginFuture.completeExceptionally(new Exception(error)); + } + if (gameFuture != null && !gameFuture.isDone()) { + gameFuture.completeExceptionally(new Exception(error)); + } + if (playerInfoFuture != null && !playerInfoFuture.isDone()) { + playerInfoFuture.completeExceptionally(new Exception(error)); + } + } + + @Override + public void setUsername(String name, int type) { + username = name; + playerType = type; + System.out.println("setUsername " + name + " " + type); + if (loginFuture != null) { + loginFuture.complete(new Player(name, type)); + } + } + + public String getUsername() { + return username; + } + public int getPlayerType() { + return playerType; + } + + @Override + public void addGameType(List gametypes) { + System.out.println("addGameType " + gametypes); + this.gametypes = gametypes; + if (gametypesFuture != null) { + gametypesFuture.complete(gametypes); + } + } + + @Override + public void addOrUpdateGame(Game game) { + System.out.println("addOrUpdateGame " + game +" " + gameQueue); + + // TODO if we are using this for creating a new game, we need to make sure this really is the new game + // this simple check if not good enough, as someone may have left a game we created a while back + // we need to check we have never been sent a game with this ID yet, so the ID is new AND we are in it + if (gameFuture != null && game.hasPlayer(username)) { + gameFuture.complete(game); + } + + gameQueue.submit(game); + } + + @Override + public void removeGame(int gameid) { + System.out.println("removeGame " + gameid); + + delQueue.submit(gameid); + } + + /** + * PlayGames private games + * @deprecated + */ + @Override + public void gameStarted(int gameId) { + System.out.println("gameStarted " + gameId); + } + + @Override + public void messageForGame(int gameid, Object object) { + System.out.println("messageForGame " + gameid + " " + object); + if (playGameFuture != null) { + playGameFuture.complete(object); + } + } + + @Override + public ClassLoader getClassLoader(GameType gameType) { + return null; + } + + @Override + public void renamePlayer(String oldname, String newname, int newtype) { + System.out.println("renamePlayer " + oldname + " " + newname + " " + newtype); + } + + @Override + public void addPlayer(Player player) { + System.out.println("addPlayer " + player); + } + + @Override + public void removePlayer(String player) { + System.out.println("removePlayer " + player); + } + + @Override + public void addPlayer(int roomid, Player player) { + System.out.println("addPlayer " + roomid + " " + player); + } + + @Override + public void removePlayer(int roomid, String player) { + System.out.println("removePlayer " + roomid + " " + player); + } + + @Override + public void incomingChat(String fromwho, String message) { + System.out.println("incomingChat " + fromwho + " " + message); + if (chatFuture != null) { + chatFuture.complete(message); + } + } + + @Override + public void incomingChat(int roomid, String fromWho, String message) { + System.out.println("incomingChat " + roomid + " " + fromWho + " " + message); + if (chatFuture != null && fromWho != null) { + chatFuture.complete(message); + } + } + + @Override + public void privateMessage(String fromwho, String message) { + System.out.println("privateMessage " + fromwho + " " + message); + } + + @Override + public void setUserInfo(String user, List info) { + System.out.println("setUserInfo " + user + " " + info); + if (playerInfoFuture != null) { + playerInfoFuture.complete(info); + } + } + + @Override + public void registerDone() { + System.out.println("registerDone"); + pushRegDone = true; + } + + @Override + public void ping(long time) { + System.out.println("ping " + time); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-07 21:17:15
|
Revision: 1006 http://sourceforge.net/p/lobby/code/1006 Author: yuranet Date: 2021-12-07 21:17:13 +0000 (Tue, 07 Dec 2021) Log Message: ----------- rollback to datanucleus 3.1.3 Modified Paths: -------------- trunk/build.xml trunk/resources/runLobbyServer.sh trunk/src_server/META-INF/MANIFEST.MF trunk/src_server/META-INF/persistence.xml trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java trunk/src_server/net/yura/lobby/server/GameLobby.java trunk/src_server/net/yura/lobby/service/Alert.java Added Paths: ----------- trunk/lib/datanucleus-api-jpa-3.1.3.jar trunk/lib/datanucleus-core-3.1.3.jar trunk/lib/datanucleus-enhancer-3.1.3.jar trunk/lib/datanucleus-rdbms-3.1.3.jar Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/build.xml 2021-12-07 21:17:13 UTC (rev 1006) @@ -110,9 +110,9 @@ <javac debug="on" srcdir="${dir.source}:src_server" destdir="${dir.build.server.classes}" - source="1.8" target="1.8" + source="1.6" target="1.6" - classpath="${basedir}/lib/UtilME.jar:${basedir}/lib/QuickServer.jar:${basedir}/lib/javax.persistence-2.2.4.jar:${basedir}/lib/datanucleus-core-5.2.8.jar:${basedir}/lib/datanucleus-api-jpa-5.2.8.jar:${basedir}/lib/Grasshopper.jar:${basedir}/lib/gcm-server.jar:${basedir}/lib/netty-all-4.1.Final.jar:${basedir}/lib/google-api-client-1.24.1.jar:${basedir}/lib/google-http-client-1.24.1.jar:${basedir}/lib/google-http-client-gson-1.24.1.jar:${basedir}/lib/google-oauth-client-1.24.1.jar:${basedir}/lib/google-auth-library-oauth2-http-0.17.1.jar:${basedir}/lib/google-auth-library-credentials-0.18.0.jar:${basedir}/lib/firebase-admin-6.13.0.jar:${basedir}/lib/guava-26.0-android.jar" + classpath="${basedir}/lib/UtilME.jar:${basedir}/lib/QuickServer.jar:${basedir}/lib/javax.persistence-2.2.4.jar:${basedir}/lib/datanucleus-core-3.1.3.jar:${basedir}/lib/datanucleus-api-jpa-3.1.3.jar:${basedir}/lib/Grasshopper.jar:${basedir}/lib/gcm-server.jar:${basedir}/lib/netty-all-4.1.Final.jar:${basedir}/lib/google-api-client-1.24.1.jar:${basedir}/lib/google-http-client-1.24.1.jar:${basedir}/lib/google-http-client-gson-1.24.1.jar:${basedir}/lib/google-oauth-client-1.24.1.jar:${basedir}/lib/google-auth-library-oauth2-http-0.17.1.jar:${basedir}/lib/google-auth-library-credentials-0.18.0.jar:${basedir}/lib/firebase-admin-6.13.0.jar:${basedir}/lib/guava-26.0-android.jar" /> Added: trunk/lib/datanucleus-api-jpa-3.1.3.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-api-jpa-3.1.3.jar =================================================================== --- trunk/lib/datanucleus-api-jpa-3.1.3.jar 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/lib/datanucleus-api-jpa-3.1.3.jar 2021-12-07 21:17:13 UTC (rev 1006) Property changes on: trunk/lib/datanucleus-api-jpa-3.1.3.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/datanucleus-core-3.1.3.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-core-3.1.3.jar =================================================================== --- trunk/lib/datanucleus-core-3.1.3.jar 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/lib/datanucleus-core-3.1.3.jar 2021-12-07 21:17:13 UTC (rev 1006) Property changes on: trunk/lib/datanucleus-core-3.1.3.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/datanucleus-enhancer-3.1.3.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-enhancer-3.1.3.jar =================================================================== --- trunk/lib/datanucleus-enhancer-3.1.3.jar 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/lib/datanucleus-enhancer-3.1.3.jar 2021-12-07 21:17:13 UTC (rev 1006) Property changes on: trunk/lib/datanucleus-enhancer-3.1.3.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/datanucleus-rdbms-3.1.3.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-rdbms-3.1.3.jar =================================================================== --- trunk/lib/datanucleus-rdbms-3.1.3.jar 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/lib/datanucleus-rdbms-3.1.3.jar 2021-12-07 21:17:13 UTC (rev 1006) Property changes on: trunk/lib/datanucleus-rdbms-3.1.3.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/resources/runLobbyServer.sh =================================================================== --- trunk/resources/runLobbyServer.sh 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/resources/runLobbyServer.sh 2021-12-07 21:17:13 UTC (rev 1006) @@ -1,6 +1,6 @@ #!/bin/sh cd "`dirname "$0"`" -exec java -server -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=4567 -Dcom.sun.management.jmxremote.rmi.port=4567 -javaagent:lib/datanucleus-core-5.2.8.jar=-api=JPA,net.yura.lobby.database -jar LobbyServer.jar "$@" +exec java -server -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=4567 -Dcom.sun.management.jmxremote.rmi.port=4567 -javaagent:lib/datanucleus-enhancer-3.1.3.jar=-api=JPA,net.yura.lobby.database -jar LobbyServer.jar "$@" # The exec here is important, it makes the started java process replace the script process, so that a) the process id doesn't change and b) we don't get an additional process because of the script. # http://www.ralfebert.de/blog/java/debian_daemon/ # may need to add -Djava.rmi.server.hostname=lobby.yura.net Modified: trunk/src_server/META-INF/MANIFEST.MF =================================================================== --- trunk/src_server/META-INF/MANIFEST.MF 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/src_server/META-INF/MANIFEST.MF 2021-12-07 21:17:13 UTC (rev 1006) @@ -1,5 +1,5 @@ Manifest-Version: 1.0 Created-By: Yura Mamyrin (yu...@yu...) Main-Class: net.yura.lobby.netty.Server -Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.26.jar lib/datanucleus-api-jpa-5.2.8.jar lib/datanucleus-core-5.2.8.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/datanucleus-rdbms-5.2.9.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar +Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.26.jar lib/datanucleus-core-3.1.3.jar lib/datanucleus-rdbms-3.1.3.jar lib/datanucleus-api-jpa-3.1.3.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar lib/firebase-admin-6.13.0.jar lib/google-http-client-jackson2-1.33.0.jar lib/jackson-core-2.10.0.jar lib/slf4j-api-1.7.25.jar lib/google-auth-library-oauth2-http-0.17.1.jar lib/google-auth-library-credentials-0.18.0.jar lib/guava-26.0-android.jar lib/api-common-1.8.1.jar Modified: trunk/src_server/META-INF/persistence.xml =================================================================== --- trunk/src_server/META-INF/persistence.xml 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/src_server/META-INF/persistence.xml 2021-12-07 21:17:13 UTC (rev 1006) @@ -12,6 +12,18 @@ <exclude-unlisted-classes/> <properties> + + <!-- DN v3 --> + <property name="datanucleus.ConnectionDriverName" value="com.mysql.jdbc.Driver"/> + <property name="datanucleus.ConnectionURL" value="jdbc:mysql://localhost:3306/lobby?useUnicode=yes&characterEncoding=UTF-8"/> + <property name="datanucleus.ConnectionUserName" value="root"/> + <property name="datanucleus.ConnectionPassword" value="pass"/> + <property name="datanucleus.autoCreateSchema" value="true"/> + <property name="datanucleus.validateTables" value="false"/> + <property name="datanucleus.validateConstraints" value="false"/> + + + <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/lobby?autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8"/> <property name="javax.persistence.jdbc.user" value="root" /> @@ -29,7 +41,7 @@ <property name="datanucleus.cache.level2.type" value="none"/> <property name="datanucleus.enableStatistics" value="true"/> - <property name="datanucleus.jmxType" value="default"/> + <!-- <property name="datanucleus.jmxType" value="default"/> --> </properties> </persistence-unit> </persistence> Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-07 21:17:13 UTC (rev 1006) @@ -23,8 +23,8 @@ import net.yura.lobby.database.GameTypeRoom; import net.yura.lobby.database.User; import net.yura.lobby.service.Alert; -import org.datanucleus.ExecutionContext; -import org.datanucleus.PersistenceNucleusContext; +import org.datanucleus.NucleusContext; +import org.datanucleus.api.jpa.JPAEntityManagerFactory; import org.datanucleus.api.jpa.NucleusJPAHelper; import org.datanucleus.management.FactoryStatistics; @@ -336,14 +336,17 @@ return errorCount.get(); } - private PersistenceNucleusContext getContext() { - return emf.unwrap(PersistenceNucleusContext.class); + private NucleusContext getContext() { + //return emf.unwrap(PersistenceNucleusContext.class); // v 5+ + + JPAEntityManagerFactory dnemf = (JPAEntityManagerFactory)emf; + return dnemf.getNucleusContext(); } - +/* private ExecutionContext getContext(EntityManager em) { return em.unwrap(ExecutionContext.class); } - +*/ @Override public FactoryStatistics getStatistics() { return getContext().getStatistics(); @@ -363,7 +366,7 @@ public boolean isHasLevel2Cache() { return getContext().hasLevel2Cache(); } - +/* @Override public boolean isFederated() { return getContext().isFederated(); @@ -374,4 +377,5 @@ .collect(Collectors.toMap(entry -> entry.getKey(), entry -> String.valueOf(entry.getValue()))); } +*/ } Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java 2021-12-07 21:17:13 UTC (rev 1006) @@ -16,5 +16,5 @@ boolean isOpen(); boolean isHasLevel2Cache(); - boolean isFederated(); + //boolean isFederated(); } Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-07 21:17:13 UTC (rev 1006) @@ -781,20 +781,20 @@ throw new IllegalStateException("please update your app"); } + List<GameType> gametypes = new ArrayList(); try { database.startTransaction(); - Collection<GameTypeRoom> c = database.getGameTypes(); - List<GameType> gametypes = new ArrayList(); for (GameTypeRoom gtr:c) { - gametypes.add( gtr.getGameType() ); + gametypes.add(gtr.getGameType()); } - Collections.sort(gametypes); - send(session, ProtoAccess.COMMAND_ALL_GAMETYPES, gametypes, LobbyLogger.NO_GAME_ID); } finally { database.endTransaction(); } + + Collections.sort(gametypes); + send(session, ProtoAccess.COMMAND_ALL_GAMETYPES, gametypes, LobbyLogger.NO_GAME_ID); } @Override @@ -1122,10 +1122,13 @@ List<GameRoom> games = new ArrayList(database.getGameType(game_type_id).getGameRooms()); Collections.sort(games); - for (GameRoom gr: games) { sendGame(session, gr.getGame()); } + + //Set<GameRoom> gameRooms = database.getGameType(game_type_id).getGameRooms(); + // and i cant fucking do this in case i will need to roll back!!! AAAAAAAA + //games = gameRooms.stream().sorted().map(g -> g.getGame()).collect(Collectors.toList()); } finally { database.endTransaction(); Modified: trunk/src_server/net/yura/lobby/service/Alert.java =================================================================== --- trunk/src_server/net/yura/lobby/service/Alert.java 2021-12-06 15:47:15 UTC (rev 1005) +++ trunk/src_server/net/yura/lobby/service/Alert.java 2021-12-07 21:17:13 UTC (rev 1006) @@ -10,7 +10,8 @@ public static void sendAlert(String type, String text) { try { - LobbyLogger.logger.info("sending alert " + text); + LobbyLogger.logger.info("sending alert " + type + " " + text); + Map<String, String> map = new HashMap(); map.put("recipient", "yu...@yu..."); map.put("subject", "Lobby Alert - " + type); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-06 15:47:18
|
Revision: 1005 http://sourceforge.net/p/lobby/code/1005 Author: yuranet Date: 2021-12-06 15:47:15 +0000 (Mon, 06 Dec 2021) Log Message: ----------- checks added to make sure user is logged in when they enter a game Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/server/GameLobby.java trunk/src_server/net/yura/lobby/server/TurnBasedGame.java Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-06 13:56:41 UTC (rev 1004) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-06 15:47:15 UTC (rev 1005) @@ -109,8 +109,6 @@ try { in.em.close(); - - } catch (Throwable ex) { logger.log(Level.WARNING, "endTransaction close error " + in, ex); Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-06 13:56:41 UTC (rev 1004) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-06 15:47:15 UTC (rev 1005) @@ -1309,6 +1309,9 @@ if (!server.isConnected(session)) { throw new IllegalStateException("session is not connected"); } + if (session.getUsername() == null) { + throw new IllegalStateException("session is not logged in yet"); + } // this will now send the game object to the client serverGame.clientEntered( session ); Modified: trunk/src_server/net/yura/lobby/server/TurnBasedGame.java =================================================================== --- trunk/src_server/net/yura/lobby/server/TurnBasedGame.java 2021-12-06 13:56:41 UTC (rev 1004) +++ trunk/src_server/net/yura/lobby/server/TurnBasedGame.java 2021-12-06 15:47:15 UTC (rev 1005) @@ -220,9 +220,13 @@ @Override public final void clientEntered(final LobbySession session) { + String username = session.getUsername(); + if (username == null) { + throw new IllegalArgumentException("username is null"); + } // we tell everyone currently in the game this person is joining - listoner.sendChatroomMessage(session.getUsername()+" has entered the game"); + listoner.sendChatroomMessage(username + " has entered the game"); // we add this new player as a spectator to make sure we do not miss any messages // from the game that can happen between clientHasJoined() and spectators.add() @@ -239,7 +243,7 @@ // // TODO we send game object to every session with this username // would be better if just sent it to the session we needed to - clientHasJoined( session.getUsername() ); + clientHasJoined(username); // // } // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-06 13:56:44
|
Revision: 1004 http://sourceforge.net/p/lobby/code/1004 Author: yuranet Date: 2021-12-06 13:56:41 +0000 (Mon, 06 Dec 2021) Log Message: ----------- back to latest mysql connector and potential fix for failing endTransaction Modified Paths: -------------- trunk/src_server/META-INF/MANIFEST.MF trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/server/GameLobby.java Removed Paths: ------------- trunk/lib/mysql-connector-java-8.0.23.jar Deleted: trunk/lib/mysql-connector-java-8.0.23.jar =================================================================== (Binary files differ) Modified: trunk/src_server/META-INF/MANIFEST.MF =================================================================== --- trunk/src_server/META-INF/MANIFEST.MF 2021-12-05 21:49:49 UTC (rev 1003) +++ trunk/src_server/META-INF/MANIFEST.MF 2021-12-06 13:56:41 UTC (rev 1004) @@ -1,5 +1,5 @@ Manifest-Version: 1.0 Created-By: Yura Mamyrin (yu...@yu...) Main-Class: net.yura.lobby.netty.Server -Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.23.jar lib/datanucleus-api-jpa-5.2.8.jar lib/datanucleus-core-5.2.8.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/datanucleus-rdbms-5.2.9.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar +Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.26.jar lib/datanucleus-api-jpa-5.2.8.jar lib/datanucleus-core-5.2.8.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/datanucleus-rdbms-5.2.9.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar lib/firebase-admin-6.13.0.jar lib/google-http-client-jackson2-1.33.0.jar lib/jackson-core-2.10.0.jar lib/slf4j-api-1.7.25.jar lib/google-auth-library-oauth2-http-0.17.1.jar lib/google-auth-library-credentials-0.18.0.jar lib/guava-26.0-android.jar lib/api-common-1.8.1.jar Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-05 21:49:49 UTC (rev 1003) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-06 13:56:41 UTC (rev 1004) @@ -23,6 +23,7 @@ import net.yura.lobby.database.GameTypeRoom; import net.yura.lobby.database.User; import net.yura.lobby.service.Alert; +import org.datanucleus.ExecutionContext; import org.datanucleus.PersistenceNucleusContext; import org.datanucleus.api.jpa.NucleusJPAHelper; import org.datanucleus.management.FactoryStatistics; @@ -108,6 +109,8 @@ try { in.em.close(); + + } catch (Throwable ex) { logger.log(Level.WARNING, "endTransaction close error " + in, ex); @@ -338,6 +341,10 @@ private PersistenceNucleusContext getContext() { return emf.unwrap(PersistenceNucleusContext.class); } + + private ExecutionContext getContext(EntityManager em) { + return em.unwrap(ExecutionContext.class); + } @Override public FactoryStatistics getStatistics() { Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-05 21:49:49 UTC (rev 1003) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-06 13:56:41 UTC (rev 1004) @@ -1534,42 +1534,41 @@ @Override public void needInputFrom(String username) { - boolean doAndroidSend=false; Game game; try { database.startTransaction(); - - LobbySession found=null; game = getGame(sg.getId()).getGame(); - Collection<LobbySession> sessions = sg.getAllClients(); - for (LobbySession session:sessions) { - sendGame(session, game); - if (session.getUsername().equals(username)) { - found = session; - } - } - - if (username!=null && found==null) { - Collection<LobbySession> session = server.getLobbySession(username); - if (!session.isEmpty()) { - for (LobbySession s:session) { - sendGame(s, game); - } - } - else { - // if they are not even connected - doAndroidSend = true; - } - } } finally { + // we want to end this trnasaction NOW, as if we leave it till later + // we may be sending User objects at the same time as detaching them, and thet gets datanucleus confused database.endTransaction(); } - if (doAndroidSend) { - pushSend(username, game); + LobbySession found = null; + Collection<LobbySession> spectators = sg.getAllClients(); + for (LobbySession session : spectators) { + sendGame(session, game); + if (session.getUsername().equals(username)) { + found = session; + } } + + if (username != null && found == null) { + Collection<LobbySession> session = server.getLobbySession(username); + if (!session.isEmpty()) { + for (LobbySession s : session) { + sendGame(s, game); + } + } + else { + // if they are not even connected + // (this HAS to be outside a DB transaction) + pushSend(username, game); + } + } } + @Override public void resignPlayer(String username) { leaveGame(sg.getId(), username); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-05 21:49:51
|
Revision: 1003 http://sourceforge.net/p/lobby/code/1003 Author: yuranet Date: 2021-12-05 21:49:49 +0000 (Sun, 05 Dec 2021) Log Message: ----------- better name Modified Paths: -------------- trunk/src_server/net/yura/lobby/server/GameLobby.java Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-05 21:38:35 UTC (rev 1002) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-05 21:49:49 UTC (rev 1003) @@ -186,7 +186,7 @@ @Override public boolean saveToDB() { LobbyLogger.logger.info("going to save games to DB"); - boolean result = true; + boolean success = true; int priority = Thread.currentThread().getPriority(); Thread.currentThread().setPriority(Thread.MAX_PRIORITY); @@ -210,7 +210,7 @@ LobbyLogger.log(gameId, Level.INFO, count+"/"+games.size()+" saved "+gameId +" took " + (System.currentTimeMillis() - start)); } catch(Exception ex) { - result = false; + success = false; throw ex; } } @@ -222,8 +222,8 @@ Thread.currentThread().setPriority(priority); - LobbyLogger.logger.info("DONE saving games to DB. success=" + result); - return result; + LobbyLogger.logger.info("DONE saving games to DB. success=" + success); + return success; } private int getGameTypeId(String gameName) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-05 21:38:37
|
Revision: 1002 http://sourceforge.net/p/lobby/code/1002 Author: yuranet Date: 2021-12-05 21:38:35 +0000 (Sun, 05 Dec 2021) Log Message: ----------- keep track of errors in endTransaction during game saves Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/Database.java trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java trunk/src_server/net/yura/lobby/server/GameLobby.java trunk/src_server/net/yura/lobby/server/LobbyLogger.java trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java Modified: trunk/src_server/net/yura/lobby/database/Database.java =================================================================== --- trunk/src_server/net/yura/lobby/database/Database.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/database/Database.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -4,8 +4,11 @@ public interface Database { - public void startTransaction(); - public void endTransaction(); + void startTransaction(); + /** + * @return true if successful + */ + boolean endTransaction(); public Collection<GameTypeRoom> getGameTypes(); public Collection<GameRoom> getGameRooms(); Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -22,6 +22,7 @@ import net.yura.lobby.database.GameRoom; import net.yura.lobby.database.GameTypeRoom; import net.yura.lobby.database.User; +import net.yura.lobby.service.Alert; import org.datanucleus.PersistenceNucleusContext; import org.datanucleus.api.jpa.NucleusJPAHelper; import org.datanucleus.management.FactoryStatistics; @@ -29,7 +30,7 @@ /** * @author Yura Mamyrin */ -public class JPADatabase implements Database,JPADatabaseMXBean { +public class JPADatabase implements Database, JPADatabaseMXBean { static final Logger logger = Logger.getLogger(JPADatabase.class.getName()); @@ -53,6 +54,8 @@ * a IllegalStateException("already have a transaction") */ final AtomicInteger interactionsCount = new AtomicInteger(); + + final AtomicInteger errorCount = new AtomicInteger(); public JPADatabase() { try { @@ -72,6 +75,7 @@ dbAccess.acquireUninterruptibly(); if (interactions.get()!=null) { + error("already have a transaction!"); throw new IllegalStateException("already have a transaction!"); } Interaction in = new Interaction(); @@ -86,8 +90,9 @@ in.tx.commit(); } @Override - public void endTransaction() { + public boolean endTransaction() { dbAccess.release(); + boolean success = true; Interaction in = interactions.get(); try { @@ -97,6 +102,8 @@ } catch (Throwable ex) { logger.log(Level.WARNING, "endTransaction rollback error " + in, ex); + error(String.valueOf(ex)); + success = false; } try { @@ -104,6 +111,8 @@ } catch (Throwable ex) { logger.log(Level.WARNING, "endTransaction close error " + in, ex); + error(String.valueOf(ex)); + success = false; } try { @@ -112,12 +121,24 @@ } catch (Throwable ex) { logger.log(Level.WARNING, "endTransaction error " + in, ex); + error(String.valueOf(ex)); + success = false; } + + return success; } + private void error(String message) { + int count = errorCount.incrementAndGet(); + if (count == 1) { + Alert.sendAlert("DB", "error count up: " + message); + } + } + private Interaction getTransaction() { Interaction in = interactions.get(); if (in == null) { + error("not in transaction"); throw new IllegalStateException("not in transaction"); } return in; @@ -303,32 +324,49 @@ public void logGameMove(String gameID, String user, String move) { } + + @Override + public int getInteractionsCount() { + return interactionsCount.get(); + } @Override - public FactoryStatistics getStatistics() { - PersistenceNucleusContext context = emf.unwrap(PersistenceNucleusContext.class); - return context.getStatistics(); + public int getErrorCount() { + return errorCount.get(); } + private PersistenceNucleusContext getContext() { + return emf.unwrap(PersistenceNucleusContext.class); + } + @Override + public FactoryStatistics getStatistics() { + return getContext().getStatistics(); + } + + @Override + public String getApiName() { + return getContext().getApiName(); + } + + @Override public boolean isOpen() { return emf.isOpen(); } + @Override + public boolean isHasLevel2Cache() { + return getContext().hasLevel2Cache(); + } + + @Override + public boolean isFederated() { + return getContext().isFederated(); + } + public Map<String, String> getProperties() { return emf.getProperties().entrySet().stream() .collect(Collectors.toMap(entry -> entry.getKey(), entry -> String.valueOf(entry.getValue()))); } - - @Override - public String getApiName() { - PersistenceNucleusContext context = emf.unwrap(PersistenceNucleusContext.class); - return context.getApiName(); - } - - @Override - public int getInteractionsCount() { - return interactionsCount.get(); - } } Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -8,7 +8,13 @@ public interface JPADatabaseMXBean { int getInteractionsCount(); + int getErrorCount(); + FactoryStatistics getStatistics(); + + String getApiName(); + boolean isOpen(); - String getApiName(); + boolean isHasLevel2Cache(); + boolean isFederated(); } Modified: trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -28,7 +28,7 @@ import net.yura.lobby.database.User; import net.yura.lobby.model.Player; -public class MemoryDatabase implements Database{ +public class MemoryDatabase implements Database { private Map<String,User> registeredPeople; // <Username,User> final Map<String,User> clientUUIDtoInt; // <UUID,Client> @@ -45,11 +45,12 @@ transaction = true; } @Override - public void endTransaction() { + public boolean endTransaction() { if (!transaction) { throw new IllegalStateException("not in transaction"); } transaction = false; + return true; } private void checkTransaction() { if (!transaction) { Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -206,7 +206,7 @@ try { LobbyLogger.log(gameId, Level.INFO, count+"/"+games.size()+" saving "+gameId); long start = System.currentTimeMillis(); - saveGame(gameId); + saveGameData(gameId); LobbyLogger.log(gameId, Level.INFO, count+"/"+games.size()+" saved "+gameId +" took " + (System.currentTimeMillis() - start)); } catch(Exception ex) { @@ -267,7 +267,8 @@ } @Override - public void saveGame(int id) { + public void saveGameData(int id) throws Exception { + boolean success; try { database.startTransaction(); @@ -281,8 +282,11 @@ database.saveGame(gameRoom); } finally { - database.endTransaction(); + success = database.endTransaction(); } + if (!success) { + throw new Exception("error in endTransaction"); + } } // TODO replace this logic with a lookup from DB Modified: trunk/src_server/net/yura/lobby/server/LobbyLogger.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyLogger.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/server/LobbyLogger.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -16,6 +16,10 @@ import java.util.logging.SimpleFormatter; import net.yura.grasshopper.BugManager; +/** + * keeps track of extra logging info, a bit like + * https://logging.apache.org/log4j/2.x/manual/thread-context.html + */ public class LobbyLogger { public static final int NO_GAME_ID = -1; @@ -32,6 +36,9 @@ logger.log(record); } + /** + * TODO: instead of having this interface, maybe set id as a thread local + */ public interface LobbyGameThread { /** * @return the correlation ID Modified: trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java 2021-12-04 16:56:23 UTC (rev 1001) +++ trunk/src_server/net/yura/lobby/server/LobbyServerMXBean.java 2021-12-05 21:38:35 UTC (rev 1002) @@ -40,7 +40,7 @@ * @return true if saving was successful, false if we had errors. */ boolean saveToDB(); - void saveGame(int gameId); + void saveGameData(int gameId) throws Exception; void removeGame(int gameId); boolean isFinished(int gameId); int countFinishedGames(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-04 16:56:26
|
Revision: 1001 http://sourceforge.net/p/lobby/code/1001 Author: yuranet Date: 2021-12-04 16:56:23 +0000 (Sat, 04 Dec 2021) Log Message: ----------- more info when transaction fails Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-04 16:17:47 UTC (rev 1000) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-12-04 16:56:23 UTC (rev 1001) @@ -4,10 +4,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.persistence.EntityManager; @@ -32,8 +34,13 @@ static final Logger logger = Logger.getLogger(JPADatabase.class.getName()); static class Interaction { + final long startTime = System.currentTimeMillis(); EntityManager em; EntityTransaction tx; + + public String toString() { + return "JPAInteraction " + startTime + " " + em + " " + tx; + } } EntityManagerFactory emf = Persistence.createEntityManagerFactory("Lobby"); @@ -89,7 +96,7 @@ } } catch (Throwable ex) { - logger.log(Level.WARNING, "endTransaction rollback error", ex); + logger.log(Level.WARNING, "endTransaction rollback error " + in, ex); } try { @@ -96,7 +103,7 @@ in.em.close(); } catch (Throwable ex) { - logger.log(Level.WARNING, "endTransaction close error", ex); + logger.log(Level.WARNING, "endTransaction close error " + in, ex); } try { @@ -104,7 +111,7 @@ interactionsCount.decrementAndGet(); } catch (Throwable ex) { - logger.log(Level.WARNING, "endTransaction error", ex); + logger.log(Level.WARNING, "endTransaction error " + in, ex); } } @@ -302,8 +309,25 @@ PersistenceNucleusContext context = emf.unwrap(PersistenceNucleusContext.class); return context.getStatistics(); } + + @Override + public boolean isOpen() { + return emf.isOpen(); + } + public Map<String, String> getProperties() { + return emf.getProperties().entrySet().stream() + .collect(Collectors.toMap(entry -> entry.getKey(), + entry -> String.valueOf(entry.getValue()))); + } + @Override + public String getApiName() { + PersistenceNucleusContext context = emf.unwrap(PersistenceNucleusContext.class); + return context.getApiName(); + } + + @Override public int getInteractionsCount() { return interactionsCount.get(); } Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java 2021-12-04 16:17:47 UTC (rev 1000) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabaseMXBean.java 2021-12-04 16:56:23 UTC (rev 1001) @@ -9,4 +9,6 @@ int getInteractionsCount(); FactoryStatistics getStatistics(); + boolean isOpen(); + String getApiName(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-04 16:17:50
|
Revision: 1000 http://sourceforge.net/p/lobby/code/1000 Author: yuranet Date: 2021-12-04 16:17:47 +0000 (Sat, 04 Dec 2021) Log Message: ----------- rollback of mysql connector update in the hopes of fixing stuck transactions bug Modified Paths: -------------- trunk/src_server/META-INF/MANIFEST.MF Added Paths: ----------- trunk/lib/mysql-connector-java-8.0.23.jar Added: trunk/lib/mysql-connector-java-8.0.23.jar =================================================================== (Binary files differ) Index: trunk/lib/mysql-connector-java-8.0.23.jar =================================================================== --- trunk/lib/mysql-connector-java-8.0.23.jar 2021-12-02 13:26:48 UTC (rev 999) +++ trunk/lib/mysql-connector-java-8.0.23.jar 2021-12-04 16:17:47 UTC (rev 1000) Property changes on: trunk/lib/mysql-connector-java-8.0.23.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/src_server/META-INF/MANIFEST.MF =================================================================== --- trunk/src_server/META-INF/MANIFEST.MF 2021-12-02 13:26:48 UTC (rev 999) +++ trunk/src_server/META-INF/MANIFEST.MF 2021-12-04 16:17:47 UTC (rev 1000) @@ -1,5 +1,5 @@ Manifest-Version: 1.0 Created-By: Yura Mamyrin (yu...@yu...) Main-Class: net.yura.lobby.netty.Server -Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.26.jar lib/datanucleus-api-jpa-5.2.8.jar lib/datanucleus-core-5.2.8.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/datanucleus-rdbms-5.2.9.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar +Class-Path: lib/QuickServer.jar lib/UtilME.jar lib/javax.persistence-2.2.4.jar lib/mysql-connector-java-8.0.23.jar lib/datanucleus-api-jpa-5.2.8.jar lib/datanucleus-core-5.2.8.jar lib/javax.jdo-3.2.0-release.jar lib/asm-4.0.jar lib/datanucleus-rdbms-5.2.9.jar lib/Grasshopper.jar lib/gcm-server.jar lib/json_simple-1.1.jar lib/netty-all-4.1.Final.jar lib/google-api-client-1.24.1.jar lib/google-http-client-1.24.1.jar lib/google-http-client-gson-1.24.1.jar lib/google-oauth-client-1.24.1.jar lib/gson-2.1.jar lib/firebase-admin-6.13.0.jar lib/google-http-client-jackson2-1.33.0.jar lib/jackson-core-2.10.0.jar lib/slf4j-api-1.7.25.jar lib/google-auth-library-oauth2-http-0.17.1.jar lib/google-auth-library-credentials-0.18.0.jar lib/guava-26.0-android.jar lib/api-common-1.8.1.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-02 13:26:50
|
Revision: 999 http://sourceforge.net/p/lobby/code/999 Author: yuranet Date: 2021-12-02 13:26:48 +0000 (Thu, 02 Dec 2021) Log Message: ----------- better name for logging with game id Modified Paths: -------------- trunk/src_server/net/yura/lobby/server/LobbyLogger.java Modified: trunk/src_server/net/yura/lobby/server/LobbyLogger.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyLogger.java 2021-12-02 11:26:34 UTC (rev 998) +++ trunk/src_server/net/yura/lobby/server/LobbyLogger.java 2021-12-02 13:26:48 UTC (rev 999) @@ -21,36 +21,43 @@ public static final int NO_GAME_ID = -1; public static final Logger logger = Logger.getLogger(LobbyLogger.class.getName()); - public static void log(int gameId, Level level, String message) { - log(gameId, level, message, null); + public static void log(int correlationId, Level level, String message) { + log(correlationId, level, message, null); } - public static void log(int gameId, Level level, String message, Throwable th) { + public static void log(int correlationId, Level level, String message, Throwable th) { LobbyGameLogRecord record = new LobbyGameLogRecord(level, message); - record.setGameId(gameId); + record.setCorrelationId(correlationId); record.setThrown(th); logger.log(record); } public interface LobbyGameThread { + /** + * @return the correlation ID + */ int getGameId(); } public static class LobbyGameLogRecord extends LogRecord { - private int gameId = NO_GAME_ID; + private int correlationId = NO_GAME_ID; public LobbyGameLogRecord(Level level, String msg) { super(level, msg); } - public int getGameId() { - return gameId; + public int getCorrelationId() { + return correlationId; } - public void setGameId(int gameId) { - this.gameId = gameId; + public void setCorrelationId(int correlationId) { + this.correlationId = correlationId; } } + /** + * this handler creates a file for each logging correlation ID, so all logs from + * all systems related to that correlation ID will be found in one file. + */ public static class LobbyHandler extends Handler { // we need to limit this or we will get "Too many open files" exception @@ -82,17 +89,17 @@ public void publish(LogRecord record) { defaultHandler.publish(record); - int gameId = NO_GAME_ID; + int correlationId = NO_GAME_ID; Thread current = Thread.currentThread(); if (current instanceof LobbyGameThread) { - gameId = ((LobbyGameThread)current).getGameId(); + correlationId = ((LobbyGameThread)current).getGameId(); } else if (record instanceof LobbyGameLogRecord) { - gameId = ((LobbyGameLogRecord)record).getGameId(); + correlationId = ((LobbyGameLogRecord)record).getCorrelationId(); } - if (gameId >= 0) { - Handler gameHandler = getHandler(gameId); + if (correlationId >= 0) { + Handler gameHandler = getHandler(correlationId); if (gameHandler != null) { gameHandler.publish(record); gameHandler.flush(); @@ -100,11 +107,11 @@ } } - private Handler getHandler(int gameId) { - Handler gameHandler = gameHandlers.get(gameId); + private Handler getHandler(int correlationId) { + Handler gameHandler = gameHandlers.get(correlationId); if (gameHandler == null) { synchronized(this) { - gameHandler = gameHandlers.get(gameId); + gameHandler = gameHandlers.get(correlationId); if (gameHandler == null) { try { File games = new File(new File("./log/"), "games"); @@ -113,9 +120,9 @@ throw new IOException("can not mkdir " + games); } } - gameHandler = new FileHandler("log/games/"+gameId+".log", true); + gameHandler = new FileHandler("log/games/"+correlationId+".log", true); gameHandler.setFormatter(getFormatter()); - gameHandlers.put(gameId, gameHandler); + gameHandlers.put(correlationId, gameHandler); } catch (Exception ex) { ex.printStackTrace(); @@ -140,13 +147,13 @@ defaultHandler.close(); } - public void close(int gameId) { - Handler gameHandler = getHandler(gameId); + public void close(int correlationId) { + Handler gameHandler = getHandler(correlationId); if (gameHandler != null) { gameHandler.close(); - gameHandlers.remove(gameId); - if (!new File("log/games/"+gameId+".log").delete()) { - throw new IllegalStateException("not able to delete log file for " + gameId); + gameHandlers.remove(correlationId); + if (!new File("log/games/"+correlationId+".log").delete()) { + throw new IllegalStateException("not able to delete log file for " + correlationId); } } } @@ -241,7 +248,7 @@ throw new IllegalStateException(); } - public static void closeGameHandler(int gameId) { - getLobbyHandler().close(gameId); + public static void closeGameHandler(int correlationId) { + getLobbyHandler().close(correlationId); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-02 11:26:36
|
Revision: 998 http://sourceforge.net/p/lobby/code/998 Author: yuranet Date: 2021-12-02 11:26:34 +0000 (Thu, 02 Dec 2021) Log Message: ----------- date time in logs Modified Paths: -------------- trunk/src_server/net/yura/lobby/server/LobbyLogger.java Modified: trunk/src_server/net/yura/lobby/server/LobbyLogger.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyLogger.java 2021-12-01 18:42:21 UTC (rev 997) +++ trunk/src_server/net/yura/lobby/server/LobbyLogger.java 2021-12-02 11:26:34 UTC (rev 998) @@ -2,6 +2,9 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; import java.util.logging.FileHandler; @@ -10,8 +13,8 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; +import java.util.logging.SimpleFormatter; import net.yura.grasshopper.BugManager; -import net.yura.grasshopper.ReallySimpleFormatter; public class LobbyLogger { @@ -151,6 +154,17 @@ public static void setupLogging() throws IOException { + System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT %4$s: %5$s%6$s%n"); + + // on java 1.8 in SOME situations, sometimes this field is set too early and so takes the wrong value + // on later versions of java this is fixed and the field is no longer static + String systemFormat = System.getProperty("java.util.logging.SimpleFormatter.format"); + if (systemFormat != null) { + // test this is a valid format + String.format(systemFormat, new Date(), "", "", "", "", ""); + setFinalStatic(SimpleFormatter.class, "format", systemFormat); + } + // intercept System.out.and System.err to java.util.logging BugManager.intercept(); @@ -190,13 +204,33 @@ int fileSize = 1024*1024*100; // 100 MB Handler txtLog = new LobbyHandler(new FileHandler("log/LobbyServer.%g.log",fileSize,100,true)); //txtLog.setFormatter(new org.quickserver.util.logging.MicroFormatter()); - txtLog.setFormatter( new ReallySimpleFormatter() ); + txtLog.setFormatter(new SimpleFormatter()); logger.addHandler(txtLog); // log SQL //Logger.getLogger("DataNucleus.Datastore.Native").setLevel(Level.FINEST); } - + + private static void setFinalStatic(Class theClass, String name, Object value) { + try { + Field formatField = theClass.getDeclaredField(name); + + if (java.lang.reflect.Modifier.isStatic(formatField.getModifiers())) { + formatField.setAccessible(true); + + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(formatField, formatField.getModifiers() & ~Modifier.FINAL); + + String oldValue = (String)formatField.get(null); + if (!oldValue.equals(value)) { + formatField.set(null, value); + } + } + } + catch (Exception ex) { } + } + public static LobbyHandler getLobbyHandler() { Logger logger = Logger.getLogger(""); for (Handler handler : logger.getHandlers()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-01 18:42:23
|
Revision: 997 http://sourceforge.net/p/lobby/code/997 Author: yuranet Date: 2021-12-01 18:42:21 +0000 (Wed, 01 Dec 2021) Log Message: ----------- enable jmx in datanucleus Modified Paths: -------------- trunk/src_server/META-INF/persistence.xml Modified: trunk/src_server/META-INF/persistence.xml =================================================================== --- trunk/src_server/META-INF/persistence.xml 2021-12-01 16:09:51 UTC (rev 996) +++ trunk/src_server/META-INF/persistence.xml 2021-12-01 18:42:21 UTC (rev 997) @@ -29,7 +29,7 @@ <property name="datanucleus.cache.level2.type" value="none"/> <property name="datanucleus.enableStatistics" value="true"/> - <!--<property name="datanucleus.jmxType" value="default"/>--> + <property name="datanucleus.jmxType" value="default"/> </properties> </persistence-unit> </persistence> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-12-01 16:09:53
|
Revision: 996 http://sourceforge.net/p/lobby/code/996 Author: yuranet Date: 2021-12-01 16:09:51 +0000 (Wed, 01 Dec 2021) Log Message: ----------- autoReconnect set to true for mysql Modified Paths: -------------- trunk/src_server/META-INF/persistence.xml Modified: trunk/src_server/META-INF/persistence.xml =================================================================== --- trunk/src_server/META-INF/persistence.xml 2021-11-30 14:08:27 UTC (rev 995) +++ trunk/src_server/META-INF/persistence.xml 2021-12-01 16:09:51 UTC (rev 996) @@ -13,7 +13,7 @@ <properties> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> - <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/lobby?useUnicode=yes&characterEncoding=UTF-8"/> + <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/lobby?autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8"/> <property name="javax.persistence.jdbc.user" value="root" /> <property name="javax.persistence.jdbc.password" value="password"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-30 14:08:29
|
Revision: 995 http://sourceforge.net/p/lobby/code/995 Author: yuranet Date: 2021-11-30 14:08:27 +0000 (Tue, 30 Nov 2021) Log Message: ----------- info about DB backup Modified Paths: -------------- trunk/server_setup.txt Modified: trunk/server_setup.txt =================================================================== --- trunk/server_setup.txt 2021-11-30 13:50:23 UTC (rev 994) +++ trunk/server_setup.txt 2021-11-30 14:08:27 UTC (rev 995) @@ -57,6 +57,14 @@ or if moving DB from another server: +mysqldump -u root -p lobby > lobby_after_users_change.sql + +CREATE DATABASE lobby; + +mysql -p -u root lobby < lobby_after_users_change.sql + + + mysqldump -u root -p --all-databases > all_databases.sql mysql -p -u root < all_databases.sql This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-30 13:50:26
|
Revision: 994 http://sourceforge.net/p/lobby/code/994 Author: yuranet Date: 2021-11-30 13:50:23 +0000 (Tue, 30 Nov 2021) Log Message: ----------- aparently it has always been gamedata Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/GameRoom.java trunk/src_server/net/yura/lobby/server/GameLobby.java Modified: trunk/src_server/net/yura/lobby/database/GameRoom.java =================================================================== --- trunk/src_server/net/yura/lobby/database/GameRoom.java 2021-11-30 12:47:16 UTC (rev 993) +++ trunk/src_server/net/yura/lobby/database/GameRoom.java 2021-11-30 13:50:23 UTC (rev 994) @@ -148,7 +148,7 @@ // this is a waste of memory to load this every time we get a list of games //@javax.persistence.Basic(fetch = FetchType.EAGER) - @Column(name="game_data", nullable=true) + @Column(name="gamedata", nullable=true) public byte[] getGameData() { return gameData; } Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-11-30 12:47:16 UTC (rev 993) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-11-30 13:50:23 UTC (rev 994) @@ -176,7 +176,7 @@ long load = System.currentTimeMillis(); LobbyLogger.log(gameId, Level.INFO, count+"/"+gameIds.size()+" loaded "+gameId+" took GET_GAME:"+(db1-start)+" GET_DATA:"+(db2-db1)+ - (data == null ? " no data" : " DATA:"+data.length+" LOAD:"+(load-db2))); + (data == null ? " no data" : " DATA:"+data.length+" LOAD:"+(load-db2)) + " - " + game.getName()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-30 12:47:19
|
Revision: 993 http://sourceforge.net/p/lobby/code/993 Author: yuranet Date: 2021-11-30 12:47:16 +0000 (Tue, 30 Nov 2021) Log Message: ----------- datanucleus 3 to datanucleus 5 move Modified Paths: -------------- trunk/build.xml trunk/nbproject/build-impl.xml trunk/nbproject/genfiles.properties trunk/nbproject/project.properties trunk/resources/runLobbyServer.cmd trunk/resources/runLobbyServer.sh trunk/src_server/META-INF/MANIFEST.MF trunk/src_server/META-INF/persistence.xml trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java trunk/test/net/yura/lobby/database/impl/DatabaseTest.java Added Paths: ----------- trunk/lib/datanucleus-api-jpa-5.2.8.jar trunk/lib/datanucleus-core-5.2.8.jar trunk/lib/datanucleus-rdbms-5.2.9.jar trunk/lib/javax.annotation-api-1.3.2.jar trunk/lib/javax.jdo-3.2.0-release.jar trunk/lib/javax.persistence-2.2.4.jar trunk/lib/mysql-connector-java-8.0.26.jar Removed Paths: ------------- trunk/lib/datanucleus-api-jdo-3.1.3.jar trunk/lib/datanucleus-api-jpa-3.1.3.jar trunk/lib/datanucleus-core-3.1.3.jar trunk/lib/datanucleus-enhancer.jar trunk/lib/datanucleus-rdbms-3.1.3.jar trunk/lib/javax.persistence-2.0.jar trunk/lib/jdo-api-3.1.jar trunk/lib/mysql-connector-java-8.0.23.jar Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/build.xml 2021-11-30 12:47:16 UTC (rev 993) @@ -100,9 +100,8 @@ <mkdir dir="${dir.build.server.classes}"/> -<!-- TARGET NEEDS TO BE 1.6!!! 1.7 or 1.8 causes ERROR: -Found Meta-Data for class X but this class is not enhanced!! -Please enhance the class before running DataNucleus. +<!-- TARGET NEEDS TO BE 1.8 for DataNucleus to work +if it is newer the DataNucleus enhancer will fail firebase-admin from: https://repo1.maven.org/maven2/com/google/firebase/firebase-admin/6.8.1/firebase-admin-6.8.1.jar --> @@ -111,9 +110,9 @@ <javac debug="on" srcdir="${dir.source}:src_server" destdir="${dir.build.server.classes}" - source="1.6" target="1.6" + source="1.8" target="1.8" - classpath="${basedir}/lib/UtilME.jar:${basedir}/lib/QuickServer.jar:${basedir}/lib/javax.persistence-2.0.jar:${basedir}/lib/datanucleus-core-3.1.3.jar:${basedir}/lib/datanucleus-api-jpa-3.1.3.jar:${basedir}/lib/Grasshopper.jar:${basedir}/lib/gcm-server.jar:${basedir}/lib/netty-all-4.1.Final.jar:${basedir}/lib/google-api-client-1.24.1.jar:${basedir}/lib/google-http-client-1.24.1.jar:${basedir}/lib/google-http-client-gson-1.24.1.jar:${basedir}/lib/google-oauth-client-1.24.1.jar:${basedir}/lib/google-auth-library-oauth2-http-0.17.1.jar:${basedir}/lib/google-auth-library-credentials-0.18.0.jar:${basedir}/lib/firebase-admin-6.13.0.jar:${basedir}/lib/guava-26.0-android.jar" + classpath="${basedir}/lib/UtilME.jar:${basedir}/lib/QuickServer.jar:${basedir}/lib/javax.persistence-2.2.4.jar:${basedir}/lib/datanucleus-core-5.2.8.jar:${basedir}/lib/datanucleus-api-jpa-5.2.8.jar:${basedir}/lib/Grasshopper.jar:${basedir}/lib/gcm-server.jar:${basedir}/lib/netty-all-4.1.Final.jar:${basedir}/lib/google-api-client-1.24.1.jar:${basedir}/lib/google-http-client-1.24.1.jar:${basedir}/lib/google-http-client-gson-1.24.1.jar:${basedir}/lib/google-oauth-client-1.24.1.jar:${basedir}/lib/google-auth-library-oauth2-http-0.17.1.jar:${basedir}/lib/google-auth-library-credentials-0.18.0.jar:${basedir}/lib/firebase-admin-6.13.0.jar:${basedir}/lib/guava-26.0-android.jar" /> Deleted: trunk/lib/datanucleus-api-jdo-3.1.3.jar =================================================================== (Binary files differ) Deleted: trunk/lib/datanucleus-api-jpa-3.1.3.jar =================================================================== (Binary files differ) Added: trunk/lib/datanucleus-api-jpa-5.2.8.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-api-jpa-5.2.8.jar =================================================================== --- trunk/lib/datanucleus-api-jpa-5.2.8.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/datanucleus-api-jpa-5.2.8.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/datanucleus-api-jpa-5.2.8.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Deleted: trunk/lib/datanucleus-core-3.1.3.jar =================================================================== (Binary files differ) Added: trunk/lib/datanucleus-core-5.2.8.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-core-5.2.8.jar =================================================================== --- trunk/lib/datanucleus-core-5.2.8.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/datanucleus-core-5.2.8.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/datanucleus-core-5.2.8.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Deleted: trunk/lib/datanucleus-enhancer.jar =================================================================== (Binary files differ) Deleted: trunk/lib/datanucleus-rdbms-3.1.3.jar =================================================================== (Binary files differ) Added: trunk/lib/datanucleus-rdbms-5.2.9.jar =================================================================== (Binary files differ) Index: trunk/lib/datanucleus-rdbms-5.2.9.jar =================================================================== --- trunk/lib/datanucleus-rdbms-5.2.9.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/datanucleus-rdbms-5.2.9.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/datanucleus-rdbms-5.2.9.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/javax.annotation-api-1.3.2.jar =================================================================== (Binary files differ) Index: trunk/lib/javax.annotation-api-1.3.2.jar =================================================================== --- trunk/lib/javax.annotation-api-1.3.2.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/javax.annotation-api-1.3.2.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/javax.annotation-api-1.3.2.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/lib/javax.jdo-3.2.0-release.jar =================================================================== (Binary files differ) Index: trunk/lib/javax.jdo-3.2.0-release.jar =================================================================== --- trunk/lib/javax.jdo-3.2.0-release.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/javax.jdo-3.2.0-release.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/javax.jdo-3.2.0-release.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Deleted: trunk/lib/javax.persistence-2.0.jar =================================================================== (Binary files differ) Added: trunk/lib/javax.persistence-2.2.4.jar =================================================================== (Binary files differ) Index: trunk/lib/javax.persistence-2.2.4.jar =================================================================== --- trunk/lib/javax.persistence-2.2.4.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/javax.persistence-2.2.4.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/javax.persistence-2.2.4.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Deleted: trunk/lib/jdo-api-3.1.jar =================================================================== (Binary files differ) Deleted: trunk/lib/mysql-connector-java-8.0.23.jar =================================================================== (Binary files differ) Added: trunk/lib/mysql-connector-java-8.0.26.jar =================================================================== (Binary files differ) Index: trunk/lib/mysql-connector-java-8.0.26.jar =================================================================== --- trunk/lib/mysql-connector-java-8.0.26.jar 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/lib/mysql-connector-java-8.0.26.jar 2021-11-30 12:47:16 UTC (rev 993) Property changes on: trunk/lib/mysql-connector-java-8.0.26.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/nbproject/build-impl.xml =================================================================== --- trunk/nbproject/build-impl.xml 2021-11-30 10:47:58 UTC (rev 992) +++ trunk/nbproject/build-impl.xml 2021-11-30 12:47:16 UTC (rev 993) @@ -19,7 +19,7 @@ - cleanup --> -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Lobby-impl"> +<project xmlns:if="ant:if" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" xmlns:unless="ant:unless" basedir=".." default="default" name="Lobby-impl"> <fail message="Please build using Ant 1.8.0 or higher."> <condition> <not> @@ -46,14 +46,79 @@ <property file="${user.properties.file}"/> <!-- The two properties below are usually overridden --> <!-- by the active platform. Just a fallback. --> - <property name="default.javac.source" value="1.6"/> - <property name="default.javac.target" value="1.6"/> + <property name="default.javac.source" value="1.8"/> + <property name="default.javac.target" value="1.8"/> </target> <target depends="-pre-init,-init-private,-init-user" name="-init-project"> <property file="nbproject/configs/${config}.properties"/> <property file="nbproject/project.properties"/> </target> - <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init"> + <target name="-init-modules-supported"> + <condition property="modules.supported.internal" value="true"> + <not> + <matches pattern="1\.[0-8](\..*)?" string="${javac.source}"/> + </not> + </condition> + </target> + <target depends="-init-modules-supported" if="modules.supported.internal" name="-init-macrodef-modulename"> + <macrodef name="modulename" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute name="property"/> + <attribute name="sourcepath"/> + <sequential> + <loadresource property="@{property}" quiet="true"> + <javaresource classpath="@{sourcepath}" name="module-info.java" parentFirst="false"/> + <filterchain> + <stripjavacomments/> + <linecontainsregexp> + <regexp pattern="module .* \{"/> + </linecontainsregexp> + <tokenfilter> + <linetokenizer/> + <replaceregex flags="s" pattern="(\s*module\s+)(\S*)(\s*\{.*)" replace="\2"/> + </tokenfilter> + <striplinebreaks/> + </filterchain> + </loadresource> + </sequential> + </macrodef> + </target> + <target depends="-init-modules-supported,-init-macrodef-modulename" if="modules.supported.internal" name="-init-source-module-properties"> + <fail message="Java 9 support requires Ant 1.10.0 or higher."> + <condition> + <not> + <antversion atleast="1.10.0"/> + </not> + </condition> + </fail> + <j2seproject3:modulename property="module.name" sourcepath="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}"/> + <condition property="named.module.internal"> + <and> + <isset property="module.name"/> + <length length="0" string="${module.name}" when="greater"/> + </and> + </condition> + <condition property="unnamed.module.internal"> + <not> + <isset property="named.module.internal"/> + </not> + </condition> + <property name="javac.modulepath" value=""/> + <property name="run.modulepath" value="${javac.modulepath}"/> + <property name="module.build.classes.dir" value="${build.classes.dir}"/> + <property name="debug.modulepath" value="${run.modulepath}"/> + <property name="javac.upgrademodulepath" value=""/> + <property name="run.upgrademodulepath" value="${javac.upgrademodulepath}"/> + <condition else="" property="javac.systemmodulepath.cmd.line.arg" value="--system '${javac.systemmodulepath}'"> + <and> + <isset property="javac.systemmodulepath"/> + <length length="0" string="${javac.systemmodulepath}" when="greater"/> + </and> + </condition> + <property name="dist.jlink.dir" value="${dist.dir}/jlink"/> + <property name="dist.jlink.output" value="${dist.jlink.dir}/${application.title}"/> + <property name="module.name" value=""/> + </target> + <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property,-init-modules-supported" name="-do-init"> <property name="platform.java" value="${java.home}/bin/java"/> <available file="${manifest.file}" property="manifest.available"/> <condition property="splashscreen.available"> @@ -76,7 +141,9 @@ <and> <isset property="javac.profile"/> <length length="0" string="${javac.profile}" when="greater"/> - <matches pattern="((1\.[89])|9)(\..*)?" string="${javac.source}"/> + <not> + <matches pattern="1\.[0-7](\..*)?" string="${javac.source}"/> + </not> </and> </condition> <condition property="do.archive"> @@ -87,15 +154,6 @@ <istrue value="${not.archive.disabled}"/> </or> </condition> - <condition property="do.mkdist"> - <and> - <isset property="do.archive"/> - <isset property="libs.CopyLibs.classpath"/> - <not> - <istrue value="${mkdist.disabled}"/> - </not> - </and> - </condition> <condition property="do.archive+manifest.available"> <and> <isset property="manifest.available"/> @@ -256,16 +314,85 @@ </sequential> </macrodef> </target> - <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors"> + <target depends="-init-ap-cmdline-properties,-init-source-module-properties" if="modules.supported.internal" name="-init-macrodef-javac-with-module"> <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}" name="srcdir"/> <attribute default="${build.classes.dir}" name="destdir"/> <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.modulepath}" name="modulepath"/> + <attribute default="${javac.upgrademodulepath}" name="upgrademodulepath"/> <attribute default="${javac.processorpath}" name="processorpath"/> + <attribute default="${javac.processormodulepath}" name="processormodulepath"/> <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> <attribute default="${javac.debug}" name="debug"/> + <attribute default="${empty.dir}" name="sourcepath" unless:set="named.module.internal"/> + <attribute default="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}" if:set="named.module.internal" name="sourcepath"/> + <attribute default="${empty.dir}" name="gensrcdir"/> + <element name="customize" optional="true"/> + <sequential> + <condition property="warn.excludes.internal"> + <and> + <isset property="named.module.internal"/> + <length length="0" string="@{excludes}" trim="true" when="greater"/> + </and> + </condition> + <echo if:set="warn.excludes.internal" level="warning" message="The javac excludes are not supported in the JDK 9 Named Module."/> + <property location="${build.dir}/empty" name="empty.dir"/> + <mkdir dir="${empty.dir}"/> + <mkdir dir="@{apgeneratedsrcdir}"/> + <condition property="processormodulepath.set"> + <resourcecount count="0" when="greater"> + <path> + <pathelement path="@{processormodulepath}"/> + </path> + </resourcecount> + </condition> + <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}"> + <src> + <dirset dir="@{gensrcdir}" erroronmissingdir="false"> + <include name="*"/> + </dirset> + </src> + <classpath> + <path path="@{classpath}"/> + </classpath> + <modulepath> + <path path="@{modulepath}"/> + </modulepath> + <upgrademodulepath> + <path path="@{upgrademodulepath}"/> + </upgrademodulepath> + <compilerarg line="${javac.systemmodulepath.cmd.line.arg}"/> + <compilerarg line="${javac.profile.cmd.line.arg}"/> + <compilerarg line="${javac.compilerargs}"/> + <compilerarg if:set="processormodulepath.set" value="--processor-module-path"/> + <compilerarg if:set="processormodulepath.set" path="@{processormodulepath}"/> + <compilerarg unless:set="processormodulepath.set" value="-processorpath"/> + <compilerarg path="@{processorpath}:${empty.dir}" unless:set="processormodulepath.set"/> + <compilerarg line="${ap.processors.internal}"/> + <compilerarg line="${annotation.processing.processor.options}"/> + <compilerarg value="-s"/> + <compilerarg path="@{apgeneratedsrcdir}"/> + <compilerarg line="${ap.proc.none.internal}"/> + <customize/> + </javac> + </sequential> + </macrodef> + </target> + <target depends="-init-ap-cmdline-properties,-init-source-module-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors" unless="modules.supported.internal"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}" name="srcdir"/> + <attribute default="${build.classes.dir}" name="destdir"/> + <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.modulepath}" name="modulepath"/> + <attribute default="${javac.upgrademodulepath}" name="upgrademodulepath"/> + <attribute default="${javac.processorpath}" name="processorpath"/> + <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="${javac.debug}" name="debug"/> <attribute default="${empty.dir}" name="sourcepath"/> <attribute default="${empty.dir}" name="gensrcdir"/> <element name="customize" optional="true"/> @@ -297,11 +424,13 @@ </sequential> </macrodef> </target> - <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal"> + <target depends="-init-ap-cmdline-properties,-init-source-module-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal"> <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}" name="srcdir"/> <attribute default="${build.classes.dir}" name="destdir"/> <attribute default="${javac.classpath}" name="classpath"/> + <attribute default="${javac.modulepath}" name="modulepath"/> + <attribute default="${javac.upgrademodulepath}" name="upgrademodulepath"/> <attribute default="${javac.processorpath}" name="processorpath"/> <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/> <attribute default="${includes}" name="includes"/> @@ -330,7 +459,7 @@ </sequential> </macrodef> </target> - <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac"> + <target depends="-init-macrodef-javac-with-module,-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac"> <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}" name="srcdir"/> <attribute default="${build.classes.dir}" name="destdir"/> @@ -385,62 +514,102 @@ <property name="test.binarytestincludes" value=""/> <property name="test.binaryexcludes" value=""/> </target> - <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}"> - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <target depends="-init-modules-supported" if="modules.supported.internal" name="-init-macrodef-junit-prototype-with-module"> + <macrodef name="junit-prototype" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> - <attribute default="**" name="testincludes"/> - <attribute default="" name="testmethods"/> - <element name="customize" optional="true"/> + <element name="customizePrototype" optional="true"/> <sequential> <property name="junit.forkmode" value="perTest"/> <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> - <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/> <syspropertyset> <propertyref prefix="test-sys-prop."/> <mapper from="test-sys-prop.*" to="*" type="glob"/> </syspropertyset> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <modulepath> + <path path="${run.test.modulepath}"/> + </modulepath> <formatter type="brief" usefile="false"/> <formatter type="xml"/> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> <jvmarg value="-ea"/> - <customize/> + <jvmarg line="${run.test.jvmargs}"/> + <customizePrototype/> </junit> </sequential> </macrodef> </target> - <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}"> - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <target depends="-init-modules-supported" name="-init-macrodef-junit-prototype-without-module" unless="modules.supported.internal"> + <macrodef name="junit-prototype" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> - <attribute default="**" name="testincludes"/> - <attribute default="" name="testmethods"/> - <element name="customize" optional="true"/> + <element name="customizePrototype" optional="true"/> <sequential> <property name="junit.forkmode" value="perTest"/> <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> - <batchtest todir="${build.test.results.dir}"> - <fileset dir="${test.src_blackjack.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> - <filename name="@{testincludes}"/> - </fileset> - <fileset dir="${test.test.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> - <filename name="@{testincludes}"/> - </fileset> - <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}"> - <filename name="${test.binarytestincludes}"/> - </fileset> - </batchtest> <syspropertyset> <propertyref prefix="test-sys-prop."/> <mapper from="test-sys-prop.*" to="*" type="glob"/> </syspropertyset> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> <formatter type="brief" usefile="false"/> <formatter type="xml"/> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> <jvmarg value="-ea"/> - <customize/> + <customizePrototype/> </junit> </sequential> </macrodef> </target> + <target depends="-init-test-properties,-init-macrodef-junit-prototype-with-module,-init-macrodef-junit-prototype-without-module" if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <j2seproject3:junit-prototype> + <customizePrototype> + <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/> + <customize/> + </customizePrototype> + </j2seproject3:junit-prototype> + </sequential> + </macrodef> + </target> + <target depends="-init-test-properties,-init-macrodef-junit-prototype-with-module,-init-macrodef-junit-prototype-without-module" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${includes}" name="includes"/> + <attribute default="${excludes}" name="excludes"/> + <attribute default="**" name="testincludes"/> + <attribute default="" name="testmethods"/> + <element name="customize" optional="true"/> + <sequential> + <j2seproject3:junit-prototype> + <customizePrototype> + <batchtest todir="${build.test.results.dir}"> + <fileset dir="${test.src_blackjack.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> + <filename name="@{testincludes}"/> + </fileset> + <fileset dir="${test.test.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> + <filename name="@{testincludes}"/> + </fileset> + <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}"> + <filename name="${test.binarytestincludes}"/> + </fileset> + </batchtest> + <customize/> + </customizePrototype> + </j2seproject3:junit-prototype> + </sequential> + </macrodef> + </target> <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/> <target if="${testng.available}" name="-init-macrodef-testng"> <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3"> @@ -468,6 +637,10 @@ <propertyref prefix="test-sys-prop."/> <mapper from="test-sys-prop.*" to="*" type="glob"/> </propertyset> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> <customize/> </testng> </sequential> @@ -522,10 +695,6 @@ <sequential> <j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> <customize> - <classpath> - <path path="${run.test.classpath}"/> - </classpath> - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> <jvmarg line="${run.jvmargs}"/> <jvmarg line="${run.jvmargs.ide}"/> </customize> @@ -533,77 +702,20 @@ </sequential> </macrodef> </target> - <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}"> - <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> - <attribute default="${includes}" name="includes"/> - <attribute default="${excludes}" name="excludes"/> - <attribute default="**" name="testincludes"/> - <attribute default="" name="testmethods"/> - <element name="customize" optional="true"/> - <sequential> - <property name="junit.forkmode" value="perTest"/> - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> - <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/> - <syspropertyset> - <propertyref prefix="test-sys-prop."/> - <mapper from="test-sys-prop.*" to="*" type="glob"/> - </syspropertyset> - <formatter type="brief" usefile="false"/> - <formatter type="xml"/> - <jvmarg value="-ea"/> - <jvmarg line="${debug-args-line}"/> - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> - <customize/> - </junit> - </sequential> - </macrodef> - </target> - <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch"> - <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3"> - <attribute default="${includes}" name="includes"/> - <attribute default="${excludes}" name="excludes"/> - <attribute default="**" name="testincludes"/> - <attribute default="" name="testmethods"/> - <element name="customize" optional="true"/> - <sequential> - <property name="junit.forkmode" value="perTest"/> - <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}"> - <batchtest todir="${build.test.results.dir}"> - <fileset dir="${test.src_blackjack.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> - <filename name="@{testincludes}"/> - </fileset> - <fileset dir="${test.test.dir}" excludes="@{excludes},${excludes}" includes="@{includes}"> - <filename name="@{testincludes}"/> - </fileset> - <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}"> - <filename name="${test.binarytestincludes}"/> - </fileset> - </batchtest> - <syspropertyset> - <propertyref prefix="test-sys-prop."/> - <mapper from="test-sys-prop.*" to="*" type="glob"/> - </syspropertyset> - <formatter type="brief" usefile="false"/> - <formatter type="xml"/> - <jvmarg value="-ea"/> - <jvmarg line="${debug-args-line}"/> - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> - <customize/> - </junit> - </sequential> - </macrodef> - </target> - <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl"> + <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-debug-impl"> <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> <attribute default="**" name="testincludes"/> <attribute default="" name="testmethods"/> - <element implicit="true" name="customize" optional="true"/> + <element name="customizeDebuggee" optional="true"/> <sequential> - <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> - <customize/> - </j2seproject3:junit-debug> + <j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> + <customize> + <jvmarg value="-agentlib:jdwp=transport=${debug-transport},address=${jpda.address}"/> + <customizeDebuggee/> + </customize> + </j2seproject3:junit> </sequential> </macrodef> </target> @@ -622,7 +734,7 @@ <delete dir="${build.test.results.dir}" quiet="true"/> <mkdir dir="${build.test.results.dir}"/> <j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}"> - <customize> + <customizeDebuggee> <customize2/> <jvmarg value="-ea"/> <arg line="${testng.debug.mode}"/> @@ -629,7 +741,7 @@ <arg line="-d ${build.test.results.dir}"/> <arg line="-listener org.testng.reporters.VerboseReporter"/> <arg line="${testng.cmd.args}"/> - </customize> + </customizeDebuggee> </j2seproject3:debug> </sequential> </macrodef> @@ -656,14 +768,10 @@ <attribute default="" name="testMethod"/> <sequential> <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}"> - <customize> - <classpath> - <path path="${run.test.classpath}"/> - </classpath> - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> + <customizeDebuggee> <jvmarg line="${run.jvmargs}"/> <jvmarg line="${run.jvmargs.ide}"/> - </customize> + </customizeDebuggee> </j2seproject3:test-debug-impl> </sequential> </macrodef> @@ -743,10 +851,14 @@ <target depends="-init-debug-args" name="-init-macrodef-nbjpda"> <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> <attribute default="${main.class}" name="name"/> + <attribute default="${debug.modulepath}" name="modulepath"/> <attribute default="${debug.classpath}" name="classpath"/> <attribute default="" name="stopclassname"/> <sequential> <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}"> + <modulepath> + <path path="@{modulepath}"/> + </modulepath> <classpath> <path path="@{classpath}"/> </classpath> @@ -765,18 +877,6 @@ </macrodef> </target> <target name="-init-debug-args"> - <property name="version-output" value="java version "${ant.java.version}"/> - <condition property="have-jdk-older-than-1.4"> - <or> - <contains string="${version-output}" substring="java version "1.0"/> - <contains string="${version-output}" substring="java version "1.1"/> - <contains string="${version-output}" substring="java version "1.2"/> - <contains string="${version-output}" substring="java version "1.3"/> - </or> - </condition> - <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none"> - <istrue value="${have-jdk-older-than-1.4}"/> - </condition> <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem"> <os family="windows"/> </condition> @@ -786,21 +886,79 @@ </target> <target depends="-init-debug-args" name="-init-macrodef-debug"> <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3"> + <attribute default="${module.name}" name="modulename"/> <attribute default="${main.class}" name="classname"/> + <attribute default="${debug.modulepath}" name="modulepath"/> <attribute default="${debug.classpath}" name="classpath"/> + <element name="customizeDebuggee" optional="true"/> + <sequential> + <j2seproject1:java classname="@{classname}" classpath="@{classpath}" modulename="@{modulename}" modulepath="@{modulepath}"> + <customize> + <jvmarg value="-agentlib:jdwp=transport=${debug-transport},address=${jpda.address}"/> + <customizeDebuggee/> + </customize> + </j2seproject1:java> + </sequential> + </macrodef> + </target> + <target depends="-init-source-module-properties" if="named.module.internal" name="-init-macrodef-java-with-module"> + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="${module.name}" name="modulename"/> + <attribute default="${main.class}" name="classname"/> + <attribute default="${run.modulepath}" name="modulepath"/> + <attribute default="${run.upgrademodulepath}" name="upgrademodulepath"/> + <attribute default="${run.classpath}" name="classpath"/> + <attribute default="jvm" name="jvm"/> <element name="customize" optional="true"/> <sequential> - <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true"> - <jvmarg line="${endorsed.classpath.cmd.line.arg}"/> - <jvmarg line="${debug-args-line}"/> - <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/> + <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true" module="@{modulename}"> + <classpath> + <path path="@{classpath}"/> + </classpath> + <modulepath> + <pathelement path="@{modulepath}"/> + <pathelement location="${module.build.classes.dir}"/> + </modulepath> + <upgrademodulepath> + <path path="@{upgrademodulepath}"/> + </upgrademodulepath> <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/> <jvmarg line="${run.jvmargs}"/> <jvmarg line="${run.jvmargs.ide}"/> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper from="run-sys-prop.*" to="*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target depends="-init-source-module-properties" if="unnamed.module.internal" name="-init-macrodef-java-with-unnamed-module"> + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="" name="modulename"/> + <attribute default="${main.class}" name="classname"/> + <attribute default="${run.modulepath}" name="modulepath"/> + <attribute default="${run.upgrademodulepath}" name="upgrademodulepath"/> + <attribute default="${run.classpath}" name="classpath"/> + <attribute default="jvm" name="jvm"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true"> <classpath> <path path="@{classpath}"/> </classpath> + <modulepath> + <path path="@{modulepath}"/> + </modulepath> + <upgrademodulepath> + <path path="@{upgrademodulepath}"/> + </upgrademodulepath> + <jvmarg value="-Dfile.encoding=${runtime.encoding}"/> + <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/> + <jvmarg line="${run.jvmargs}"/> + <jvmarg line="${run.jvmargs.ide}"/> <syspropertyset> <propertyref prefix="run-sys-prop."/> <mapper from="run-sys-prop.*" to="*" type="glob"/> @@ -810,9 +968,11 @@ </sequential> </macrodef> </target> - <target name="-init-macrodef-java"> + <target depends="-init-source-module-properties" name="-init-macrodef-java-without-module" unless="modules.supported.internal"> <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute default="" name="modulename"/> <attribute default="${main.class}" name="classname"/> + <attribute default="" name="modulepath"/> <attribute default="${run.classpath}" name="classpath"/> <attribute default="jvm" name="jvm"/> <element name="customize" optional="true"/> @@ -835,6 +995,7 @@ </sequential> </macrodef> </target> + <target depends="-init-macrodef-java-with-module, -init-macrodef-java-with-unnamed-module, -init-macrodef-java-without-module" name="-init-macrodef-java"/> <target name="-init-macrodef-copylibs"> <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3"> <attribute default="${manifest.file}" name="manifest"/> @@ -924,7 +1085,9 @@ <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/> </target> <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build"> - <antcall target="clean"/> + <antcall target="clean"> + <param name="no.dependencies" value="true"/> + </antcall> </target> <target depends="init,deps-jar" name="-pre-pre-compile"> <mkdir dir="${build.classes.dir}"/> @@ -967,7 +1130,7 @@ <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single"> <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> <j2seproject3:force-recompile/> - <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}"/> + <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}, module-info.java" sourcepath="${src.src.dir}:${src.src_client.dir}:${src.src_server.dir}"/> </target> <target name="-post-compile-single"> <!-- Empty placeholder for easier customization. --> @@ -987,6 +1150,25 @@ <!-- Empty placeholder for easier customization. --> <!-- You can override this target in the ../build.xml file. --> </target> + <target depends="init,compile" name="-check-module-main-class"> + <pathconvert property="main.class.file"> + <string value="${main.class}"/> + <unpackagemapper from="*" to="*.class"/> + </pathconvert> + <condition property="do.module.main.class"> + <and> + <isset property="main.class.available"/> + <available file="${build.classes.dir}/module-info.class"/> + <available file="${build.classes.dir}/${main.class.file}"/> + <isset property="libs.CopyLibs.classpath"/> + <available classname="org.netbeans.modules.java.j2seproject.moduletask.ModuleMainClass" classpath="${libs.CopyLibs.classpath}"/> + </and> + </condition> + </target> + <target depends="-check-module-main-class" if="do.module.main.class" name="-set-module-main-class"> + <taskdef classname="org.netbeans.modules.java.j2seproject.moduletask.ModuleMainClass" classpath="${libs.CopyLibs.classpath}" name="modulemainclass"/> + <modulemainclass failonerror="false" mainclass="${main.class}" moduleinfo="${build.classes.dir}/module-info.class"/> + </target> <target depends="init" if="do.archive" name="-do-jar-create-manifest" unless="manifest.available"> <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/> <touch file="${tmp.manifest.file}" verbose="false"/> @@ -1013,21 +1195,61 @@ <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/> </manifest> </target> - <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.mkdist" name="-do-jar-copylibs"> + <target depends="init,compile" name="-check-do-mkdist"> + <condition property="do.mkdist"> + <and> + <isset property="do.archive"/> + <isset property="libs.CopyLibs.classpath"/> + <not> + <istrue value="${mkdist.disabled}"/> + </not> + <not> + <available file="${build.classes.dir}/module-info.class"/> + </not> + </and> + </condition> + </target> + <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-check-do-mkdist" if="do.mkdist" name="-do-jar-copylibs"> <j2seproject3:copylibs manifest="${tmp.manifest.file}"/> <echo level="info">To run this application from the command line without Ant, try:</echo> <property location="${dist.jar}" name="dist.jar.resolved"/> <echo level="info">java -jar "${dist.jar.resolved}"</echo> </target> - <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.archive" name="-do-jar-jar" unless="do.mkdist"> + <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-check-do-mkdist" if="do.archive" name="-do-jar-jar" unless="do.mkdist"> <j2seproject1:jar manifest="${tmp.manifest.file}"/> <property location="${build.classes.dir}" name="build.classes.dir.resolved"/> <property location="${dist.jar}" name="dist.jar.resolved"/> + <condition else="${dist.jar.resolved}" property="jar.usage.message.class.path.replacement" value=""> + <isset property="named.module.internal"/> + </condition> <pathconvert property="run.classpath.with.dist.jar"> <path path="${run.classpath}"/> + <map from="${build.classes.dir.resolved}" to="${jar.usage.message.class.path.replacement}"/> + </pathconvert> + <pathconvert property="run.modulepath.with.dist.jar"> + <path location="${dist.jar.resolved}"/> + <path path="${run.modulepath}"/> <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/> </pathconvert> - <condition else="" property="jar.usage.message" value="To run this application from the command line without Ant, try:${line.separator}${platform.java} -cp ${run.classpath.with.dist.jar} ${main.class}"> + <condition else="${run.modulepath}" property="jar.usage.message.run.modulepath.with.dist.jar" value="${run.modulepath.with.dist.jar}"> + <isset property="named.module.internal"/> + </condition> + <condition else="" property="jar.usage.message.module.path" value=" -p ${jar.usage.message.run.modulepath.with.dist.jar}"> + <and> + <isset property="modules.supported.internal"/> + <length length="0" string="${jar.usage.message.run.modulepath.with.dist.jar}" when="greater"/> + </and> + </condition> + <condition else="" property="jar.usage.message.class.path" value=" -cp ${run.classpath.with.dist.jar}"> + <length length="0" string="${run.classpath.with.dist.jar}" when="greater"/> + </condition> + <condition else="/${main.class}" property="jar.usage.message.main.class.class.selector" value=""> + <isset property="do.module.main.class"/> + </condition> + <condition else=" ${main.class}" property="jar.usage.message.main.class" value=" -m ${module.name}${jar.usage.message.main.class.class.selector}"> + <isset property="named.module.internal"/> + </condition> + <condition else="" property="jar.usage.message" value="To run this application from the command line without Ant, try:${line.separator}${platform.java}${jar.usage.message.module.path}${jar.usage.message.class.path}${jar.usage.message.main.class}"> <isset property="main.class.available"/> </condition> <condition else="debug" property="jar.usage.level" value="info"> @@ -1046,10 +1268,75 @@ <!-- Empty placeholder for easier customization. --> <!-- You can override this target in the ../build.xml file. --> </target> - <target depends="init,compile,-pre-jar,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/> - <target depends="init,compile,-pre-jar,-do-jar,-post-jar" description="Build JAR." name="jar"/> + <target depends="init,compile,-pre-jar,-set-module-main-class,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/> + <target depends="init,compile,-pre-jar,-do-jar,-post-jar,deploy" description="Build JAR." name="jar"/> <!-- ================= + DEPLOY SECTION + ================= + --> + <target name="-pre-deploy"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="init" name="-check-jlink"> + <condition property="do.jlink.internal"> + <and> + <istrue value="${do.jlink}"/> + <isset property="do.archive"/> + <isset property="named.module.internal"/> + </and> + </condition> + </target> + <target depends="init,-do-jar,-post-jar,-pre-deploy,-check-jlink" if="do.jlink.internal" name="-do-deploy"> + <delete dir="${dist.jlink.dir}" failonerror="false" quiet="true"/> + <property name="jlink.launcher.name" value="${application.title}"/> + <condition else="${module.name}" property="jlink.add.modules" value="${module.name},${jlink.additionalmodules}"> + <and> + <isset property="jlink.additionalmodules"/> + <length length="0" string="${jlink.additionalmodules}" when="greater"/> + </and> + </condition> + <condition property="jlink.do.strip.internal"> + <and> + <isset property="jlink.strip"/> + <istrue value="${jlink.strip}"/> + </and> + </condition> + <condition property="jlink.do.additionalparam.internal"> + <and> + <isset property="jlink.additionalparam"/> + <length length="0" string="${jlink.additionalparam}" when="greater"/> + </and> + </condition> + <condition property="jlink.do.launcher.internal"> + <and> + <istrue value="${jlink.launcher}"/> + <isset property="main.class.available"/> + </and> + </condition> + <property name="platform.jlink" value="${jdk.home}/bin/jlink"/> + <property name="jlink.systemmodules.internal" value="${jdk.home}/jmods"/> + <exec executable="${platform.jlink}"> + <arg value="--module-path"/> + <arg path="${jlink.systemmodules.internal}:${run.modulepath}:${dist.jar}"/> + <arg value="--add-modules"/> + <arg value="${jlink.add.modules}"/> + <arg if:set="jlink.do.strip.internal" value="--strip-debug"/> + <arg if:set="jlink.do.launcher.internal" value="--launcher"/> + <arg if:set="jlink.do.launcher.internal" value="${jlink.launcher.name}=${module.name}/${main.class}"/> + <arg if:set="jlink.do.additionalparam.internal" line="${jlink.additionalparam}"/> + <arg value="--output"/> + <arg value="${dist.jlink.output}"/> + </exec> + </target> + <target name="-post-deploy"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target depends="-do-jar,-post-jar,-pre-deploy,-do-deploy,-post-deploy" name="deploy"/> + <!-- + ================= EXECUTION SECTION ================= --> @@ -1084,9 +1371,9 @@ </target> <target depends="init,compile" name="-debug-start-debuggee"> <j2seproject3:debug> - <customize> + <customizeDebuggee> <arg line="${application.args}"/> - </customize> + </customizeDebuggee> </j2seproject3:debug> </target> <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/> @@ -1152,7 +1439,7 @@ </customize> </profile> </target> - <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72"> + <target depends="-init-macrodef-junit,profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72"> <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail> <nbprofiledirect> <classpath> @@ -1159,21 +1446,17 @@ <path path="${run.test.classpath}"/> </classpath> </nbprofiledirect> - <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true"> - <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/> - <jvmarg value="${profiler.info.jvmargs.agent}"/> - <jvmarg line="${profiler.info.jvmargs}"/> - <test name="${profile.class}"/> - <classpath> - <path path="${run.test.classpath}"/> - </classpath> - <syspropertyset> - <propertyref prefix="test-sys-prop."/> - <mapper from="test-sys-prop.*" to="*" type="glob"/> ... [truncated message content] |
From: <yu...@us...> - 2021-11-30 10:48:04
|
Revision: 992 http://sourceforge.net/p/lobby/code/992 Author: yuranet Date: 2021-11-30 10:47:58 +0000 (Tue, 30 Nov 2021) Log Message: ----------- users table renamed to players Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/User.java Modified: trunk/src_server/net/yura/lobby/database/User.java =================================================================== --- trunk/src_server/net/yura/lobby/database/User.java 2021-11-29 19:21:44 UTC (rev 991) +++ trunk/src_server/net/yura/lobby/database/User.java 2021-11-30 10:47:58 UTC (rev 992) @@ -19,15 +19,10 @@ * @author Yura Mamyrin * * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! - * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! - * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! - * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! - * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! * https://github.com/datanucleus/datanucleus-core/issues/422 - * */ @Entity -@Table(name="users") +@Table(name="players") public class User extends Player { /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-29 19:21:46
|
Revision: 991 http://sourceforge.net/p/lobby/code/991 Author: yuranet Date: 2021-11-29 19:21:44 +0000 (Mon, 29 Nov 2021) Log Message: ----------- wanring about table name added Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/User.java Modified: trunk/src_server/net/yura/lobby/database/User.java =================================================================== --- trunk/src_server/net/yura/lobby/database/User.java 2021-11-26 13:21:40 UTC (rev 990) +++ trunk/src_server/net/yura/lobby/database/User.java 2021-11-29 19:21:44 UTC (rev 991) @@ -17,6 +17,14 @@ /** * @author Yura Mamyrin + * + * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! + * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! + * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! + * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! + * WARNING!!!! DataNucleus 5 can not handle "user" or "users" as a table name!!!!!! + * https://github.com/datanucleus/datanucleus-core/issues/422 + * */ @Entity @Table(name="users") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-26 13:21:42
|
Revision: 990 http://sourceforge.net/p/lobby/code/990 Author: yuranet Date: 2021-11-26 13:21:40 +0000 (Fri, 26 Nov 2021) Log Message: ----------- better default size Modified Paths: -------------- trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java Modified: trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java =================================================================== --- trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java 2021-11-25 02:00:20 UTC (rev 989) +++ trunk/src_client/net/yura/lobby/client/LobbyClientGUI.java 2021-11-26 13:21:40 UTC (rev 990) @@ -591,7 +591,7 @@ bottom.setResizeWeight(1.0); top.setDividerLocation(120); - bottom.setDividerLocation(500); + bottom.setDividerLocation(450); setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20)); main.setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 0, 20, 0)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-25 02:00:22
|
Revision: 989 http://sourceforge.net/p/lobby/code/989 Author: yuranet Date: 2021-11-25 02:00:20 +0000 (Thu, 25 Nov 2021) Log Message: ----------- fix for user field rename Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/User.java trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java Modified: trunk/src_server/net/yura/lobby/database/User.java =================================================================== --- trunk/src_server/net/yura/lobby/database/User.java 2021-11-24 17:46:11 UTC (rev 988) +++ trunk/src_server/net/yura/lobby/database/User.java 2021-11-25 02:00:20 UTC (rev 989) @@ -23,7 +23,7 @@ public class User extends Player { /** - * FIELD NAMES HAVE TO MACH GET/SET METHOD NAMES OR DATANUCLEUS WILL BE ANGRY + * FIELD NAMES HAVE TO MATCH GET/SET METHOD NAMES OR DATANUCLEUS WILL BE ANGRY */ private Integer id; Modified: trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-11-24 17:46:11 UTC (rev 988) +++ trunk/src_server/net/yura/lobby/database/impl/JPADatabase.java 2021-11-25 02:00:20 UTC (rev 989) @@ -193,7 +193,8 @@ @Override public User getUserByClientLobbyID(String uuid) { Interaction in = getTransaction(); - Query q = in.em.createQuery("SELECT c FROM User c WHERE c.uid = ?1"); + // field has to match java field name, NOT db col name + Query q = in.em.createQuery("SELECT c FROM User c WHERE c.clientUuid = ?1"); q.setParameter(1, uuid); try { return (User)q.getSingleResult(); @@ -241,6 +242,7 @@ @Override public User getUserByPushToken(String key) { Interaction in = getTransaction(); + // field has to match java field name, NOT db col name Query q = in.em.createQuery("SELECT c FROM User c WHERE c.pushToken = ?1"); q.setParameter(1, key); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-24 17:46:13
|
Revision: 988 http://sourceforge.net/p/lobby/code/988 Author: yuranet Date: 2021-11-24 17:46:11 +0000 (Wed, 24 Nov 2021) Log Message: ----------- no magic strings Modified Paths: -------------- trunk/src/net/yura/lobby/client/Connection.java trunk/src/net/yura/lobby/client/LobbyCom.java trunk/src/net/yura/lobby/client/PushLobbyClient.java trunk/src_server/net/yura/lobby/server/LobbyController.java trunk/test/net/yura/lobby/server/ServerTest.java Modified: trunk/src/net/yura/lobby/client/Connection.java =================================================================== --- trunk/src/net/yura/lobby/client/Connection.java 2021-11-24 14:21:50 UTC (rev 987) +++ trunk/src/net/yura/lobby/client/Connection.java 2021-11-24 17:46:11 UTC (rev 988) @@ -38,7 +38,7 @@ void setOAuthToken(String system, String token); /** - * @param system can be "FCM" or "APN" + * @param system can be {@link PushLobbyClient#PUSH_SYSTEM_FCM} or {@link PushLobbyClient#PUSH_SYSTEM_APN} * @param token send null to unregister */ void setPushToken(String system, String token); Modified: trunk/src/net/yura/lobby/client/LobbyCom.java =================================================================== --- trunk/src/net/yura/lobby/client/LobbyCom.java 2021-11-24 14:21:50 UTC (rev 987) +++ trunk/src/net/yura/lobby/client/LobbyCom.java 2021-11-24 17:46:11 UTC (rev 988) @@ -508,12 +508,12 @@ } /** - * @param system can be "FCM" or "ADM" + * @param system can be {@link PushLobbyClient#PUSH_SYSTEM_FCM} or {@link PushLobbyClient#PUSH_SYSTEM_APN} * @param token to clear a token, pass null as a the token */ public void setPushToken(String system, String token) { - if (!"FCM".equals(system) && !"ADM".equals(system)) { - throw new IllegalArgumentException("only \"FCM\" and \"ADM\" supported"); + if (!PushLobbyClient.PUSH_SYSTEM_FCM.equals(system) && !PushLobbyClient.PUSH_SYSTEM_APN.equals(system)) { + throw new IllegalArgumentException("unsupported system: " + system); } Map request = new HashMap(); request.put("system", system); Modified: trunk/src/net/yura/lobby/client/PushLobbyClient.java =================================================================== --- trunk/src/net/yura/lobby/client/PushLobbyClient.java 2021-11-24 14:21:50 UTC (rev 987) +++ trunk/src/net/yura/lobby/client/PushLobbyClient.java 2021-11-24 17:46:11 UTC (rev 988) @@ -2,6 +2,10 @@ public interface PushLobbyClient { + public static final String PUSH_SYSTEM_FCM = "FCM"; // Firebase Cloud Messaging + public static final String PUSH_SYSTEM_APN = "APN"; // Apple Push Notification service + public static final String PUSH_SYSTEM_ADM = "ADM"; // Amazon Device Messaging + public static final String MESSAGE = "message"; public static final String GAME_ID = "gameId"; public static final String OPTIONS = "options"; Modified: trunk/src_server/net/yura/lobby/server/LobbyController.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyController.java 2021-11-24 14:21:50 UTC (rev 987) +++ trunk/src_server/net/yura/lobby/server/LobbyController.java 2021-11-24 17:46:11 UTC (rev 988) @@ -20,6 +20,7 @@ import javax.crypto.Cipher; import net.yura.lobby.client.ProtoAccess; import net.yura.lobby.client.ProtoAccess.ObjectProvider; +import net.yura.lobby.client.PushLobbyClient; import net.yura.lobby.database.Database; import net.yura.lobby.database.GameRoom; import net.yura.lobby.database.User; @@ -165,7 +166,7 @@ String system; String token; if (param == null || param instanceof String) { // dom android <= 82 - system = "FCM"; + system = PushLobbyClient.PUSH_SYSTEM_FCM; token = (String)param; } else { @@ -173,7 +174,7 @@ system = (String)request.get("system"); token = decrypt(request.get("token")); } - if (token != null && "APN".equals(system)) { + if (token != null && PushLobbyClient.PUSH_SYSTEM_APN.equals(system)) { token = "Apple-" + token; } Modified: trunk/test/net/yura/lobby/server/ServerTest.java =================================================================== --- trunk/test/net/yura/lobby/server/ServerTest.java 2021-11-24 14:21:50 UTC (rev 987) +++ trunk/test/net/yura/lobby/server/ServerTest.java 2021-11-24 17:46:11 UTC (rev 988) @@ -8,6 +8,7 @@ import javax.management.ObjectName; import net.yura.lobby.client.Connection; import net.yura.lobby.client.LobbyCom; +import net.yura.lobby.client.PushLobbyClient; import net.yura.lobby.database.Database; import net.yura.lobby.database.impl.MemoryDatabase; import net.yura.lobby.model.Game; @@ -71,7 +72,7 @@ Connection mycom = newConnection(id1, client); connectAndWaitForConnection(mycom); - mycom.setPushToken("FCM", androidID); + mycom.setPushToken(PushLobbyClient.PUSH_SYSTEM_FCM, androidID); sleep(1000); mycom.disconnect(); String username1 = client.getUsername(); @@ -82,7 +83,7 @@ mycom = newConnection(id2, client); connectAndWaitForConnection(mycom); Assert.assertFalse(username1.equals(client.getUsername())); - mycom.setPushToken("FCM", androidID); + mycom.setPushToken(PushLobbyClient.PUSH_SYSTEM_FCM, androidID); sleep(1000); mycom.disconnect(); Assert.assertEquals(username1, client.getUsername()); @@ -98,7 +99,7 @@ Connection mycom = newConnection(id1, client); connectAndWaitForConnection(mycom); makeGame(mycom, client); - mycom.setPushToken("FCM", androidID); + mycom.setPushToken(PushLobbyClient.PUSH_SYSTEM_FCM, androidID); sleep(1000); mycom.disconnect(); String username1 = client.getUsername(); @@ -110,7 +111,7 @@ connectAndWaitForConnection(mycom); makeGame(mycom, client); Assert.assertFalse(username1.equals(client.getUsername())); - mycom.setPushToken("FCM", androidID); + mycom.setPushToken(PushLobbyClient.PUSH_SYSTEM_FCM, androidID); sleep(1000); mycom.disconnect(); Assert.assertFalse(username1.equals(client.getUsername())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-24 14:21:53
|
Revision: 987 http://sourceforge.net/p/lobby/code/987 Author: yuranet Date: 2021-11-24 14:21:50 +0000 (Wed, 24 Nov 2021) Log Message: ----------- proto update Modified Paths: -------------- trunk/lobby.proto Modified: trunk/lobby.proto =================================================================== --- trunk/lobby.proto 2021-11-24 14:12:53 UTC (rev 986) +++ trunk/lobby.proto 2021-11-24 14:21:50 UTC (rev 987) @@ -96,12 +96,10 @@ REQUEST_PLAYER_INFO = 31; // username COMMAND_PLAYER_INFO = 32; // {username=String,info=List<PlayerInfo>} -// ANDROID +// Push Tokens (Android & iOS) - REQUEST_ANDROID_REGISTER = 41; - REQUEST_ANDROID_UNREGISTER = 42; - COMMAND_ANDROID_REGISTER_DONE = 43; - COMMAND_ANDROID_UNREGISTER_DONE = 44; + REQUEST_PUSH_REGISTER = 41; {system=String,token=byte[]} + COMMAND_PUSH_REGISTER_DONE = 43; // ADMIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-24 14:12:56
|
Revision: 986 http://sourceforge.net/p/lobby/code/986 Author: yuranet Date: 2021-11-24 14:12:53 +0000 (Wed, 24 Nov 2021) Log Message: ----------- server runs again, DB fix Modified Paths: -------------- trunk/src_server/net/yura/lobby/database/User.java trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java trunk/src_server/net/yura/lobby/server/GameLobby.java trunk/src_server/net/yura/lobby/server/LobbyController.java Modified: trunk/src_server/net/yura/lobby/database/User.java =================================================================== --- trunk/src_server/net/yura/lobby/database/User.java 2021-11-24 13:31:53 UTC (rev 985) +++ trunk/src_server/net/yura/lobby/database/User.java 2021-11-24 14:12:53 UTC (rev 986) @@ -22,6 +22,10 @@ @Table(name="users") public class User extends Player { + /** + * FIELD NAMES HAVE TO MACH GET/SET METHOD NAMES OR DATANUCLEUS WILL BE ANGRY + */ + private Integer id; /** * the uuid of the last device a player logged in on. @@ -75,10 +79,10 @@ * unique id that is generated on the client and is used to identify it */ @Column(name="uid", nullable=true, length=200, unique=true) - public String getUid() { + public String getClientUuid() { return clientUuid; } - public void setUid(String uid) { + public void setClientUuid(String uid) { this.clientUuid = uid; } Modified: trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java =================================================================== --- trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java 2021-11-24 13:31:53 UTC (rev 985) +++ trunk/src_server/net/yura/lobby/database/impl/MemoryDatabase.java 2021-11-24 14:12:53 UTC (rev 986) @@ -139,7 +139,7 @@ private static User makeNewUser(String name, int type) { User newUser = new User(); newUser.setName(name); - newUser.setUid(name + "-uuid"); + newUser.setClientUuid(name + "-uuid"); newUser.setType(type); return newUser; } @@ -223,12 +223,12 @@ if (registeredPeople.containsKey(user.getName())) { throw new IllegalArgumentException("username already taken"); } - if (clientUUIDtoInt.containsKey(user.getUid())) { + if (clientUUIDtoInt.containsKey(user.getClientUuid())) { throw new IllegalArgumentException("uuid already taken"); } } registeredPeople.put(user.getName(), user); - clientUUIDtoInt.put(user.getUid(), user); + clientUUIDtoInt.put(user.getClientUuid(), user); } @Override Modified: trunk/src_server/net/yura/lobby/server/GameLobby.java =================================================================== --- trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-11-24 13:31:53 UTC (rev 985) +++ trunk/src_server/net/yura/lobby/server/GameLobby.java 2021-11-24 14:12:53 UTC (rev 986) @@ -320,7 +320,7 @@ User user = database.getUserByClientLobbyID(uuid); if (user == null) { user = new User(); - user.setUid(uuid); + user.setClientUuid(uuid); user.setType(Player.PLAYER_GUEST); database.saveUser(user); } @@ -377,7 +377,7 @@ // we DO allow taking over a blocked accont, as why would anyone want to if (userByEmail.getType() <= Player.PLAYER_FLAGGED) { user = userByEmail; - user.setUid(uuid); + user.setClientUuid(uuid); database.saveUser(user); } } @@ -385,7 +385,7 @@ if (user == null) { user = new User(); - user.setUid(uuid); + user.setClientUuid(uuid); user.setType(Player.PLAYER_GUEST); user.setEmail(email); // EMAIL IS UNVERIFIED! database.saveUser(user); @@ -427,11 +427,11 @@ user = database.getUserByEmail(email); } - if (user != null && !uuid.equals(user.getUid())) { + if (user != null && !uuid.equals(user.getClientUuid())) { User other = database.getUserByClientLobbyID(uuid); if (other != null) { pushToken = other.getPushToken(); - other.setUid(null); + other.setClientUuid(null); database.saveUser(other); userFoundButUUIDMissmatch = true; } @@ -484,9 +484,9 @@ if (gcmUser != null && user.getType() == Player.PLAYER_GUEST && user.getGames().isEmpty() && session.playingOrWatchingGame.isEmpty()) { // the user has not started using there new account // so we will swap the uids of the 2 account to give them there old account back - oldLobbyId = gcmUser.getUid(); - newLobbyId = user.getUid(); - user.setUid(null); + oldLobbyId = gcmUser.getClientUuid(); + newLobbyId = user.getClientUuid(); + user.setClientUuid(null); } else { user.setPushToken(pushSystemToken); @@ -503,7 +503,7 @@ database.startTransaction(); User user = database.getUserByClientLobbyID(oldLobbyId); - user.setUid(newLobbyId); + user.setClientUuid(newLobbyId); database.saveUser(user); session.setUser(user); Map responce = loginResponce(user); @@ -520,8 +520,8 @@ private void loginAndUpdateUser(User user, LobbySession session, String uuid, String email, String oauthId, String pushToken) { boolean changed = false; - if (!uuid.equals(user.getUid())) { - user.setUid(uuid); + if (!uuid.equals(user.getClientUuid())) { + user.setClientUuid(uuid); changed = true; } Modified: trunk/src_server/net/yura/lobby/server/LobbyController.java =================================================================== --- trunk/src_server/net/yura/lobby/server/LobbyController.java 2021-11-24 13:31:53 UTC (rev 985) +++ trunk/src_server/net/yura/lobby/server/LobbyController.java 2021-11-24 14:12:53 UTC (rev 986) @@ -241,7 +241,7 @@ if (lobby.checkIAm(session, Player.PLAYER_GOD)) { info.add(new PlayerInfo("reporters", String.valueOf(user.getReporters()), false)); // get UID so can match it against emails to that person - info.add(new PlayerInfo("UID", user.getUid(), false)); + info.add(new PlayerInfo("clientUUID", user.getClientUuid(), false)); } Map responce = new HashMap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yu...@us...> - 2021-11-24 13:31:56
|
Revision: 985 http://sourceforge.net/p/lobby/code/985 Author: yuranet Date: 2021-11-24 13:31:53 +0000 (Wed, 24 Nov 2021) Log Message: ----------- compile fix Modified Paths: -------------- trunk/src_server/net/yura/lobby/quickserver/QSAdminCommandPlugin.java Modified: trunk/src_server/net/yura/lobby/quickserver/QSAdminCommandPlugin.java =================================================================== --- trunk/src_server/net/yura/lobby/quickserver/QSAdminCommandPlugin.java 2021-11-24 13:06:03 UTC (rev 984) +++ trunk/src_server/net/yura/lobby/quickserver/QSAdminCommandPlugin.java 2021-11-24 13:31:53 UTC (rev 985) @@ -14,21 +14,20 @@ Server server = (Server)handler.getServer().getStoreObjects()[0]; GameLobby lobbyServer = server.lobbyController.lobby; - + if(command.toLowerCase().startsWith("savedb")) { lobbyServer.saveToDB(); - + handler.sendClientMsg("DONE"); return true; } if(command.toLowerCase().startsWith("asend ")) { - - lobbyServer.androidSend(command.substring("asend ".length()), "test message"); - + + lobbyServer.pushSend(command.substring("asend ".length()), "test message"); + handler.sendClientMsg("DONE"); return true; - } return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |