Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2155

Weight loss program

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Obsolete
    • Major
    • None
    • None
    • None

    Description

      JGroups jar is quite large and it is sometime desirable to shrink it some way.

      Currently the jar contains unnecessary class (demo, test and perf) and it is not possible to keep the only needed protocols using tools like Proguard (it's like having a server with all ports open).

      My suggestions are:

      Move JGroups' side class

      Demo: Move the demo package to a maven module.

      Test and perf: Move the test package to the maven test source and generate test-source jars.
      Note that the MPerf$MPerfHeader must be removed from the jg-magic-map.xml file.

      Make JGroups Proguard compatible

      A classical way to shrink and optimize project is to use the *{{Proguard }}*tools.
      This tool cannot be used for JGroups mainly because of the two configuration files jg-magic-map.xml and jg-protocol-ids.xml.

      These two files contain all class files for all possible protocols, even those that are not required by the selected configuration for the project (for example, using fast.xml does not require ENCRYPT, TUNNEL and many more.)

      The problem is that Proguard could not understand these two files and removes all class because there is no entry points.

      One way to solve this may be to create Annotation (for example @MagicMap and @ProtocolIds) and remove the two files. These annotations could be searched by the initialization process in the class maintained by the Proguard tools. This should not affect the loading time as all relevant class are in the same package org.jgroups.protocols.

      This is not enough because some fields are initialized by reflection using hard coded name (for example "bind_add"). For such fields we need an Annotation like @KeepField to tell Proguard not to optimize, remove or rename the fields. For example:

      -keepclassmembers class *

      { @jgroups.annotations.KeepField <fields>; }

      This Annotation may also be used for class where instance are created by reflection (like GMS.GmsHeader).

      Last we need to specify the entry points for the project configuration else Proguard will still remove all. The xml configuration files (like fast.xml) should be kept to provide the protocols configuration.

      This is a matter of the Proguard configuration file. For example in a project using{{ fast.xml}}, we should have:

      -keep public class org.jgroups.protocols.UDP.**

      { *; }
      -keep public class org.jgroups.protocols.PING.** { *; }


      -keep public class org.jgroups.protocols.MERGE3.**

      { *; }
      -keep public class org.jgroups.protocols.FD_SOCK.** { *; }


      -keep public class org.jgroups.protocols.FD_ALL.**

      { *; }
      -keep public class org.jgroups.protocols.VERIFY_SUSPECT.** { *; }


      -keep public class org.jgroups.protocols.BARRIER.**

      { *; }
      -keep public class org.jgroups.protocols.pbcast.NAKACK2.** { *; }


      ... etc

      My 2 cents.
      Yves

      Attachments

        Activity

          People

            rhn-engineering-bban Bela Ban
            ycuicui Yves Cuillerdier (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: