Modyfy Splitter: Additional constructors. Now only k and m are necessary
authorMaximilian Quellmalz <maximilian.quellmalz@mailbox.tu-dresden.de>
Tue, 11 Nov 2014 19:45:27 +0000 (20:45 +0100)
committerMaximilian Quellmalz <maximilian.quellmalz@mailbox.tu-dresden.de>
Tue, 11 Nov 2014 19:45:27 +0000 (20:45 +0100)
Modyfy CodecDescription:  introduce default values.
Modify SplitterTest: use default parameter
Modify all Codecs: introduce default parameter, modify Parameter Check

16 files changed:
Splitter-ng-plugin-JSharing/src/ShamirCodec.java
Splitter-ng-plugin-bitsplitter/src/bitsplitterplugin/BitsplitterPlugin.java
Splitter-ng-plugin-bitsplitter/src/bitsplitterplugin/CodecBitsplitter.java
Splitter-ng-plugin-jerasure-purejava/src/hpijerasureplugin/JavaCRSCodec.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/CodecBlaumRoth.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/CodecCauchyGood.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/CodecCauchyOrg.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/CodecLiber8tion.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/CodecLiberation.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/CodecReedSolomonVandermonde.java
Splitter-ng-plugin-jerasure/src/jerasureplugin/JerasurePlugin.java
Splitter-ng-plugin-jigdfs/src/jigdfsplugin/CodecJigDFS.java
Splitter-ng-plugin-raid1/src/CodecRaid1.java
Splitter-ng-test/src/SplitterTest.java
Splitter-ng/src/splitterng/Splitter.java
Splitter-ng/src/splitterng/plugin/CodecDescription.java

