Changes
authorAli Younis <ayounis@uci.edu>
Thu, 18 May 2017 00:00:35 +0000 (17:00 -0700)
committerAli Younis <ayounis@uci.edu>
Thu, 18 May 2017 00:00:35 +0000 (17:00 -0700)
version2/src/java/iotcloud/Table.java
version2/src/java/iotcloud/Test.java

index 6a00f82..b6801c0 100644 (file)
@@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
 final public class Table {
 
        /* Constants */
-       static final int FREE_SLOTS = 10; // Number of slots that should be kept free
+       static final int FREE_SLOTS = 2; // Number of slots that should be kept free // 10
        static final int SKIP_THRESHOLD = 10;
        static final double RESIZE_MULTIPLE = 1.2;
        static final double RESIZE_THRESHOLD = 0.75;
@@ -169,9 +169,16 @@ final public class Table {
 
                int casdasd = 0;
 
+               int liveslo = 0;
+
                for (long i = o; i < (n + 1); i++) {
                        Slot s = buffer.getSlot(i);
 
+
+                       if (s.isLive()) {
+                               liveslo++;
+                       }
+
                        Vector<Entry> entries = s.getEntries();
 
                        for (Entry e : entries) {
@@ -179,8 +186,7 @@ final public class Table {
                                        int type = e.getType();
 
 
-                                       if(type == 6)
-                                       {
+                                       if (type == 6) {
                                                RejectedMessage rej = (RejectedMessage)e;
                                                casdasd++;
 
@@ -201,6 +207,8 @@ final public class Table {
                        System.out.println(i + "    " + types[i]);
                }
                System.out.println("Live count:   " + livec);
+               System.out.println("Live Slot count:   " + liveslo);
+
                System.out.println("Dead count:   " + deadc);
                System.out.println("Old:   " + o);
                System.out.println("New:   " + n);
@@ -259,7 +267,7 @@ final public class Table {
                Slot[] newslots = cloud.getSlots(sequenceNumber + 1);
                validateAndUpdate(newslots, true);
                sendToServer(null);
-                                       updateLiveTransactionsAndStatus();
+               updateLiveTransactionsAndStatus();
 
        }
 
@@ -398,6 +406,7 @@ final public class Table {
                        }
 
                        NewKey newKey = new NewKey(null, keyName, machineId);
+
                        if (sendToServer(newKey)) {
                                // If successfully inserted
                                return true;
@@ -706,9 +715,12 @@ final public class Table {
                }
 
 
+
                try {
                        // While we have stuff that needs inserting into the block chain
                        while ((pendingTransactionQueue.size() > 0) || (pendingSendArbitrationRounds.size() > 0) || (newKey != null)) {
+
+
                                fromRetry = false;
 
                                if (hadPartialSendToServer) {
@@ -770,7 +782,7 @@ final public class Table {
 
                                                // New Key was successfully inserted into the block chain so dont want to insert it again
                                                newKey = null;
-                                       }
+                                       } 
 
                                        // Remove the aborts and commit parts that were sent from the pending to send queue
                                        for (Iterator<ArbitrationRound> iter = pendingSendArbitrationRounds.iterator(); iter.hasNext(); ) {
@@ -1201,9 +1213,12 @@ final public class Table {
         * Returns false if a resize was needed
         */
        private ThreeTuple<Boolean, Integer, Boolean> fillSlot(Slot slot, boolean resize, NewKey newKeyEntry) {
+
+
                int newSize = 0;
                if (liveSlotCount > bufferResizeThreshold) {
                        resize = true; //Resize is forced
+
                }
 
                if (resize) {
@@ -1232,9 +1247,10 @@ final public class Table {
                if (newKeyEntry != null) {
                        newKeyEntry.setSlot(slot);
                        if (slot.hasSpace(newKeyEntry)) {
+
                                slot.addEntry(newKeyEntry);
                                inserted = true;
-                       }
+                       } 
                }
 
                // Clear the transactions, aborts and commits that were sent previously
@@ -1561,9 +1577,6 @@ final public class Table {
                if (expectedsize > currMaxSize) {
                        expectedsize = currMaxSize;
                }
-
-                                       // System.out.println("" + expectedsize);
-
        }
 
 
@@ -1598,6 +1611,7 @@ final public class Table {
                // Change the number of local slots to the new size
                numberOfSlots = (int)currMaxSize;
 
+
                // Recalculate the resize threshold since the size of the local buffer has changed
                setResizeThreshold();
        }
index 62581d8..b0ab607 100644 (file)
@@ -11,7 +11,7 @@ import java.util.ArrayList;
 
 public class Test {
 
-    public static final  int NUMBER_OF_TESTS = 1000;
+    public static final  int NUMBER_OF_TESTS = 1000; 
 
     public static void main(String[] args)  throws ServerException {
         if (args[0].equals("2")) {
@@ -78,6 +78,9 @@ public class Test {
         System.out.println("Total Key Create Time Network: " + keysNet / 1000000);
         System.out.println("Total Key Create Time no Network: " + (keysDt - keysNet) / 1000000);
         System.out.println();
+
+
+        // t1.printSlots();
    }