Feature #76

Java bindings using JNI

Added by Madars Vitolins over 1 year ago. Updated 2 days ago.

Status:NewStart date:04/23/2018
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:-

CallingCLibraryRoutinesfromJava.pdf (523 KB) Madars Vitolins, 11/13/2017 02:35 PM


Subtasks

Feature #307: error codes in string format - needed for JAVA exception buildingClosed

History

#1 Updated by Madars Vitolins over 1 year ago

  • Subject changed from Java bindings to Java bindings using JNI

#9 Updated by Madars Vitolins over 1 year ago

Technology sample: http://java-gnome.sourceforge.net/HACKING.html
$ git clone git://github.com/afcowie/java-gnome.git java-gnome

#20 Updated by Madars Vitolins 3 months ago

  • Tracker changed from Bug to Feature

#24 Updated by Madars Vitolins 3 months ago

- Inside JNI functions, firstly we shall set the context manually, and then use standard tp commands (not O).

- When JNI error occurs, throw runtime exception. For ATMI errors, instantiate ATMI exception. For example if context is NULL.

#25 Updated by Madars Vitolins 3 months ago

ndrxconfig.xml could look like:

        <servers>
                <server name="someprocess">
                        <srvid>1</srvid>
                        <min>1</min>
                        <max>1</max>
                        <interpret>java -jar someprocess_package.jar</interpret>
                        <sysopt>-e /tmp/RECOVER -r</sysopt>
                        <appopt>-c10</appopt>
                </server>

So "someprocess" becomes logical name of the given server. But shall give options for formatting the command. There could be option for logical name in format string and the sysopt and appopt too:

        <servers>
                <server name="someprocess">
                        <srvid>1</srvid>
                        <min>1</min>
                        <max>1</max>
                        <sysopt>-e /tmp/RECOVER -r</sysopt>
                        <appopt>-c10</appopt>
                        <interpret>java -jar ${NDRX_PROCESS}_package.jar -- ${NDRX_SYSOPT} ${NDRX_APPOPT}</interpret>
                </server>

Which would in the final make following runnable:

java -jar someprocess_package.jar -e /tmp/RECOVER -r  -c10

#26 Updated by Madars Vitolins 3 months ago

This will require some changes in housekeep processes, as real executable will be java.

#31 Updated by Madars Vitolins 3 months ago

We need following interface for service advertise:

interface Server {
   public void tpSvrInit(string [] argv);
   public void tpSvrDone();
}

interface Service {
  public void tpService(TpSvcInfo svcinfo);
}

#34 Updated by Madars Vitolins about 2 months ago

Seems for server's we need something like

    <defaults>
        <envs group="ENV1">
            <env>SOME_OTHER_ENV=HELLO WORLD</env>
        <envs>
        <envs group="ENV2">
            <env>SOME_OTHER_ENV2=HELLO WORLD</env>
        <envs>
    </defaults>
    <server name="cconfsrv">
        <srvid>1700</srvid>
        <min>1</min>
        <max>1</max>
        <sysopt>-e /tmp/CCONF</sysopt>
        <envs>
            <usegroup>ENV1</usegroup>
            <usegroup>ENV2</usegroup>
            <env>JAVA_OPTS=-some -flags ${SOME_OTHER_ENV}</env>
            <env>JAVA_CLASSPATH=-some2 -flags2</env>
        ...
        </envs>
    </server>
..
        <clients>
        <envs group="ENV1">
            <env>SOME_OTHER_ENV=HELLO WORLD</env>
        </envs>
                <client cmdline="/opt/bin/my_binary -t ${NDRX_CLTTAG} -s ${NDRX_CLTSUBSECT}">
            <env>
                <usegroup>ENV1</usegroup>
                <usegroup>ENV2</usegroup>
                <env>JAVA_OPTS=-some -flags ${SOME_OTHER_ENV}</env>
                <env>JAVA_CLASSPATH=-some2 -flags2</env>
            <env/>
                        <exec tag="BINARY1" subsect="1" autostart="Y" />
                        <exec tag="BINARY2" subsect="2" autostart="Y" />
                </client>
                <client cmdline="firefox"> <exec tag="FF"/> </client>
                <client cmdline="/tmp/test.bin" env="/tmp/yopt.env"> <exec tag="TT" log="/tmp/test.out"/> </client>
                <client cmdline="mongod -dbpath /home/mvitolin/tmp/data/db" >
                        <exec tag="mongo" autostart="Y"/>
                </client>
        </clients>

1. So we need to keep in defaults hash list of envs by set id.
2. The server keeps the linked list of envs
3. Server keeps linked list of pointer to linked resolved sets.

The same approach goes with client admin.

#35 Updated by Madars Vitolins about 2 months ago

we shall provide exjc (Enduro/X Java Compiler) so that we could embed the JVM and compile in the jar files, which at the process boot we could extract to disk (/dev/shm preffered) load the jars, and start the binary.

This way we can get the normal executable, and customer have zero config requirements for the binary configuration.

#36 Updated by Madars Vitolins about 2 months ago

Alos we might want to export server id too to env variables. So that any startup scripts might want to adjust their tcp port numbers or any other resources according to the server id

#37 Updated by Madars Vitolins about 2 months ago

Also needs to consider what happens in cases when atmi server runs in background and the atmi server parent went off.

#40 Updated by Madars Vitolins 14 days ago

seems exembedfile adds some un needed zero at end of the array...

#41 Updated by Madars Vitolins 2 days ago

Seems like "setContextClassLoader" is needed for exjld for runner context to set the class loader.

#42 Updated by Madars Vitolins 2 days ago

Also available in: Atom PDF