Extension Reload Mode

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 03:25

Hello.

This is strange. I have set the Extension's Reload Mode to "NONE", and Start Extension File Monitor to be switched off. But for some reason even after a fresh reboot. When I upload an extension jar file, the code automatically starts being executed.

How do I completely turn off this feature? It's a nice feature but because the jars in the Extension reloads while the jars in the __jar__ folders don't, so my code becomes out of sync unless I can reload them all, which I know based on the docs, you cannot. So best thing is to turn it off completely and reboot smartfox whenever I need to change code.

p.s. I start the server via "sfs2x-service -start"

Thank you.
trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Re: Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 06:34

I see in the console that it's the room extension that's reload mode is AUTO. The room extensions are attached via server extension code when creating the room. But there's no API to set the extension reload mode. Closest I've found is RoomExtensionSettings.setPropertiesFile() but I don't know the format...
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Extension Reload Mode

Postby Lapo » 15 Sep 2016, 07:48

Room Extensions are never reloaded at runtime. Only Zone Extensions are.
I am not clear about what is happening. Can you clarify?

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Re: Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 13:43

Ok. Create a zone in the admin console and setup the zone extension assuming the following is already done.

Create a zone extension and a room extension in java. In the zone extension code create a room, then insert a room extension into that room. Now use the admin console. Go to zone monitor, select the zone, select the room, choose monitor the room. Look at the settings of reload mode. It will say "AUTO".
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Extension Reload Mode

Postby Lapo » 15 Sep 2016, 13:58

The reload mode parameter for Room Extension is irrelevant. As I said it's not used, but thanks for pointing the Admin thing. We'll remove it from view for Room Extensions.
Lapo

--

gotoAndPlay()

...addicted to flash games
trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Re: Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 14:04

Ok. But unfortunately. When I copy a jar to the extension folder the new code gets run immediately. I can't turn it off. If I use sfs2x.sh it seems to behave correctly. But with sfs2x-service -start the extension reloads automatically.
trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Re: Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 14:07

Try adding a new model I'm the __jar__ folder. And references it in the extension. Deploy both jars without restarting. The logs will complain that no class doing referring to the new model. Because the __jar__ class loader didn't reload as expected. But the extension got reloaded which is not expected.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Extension Reload Mode

Postby Lapo » 15 Sep 2016, 14:48

nepoez wrote:Ok. But unfortunately. When I copy a jar to the extension folder the new code gets run immediately. I can't turn it off. If I use sfs2x.sh it seems to behave correctly. But with sfs2x-service -start the extension reloads automatically.

If the JAR contains Extensions that run at Zone Levels those will be reloaded if their Reload Mode == AUTO.
This does not affect Room level Extensions.

I think you're confusing the two. There is no way to reload a Room Extension.

Also however you run the server doesn't affect the reloading process. sfs2x.sh and sfs2x-service are just launch scripts, they don't affect how the server behaves.

I am really confused as what you're reporting here. Your last post is very confusing for me. Maybe it would be best if you could describe what your setup is, how extensions are deployed, the structure of files on disk and show us the Zone config.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Re: Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 17:05

Below is the zone config and how it's setup.



[MyGameExtension Folder]
Extension.jar
- MyZoneExtension.class
- MyRoomExtension.class

[__LIB__ Folder]
Service.jar
- MyService.class (with services for db)
- xxx ... xxx (and models etc)

How a room is created:

Code: Select all


            CreateRoomSettings config = new CreateRoomSettings();

            config.setMaxUsers(15);

            config.setName(roomName);

config.setRoomSettings(EnumSet.of(SFSRoomSettings.PUBLIC_MESSAGES,SFSRoomSettings.USER_ENTER_EVENT,SFSRoomSettings.USER_EXIT_EVENT,SFSRoomSettings.USER_VARIABLES_UPDATE_EVENT));
                  
            config.setExtension( new RoomExtensionSettings("MyGameExtension",MyRoomExtension.class.getName()));
            config.setGroupId("g");
            config.setHidden(false);
            config.setDynamic(true);
            //config.setUsingFloodingFilter(true);
            config.setUseWordsFilter(true);
            config.setGame(true);
            config.setAutoRemoveMode(SFSRoomRemoveMode.NEVER_REMOVE);
            
            ...
            
            room = getApi().createRoom(getParentExtension().getParentZone(), config, sfUser);
                   getApi().joinRoom(sfUser, room);


Code: Select all

<zone>
  <name>myzone</name>
  <isCustomLogin>true</isCustomLogin>
  <isForceLogout>true</isForceLogout>
  <applyWordsFilterToUserName>false</applyWordsFilterToUserName>
  <applyWordsFilterToRoomName>false</applyWordsFilterToRoomName>
  <applyWordsFilterToPrivateMessages>true</applyWordsFilterToPrivateMessages>
  <isFilterBuddyMessages>true</isFilterBuddyMessages>
  <isEncrypted>false</isEncrypted>
  <maxUsers>9000</maxUsers>
  <maxUserVariablesAllowed>15</maxUserVariablesAllowed>
  <maxRoomVariablesAllowed>5</maxRoomVariablesAllowed>
  <minRoomNameChars>3</minRoomNameChars>
  <maxRoomNameChars>50</maxRoomNameChars>
  <maxRooms>9000</maxRooms>
  <maxRoomsCreatedPerUser>1</maxRoomsCreatedPerUser>
  <userCountChangeUpdateInterval>1000</userCountChangeUpdateInterval>
  <userReconnectionSeconds>0</userReconnectionSeconds>
  <overrideMaxUserIdleTime>20</overrideMaxUserIdleTime>
  <allowGuestUsers>false</allowGuestUsers>
  <guestUserNamePrefix>Guest#</guestUserNamePrefix>
  <publicRoomGroups></publicRoomGroups>
  <defaultRoomGroups></defaultRoomGroups>
  <defaultPlayerIdGeneratorClass></defaultPlayerIdGeneratorClass>
  <wordsFilter active="true">
    <useWarnings>true</useWarnings>
    <warningsBeforeKick>3</warningsBeforeKick>
    <kicksBeforeBan>2</kicksBeforeBan>
    <banDuration>1440</banDuration>
    <maxBadWordsPerMessage>0</maxBadWordsPerMessage>
    <kicksBeforeBanMinutes>3</kicksBeforeBanMinutes>
    <secondsBeforeBanOrKick>5</secondsBeforeBanOrKick>
    <warningMessage>Stop swearing or you will be banned</warningMessage>
    <kickMessage>Swearing not allowed: you are being kicked</kickMessage>
    <banMessage>Too much swearing: you are banned</banMessage>
    <wordsFile>config/wordsFile.txt</wordsFile>
    <filterMode>BLACKLIST</filterMode>
    <banMode>NAME</banMode>
    <hideBadWordWithCharacter>*</hideBadWordWithCharacter>
  </wordsFilter>
  <floodFilter active="true">
    <banDurationMinutes>1440</banDurationMinutes>
    <maxFloodingAttempts>5</maxFloodingAttempts>
    <secondsBeforeBan>5</secondsBeforeBan>
    <banMode>NAME</banMode>
    <logFloodingAttempts>true</logFloodingAttempts>
    <banMessage>Too much flooding, you are banned</banMessage>
  </floodFilter>
  <rooms/>
  <disabledSystemEvents/>
  <privilegeManager active="false">
    <profiles class="java.util.Arrays$ArrayList">
      <a class="profile-array">
        <profile id="0">
          <name>Guest</name>
          <deniedRequests class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>CreateRoom</string>
              <string>PrivateMessage</string>
              <string>SetRoomVariables</string>
              <string>SetUserVariables</string>
              <string>ChangeRoomName</string>
              <string>ChangeRoomPassword</string>
              <string>ChangeRoomCapacity</string>
              <string>InitBuddyList</string>
              <string>AddBuddy</string>
              <string>BlockBuddy</string>
              <string>RemoveBuddy</string>
              <string>SetBuddyVariables</string>
              <string>GoOnline</string>
              <string>BuddyMessage</string>
              <string>ModeratorMessage</string>
              <string>AdminMessage</string>
              <string>KickUser</string>
              <string>BanUser</string>
            </a>
          </deniedRequests>
          <permissionFlags/>
        </profile>
        <profile id="1">
          <name>Standard</name>
          <deniedRequests class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ModeratorMessage</string>
              <string>AdminMessage</string>
              <string>KickUser</string>
              <string>BanUser</string>
            </a>
          </deniedRequests>
          <permissionFlags class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ExtensionCalls</string>
            </a>
          </permissionFlags>
        </profile>
        <profile id="2">
          <name>Moderator</name>
          <deniedRequests class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>AdminMessage</string>
            </a>
          </deniedRequests>
          <permissionFlags class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ExtensionCalls</string>
              <string>SuperUser</string>
            </a>
          </permissionFlags>
        </profile>
        <profile id="3">
          <name>Administrator</name>
          <deniedRequests/>
          <permissionFlags class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>ExtensionCalls</string>
              <string>SuperUser</string>
            </a>
          </permissionFlags>
        </profile>
      </a>
    </profiles>
  </privilegeManager>
  <extension>
    <name>MyGameExtension</name>
    <type>JAVA</type>
    <file>com.test.mmo.MyZoneExtension</file>
    <propertiesFile></propertiesFile>
    <reloadMode>NONE</reloadMode>
  </extension>
  <buddyList active="false">
    <allowOfflineBuddyVariables>true</allowOfflineBuddyVariables>
    <maxItemsPerList>100</maxItemsPerList>
    <maxBuddyVariables>15</maxBuddyVariables>
    <offlineBuddyVariablesCacheSize>500</offlineBuddyVariablesCacheSize>
    <customStorageClass></customStorageClass>
    <useTempBuddies>true</useTempBuddies>
    <buddyStates class="java.util.Arrays$ArrayList">
      <a class="string-array">
        <string>Available</string>
       <string>Away</string>
        <string>Occupied</string>
      </a>
    </buddyStates>
    <badWordsFilter isActive="false"/>
  </buddyList>
  <databaseManager active="false">
    <driverName></driverName>
    <connectionString></connectionString>
    <userName></userName>
    <password></password>
    <testSql></testSql>
    <maxActiveConnections>10</maxActiveConnections>
    <maxIdleConnections>10</maxIdleConnections>
    <exhaustedPoolAction>FAIL</exhaustedPoolAction>
    <blockTime>3000</blockTime>
  </databaseManager>
  <allowUploads>false</allowUploads>
