avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r999568 - in /avro/branches/branch-1.4: ./ lang/java/src/java/org/apache/avro/generic/ lang/java/src/java/org/apache/avro/io/ lang/java/src/java/org/apache/avro/util/ lang/java/src/test/java/org/apache/avro/generic/ lang/ruby/test/ share/te...
Date Tue, 21 Sep 2010 19:35:10 GMT
Author: cutting
Date: Tue Sep 21 19:35:10 2010
New Revision: 999568

URL: http://svn.apache.org/viewvc?rev=999568&view=rev
Log:
Merge r996877, r997962, r999554, and r999556 from trunk to 1.4 branch.  Fixes: AVRO-664, AVRO-667,
and AVRO-668.

Modified:
    avro/branches/branch-1.4/   (props changed)
    avro/branches/branch-1.4/CHANGES.txt
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericData.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericDatumWriter.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/Encoder.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/JsonEncoder.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java
    avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/util/Utf8.java
    avro/branches/branch-1.4/lang/java/src/test/java/org/apache/avro/generic/TestGenericData.java
    avro/branches/branch-1.4/lang/ruby/test/tool.rb
    avro/branches/branch-1.4/share/test/interop/bin/test_rpc_interop.sh

Propchange: avro/branches/branch-1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 21 19:35:10 2010
@@ -1 +1 @@
-/avro/trunk:990852,990860,990867,990871,990878,991031,991423,992146,992149,992167,996640,996642,996649,998347,998354
+/avro/trunk:990852,990860,990867,990871,990878,991031,991423,992146,992149,992167,996640,996642,996649,996877,997962,998347,998354,999554,999556

Modified: avro/branches/branch-1.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/CHANGES.txt?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/CHANGES.txt (original)
+++ avro/branches/branch-1.4/CHANGES.txt Tue Sep 21 19:35:10 2010
@@ -16,11 +16,19 @@ Avro 1.4.1 (unreleased)
 
     AVRO-634. IDL: Add support for aliases. (cutting)
 
+    AVRO-668. Java: Reduce object allocations while writing strings.
+    (scottcarey)
+
   BUG FIXES
 
     AVRO-657. Fix build so that md5 and sha1 checksum files contain
     only the file's basename without any directories. (cutting)
 
