geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [5/5] incubator-geode git commit: GEODE-892: Cleanup unnecessary compression code from wan test
Date Wed, 03 Feb 2016 02:14:53 GMT
GEODE-892: Cleanup unnecessary compression code from wan test


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/c8ff05ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/c8ff05ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/c8ff05ab

Branch: refs/heads/develop
Commit: c8ff05abbb6d8c3a76f458e1c775921fdb1ed585
Parents: d0ef1fe
Author: Anthony Baker <abaker@apache.org>
Authored: Mon Feb 1 20:05:42 2016 -0800
Committer: Anthony Baker <abaker@apache.org>
Committed: Tue Feb 2 18:14:32 2016 -0800

----------------------------------------------------------------------
 .../cache/wan/CompressionConstants.java         |  37 -----
 .../cache/wan/CompressionInputStream.java       | 147 -------------------
 .../cache/wan/CompressionOutputStream.java      | 123 ----------------
 .../SenderWithTransportFilterDUnitTest.java     |  33 -----
 4 files changed, 340 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ff05ab/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionConstants.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionConstants.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionConstants.java
deleted file mode 100644
index 8f87c20..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionConstants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.cache.wan;
-
-public interface CompressionConstants {
-
-  /** Constants for 6-bit code values. */
-
-  /** No operation: used to pad words on flush. */
-  static final int NOP     = 0;  
-
-  /** Introduces raw byte format. */
-  static final int RAW     = 1;  
-
-  /** Format indicator for characters found in lookup table. */
-  static final int BASE    = 2;  
-
-  /** A character's code is it's index in the lookup table. */
-  static final String codeTable =
-      "abcdefghijklmnopqrstuvwxyz" +
-      "ABCDEFGHIJKLMNOPQRSTUVWXYZ ,.!?\"'()";
-  
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ff05ab/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionInputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionInputStream.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionInputStream.java
deleted file mode 100644
index a5fa906..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionInputStream.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.cache.wan;
-
-import java.io.*;
-
-public class CompressionInputStream extends FilterInputStream
-    implements CompressionConstants
-{
-    /*
-     * Constructor calls constructor of superclass
-     */
-    public CompressionInputStream(InputStream in) {
-        super(in);
-    }
- 
-    /* 
-     * Buffer of unpacked 6-bit codes 
-     * from last 32 bits read.
-     */
-    int buf[] = new int[5];
- 
-    /*
-     * Position of next code to read in buffer (5 signifies end). 
-     */ 
-    int bufPos = 5;
- 
-    /*
-     * Reads in format code and decompresses character
-     * accordingly.  
-     */
-    public int read() throws IOException {
-        try {
-            int code;
-
-            // Read in and ignore empty bytes (NOP's) as 
-            // long as they arrive. 
-            do {
-                code = readCode();
-            } while (code == NOP);      
- 
-            if (code >= BASE) {
-                // Retrieve index of character in codeTable 
-                // if the code is in the correct range.
-
-                return codeTable.charAt(code - BASE);
-            } else if (code == RAW) {
-                // read in the lower 4 bits and the 
-                // higher 4 bits, and return the 
-                // reconstructed character
-                int high = readCode();
-                int low = readCode();
-                return (high << 4) | low;
-            } else 
-                throw new IOException("unknown compression code: " 
-                                      + code);
-        } catch (EOFException e) {
-            // Return the end of file code
-            return -1;
-        }
-    }
- 
-    /* 
-     * This method reads up to len bytes from the input stream.
-     * Returns if read blocks before len bytes are read. 
-     */ 
-    public int read(byte b[], int off, int len) 
-        throws IOException 
-    {
-        if (len <= 0) {
-            return 0;
-        }
- 
-        // Read in a word and return -1 if no more data.
-        int c = read();
-        if (c == -1) {
-            return -1;
-        }
-
-        // Save c in buffer b
-        b[off] = (byte)c;
- 
-        int i = 1;
-        // Try to read up to len bytes or until no
-        // more bytes can be read without blocking.
-        try {
-            for (; (i < len) && (in.available() > 0); i++) {
-                c = read();
-                if (c == -1) {
-                    break;
-                }
-                if (b != null) {
-                    b[off + i] = (byte)c;
-                }
-            }
-        } catch (IOException ee) {
-        }
-        return i;
-    }
-
-    /*
-     * If there is no more data to decode left
-     * in buf, read the next four bytes from the 
-     * wire. Then store each group of 6 bits in an
-     * element of buf.  Return one element of buf.
-     */
-    private int readCode() throws IOException {
-        // As soon as all the data in buf has been read
-        // (when bufPos == 5) read in another four bytes.
-        if (bufPos == 5) {
-            int b1 = in.read();
-            int b2 = in.read();
-            int b3 = in.read();
-            int b4 = in.read();
-
-            // make sure none of the bytes signify the
-            // end of the data in the stream
-            if ((b1 | b2 | b3 | b4) < 0)
-                throw new EOFException();
-            // Assign each group of 6 bits to an 
-            // element of buf.
-            int pack = (b1 << 24) | (b2 << 16) | 
-                       (b3 << 8) | b4;
-            buf[0] = (pack >>> 24) & 0x3F;
-            buf[1] = (pack >>> 18) & 0x3F;
-            buf[2] = (pack >>> 12) & 0x3F;
-            buf[3] = (pack >>>  6) & 0x3F;
-            buf[4] = (pack >>>  0) & 0x3F;
-            bufPos = 0;
-        }
-        return buf[bufPos++];
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ff05ab/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionOutputStream.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionOutputStream.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionOutputStream.java
deleted file mode 100644
index 28a2c11..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/wan/CompressionOutputStream.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.internal.cache.wan;
-
-import java.io.*;
-
-public class CompressionOutputStream extends FilterOutputStream
-    implements CompressionConstants
-{
-
-    /*
-     * Constructor calls constructor of superclass.
-     */
-    public CompressionOutputStream(OutputStream out) {
-        super(out);
-    }
- 
-    /* 
-     * Buffer of 6-bit codes to pack into next 32-bit
-     * word.  Five 6-bit codes fit into 4 words. 
-     */
-    int buf[] = new int[5];
- 
-    /*
-     * Index of valid codes waiting in buf. 
-     */
-    int bufPos = 0;
- 
-
-    /*  
-     * This method writes one byte to the socket stream. 
-     */ 
-    public void write(int b) throws IOException {
-        // force argument to one byte
-        b &= 0xFF;                      
- 
-        // Look up pos in codeTable to get its encoding. 
-        int pos = codeTable.indexOf((char)b);
-
-        if (pos != -1)
-            // If pos is in the codeTable, write 
-            // BASE + pos into buf. By adding BASE 
-            // to pos, we know that the characters in
-            // the codeTable will always have a code 
-            // between 2 and 63 inclusive. This allows 
-            // us to use RAW (RAW is equal to 1) to signify 
-            // that the next two groups of 6-bits are necessary
-            // for decompression of the next character. 
-
-            writeCode(BASE + pos);
-
-        else {
-            // Otherwise, write RAW into buf to signify that
-            // the Character is being sent in 12 bits.
-            writeCode(RAW);
-
-            // Write the last 4 bits of b into the buf.
-            writeCode(b >> 4);
-
-            // Truncate b to contain data in only the first 4
-            // bits and write the first 4 bits of b into buf.
-            writeCode(b & 0xF);
-        }
-    }
- 
-    /* 
-     * This method writes up to len bytes to the socket stream. 
-     */
-    public void write(byte b[], int off, int len) 
-        throws IOException 
-    {
-        // This implementation is quite inefficient because 
-        // it has to call the other write method for every 
-        // byte in the array.  It could be optimized for 
-        // performance by doing all the processing in this 
-        // method.
-
-        for (int i = 0; i < len; i++)
-            write(b[off + i]);
-    }
- 
-   /* 
-    * Clears buffer of all data (zeroes it out). 
-    */ 
-   public void flush() throws IOException {
-        while (bufPos > 0)
-            writeCode(NOP);
-    }
- 
-    /* 
-     * This method actually puts the data into the output stream
-     * after packing the data from all 5 bytes in buf into one
-     * word. Remember, each byte has, at most, 6 significant bits.
-     */
-    private void writeCode(int c) throws IOException {
-        buf[bufPos++] = c;
-
-        // write next word when we have 5 codes
-        if (bufPos == 5) {      
-            int pack = (buf[0] << 24) | (buf[1] << 18) | 
-                       (buf[2] << 12) | (buf[3] << 6) | buf[4];
-            out.write((pack >>> 24) & 0xFF);
-            out.write((pack >>> 16) & 0xFF);
-            out.write((pack >>> 8)  & 0xFF);
-            out.write((pack >>> 0)  & 0xFF);
-            bufPos = 0;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c8ff05ab/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/SenderWithTransportFilterDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/SenderWithTransportFilterDUnitTest.java
b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/SenderWithTransportFilterDUnitTest.java
index 3fdc672..a00dd1b 100644
--- a/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/SenderWithTransportFilterDUnitTest.java
+++ b/gemfire-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/SenderWithTransportFilterDUnitTest.java
@@ -36,11 +36,8 @@ import com.gemstone.gemfire.cache.wan.GatewayTransportFilter;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.cache.wan.CompressionInputStream;
-import com.gemstone.gemfire.internal.cache.wan.CompressionOutputStream;
 import com.gemstone.gemfire.internal.cache.wan.InternalGatewaySenderFactory;
 import com.gemstone.gemfire.internal.cache.wan.WANTestBase;
-import com.gemstone.gemfire.internal.cache.wan.WANTestBase.MyLocatorCallback;
 import com.gemstone.gemfire.test.dunit.VM;
 
 public class SenderWithTransportFilterDUnitTest extends WANTestBase {
@@ -130,7 +127,6 @@ public class SenderWithTransportFilterDUnitTest extends WANTestBase {
     fact.setEndPort(port);
     ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
     transportFilters.add(new CheckSumTranportFilter("CheckSumTranportFilter"));
-    transportFilters.add(new CompressionTranportFilter("CompressionTranportFilter"));
     if (!transportFilters.isEmpty()) {
       for (GatewayTransportFilter filter : transportFilters) {
         fact.addGatewayTransportFilter(filter);
@@ -165,7 +161,6 @@ public class SenderWithTransportFilterDUnitTest extends WANTestBase {
       gateway.setBatchSize(batchSize);
       ((InternalGatewaySenderFactory)gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
       ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
-      transportFilters.add(new CompressionTranportFilter("CompressionTranportFilter"));
       transportFilters.add(new CheckSumTranportFilter("CheckSumTranportFilter"));
       if (!transportFilters.isEmpty()) {
         for (GatewayTransportFilter filter : transportFilters) {
@@ -194,7 +189,6 @@ public class SenderWithTransportFilterDUnitTest extends WANTestBase {
       ((InternalGatewaySenderFactory)gateway)
           .setLocatorDiscoveryCallback(new MyLocatorCallback());
       ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
-      transportFilters.add(new CompressionTranportFilter("CompressionTranportFilter"));
       transportFilters.add(new CheckSumTranportFilter("CheckSumTranportFilter"));
       if (!transportFilters.isEmpty()) {
         for (GatewayTransportFilter filter : transportFilters) {
@@ -215,33 +209,6 @@ public class SenderWithTransportFilterDUnitTest extends WANTestBase {
     }
   }
 
-  static class CompressionTranportFilter implements GatewayTransportFilter {
-
-    private String name;
-    
-    public CompressionTranportFilter(String name){
-      this.name = name;
-    }
-    
-    public String toString(){
-      return this.name;
-    }
-    public InputStream getInputStream(InputStream stream) {
-      return new CompressionInputStream(stream);
-      // return new ZipInputStream(stream);
-    }
-
-    public OutputStream getOutputStream(OutputStream stream) {
-      return new CompressionOutputStream(stream);
-      // return new ZipOutputStream(stream);
-    }
-
-    public void close() {
-      // TODO Auto-generated method stub
-    }
-
-  }
-  
   static class CheckSumTranportFilter implements GatewayTransportFilter {
 
     Adler32 checker = new Adler32();


Mime
View raw message