</zone>




When I look in monitor for a room created by code above:

Code: Select all

Name: MyGameExtension
Type: JAVA
Main class: com.test.mmo.MyRoomExtension
Properties file: config.properties
Reload Mode: AUTO
trianglehead
Posts: 90
Joined: 13 Aug 2016, 04:28

Re: Extension Reload Mode

Postby trianglehead » 15 Sep 2016, 17:21

Firstly. I need to say thanks for the quick response!

So. The issue is, when I upload the jar files into the server, overriding old jar files specified above, I don't expect it to reload until I restart smartfox. However, it reloads.

How I know is because if I add a new variable say a String variable called "String myNewString" in any of the models, which goes into the __lib__ folder jars. And in the MyRoomExtension.java I reference it by logger.info( myModel.myNewString );. When I upload the jars, it will complain that myNewString is not found, because the extension has been reloaded, knowing that I've added this code "logger.info( myModel.myNewString );"... It should not even know that I changed that until I reboot. Obviously the __lib__ stuff didn't reload as specified in the smartfox docs, it cannot. But Extension should not either, if I configured it to be that way...

p.s. slightly different question: Does each instance of the room extension have it's own class loader? Because once I put a static variable in my room extension, and assign a value to it. When I reference the static var from another room, that value is null. So if I have 500 rooms, I have 500 different class loaders?

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 70 guests