minor changes
authorMaximilian Quellmalz <maximilian.quellmalz@mailbox.tu-dresden.de>
Thu, 24 Jul 2014 13:37:11 +0000 (15:37 +0200)
committerMaximilian Quellmalz <maximilian.quellmalz@mailbox.tu-dresden.de>
Thu, 24 Jul 2014 13:37:11 +0000 (15:37 +0200)
12 files changed:
.gitignore
Splitter-ng-plugin-JSharing/.directory [deleted file]
Splitter-ng-plugin-JSharing/src/.directory [deleted file]
Splitter-ng-plugin-bitsplitter/.classpath
Splitter-ng-plugin-bitsplitter/build.xml
Splitter-ng-plugin-bitsplitter/src/BitSplitter/.gitignore [new file with mode: 0644]
Splitter-ng-plugin-bitsplitter/src/bitsplitterplugin/BitsplitterPlugin.java
Splitter-ng-plugin-bitsplitter/src/bitsplitterplugin/CodecBitsplitter.java
Splitter-ng-plugin-bitsplitter/src/cz/adamh/utils/NativeUtils.java
Splitter-ng-plugin-jerasure/.directory [deleted file]
Splitter-ng-test/starttest
Splitter-ng/.directory [deleted file]

index 727bc05..400a411 100644 (file)
@@ -1 +1,2 @@
 .directory
+/dist/
diff --git a/Splitter-ng-plugin-JSharing/.directory b/Splitter-ng-plugin-JSharing/.directory
deleted file mode 100644 (file)
index 1712f09..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Dolphin]
-SortRole=orientation
-Timestamp=2013,11,7,18,6,2
-Version=3
-ViewMode=1
-VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails
-
-[Settings]
-HiddenFilesShown=true
diff --git a/Splitter-ng-plugin-JSharing/src/.directory b/Splitter-ng-plugin-JSharing/src/.directory
deleted file mode 100644 (file)
index b5b3950..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Dolphin]
-SortRole=orientation
-Timestamp=2013,11,7,18,6,59
-Version=3
-ViewMode=1
-VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails
-
-[Settings]
-HiddenFilesShown=true
index 6524273..79944ec 100644 (file)
@@ -7,6 +7,5 @@
                </attributes>
        </classpathentry>
        <classpathentry combineaccessrules="false" kind="src" path="/Splitter-ng"/>
-       <classpathentry kind="lib" path="bitsplitter/java/lib" sourcepath="bitsplitter/java"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 4851e44..286a97a 100644 (file)
@@ -13,7 +13,7 @@
   </path>
   <path id="Splitter-ng-plugin-bitsplitter.classpath">
     <pathelement location="bin"/>
-    <pathelement location="${bitsplitter.location}/java/lib"/>
+    <!--pathelement location="${bitsplitter.location}/java/lib"/-->
     <path refid="Splitter-ng.classpath"/>
   </path>
   <target name="init">
@@ -51,6 +51,7 @@
   <target name="clean">
     <delete dir="bin"/>
     <delete dir="lib"/>
+    <delete file="src/BitSplitter/BitSplitter.java" />
     <exec executable="make" dir="${bitsplitter.location}" failonerror="true">
       <arg line="-f Makefile clean"/>
     </exec>
     </javac>
   </target>
   <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
-  <target name="jni">
+  <target name="jni" depends="fetchbitsplitter">
     <exec executable="make" dir="${bitsplitter.location}" failonerror="true">
       <arg line="-f Makefile"/>
     </exec>
-    <!--copy todir="lib">
-    <fileset dir="${bitsplitter.location}/lib"/>
-    </copy-->
+       <exec executable="make" dir="${bitsplitter.location}/java" failonerror="true">
+       <arg line="-f Makefile"/>
+       </exec>
+       <mkdir dir="src/BitSplitter" />
+      <copy file="${bitsplitter.location}/java/BitSplitter.java"  todir="src/BitSplitter" />
   </target>
   <target name ="makejar" depends="build" description="Create a jar for the project">
     <jar jarfile="bin/${ant.project.name}.jar" >
       <fileset dir="bin" includes="**/*.class" />
-      <fileset dir="." includes="${bitsplitter.location}/java/lib/**/*.class" />
+      <!--fileset dir="." includes="${bitsplitter.location}/java/lib/**/*.class" /-->
       <fileset dir="." includes="${bitsplitter.location}/*.so" />
       <fileset dir="." includes="${bitsplitter.location}/java/*.so" />
     </jar>
diff --git a/Splitter-ng-plugin-bitsplitter/src/BitSplitter/.gitignore b/Splitter-ng-plugin-bitsplitter/src/BitSplitter/.gitignore
new file mode 100644 (file)
index 0000000..afcf4fd
--- /dev/null
@@ -0,0 +1 @@
+/BitSplitter.java
index b7cb04d..9148eb7 100644 (file)
@@ -1,10 +1,12 @@
 package bitsplitterplugin;
 
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Vector;
 
 import splitterng.plugin.CodecDescription;
 import splitterng.plugin.PluginDescription;
