]> rtime.felk.cvut.cz Git - orte.git/commitdiff
JORTE: add basic Java domain manager
authorMartin Vajnar <martin.vajnar@gmail.com>
Thu, 11 Jul 2013 11:40:26 +0000 (13:40 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 23 Sep 2013 09:06:25 +0000 (11:06 +0200)
This adds basic Java manager. Currently it is only possible to set IP
addresses of fellow managers.

orte/include/jorte/org_ocera_orte_Manager.h [deleted file]
orte/include/jorte/org_ocera_orte_types_DomainProp.h
orte/java/src/org/ocera/orte/DomainMgr.java
orte/java/src/org/ocera/orte/Manager.java [new file with mode: 0644]
orte/java/src/org/ocera/orte/types/DomainProp.java
orte/libjorte/JORTEDomainMgrCreate.c
orte/libjorte/JORTEDomainMgrDestroy.c
orte/libjorte/JORTEDomainPropMgrsSet.c [new file with mode: 0644]
orte/libjorte/Makefile.omk

diff --git a/orte/include/jorte/org_ocera_orte_Manager.h b/orte/include/jorte/org_ocera_orte_Manager.h
deleted file mode 100644 (file)
index d708fce..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class org_ocera_orte_Manager */
-
-#ifndef _Included_org_ocera_orte_Manager
-#define _Included_org_ocera_orte_Manager
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     org_ocera_orte_Manager
- * Method:    jORTEDomainDefaultMgrCreate
- * Signature: (IZ)I
- */
-JNIEXPORT jint JNICALL Java_org_ocera_orte_Manager_jORTEDomainDefaultMgrCreate
-  (JNIEnv *, jclass, jint, jboolean);
-
-/*
- * Class:     org_ocera_orte_Manager
- * Method:    jORTEDomainMgrCreate
- * Signature: (IIIZ)I
- */
-JNIEXPORT jint JNICALL Java_org_ocera_orte_Manager_jORTEDomainMgrCreate
-  (JNIEnv *, jclass, jint, jint, jint, jboolean);
-
-/*
- * Class:     org_ocera_orte_Manager
- * Method:    jORTEDomainMgrDestroy
- * Signature: (I)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_ocera_orte_Manager_jORTEDomainMgrDestroy
-  (JNIEnv *, jclass, jint);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
index 7429330b7b879bfb0ab409c7ff618d2421d62458..f0ebe8af5c2ddf2325f9488767faac9eb3b69228 100644 (file)
@@ -15,6 +15,14 @@ extern "C" {
 JNIEXPORT jlong JNICALL Java_org_ocera_orte_types_DomainProp_jORTEDomainPropDefaultGet
   (JNIEnv *, jclass);
 
+/*
+ * Class:     org_ocera_orte_types_DomainProp
+ * Method:    jORTEDomainPropMgrsSet
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ocera_orte_types_DomainProp_jORTEDomainPropMgrsSet
+  (JNIEnv *, jobject);
+
 #ifdef __cplusplus
 }
 #endif
index 6f034826212565793c380434eb039fa31b7ddf1d..bf4394c78cb249db09565a9d429fb32b6bf7e660 100644 (file)
@@ -36,6 +36,7 @@ public class DomainMgr extends Domain
        **/
    public DomainMgr()
    {
+        super();
      handle = jORTEDomainDefaultMgrCreate(ORTEConstant.ORTE_DEFAULT_DOMAIN,
                                              false);
    }
@@ -56,7 +57,7 @@ public class DomainMgr extends Domain
     {
           handle = jORTEDomainMgrCreate(domain,
                                         props.handle,
-                                            events.getHandle(),
+                                            events==null ? 0 : events.getHandle(),
                                                                 suspend);
     }
 
diff --git a/orte/java/src/org/ocera/orte/Manager.java b/orte/java/src/org/ocera/orte/Manager.java
new file mode 100644 (file)
index 0000000..4ad03ee
--- /dev/null
@@ -0,0 +1,19 @@
+package org.ocera.orte;
+
+import org.ocera.orte.types.*;;
+
+public class Manager {
+       
+       private DomainProp dprops;
+       private DomainMgr dmgr;
+       
+       public Manager(String[] mgrs) {
+               dprops = DomainProp.defaultPropsCreate();
+               dprops.setMgrs(mgrs);
+               
+               dmgr = new DomainMgr(ORTEConstant.ORTE_DEFAULT_DOMAIN,
+                                                        dprops,
+                                                        null,
+                                                        false);
+       }
+}
index b4b731017d76fea6c2affa2f37201f6ef9945e8e..a556669ee36cafda4cd6e2ebe622b870c6440e9e 100644 (file)
@@ -25,8 +25,7 @@ package org.ocera.orte.types;
 
 
 public class DomainProp {
-
-
+       
  /* load native library 'libjorte.so' */
   static {
      System.loadLibrary("jorte");
@@ -35,8 +34,19 @@ public class DomainProp {
 
  /* handler to C struct with default domain properties  */
   public long handle = 0;
-
-
+  private String mgrs = "";
+  
+  public void setMgrs(String[] mgrs) {
+         for (String item : mgrs) {
+                 this.mgrs += item + ":";
+         }
+         
+         this.mgrs = this.mgrs.substring(0, this.mgrs.length()-1);
+         
+         if(!jORTEDomainPropMgrsSet())
+                 System.out.println(":j: Mgrs not set !!!");
+  }
+  
  /**
   * defaultPropsCreate - create DomainProp with handle to default
   * domain properties
@@ -67,6 +77,9 @@ public class DomainProp {
   */
   private static native
   long jORTEDomainPropDefaultGet();
+  
+  private native
+  boolean jORTEDomainPropMgrsSet();
 
 }
 
index 75bf2a8d104ff1ac8bf062a5ed3dd8549d1cdf82..7c4358a4b9161c7ce7563e69a686753e0ae07031 100644 (file)
@@ -62,7 +62,7 @@ Java_org_ocera_orte_DomainMgr_jORTEDomainDefaultMgrCreate
  *  create user manager domain *
  * *************************** */
 JNIEXPORT jlong JNICALL
-Java_org_ocera_orte_DomainMg_jORTEDomainMgrCreate
+Java_org_ocera_orte_DomainMgr_jORTEDomainMgrCreate
 (JNIEnv *env, jclass cls, jint jdomain, jlong propHandle,
  jlong eventsHandle, jboolean susp)
 {
index d38df5ef020da4b2ce616f4dd858337eebf224de..0ba620768d9a1942211587064e1498c23fbf806b 100644 (file)
@@ -42,14 +42,14 @@ Java_org_ocera_orte_DomainMgr_jORTEDomainMgrDestroy
 
   // call ORTE function
   b = ORTEDomainMgrDestroy((ORTEDomain *) dhandle);
-  if(b == ORTE_OK)
+  if(b == ORTE_TRUE)
   {
     #ifdef TEST_STAGE
       printf(":c: mgrDomain destroy successfully.. \n");
     #endif
     return 1;
   }
-  if (b == ORTE_BAD_HANDLE)
+  else
     printf(":!c: mgrDomain destroy failed! [bad domain handle] \n");
   return 0;
 }
diff --git a/orte/libjorte/JORTEDomainPropMgrsSet.c b/orte/libjorte/JORTEDomainPropMgrsSet.c
new file mode 100644 (file)
index 0000000..0beef4a
--- /dev/null
@@ -0,0 +1,83 @@
+#include <string.h>
+#include <stdlib.h>
+#include "orte.h"
+#include "jorte/4all.h"
+
+#include "jorte/org_ocera_orte_types_DomainProp.h"
+
+  JNIEXPORT jboolean JNICALL Java_org_ocera_orte_types_DomainProp_jORTEDomainPropMgrsSet
+  (JNIEnv *env, jobject obj)
+  {
+    jclass         cls_dp = NULL;
+    jfieldID       fid = NULL;
+    jobject        obj_str = NULL;
+    const char     *str = NULL;
+    //
+    int flag_ok = 0;
+
+    ORTEDomainProp *dp;
+
+       #ifdef TEST_STAGE
+         printf(":c: jORTEDomainPropMgrsSet() called.. \n");
+       #endif
+
+       do {
+               cls_dp = (*env)->GetObjectClass(env, obj);
+
+               if (cls_dp == 0) {
+                       printf(":!c: class 'org.ocera.orte.types.DomainProp' not found! \n");
+                       break;
+               }
+
+               fid = (*env)->GetFieldID(env,
+                                                cls_dp,
+                                                "handle",
+                                                "J");
+           if(fid == 0)
+           {
+             #ifdef TEST_STAGE
+               printf(":!c: fid = NULL \n");
+             #endif
+             break;
+           }
+           dp = (ORTEDomainProp *) (*env)->GetLongField(env, obj, fid);
+           if(dp == 0)
+           {
+             #ifdef TEST_STAGE
+               printf(":!c: *dp = NULL \n");
+             #endif
+             break;
+           }
+
+           fid = (*env)->GetFieldID(env,
+                                                        cls_dp,
+                                                        "mgrs",
+                                                        "Ljava/lang/String;");
+           if(fid == 0)
+           {
+             #ifdef TEST_STAGE
+               printf(":!c: fid = NULL \n");
+             #endif
+             break;
+           }
+
+           obj_str = (*env)->GetObjectField(env, obj, fid);
+           if(obj_str == 0)
+           {
+             #ifdef TEST_STAGE
+               printf(":!c: obj_str = NULL \n");
+             #endif
+             break;
+           }
+           str = (*env)->GetStringUTFChars(env,obj_str,0);
+           dp->mgrs=str;
+
+           flag_ok = 1;
+       } while (0);
+
+       if(flag_ok) {
+         return  ORTE_FALSE;
+       }
+
+       return ORTE_TRUE;
+  }
index bb1c0214183ccf07f6cfa48afa1fc7e776365d35..86b393d64dc28a6fcf12256549ec113a90a05d95 100644 (file)
@@ -33,6 +33,7 @@ JORTEDomainInitEvents.c \
 JORTEDomainMgrCreate.c \
 JORTEDomainMgrDestroy.c \
 JORTEDomainPropDefaultGet.c \
+JORTEDomainPropMgrsSet.c \
 JORTEDomainStart.c \
 JORTEInit.c \
 JORTEPublicationCreate.c \