+    AVRO-664. Ruby server takes a long time to start in interop tests. (thiru)
+
+    AVRO-667. GenericArray fails to compare with List. SpecificRecord
+    compare gets ClassCastException. (scottcarey & cutting)
+
 Avro 1.4.0 (31 August 2010)
 
   INCOMPATIBLE CHANGES

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericData.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericData.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericData.java (original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericData.java Tue
Sep 21 19:35:10 2010
@@ -18,11 +18,11 @@
 package org.apache.avro.generic;
 
 import java.nio.ByteBuffer;
-import java.util.Iterator;
+import java.util.AbstractList;
 import java.util.Arrays;
-import java.util.Map;
 import java.util.Collection;
-import java.util.AbstractList;
+import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.avro.AvroRuntimeException;
 import org.apache.avro.AvroTypeException;
@@ -30,6 +30,7 @@ import org.apache.avro.Schema;
 import org.apache.avro.Schema.Field;
 import org.apache.avro.Schema.Type;
 import org.apache.avro.io.BinaryData;
+import org.apache.avro.util.Utf8;
 
 /** Utilities for generic Java data. */
 public class GenericData {
@@ -120,9 +121,11 @@ public class GenericData {
     public T peek() {
       return (size < elements.length) ? (T)elements[size] : null;
     }
+    @Override
     public int hashCode() {
       return GenericData.get().hashCode(this, schema);
     }
+    @Override
     public boolean equals(Object o) {
       if (o == this) return true;                 // identical object
       if (!(o instanceof Array)) return false;    // not an array
@@ -147,6 +150,7 @@ public class GenericData {
         right--;
       }
     }
+    @Override
     public String toString() {
       StringBuffer buffer = new StringBuffer();
       buffer.append("[");
@@ -173,14 +177,17 @@ public class GenericData {
 
     public byte[] bytes() { return bytes; }
 
+    @Override
     public boolean equals(Object o) {
       if (o == this) return true;
       return o instanceof GenericFixed
         && Arrays.equals(bytes, ((GenericFixed)o).bytes());
     }
 
+    @Override
     public int hashCode() { return Arrays.hashCode(bytes); }
 
+    @Override
     public String toString() { return Arrays.toString(bytes); }
 
     public int compareTo(Fixed that) {
@@ -194,14 +201,17 @@ public class GenericData {
     private String symbol;
     public EnumSymbol(String symbol) { this.symbol = symbol; }
 
+    @Override
     public boolean equals(Object o) {
       if (o == this) return true;
       return o instanceof GenericEnumSymbol
         && symbol.equals(o.toString());
     }
 
+    @Override
     public int hashCode() { return symbol.hashCode(); }
 
+    @Override
     public String toString() { return symbol; }
   }
 
@@ -219,8 +229,8 @@ public class GenericData {
     case ENUM:
       return schema.getEnumSymbols().contains(datum.toString());
     case ARRAY:
-      if (!(datum instanceof GenericArray)) return false;
-      for (Object element : (GenericArray)datum)
+      if (!(datum instanceof Collection)) return false;
+      for (Object element : (Collection<?>)datum)
         if (!validate(schema.getElementType(), element))
           return false;
       return true;
@@ -273,7 +283,7 @@ public class GenericData {
       }
       buffer.append("}");
     } else if (datum instanceof Collection) {
-      Collection array = (Collection)datum;
+      Collection<?> array = (Collection<?>)datum;
       buffer.append("[");
       long last = array.size()-1;
       int i = 0;
@@ -317,7 +327,7 @@ public class GenericData {
       return ((IndexedRecord)datum).getSchema();
     } else if (datum instanceof Collection) {
       Schema elementType = null;
-      for (Object element : (Collection)datum) {
+      for (Object element : (Collection<?>)datum) {
         if (elementType == null) {
           elementType = induce(element);
         } else if (!elementType.equals(induce(element))) {
@@ -453,8 +463,8 @@ public class GenericData {
       }
       return hashCode;
     case ARRAY:
-      GenericArray a = (GenericArray)o;
-      Schema elementType = a.getSchema().getElementType();
+      Collection<?> a = (Collection<?>)o;
+      Schema elementType = s.getElementType();
       for (Object e : a)
         hashCode = hashCodeAdd(hashCode, e, elementType);
       return hashCode;
@@ -464,6 +474,8 @@ public class GenericData {
       return s.getEnumOrdinal(o.toString());
     case NULL:
       return 0;
+    case STRING:
+      return (o instanceof Utf8 ? o : new Utf8(o.toString())).hashCode();
     default:
       return o.hashCode();
     }
@@ -499,11 +511,11 @@ public class GenericData {
     case ENUM:
       return s.getEnumOrdinal(o1.toString()) - s.getEnumOrdinal(o2.toString());
     case ARRAY:
-      GenericArray a1 = (GenericArray)o1;
-      GenericArray a2 = (GenericArray)o2;
+      Collection a1 = (Collection)o1;
+      Collection a2 = (Collection)o2;
       Iterator e1 = a1.iterator();
       Iterator e2 = a2.iterator();
-      Schema elementType = a1.getSchema().getElementType();
+      Schema elementType = s.getElementType();
       while(e1.hasNext() && e2.hasNext()) {
         int compare = compare(e1.next(), e2.next(), elementType);
         if (compare != 0) return compare;
@@ -519,6 +531,10 @@ public class GenericData {
         : i1 - i2;
     case NULL:
       return 0;
+    case STRING:
+      Utf8 u1 = o1 instanceof Utf8 ? (Utf8)o1 : new Utf8(o1.toString());
+      Utf8 u2 = o2 instanceof Utf8 ? (Utf8)o2 : new Utf8(o2.toString());
+      return u1.compareTo(u2);
     default:
       return ((Comparable)o1).compareTo(o2);
     }

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericDatumWriter.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericDatumWriter.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericDatumWriter.java
(original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/generic/GenericDatumWriter.java
Tue Sep 21 19:35:10 2010
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Collection;
 
 import org.apache.avro.AvroTypeException;
@@ -29,7 +28,6 @@ import org.apache.avro.Schema;
 import org.apache.avro.Schema.Field;
 import org.apache.avro.io.DatumWriter;
 import org.apache.avro.io.Encoder;
-import org.apache.avro.util.Utf8;
 
 /** {@link DatumWriter} for generic Java objects. */
 public class GenericDatumWriter<D> implements DatumWriter<D> {
@@ -188,9 +186,7 @@ public class GenericDatumWriter<D> imple
   /** Called to write a string.  May be overridden for alternate string
    * representations.*/
   protected void writeString(Object datum, Encoder out) throws IOException {
-    out.writeString(datum instanceof Utf8
-                    ? (Utf8)datum
-                    : new Utf8(datum.toString()));
+    out.writeString((CharSequence) datum);
   }
 
   /** Called to write a bytes.  May be overridden for alternate bytes

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java (original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java Tue
Sep 21 19:35:10 2010
@@ -130,10 +130,20 @@ public class BinaryEncoder extends Encod
 
   @Override
   public void writeString(Utf8 utf8) throws IOException {
-    encodeLong(utf8.getLength(), out);
-    out.write(utf8.getBytes(), 0, utf8.getLength());
+    encodeString(utf8.getBytes(), 0, utf8.getByteLength());
   }
-
+  
+  @Override
+  public void writeString(String string) throws IOException {
+    byte[] bytes = Utf8.getBytesFor(string);
+    encodeString(bytes, 0, bytes.length);
+  }
+  
+  private void encodeString(byte[] bytes, int offset, int length) throws IOException {
+    encodeLong(length, out);
+    out.write(bytes, offset, length);
+  }
+  
   @Override
   public void writeBytes(ByteBuffer bytes) throws IOException {
     byteWriter.write(bytes);

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java
(original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java
Tue Sep 21 19:35:10 2010
@@ -85,7 +85,7 @@ public class BlockingBinaryEncoder exten
        *  _containing_ this block must be in the {@link #OVERFLOW}
        *  state. */
      OVERFLOW
-    };
+    }
 
     /** The type of this blocked value (ARRAY or MAP). */
     public Schema.Type type;
@@ -313,9 +313,15 @@ public class BlockingBinaryEncoder exten
 
   @Override
   public void writeString(Utf8 utf8) throws IOException {
-    writeBytes(utf8.getBytes(), 0, utf8.getLength());
-
-    assert check();
+    writeBytes(utf8.getBytes(), 0, utf8.getByteLength());
+    // assert called in writeBytes
+  }
+  
+  @Override
+  public void writeString(String str) throws IOException {
+    byte[] utf8bytes = Utf8.getBytesFor(str);
+    writeBytes(utf8bytes, 0, utf8bytes.length);
+    // assert called in writeBytes
   }
 
   @Override

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/Encoder.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/Encoder.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/Encoder.java (original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/Encoder.java Tue Sep 21
19:35:10 2010
@@ -98,7 +98,9 @@ public abstract class Encoder implements
   public abstract void writeString(Utf8 utf8) throws IOException;
 
   /**
-   * Write a Unicode character string.
+   * Write a Unicode character string.  The default implementation converts
+   * the String to a {@link org.apache.avro.util.Utf8}.  Some Encoder 
+   * implementations may want to do something different as a performance optimization.
    * @throws AvroTypeException If this is a stateful writer and a
    * char-string is not expected
    */
@@ -107,6 +109,20 @@ public abstract class Encoder implements
   }
 
   /**
+   * Write a Unicode character string.  If the CharSequence is an
+   * {@link org.apache.avro.util.Utf8} it writes this directly, otherwise
+   * the CharSequence is converted to a String via toString() and written.
+   * @throws AvroTypeException If this is a stateful writer and a
+   * char-string is not expected
+   */
+  public void writeString(CharSequence charSequence) throws IOException {
+    if (charSequence instanceof Utf8)
+      writeString((Utf8)charSequence);
+    else
+      writeString(charSequence.toString());
+  }
+  
+  /**
    * Write a byte string.
    * @throws AvroTypeException If this is a stateful writer and a
    *         byte-string is not expected

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/JsonEncoder.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/JsonEncoder.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/JsonEncoder.java (original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/JsonEncoder.java Tue Sep
21 19:35:10 2010
@@ -109,12 +109,17 @@ public class JsonEncoder extends Parsing
 
   @Override
   public void writeString(Utf8 utf8) throws IOException {
+    writeString(utf8.toString());
+  }
+  
+  @Override 
+  public void writeString(String str) throws IOException {
     parser.advance(Symbol.STRING);
     if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
       parser.advance(Symbol.MAP_KEY_MARKER);
-      out.writeFieldName(utf8.toString());
+      out.writeFieldName(str);
     } else {
-      out.writeString(utf8.toString());
+      out.writeString(str);
     }
   }
 

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java
(original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java
Tue Sep 21 19:35:10 2010
@@ -105,6 +105,18 @@ public class ValidatingEncoder extends P
     parser.advance(Symbol.STRING);
     out.writeString(utf8);
   }
+  
+  @Override
+  public void writeString(String str) throws IOException {
+    parser.advance(Symbol.STRING);
+    out.writeString(str);
+  }
+  
+  @Override
+  public void writeString(CharSequence charSequence) throws IOException {
+    parser.advance(Symbol.STRING);
+    out.writeString(charSequence);
+  }
 
   @Override
   public void writeBytes(ByteBuffer bytes) throws IOException {

Modified: avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/util/Utf8.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/util/Utf8.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/util/Utf8.java (original)
+++ avro/branches/branch-1.4/lang/java/src/java/org/apache/avro/util/Utf8.java Tue Sep 21
19:35:10 2010
@@ -18,6 +18,7 @@
 package org.apache.avro.util;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 
 import org.apache.avro.io.BinaryData;
 
@@ -27,6 +28,10 @@ import org.apache.avro.io.BinaryData;
 public class Utf8 implements Comparable<Utf8>, CharSequence {
   private static final byte[] EMPTY = new byte[0];
 
+  private static final Charset UTF8_CS;
+  static {
+    UTF8_CS = Charset.forName("UTF-8");
+  }
   private byte[] bytes = EMPTY;
   private int length;
   private String string;
@@ -34,11 +39,7 @@ public class Utf8 implements Comparable<
   public Utf8() {}
 
   public Utf8(String string) {
-    try {
-      this.bytes = string.getBytes("UTF-8");
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    }
+    this.bytes = string.getBytes(UTF8_CS);
     this.length = bytes.length;
     this.string = string;
   }
@@ -79,6 +80,7 @@ public class Utf8 implements Comparable<
     return this;
   }
 
+  @Override
   public String toString() {
     if (this.string == null)
       try {
@@ -89,6 +91,7 @@ public class Utf8 implements Comparable<
     return this.string;
   }
 
+  @Override
   public boolean equals(Object o) {
     if (o == this) return true;
     if (!(o instanceof Utf8)) return false;
@@ -101,6 +104,7 @@ public class Utf8 implements Comparable<
     return true;
   }
 
+  @Override
   public int hashCode() {
     int hash = 0;
     for (int i = 0; i < this.length; i++)
@@ -120,5 +124,9 @@ public class Utf8 implements Comparable<
     return toString().subSequence(start, end);
   }
 
+  /** Gets the UTF-8 bytes for a String */
+  public static byte[] getBytesFor(String str) {
+    return str.getBytes(UTF8_CS);
+  }
 
 }

Modified: avro/branches/branch-1.4/lang/java/src/test/java/org/apache/avro/generic/TestGenericData.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/java/src/test/java/org/apache/avro/generic/TestGenericData.java?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/java/src/test/java/org/apache/avro/generic/TestGenericData.java
(original)
+++ avro/branches/branch-1.4/lang/java/src/test/java/org/apache/avro/generic/TestGenericData.java
Tue Sep 21 19:35:10 2010
@@ -19,6 +19,8 @@ package org.apache.avro.generic;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Collection;
+import java.util.ArrayDeque;
 
 import static org.junit.Assert.*;
 
@@ -28,6 +30,7 @@ import org.apache.avro.Schema;
 import org.apache.avro.Schema.Field;
 import org.apache.avro.AvroRuntimeException;
 import org.apache.avro.Schema.Type;
+import org.apache.avro.util.Utf8;
 
 import org.junit.Test;
 
@@ -59,6 +62,43 @@ public class TestGenericData {
     GenericData.get().hashCode(null, Schema.create(Type.NULL));
     GenericData.get().hashCode(null, Schema.createUnion(
         Arrays.asList(Schema.create(Type.BOOLEAN), Schema.create(Type.STRING))));
+    List<CharSequence> stuff = new ArrayList<CharSequence>();
+    stuff.add("string");
+    Schema schema = recordSchema();
+    GenericRecord r = new GenericData.Record(schema);
+    r.put(0, stuff);
+    GenericData.get().hashCode(r, schema);
+  }
+  
+  @Test
+  public void testEquals() {
+    Schema s = recordSchema();
+    GenericRecord r0 = new GenericData.Record(s);
+    GenericRecord r1 = new GenericData.Record(s);
+    GenericRecord r2 = new GenericData.Record(s);
+    Collection<CharSequence> l0 = new ArrayDeque<CharSequence>();
+    List<CharSequence> l1 = new ArrayList<CharSequence>();
+    GenericArray<CharSequence> l2 = 
+      new GenericData.Array<CharSequence>(1,s.getFields().get(0).schema());
+    String foo = "foo";
+    l0.add(new StringBuffer(foo));
+    l1.add(foo);
+    l2.add(new Utf8(foo));
+    r0.put(0, l0);
+    r1.put(0, l1);
+    r2.put(0, l2);
+    assertEquals(r0, r1);
+    assertEquals(r0, r2);
+    assertEquals(r1, r2);
+  }
+  
+  private Schema recordSchema() {
+    List<Field> fields = new ArrayList<Field>();
+    fields.add(new Field("anArray", Schema.createArray(Schema.create(Type.STRING)), null,
null));
+    Schema schema = Schema.createRecord("arrayFoo", "test", "mytest", false);
+    schema.setFields(fields);
+    
+    return schema;
   }
 
   @Test

Modified: avro/branches/branch-1.4/lang/ruby/test/tool.rb
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/lang/ruby/test/tool.rb?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/lang/ruby/test/tool.rb (original)
+++ avro/branches/branch-1.4/lang/ruby/test/tool.rb Tue Sep 21 19:35:10 2010
@@ -49,7 +49,7 @@ end
 def run_server(uri, proto, msg, datum)
   uri = URI.parse(uri)
   $responder = GenericResponder.new(proto, msg, datum)
-  server = WEBrick::HTTPServer.new(:Host => uri.host,
+  server = WEBrick::HTTPServer.new(:BindAddress => uri.host,
                                    :Port => uri.port,
                                    :Logger => Logger.new(StringIO.new))
   server.mount '/', GenericHandler

Modified: avro/branches/branch-1.4/share/test/interop/bin/test_rpc_interop.sh
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.4/share/test/interop/bin/test_rpc_interop.sh?rev=999568&r1=999567&r2=999568&view=diff
==============================================================================
--- avro/branches/branch-1.4/share/test/interop/bin/test_rpc_interop.sh (original)
+++ avro/branches/branch-1.4/share/test/interop/bin/test_rpc_interop.sh Tue Sep 21 19:35:10
2010
@@ -58,9 +58,20 @@ do
 	    echo TEST: $c
 	    for client in "${clients[@]}"
 	    do
+        rm -rf $portfile
 		$server http://127.0.0.1:0/ $proto $msg -file $c/response.avro \
 		    > $portfile &
-		sleep 1				  # wait for server to start
+        count=0
+        while [ ! -s $portfile ]
+        do
+            sleep 1
+            if [ $count -ge 10 ]
+            then
+                echo $server did not start.
+                exit 1
+            fi
+            count=`expr $count + 1`
+        done
 		read ignore port < $portfile
 	    	$client http://127.0.0.1:$port $proto $msg -file $c/request.avro
 		wait



Mime
View raw message