@@ -41,22 +43,32 @@ public class BitsplitterPlugin implements Plugable {
                // }
 
                try {
-                       // if (!libJerasureLoaded){
-                       // System.out.println("Skip loading Jerasure");
-                       BitsplitterPlugin.loadJerasureJni();
-                       // }
-                       try {
-                               //Liberation.liber8tion_coding_bitmatrix(3);
-                               // System.out.println("Correctly loaded libJerasure.so");
-                       } catch (UnsatisfiedLinkError e) {
-                               System.err
-                                               .println("Native code library failed to load: libJerasure.so \n"
-                                                               + e);
-                       }
+                               BitsplitterPlugin.loadNative();
+
                } catch (UnsatisfiedLinkError e) {
                        System.err
-                                       .println("Native code library failed to load: libJerasure.jni.so \n"
+                                       .println("Native code library failed to load \n"
                                                        + e);
+                       Field loadedLibraryNamesField = null;
+                       try {
+                               loadedLibraryNamesField = ClassLoader.class
+                                  .getDeclaredField("loadedLibraryNames");
+                       } catch (NoSuchFieldException | SecurityException e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
+                   loadedLibraryNamesField.setAccessible(true);
+                   @SuppressWarnings("unchecked")
+                       Vector<String> loadedLibraryNames = null;
+                       try {
+                               loadedLibraryNames = (Vector<String>) loadedLibraryNamesField.get(null);
+                       } catch (IllegalArgumentException | IllegalAccessException en) {
+                               // TODO Auto-generated catch block
+                               en.printStackTrace();
+                       }
+                   for (String string : loadedLibraryNames) {
+                       System.out.println(string);
+                   }
                }
 
                // codecMap.put(JerasureCodecParity.getCodecDescription().getCodecID(),
@@ -77,12 +89,14 @@ public class BitsplitterPlugin implements Plugable {
 
        }
 
-       public static void loadJerasureJni() {
+       public static void loadNative() {
                try {
+                       System.out.println("try libbitsplit.so");
                        NativeUtils
-                                       .loadLibraryFromJar("/bitsplitter/libbitsplit.so");
+                                       .loadLibraryFromJar("/dispersedalgorithms/bitsplitter/libbitsplit.so");
+                       System.out.println("try libjbitsplitter.so");
                        NativeUtils
-                                       .loadLibraryFromJar("/bitsplitter/java/libjbitsplitter.so");
+                                       .loadLibraryFromJar("/dispersedalgorithms/bitsplitter/java/libjbitsplitter.so");
                } catch (IOException e) {
                        e.printStackTrace();
                        System.out
index ad3ed69..4004579 100644 (file)
@@ -97,8 +97,8 @@ public class CodecBitsplitter implements SplitterCodec {
                        coding_ptrs[i-k]=dataAndCoding_ptrs[i];
                }
                
-               //Jerasure.jerasure_matrix_encode(k, m, w, matrix, data_ptrs, coding_ptrs, blocksize);
-               bs.bitjoinfile(null, null, (Integer) null);
+               throw new IllegalArgumentException("Decoding not jet implemented... sorry");
+               //bs.bitjoinfile(null, null, (Integer) null);
 
                return data_ptrs;
        }
@@ -120,6 +120,7 @@ public class CodecBitsplitter implements SplitterCodec {
                 * Array packen
                 * zurückgeben
                 */
+               //Path tempDir = Files.createTempDirectory("bitsplittemp");
                bs.bitsplitfile(null, null, k, m);
                
                                
@@ -149,4 +150,8 @@ public class CodecBitsplitter implements SplitterCodec {
                        dataAndCoding_ptrs = new byte[k+m][fragmentsize];
                }
        }
+       private void fill(int fragmentsize) {
+       
+       }
+       
 }
\ No newline at end of file
index 33bf3d9..581eac0 100644 (file)
@@ -6,6 +6,11 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Vector;
  
 /**
  * Simple library class for working with JNI (Java Native Interface)
@@ -58,9 +63,21 @@ public class NativeUtils {
                }
  
                // Prepare temporary file
-               File temp = File.createTempFile(prefix, suffix);
+               //Path tempDir = Files.createTempDirectory("tempfiles");
+               Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));
+               File temp = new File(tempDir.toString(),prefix+suffix);
+               Files.createFile(temp.toPath());
                temp.deleteOnExit();
+               
+               // Prepare temporary file
+               //File temp = File.createTempFile(prefix, suffix);
+               //temp.deleteOnExit();
  
+               
+               System.out.println("Librarypath "+System.getProperty("java.library.path"));
+               //System.setProperty( "java.library.path", System.getProperty("java.library.path") + ":" + tempDir );
+               //System.out.println("Librarypath "+System.getProperty("java.library.path"));
+                
                if (!temp.exists()) {
                        throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist.");
                }
@@ -89,5 +106,7 @@ public class NativeUtils {
  
                // Finally, load the library
                System.load(temp.getAbsolutePath());
+               //System.out.println(temp.getAbsolutePath()+" geladen");
+
        }
 }
diff --git a/Splitter-ng-plugin-jerasure/.directory b/Splitter-ng-plugin-jerasure/.directory
deleted file mode 100644 (file)
index cc1fe07..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-[Dolphin]
-HeaderColumnWidths=294,83,146,164
-SortRole=orientation
-Timestamp=2014,5,20,10,30,30
-Version=3
-ViewMode=1
-VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails
-
-[Settings]
-HiddenFilesShown=true
index 04fa87b..b267fea 100755 (executable)
@@ -2,5 +2,5 @@
 #Nicht mehr nötig wenn jerasure im plugin-jar ist
 #PWD="`dirname \`readlink -f $0\``"
 #cd $PWD
-#LD_LIBRARY_PATH="$PWD/plugin/" java -jar splittertest.jar
-java -jar Splitter-ng-test.jar
+LD_LIBRARY_PATH="/tmp/:$PWD/plugin/" java -jar Splitter-ng-test.jar
+#java -jar Splitter-ng-test.jar
diff --git a/Splitter-ng/.directory b/Splitter-ng/.directory
deleted file mode 100644 (file)
index d0771be..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[Dolphin]
-SortOrder=1
-Timestamp=2013,11,7,17,53,2
-Version=3
-ViewMode=1
-VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails
-
-[Settings]
-HiddenFilesShown=true