Commit 0fbf0e09 authored by lichenchong's avatar lichenchong
Browse files

1. Add proto file sync and build scripts; Add script usages instruction

in readme.txt.
2. Modify capacity type from float to long in CapacityUtil.
3. Modify the simulator version in ConfigurationUtil.
parent bf447a00
Loading
Loading
Loading
Loading

bin/buildProto.sh

0 → 100755
+13 −0
Original line number Diff line number Diff line
#! /usr/bin/env bash
BASE_DIR=`dirname "$0"`/..
BASE_DIR=`cd "$BASE_DIR"; pwd`
#echo "BASE_DIR=$BASE_DIR"

echo "Compile protocol file."
protoc --proto_path=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto --java_out=$BASE_DIR/kinetic-common/src/main/java/ $BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kinetic.proto
protoc --proto_path=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto --java_out=$BASE_DIR/kinetic-common/src/main/java/ $BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kineticDb.proto
protoc --proto_path=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto --java_out=$BASE_DIR/kinetic-common/src/main/java/ $BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kineticIo.proto

echo "Compile finished."

exit 0
 No newline at end of file
+23 −1
Original line number Diff line number Diff line
@@ -223,3 +223,25 @@ Usage of Kinetic Admin API script
   After setup new cluster version (sh kineticAdmin.sh -setup -newclversion 1) for the simulator/drive
         sh kineticAdmin.sh -firmware /Users/Emma/123.run -host 10.24.70.123 -clversion 1  
         
Usage of proto scripts
===========================
1. Sync protocol file from Kinetic-Protocol github repo [https://github.com/Seagate/Kinetic-Protocol.git] to local.
   $sh syncProtoFromRepo.sh  to get the latest version.
   $sh syncProtoFromRepo.sh $commitHash to get the commit hash version. 
   For example,
   $sh syncProtoFromRepo.sh c4c95530b099c4882f3229560038e427e85fe219
   
2. Build protocol file locally, including compile kinetic.proto, kineticDb.proto, kineticIo.proto.
   $sh buildProto.sh










                    
       
 No newline at end of file
+31 −0
Original line number Diff line number Diff line
#! /usr/bin/env bash
BASE_DIR=`dirname "$0"`/..
BASE_DIR=`cd "$BASE_DIR"; pwd`
#echo "BASE_DIR=$BASE_DIR"

CLONE_DIR=$BASE_DIR/bin/Kinetic-ProtocoL

if [ -d "$CLONE_DIR" ]; then
    rm -rf "$CLONE_DIR"
fi

if [ $# -eq 0 ]; then
    echo "Clone protocol file from github:"
    git clone https://github.com/Seagate/Kinetic-Protocol.git $CLONE_DIR
fi

if [ $# -eq 1 ]; then
    echo "Clone protocol file $1 from github:"
    git clone https://github.com/Seagate/Kinetic-Protocol.git $CLONE_DIR
    cd $CLONE_DIR
    git checkout $1
    echo "$1"
fi

cp $CLONE_DIR/kinetic.proto $BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kinetic.proto

rm -rf "$CLONE_DIR"

echo "Sync protocol file finished."

exit 0
+9 −14
Original line number Diff line number Diff line
@@ -44,22 +44,20 @@ public abstract class CapacityUtil {
    private static long MB = 1000000;

    public static Capacity getCapacity() {
        // return CapacityGenerator.generate();

        Capacity capacity = null;

        try {
            // XXX 10/18/2013 chiaming: use db file path
            File file = new File("/");

            float total = (float) Double.parseDouble(format.format(file
            long total = (long)Double.parseDouble(format.format(file
                    .getTotalSpace() / MB));

            float remaining = (float) Double.parseDouble(format.format(file
            long remaining = (long) Double.parseDouble(format.format(file
                    .getFreeSpace() / MB));

            capacity = Capacity.newBuilder().setTotal((long) total)
                    .setRemaining((long) remaining).build();
            capacity = Capacity.newBuilder().setTotal(total)
                    .setRemaining(remaining).build();

        } catch (Exception e) {

@@ -74,19 +72,16 @@ public abstract class CapacityUtil {

class CapacityGenerator {
    private static final Random random = new Random();
    private static final float TB = 1024 * 1024; // Unit: MB
    private static final long TB = 1024 * 1024; // Unit: MB

    public static Capacity generate() {
        float total = 4 * TB;
        float remaining = total * random.nextFloat();
        DecimalFormat df = new DecimalFormat("########.00");
        double remainValue = Double.parseDouble(df.format(remaining));
        long total = 4 * TB;
        long remaining = total * random.nextLong();

        Capacity capacity = null;
        capacity = Capacity.newBuilder().setTotal((long) total)
                .setRemaining((long) remainValue).build();
        capacity = Capacity.newBuilder().setTotal(total)
                .setRemaining(remaining).build();

        return capacity;
    }

}
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public abstract class ConfigurationUtil {
    private final static String MODEL = "Simulator";
    private final static byte[] SERIAL_NUMBER = "93C3DAFD-C894-3C88-A4B0-632A90D2A04B"
            .getBytes(Charset.forName("UTF-8"));
    private final static String VERSION = "0.5.0.1-SNAPSHOT";
    private final static String VERSION = "0.6.0.1-SNAPSHOT";
    private final static String COMPILATION_DATE = new Date().toString();
    private final static String SOURCE_HASH = "aee0d511896d85da71eb24e1d148fba1";