index dcd5bc1..e63de12 100644 (file)
@@ -23,6 +23,7 @@ public class ShamirCodec implements SplitterCodec {
        public final static String codecDescriptionText = "Shamir Codec. numBits: number of bits of p";
 
        public final static Map<String, Integer[]> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k, m, numBits; // number of bits of p
 
@@ -35,10 +36,15 @@ public class ShamirCodec implements SplitterCodec {
                // TODO grenzen für numBits
 
                codecParameterMinMax = Collections.unmodifiableMap(tmpMap);
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               //leer
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
 
        private static final CodecDescription codecDescription = new CodecDescription(
-                       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+                       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
 
        private byte[][] data_ptrs;
        private byte[] data_ptrs_flat;
@@ -54,8 +60,8 @@ public class ShamirCodec implements SplitterCodec {
         */
        public ShamirCodec(Map<String, Integer> codecParameter) {
 
-               // Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : ShamirCodec.codecParameterMinMax
+               //Test CodecParameter
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -71,6 +77,8 @@ public class ShamirCodec implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
index c831611..c34314e 100644 (file)
@@ -91,10 +91,10 @@ public class BitsplitterPlugin implements Plugable {
 
        public static void loadNative() {
                try {
-                       System.out.println("try libbitsplit.so");
+                       //System.out.println("try libbitsplit.so");
                        NativeUtils
                                        .loadLibraryFromJar("/dispersedalgorithms/bitsplitter/libbitsplit.so");
-                       System.out.println("try libjbitsplitter.so");
+                       //System.out.println("try libjbitsplitter.so");
                        NativeUtils
                                        .loadLibraryFromJar("/dispersedalgorithms/bitsplitter/java/libjbitsplitter.so");
                } catch (IOException e) {
index 3f5e47f..2eb4757 100644 (file)
@@ -26,6 +26,7 @@ public class CodecBitsplitter implements SplitterCodec {
        public final static String codecDescriptionText = "Simple bitsplitter. 1234567812345678 -> 12341234 56785678";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize;
        
@@ -35,11 +36,16 @@ public class CodecBitsplitter implements SplitterCodec {
                tmpMap.put("m", new Integer[] {new Integer(0),new Integer(1)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               //leer
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
     private byte[][] coding_ptrs;
        private byte[][] data_ptrs;
@@ -60,7 +66,7 @@ public class CodecBitsplitter implements SplitterCodec {
        public CodecBitsplitter(Map<String, Integer> codecParameter) {
                super();
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecBitsplitter.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -76,6 +82,8 @@ public class CodecBitsplitter implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
index bee97f5..5131a3f 100644 (file)
@@ -28,6 +28,7 @@ public class JavaCRSCodec implements SplitterCodec {
                        + "\nRequirements:   (fragmentsize % (packetsize * w)) == 0";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize;
        
@@ -39,11 +40,17 @@ public class JavaCRSCodec implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(8));
+               tmpMap2.put("packetsize", new Integer(8));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private Matrix matrix;
        private BitMatrix bitmatrix;
@@ -76,7 +83,7 @@ public class JavaCRSCodec implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : JavaCRSCodec.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -92,11 +99,14 @@ public class JavaCRSCodec implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
                        }
                }
+
                
                k=(int)codecParameter.get("k");
                m=(int)codecParameter.get("m");
index 6699763..8950a4f 100644 (file)
@@ -20,6 +20,7 @@ public class CodecBlaumRoth implements SplitterCodec {
                        + "Requirements: k<=w , m=2 , w>=4 and w+1 must be prim";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize=0;
        
@@ -31,11 +32,17 @@ public class CodecBlaumRoth implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+               
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(4));
+               tmpMap2.put("packetsize", new Integer(8));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -59,7 +66,7 @@ public class CodecBlaumRoth implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecBlaumRoth.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -75,11 +82,14 @@ public class CodecBlaumRoth implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
                        }
                }
+
                
                k=(int)codecParameter.get("k");
                m=(int)codecParameter.get("m");
index eb1f70a..f0514e8 100644 (file)
@@ -24,6 +24,7 @@ public class CodecCauchyGood implements SplitterCodec {
                        + "\nRequirements:   (fragmentsize % (packetsize * w)) == 0";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize;
        
@@ -35,11 +36,16 @@ public class CodecCauchyGood implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(8));
+               tmpMap2.put("packetsize", new Integer(8));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
-       
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -63,7 +69,7 @@ public class CodecCauchyGood implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecCauchyGood.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -79,6 +85,8 @@ public class CodecCauchyGood implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
index 04a3c8a..c0d1a3b 100644 (file)
@@ -19,6 +19,7 @@ public class CodecCauchyOrg implements SplitterCodec {
                        + "\nRequirements:   (fragmentsize % (packetsize * w)) == 0";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize;
        
@@ -30,11 +31,17 @@ public class CodecCauchyOrg implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(8));
+               tmpMap2.put("packetsize", new Integer(8));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2); 
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -58,7 +65,7 @@ public class CodecCauchyOrg implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecCauchyOrg.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -74,6 +81,8 @@ public class CodecCauchyOrg implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
index 4cc80b4..7f863e5 100644 (file)
@@ -20,6 +20,7 @@ public class CodecLiber8tion implements SplitterCodec {
                        + "Requirements: k<=w , m=2 , w=8";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize=0;
        
@@ -31,11 +32,17 @@ public class CodecLiber8tion implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(32),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               //tmpMap2.put("w", new Integer(8));
+               tmpMap2.put("packetsize", new Integer(32));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -59,7 +66,7 @@ public class CodecLiber8tion implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecLiber8tion.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -75,11 +82,14 @@ public class CodecLiber8tion implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
                        }
                }
+
                
                k=(int)codecParameter.get("k");
                m=(int)codecParameter.get("m");
index af0746d..45ca704 100644 (file)
@@ -20,6 +20,7 @@ public class CodecLiberation implements SplitterCodec {
                        + "Requirements: k<=w , m=2 , w>=3 and prim";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize;
        
@@ -31,11 +32,17 @@ public class CodecLiberation implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(7));
+               tmpMap2.put("packetsize", new Integer(32));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -59,7 +66,7 @@ public class CodecLiberation implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecLiberation.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -75,6 +82,8 @@ public class CodecLiberation implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
index 7123813..be74a02 100644 (file)
@@ -17,6 +17,7 @@ public class CodecReedSolomonVandermonde  implements SplitterCodec {
        public final static String codecDescriptionText = "This Codec implements Reed Solomon coding with Vandermonde Distribution Matrices.";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w;//,packetsize;
        
@@ -28,11 +29,16 @@ public class CodecReedSolomonVandermonde  implements SplitterCodec {
                //tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(8));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -56,7 +62,7 @@ public class CodecReedSolomonVandermonde  implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecReedSolomonVandermonde.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -72,11 +78,14 @@ public class CodecReedSolomonVandermonde  implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
                        }
                }
+
                
                k=(int)codecParameter.get("k");
                m=(int)codecParameter.get("m");
index 9ad693e..44f86cb 100644 (file)
@@ -68,8 +68,7 @@ public class JerasurePlugin implements Plugable {
                this.codecDescriptions = new LinkedList<CodecDescription>();
                this.codecDescriptions.add(CodecCauchyGood.getCodecDescription());
                this.codecDescriptions.add(CodecCauchyOrg.getCodecDescription());
-               this.codecDescriptions.add(CodecReedSolomonVandermonde
-                               .getCodecDescription());
+               this.codecDescriptions.add(CodecReedSolomonVandermonde.getCodecDescription());
                this.codecDescriptions.add(CodecLiberation.getCodecDescription());
                this.codecDescriptions.add(CodecLiber8tion.getCodecDescription());
                this.codecDescriptions.add(CodecBlaumRoth.getCodecDescription());
index 3cf1394..9a52848 100644 (file)
@@ -24,17 +24,23 @@ public class CodecJigDFS implements SplitterCodec {
        public final static String codecName = "JigDFS CRS Codec";
        public final static String codecDescriptionText = "Dieser Codec verwendet JigDFS";
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
        static {
                // ParameterMinMax Map erstellen
                Map <String, Integer []> tmpMap = new HashMap<String, Integer[]>();
-               tmpMap.put("k", new Integer[] {new Integer(1),new Integer(1)});
-               tmpMap.put("m", new Integer[] {new Integer(1),new Integer(1)});
+               tmpMap.put("k", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
+               tmpMap.put("m", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                tmpMap.put("chunksize", new Integer[] {new Integer(1),new Integer(4096)});
                // Weitere Parameter hier einfügen und deren Grenzen festlegen
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("chunksize", new Integer(16));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        // codecDescription bauen und statisch zur Verfügung stellen
-       private static final CodecDescription codecDescription = new CodecDescription(codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       private static final CodecDescription codecDescription = new CodecDescription(codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        public static final CodecDescription getCodecDescription(){
                return CodecJigDFS.codecDescription;
        }
@@ -55,7 +61,7 @@ public class CodecJigDFS implements SplitterCodec {
                codecParameter.put("k", k);
                codecParameter.put("m", m);
 //             codecParameter.put("packetsize", 4096);
-               codecParameter.put("chunksize", 64);
+//             codecParameter.put("chunksize", 64);
                init(codecParameter);
        }
        
@@ -64,40 +70,42 @@ public class CodecJigDFS implements SplitterCodec {
        }
        
        private void init(Map<String, Integer> codecParameter) {
-               // Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecJigDFS.codecParameterMinMax
+               //Test CodecParameter
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
-                               // Test ob Parameter vorhanden und in den gültigen grenzen liegen
-                               if (codecParameter.get(requiredEntry.getKey()) < requiredEntry
-                                               .getValue()[0])
-                                       new IllegalArgumentException(
+                               // Test ob Parameter vorhanden und in den gültigen grenzen
+                               // liegen
+                               //System.out.println("Test" +codecParameter.get(requiredEntry.getKey()) +" "+  requiredEntry.getValue()[0]);
+                               if (codecParameter.get(requiredEntry.getKey()) < requiredEntry.getValue()[0])
+                                       throw new IllegalArgumentException(
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " < "
                                                                        + requiredEntry.getValue()[0]);
-                               if (codecParameter.get(requiredEntry.getKey()) > requiredEntry
-                                               .getValue()[1])
-                                       new IllegalArgumentException(
+                               if (codecParameter.get(requiredEntry.getKey()) > requiredEntry.getValue()[1])
+                                       throw new IllegalArgumentException(
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
                        }
-                       k = (int) codecParameter.get("k");
-                       m = (int) codecParameter.get("m");
-                       chunkSize = (int) codecParameter.get("chunksize");
+               }
+               k = (int) codecParameter.get("k");
+               m = (int) codecParameter.get("m");
+               chunkSize = (int) codecParameter.get("chunksize");
                        
-                       try {
-                               crsidacodec = new CauchyInformationDispersalCodec(k+m, m, chunkSize);
-                               encoder = crsidacodec.getEncoder();
-                               decoder = crsidacodec.getDecoder();
-                       } catch (IDAInvalidParametersException e) {
-                               throw new IllegalArgumentException("JigDFS IDAInvalidParametersException: \n"+e.toString());
-                       } catch (IDANotInitializedException e) {
-                               throw new IllegalArgumentException("JigDFS IDANotInitializedException: \n"+e.toString());
-                       }
+               try {
+                       crsidacodec = new CauchyInformationDispersalCodec(k+m, m, chunkSize);
+                       encoder = crsidacodec.getEncoder();
+                       decoder = crsidacodec.getDecoder();
+               } catch (IDAInvalidParametersException e) {
+                       throw new IllegalArgumentException("JigDFS IDAInvalidParametersException: \n"+e.toString());
+               } catch (IDANotInitializedException e) {
+                       throw new IllegalArgumentException("JigDFS IDANotInitializedException: \n"+e.toString());
                }
        }
 
index 240dc60..786254d 100644 (file)
@@ -12,6 +12,7 @@ public class CodecRaid1 implements SplitterCodec {
        public final static String codecName = "Raid1 Codec";
        public final static String codecDescriptionText = "Dieser Codec repliziert die ursprüngliche Datei";
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
        static {
                // ParameterMinMax Map erstellen
                Map <String, Integer []> tmpMap = new HashMap<String, Integer[]>();
@@ -19,9 +20,15 @@ public class CodecRaid1 implements SplitterCodec {
                tmpMap.put("m", new Integer[] {new Integer(1),new Integer(1)});
                // Weitere Parameter hier einfügen und deren Grenzen festlegen
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               //leer
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        // codecDescription bauen und statisch zur Verfügung stellen
-       private static final CodecDescription codecDescription = new CodecDescription(codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       private static final CodecDescription codecDescription = new CodecDescription(codecID, codecName,
+                       codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        public static final CodecDescription getCodecDescription(){
                return CodecRaid1.codecDescription;
        }
@@ -33,31 +40,34 @@ public class CodecRaid1 implements SplitterCodec {
        
        public CodecRaid1(Map<String, Integer> codecParameter) {
                
-               // Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecRaid1.codecParameterMinMax
+               //Test CodecParameter
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
-                               // Test ob Parameter vorhanden und in den gültigen grenzen liegen
-                               if (codecParameter.get(requiredEntry.getKey()) < requiredEntry
-                                               .getValue()[0])
-                                       new IllegalArgumentException(
+                               // Test ob Parameter vorhanden und in den gültigen grenzen
+                               // liegen
+                               //System.out.println("Test" +codecParameter.get(requiredEntry.getKey()) +" "+  requiredEntry.getValue()[0]);
+                               if (codecParameter.get(requiredEntry.getKey()) < requiredEntry.getValue()[0])
+                                       throw new IllegalArgumentException(
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " < "
                                                                        + requiredEntry.getValue()[0]);
-                               if (codecParameter.get(requiredEntry.getKey()) > requiredEntry
-                                               .getValue()[1])
-                                       new IllegalArgumentException(
+                               if (codecParameter.get(requiredEntry.getKey()) > requiredEntry.getValue()[1])
+                                       throw new IllegalArgumentException(
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());
                        }
-                       k = (int) codecParameter.get("k");
-                       m = (int) codecParameter.get("m");
                }
-       }
+               
+               k = (int) codecParameter.get("k");
+               m = (int) codecParameter.get("m");
+       }
 
        @Override
        public byte[][] encode(byte[][] data_ptrs){
index 8d873e4..aebb931 100644 (file)
@@ -54,7 +54,7 @@ public class SplitterTest implements SplitterCallback {
                                for (Entry<String, Integer[]> e : codecParameterMinMax
                                                .entrySet()) {
                                        System.out.println("\t|\t" + e.getKey() + "\tmin:"
-                                                       + e.getValue()[0] + "  max:" + e.getValue()[1]);
+                                                       + e.getValue()[0] + "  max:" + e.getValue()[1] + " default: " + c.getCodecParameterDefaults().get(e.getKey()));
                                }
                                // Wenn hier eine Konfiguration für eine plugin-codec
                                // Kombination vorhanden ist, wird der Splitter initialisiert.
@@ -68,8 +68,8 @@ public class SplitterTest implements SplitterCallback {
                                        Map<String, Integer> codecParameter = new TreeMap<String, Integer>();
                                        codecParameter.put("k", 2);
                                        codecParameter.put("m", 2);
-                                       codecParameter.put("w", 8);
-                                       codecParameter.put("packetsize", 8);
+                                       //codecParameter.put("w", 8);
+                                       //codecParameter.put("packetsize", 8);
                                        System.out.println("\t\tinitialisiere mit" + " k="
                                                        + codecParameter.get("k") + " m="
                                                        + codecParameter.get("m") + " w="
@@ -94,8 +94,8 @@ public class SplitterTest implements SplitterCallback {
                                        Map<String, Integer> codecParameter1 = new TreeMap<String, Integer>();
                                        codecParameter1.put("k", 3);
                                        codecParameter1.put("m", 3);
-                                       codecParameter1.put("w", 16);
-                                       codecParameter1.put("packetsize", 64);
+                                       //codecParameter1.put("w", 16);
+                                       //codecParameter1.put("packetsize", 64);
                                        System.out.println("\t\tinitialisiere mit" + " k="
                                                        + codecParameter1.get("k") + " m="
                                                        + codecParameter1.get("m") + " w="
@@ -120,12 +120,11 @@ public class SplitterTest implements SplitterCallback {
                                        Map<String, Integer> codecParameter2 = new TreeMap<String, Integer>();
                                        codecParameter2.put("k", 3);
                                        codecParameter2.put("m", 2);
-                                       //codecParameter.put("w", 16);
                                        codecParameter2.put("packetsize", 64);
-                                       System.out.println("\t\tinitialisiere mit" + " k="
-                                                       + codecParameter2.get("k") + " m="
-                                                       + codecParameter2.get("m") + " w="
-                                                       + codecParameter2.get("packetsize"));
+                                       System.out.println("\t\tinitialisiere mit"
+                                                       + " k=" + codecParameter2.get("k") 
+                                                       + " m=" + codecParameter2.get("m")
+                                                       + " packetsize=" + codecParameter2.get("packetsize"));
                                        // Splitter mit Plugin-ID CodecID und codecparametern
                                        // initialisieren
                                        Splitter splitterjerasure2 = new Splitter(p.getPluginID(), c.getCodecID(),
@@ -145,11 +144,10 @@ public class SplitterTest implements SplitterCallback {
                                        Map<String, Integer> codecParameternoop = new TreeMap<String, Integer>();
                                        codecParameternoop.put("k", 1);
                                        codecParameternoop.put("m", 1);
-                                       // codecParameternoop.put("w", 4);
-                                       //codecParameternoop.put("packetsize", 16);
-                                       System.out.println("\t\tinitialisiere mit k="
-                                                       + codecParameternoop.get("k") + " m="
-                                                       + codecParameternoop.get("m"));
+                                       System.out.println("\t\tinitialisiere mit"
+                                                       + " k=" + codecParameternoop.get("k")
+                                                       + " m=" + codecParameternoop.get("m")
+                                                       );
                                        // Splitter mit Plugin-ID CodecID und codecparametern
                                        // initialisieren
                                        Splitter splitterraid1 = new Splitter(p.getPluginID(), c.getCodecID(),
@@ -192,13 +190,14 @@ public class SplitterTest implements SplitterCallback {
                                        Map<String, Integer> codecParameter11 = new TreeMap<String, Integer>();
                                        codecParameter11.put("k", 2);
                                        codecParameter11.put("m", 2);
-                                       codecParameter11.put("w", 8);
-                                       codecParameter11.put("packetsize", 8);
-                                       System.out.println("\t\tinitialisiere mit" + " k="
-                                                       + codecParameter11.get("k") + " m="
-                                                       + codecParameter11.get("m") + " w="
-                                                       + codecParameter11.get("w") + " packetsize="
-                                                       + codecParameter11.get("packetsize"));
+                                       //codecParameter11.put("w", 8);
+                                       //codecParameter11.put("packetsize", 8);
+                                       System.out.println("\t\tinitialisiere mit"
+                                                       + " k=" + codecParameter11.get("k")
+                                                       + " m=" + codecParameter11.get("m") 
+                                                       + " w=" + codecParameter11.get("w")
+                                                       + " packetsize=" + codecParameter11.get("packetsize")
+                                                       );
                                        // Splitter mit Plugin-ID CodecID und codecparametern
                                        // initialisieren
                                        Splitter splitterjerasure11 = new Splitter(p.getPluginID(), c.getCodecID(),
@@ -219,11 +218,12 @@ public class SplitterTest implements SplitterCallback {
                                        Map<String, Integer> codecParameter111 = new TreeMap<String, Integer>();
                                        codecParameter111.put("k", 2);
                                        codecParameter111.put("m", 1);
-                                       codecParameter111.put("chunksize", 16);
+                                       //codecParameter111.put("chunksize", 16);
                                        System.out.println("\t\tinitialisiere mit" + " k="
                                                        + codecParameter111.get("k") + " m="
-                                                       + codecParameter111.get("m") + " chunksize="
-                                                       + codecParameter111.get("chunksize"));
+                                                       + codecParameter111.get("m")
+                                                       + " chunksize=" + codecParameter111.get("chunksize")
+                                                       );
                                        // Splitter mit Plugin-ID CodecID und codecparametern
                                        // initialisieren
                                        Splitter splitterjerasure111 = new Splitter(p.getPluginID(), c.getCodecID(),
@@ -243,11 +243,11 @@ public class SplitterTest implements SplitterCallback {
                                case "bitsplitter/bitsplitter":
                                        // Codecparameter Bauen
                                        Map<String, Integer> codecParameter1111 = new TreeMap<String, Integer>();
-                                       codecParameter1111.put("k", 3);
-                                       codecParameter1111.put("m", 1);
+                                       codecParameter1111.put("k", 4);
+                                       codecParameter1111.put("m", 0);
                                        System.out.println("\t\tinitialisiere mit" + " k="
                                                        + codecParameter1111.get("k") + " m="
-                                                       + codecParameter1111.get("m") + " w=" );
+                                                       + codecParameter1111.get("m"));
                                        // Splitter mit Plugin-ID CodecID und codecparametern
                                        // initialisieren
                                        Splitter splitter1111 = new Splitter(p.getPluginID(), c.getCodecID(),
@@ -256,7 +256,7 @@ public class SplitterTest implements SplitterCallback {
                                        
                                        // Metadaten bauen vorlage
                                        Map<String, Object> metadata1111 = new TreeMap<String, Object>();
-                                       metadata1111.put("fragmentsize", (int) 43);
+                                       metadata1111.put("fragmentsize", (int) 409600);
                                        // Beleiebige weitere Metadaten
                                        
                                        splitter_metadata_map.put(splitter1111, metadata1111);
index 4ee96eb..ff9d1b6 100644 (file)
@@ -3,6 +3,7 @@ package splitterng;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -59,19 +60,34 @@ public class Splitter {
        public Splitter(String pluginID, String codecID,
                        Map<String, Integer> codecParameter)
                        throws IllegalArgumentException {
+       
+               checkAndSetPlugin(pluginID, codecID);
+               this.codecParameter = codecParameter;
+               start();
                
-               this.statistics = new Statistics(); 
+       }
+       
+       public Splitter(String pluginID, String codecID, int k, int m)
+                       throws IllegalArgumentException {
                
                checkAndSetPlugin(pluginID, codecID);
-
-               // TODO Codecparameter hier Testen?
-               // Store codec Parameter in field
-               this.codecParameter = codecParameter;
-
+               this.codecParameter = new HashMap<String, Integer>();
+               codecParameter.put("k", k);
+               codecParameter.put("m", m);
                start();
                
        }
-
+       
+       public Splitter(String pluginID, String codecID, int k, int m, Map<String, Integer> codecParameter)
+                       throws IllegalArgumentException {
+               
+               checkAndSetPlugin(pluginID, codecID);
+               this.codecParameter = codecParameter;
+               codecParameter.put("k", k);
+               codecParameter.put("m", m);
+               start();
+               
+       }       
        private void checkAndSetPlugin(String pluginID, String codecID)
                        throws IllegalArgumentException {
                // Search Plugin an store in field, throw exception if plugin not found
@@ -103,6 +119,7 @@ public class Splitter {
        }
        
        public void start(int count) {
+               this.statistics = new Statistics(); 
                // generate SplitterWorker
                for (int i = 0; i < count; i++) {
                        
index 5e0bc1b..36b6706 100644 (file)
@@ -8,6 +8,7 @@ public class CodecDescription {
        private String codecName;
        private String codecDescriptionText;
        private Map<String,Integer[]> codecParameterMinMax;
+       private Map<String,Integer> codecParameterDefaults;
 
 
        /**
@@ -15,15 +16,18 @@ public class CodecDescription {
         * @param codecName
         * @param codecDescriptionText
         * @param codecParameterMinMax
+        * @param codecParameterDefaults
         */
        public CodecDescription(String codecID, String codecName,
                        String codecDescriptionText,
-                       Map<String, Integer[]> codecParameterMinMax) {
+                       Map<String, Integer[]> codecParameterMinMax,
+                       Map<String, Integer> codecParameterDefaults) {
                super();
                this.codecID = codecID;
                this.codecName = codecName;
                this.codecDescriptionText = codecDescriptionText;
                this.codecParameterMinMax = codecParameterMinMax;
+               this.codecParameterDefaults = codecParameterDefaults;
        }
 
 
@@ -50,6 +54,14 @@ public class CodecDescription {
                return this.codecParameterMinMax;
        }
 
+       /**
+        * @param codecID
+        * @return a Map of  <parameter name, Array [minimal value, maximal value ]>
+        * @throws IllegalArgumentException
+        */
+       public Map<String,Integer> getCodecParameterDefaults(){
+               return this.codecParameterDefaults;
+       }
 
        @Override
        public String toString() {