You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by se...@apache.org on 2018/01/08 08:30:32 UTC

[incubator-servicecomb-saga] branch master updated (5880e16 -> 6d4c084)

This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git.


    from 5880e16  SCB-157 Updated the travis setting xml
     new 828b2a7  SCB-174 add kryo serializer
     new d726294  SCB-174 remove redudant test codes
     new 390271d  SCB-174 retrieve kryo instance from pool
     new 6d4c084  SCB-174 remove useless NativeMessageFormat implementation

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 omega/omega-format/pom.xml                         |  4 ++
 .../saga/omega/format/KryoMessageFormat.java       | 64 ++++++++++++++++++++++
 .../saga/omega/format/MessageFormat.java}          | 31 ++++-------
 .../saga/omega/format/NativeMessageFormat.java     | 62 ---------------------
 .../saga/omega/format/KryoMessageFormatTest.java   | 23 +++++---
 ...eFormatTest.java => MessageFormatTestBase.java} | 25 +++++----
 .../saga/omega/spring/OmegaSpringConfig.java       |  5 +-
 pom.xml                                            |  6 ++
 8 files changed, 116 insertions(+), 104 deletions(-)
 create mode 100644 omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
 copy omega/{omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/ServiceConfig.java => omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java} (56%)
 delete mode 100644 omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
 copy saga-core/src/test/java/org/apache/servicecomb/saga/core/LongIdGeneratorTest.java => omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java (64%)
 rename omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/{NativeMessageFormatTest.java => MessageFormatTestBase.java} (78%)

-- 
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].

[incubator-servicecomb-saga] 02/04: SCB-174 remove redudant test codes

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit d7262946e6be01082b5a62a9edb6b9ecda1857d7
Author: Eric Lee <da...@huawei.com>
AuthorDate: Sat Jan 6 22:02:13 2018 +0800

    SCB-174 remove redudant test codes
    
    Signed-off-by: Eric Lee <da...@huawei.com>
---
 .../saga/omega/format/KryoMessageFormat.java       | 24 ++++++-------
 .../saga/omega/format/MessageFormat.java           | 24 ++++++-------
 .../saga/omega/format/KryoMessageFormatTest.java   | 42 +++++++---------------
 .../saga/omega/format/MessageFormatTestBase.java   |  6 ++++
 .../saga/omega/format/NativeMessageFormatTest.java | 42 +++++++---------------
 pom.xml                                            |  3 +-
 6 files changed, 56 insertions(+), 85 deletions(-)

diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
index 2a0dd8d..7ef16a2 100644
--- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
+++ b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
@@ -1,18 +1,18 @@
 /*
- *  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
+ * 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
+ *      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.
+ * 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 org.apache.servicecomb.saga.omega.format;
diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java
index 8adde72..0ccac37 100644
--- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java
+++ b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java
@@ -1,18 +1,18 @@
 /*
- *  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
+ * 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
+ *      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.
+ * 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 org.apache.servicecomb.saga.omega.format;
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java
index 434067e..1f63d74 100644
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java
+++ b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java
@@ -1,18 +1,18 @@
 /*
- *  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
+ * 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
+ *      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.
+ * 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 org.apache.servicecomb.saga.omega.format;
@@ -31,24 +31,6 @@ public class KryoMessageFormatTest extends MessageFormatTestBase {
   }
 
   @Test
-  @Override
-  public void serializeObjectIntoBytes() throws Exception {
-    super.serializeObjectIntoBytes();
-  }
-
-  @Test
-  @Override
-  public void serializeNullIntoBytes() throws Exception {
-    super.serializeNullIntoBytes();
-  }
-
-  @Test
-  @Override
-  public void blowsUpWhenObjectIsNotDeserializable() throws Exception {
-    super.blowsUpWhenObjectIsNotDeserializable();
-  }
-
-  @Test
   public void serializeEmptyClassIntoBytes() {
     byte[] bytes = format.serialize(eventOf(new EmptyClass()));
 
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java
index 2188447..17674b7 100644
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java
+++ b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java
@@ -27,11 +27,15 @@ import static org.junit.Assert.assertThat;
 
 import org.apache.servicecomb.saga.omega.transaction.OmegaException;
 import org.apache.servicecomb.saga.omega.transaction.TxEvent;
+import org.junit.Ignore;
+import org.junit.Test;
 
+@Ignore
 public class MessageFormatTestBase {
 
   static MessageFormat format;
 
+  @Test
   public void serializeObjectIntoBytes() throws Exception {
     byte[] bytes = format.serialize(eventOf("hello", "world"));
 
@@ -40,6 +44,7 @@ public class MessageFormatTestBase {
     assertThat(asList(message), contains("hello", "world"));
   }
 
+  @Test
   public void serializeNullIntoBytes() throws Exception {
     byte[] bytes = format.serialize(eventOf((Object[]) null));
 
@@ -48,6 +53,7 @@ public class MessageFormatTestBase {
     assertThat(message, is(nullValue()));
   }
 
+  @Test
   public void blowsUpWhenObjectIsNotDeserializable() throws Exception {
     try {
       format.deserialize(new byte[0]);
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
index e07bb61..e460f63 100644
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
+++ b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
@@ -1,18 +1,18 @@
 /*
- *  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
+ * 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
+ *      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.
+ * 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 org.apache.servicecomb.saga.omega.format;
@@ -33,24 +33,6 @@ public class NativeMessageFormatTest extends MessageFormatTestBase {
   }
 
   @Test
-  @Override
-  public void serializeObjectIntoBytes() throws Exception {
-    super.serializeObjectIntoBytes();
-  }
-
-  @Test
-  @Override
-  public void serializeNullIntoBytes() throws Exception {
-    super.serializeNullIntoBytes();
-  }
-
-  @Test
-  @Override
-  public void blowsUpWhenObjectIsNotDeserializable() throws Exception {
-    super.blowsUpWhenObjectIsNotDeserializable();
-  }
-
-  @Test
   public void blowsUpWhenSerializeEmptyClass() {
     try {
       format.serialize(eventOf(new EmptyClass()));
diff --git a/pom.xml b/pom.xml
index 2458bc8..f2d275b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,7 @@
     <rat.version>0.12</rat.version>
     <maven.failsafe.version>2.19.1</maven.failsafe.version>
     <grpc.version>1.8.0</grpc.version>
+    <kryo.version>4.0.1</kryo.version>
   </properties>
 
   <name>ServiceComb Saga</name>
@@ -332,7 +333,7 @@
       <dependency>
         <groupId>com.esotericsoftware</groupId>
         <artifactId>kryo</artifactId>
-        <version>4.0.1</version>
+        <version>${kryo.version}</version>
       </dependency>
 
       <!-- test dependencies -->

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.

[incubator-servicecomb-saga] 04/04: SCB-174 remove useless NativeMessageFormat implementation

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 6d4c0848b8ef1344823f2fca0cd35ed83fbdc4db
Author: Eric Lee <da...@huawei.com>
AuthorDate: Mon Jan 8 15:09:01 2018 +0800

    SCB-174 remove useless NativeMessageFormat implementation
    
    Signed-off-by: Eric Lee <da...@huawei.com>
---
 .../saga/omega/format/NativeMessageFormat.java     | 50 ----------------------
 .../saga/omega/format/NativeMessageFormatTest.java | 44 -------------------
 2 files changed, 94 deletions(-)

diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
deleted file mode 100644
index 383afeb..0000000
--- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
+++ /dev/null
@@ -1,50 +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 org.apache.servicecomb.saga.omega.format;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import org.apache.servicecomb.saga.omega.transaction.OmegaException;
-
-public class NativeMessageFormat implements MessageFormat {
-  @Override
-  public byte[] serialize(Object[] objects) {
-    try {
-      ByteArrayOutputStream out = new ByteArrayOutputStream();
-      try (ObjectOutputStream outputStream = new ObjectOutputStream(out)) {
-        outputStream.writeObject(objects);
-        return out.toByteArray();
-      }
-    } catch (IOException e) {
-      throw new OmegaException("Unable to serialize object", e);
-    }
-  }
-
-  @Override
-  public Object[] deserialize(byte[] message) {
-    try (ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(message))) {
-      return (Object[]) inputStream.readObject();
-    } catch (IOException | ClassNotFoundException e) {
-      throw new OmegaException("Unable to deserialize message", e);
-    }
-  }
-}
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
deleted file mode 100644
index e460f63..0000000
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
+++ /dev/null
@@ -1,44 +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 org.apache.servicecomb.saga.omega.format;
-
-import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertThat;
-
-import org.apache.servicecomb.saga.omega.transaction.OmegaException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class NativeMessageFormatTest extends MessageFormatTestBase {
-
-  @BeforeClass
-  public static void setUp() {
-    format = new NativeMessageFormat();
-  }
-
-  @Test
-  public void blowsUpWhenSerializeEmptyClass() {
-    try {
-      format.serialize(eventOf(new EmptyClass()));
-      expectFailing(OmegaException.class);
-    } catch (OmegaException e) {
-      assertThat(e.getMessage(), startsWith("Unable to serialize event with global tx id"));
-    }
-  }
-}

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.

[incubator-servicecomb-saga] 03/04: SCB-174 retrieve kryo instance from pool

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 390271d76f7f20ccab120851d7522b82d4c277fa
Author: Eric Lee <da...@huawei.com>
AuthorDate: Sun Jan 7 16:11:48 2018 +0800

    SCB-174 retrieve kryo instance from pool
    
    Signed-off-by: Eric Lee <da...@huawei.com>
---
 .../servicecomb/saga/omega/format/KryoMessageFormat.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
index 7ef16a2..f948963 100644
--- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
+++ b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
@@ -25,17 +25,24 @@ import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.KryoException;
 import com.esotericsoftware.kryo.io.Input;
 import com.esotericsoftware.kryo.io.Output;
+import com.esotericsoftware.kryo.pool.KryoFactory;
+import com.esotericsoftware.kryo.pool.KryoPool;
 
 public class KryoMessageFormat implements MessageFormat {
 
   private static final int DEFAULT_BUFFER_SIZE = 4096;
 
-  private static final Kryo kryo = new Kryo();
+  private static final KryoFactory factory = Kryo::new;
+
+  private static final KryoPool pool = new KryoPool.Builder(factory).softReferences().build();
 
   @Override
   public byte[] serialize(Object[] objects) {
     Output output = new Output(DEFAULT_BUFFER_SIZE, -1);
+
+    Kryo kryo = pool.borrow();
     kryo.writeObjectOrNull(output, objects, Object[].class);
+    pool.release(kryo);
 
     return output.toBytes();
   }
@@ -44,7 +51,12 @@ public class KryoMessageFormat implements MessageFormat {
   public Object[] deserialize(byte[] message) {
     try {
       Input input = new Input(new ByteArrayInputStream(message));
-      return kryo.readObjectOrNull(input, Object[].class);
+
+      Kryo kryo = pool.borrow();
+      Object[] objects = kryo.readObjectOrNull(input, Object[].class);
+      pool.release(kryo);
+
+      return objects;
     } catch (KryoException e) {
       throw new OmegaException("Unable to deserialize message", e);
     }

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.

[incubator-servicecomb-saga] 01/04: SCB-174 add kryo serializer

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seanyinx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 828b2a769dd8aa16562fa11fbf9c568f3f4ba00d
Author: Eric Lee <da...@huawei.com>
AuthorDate: Sat Jan 6 19:28:52 2018 +0800

    SCB-174 add kryo serializer
    
    Signed-off-by: Eric Lee <da...@huawei.com>
---
 omega/omega-format/pom.xml                         |  4 ++
 .../saga/omega/format/KryoMessageFormat.java       | 52 ++++++++++++++++
 .../saga/omega/format/MessageFormat.java           | 34 +++++++++++
 .../saga/omega/format/NativeMessageFormat.java     | 14 +----
 .../saga/omega/format/KryoMessageFormatTest.java   | 59 ++++++++++++++++++
 ...eFormatTest.java => MessageFormatTestBase.java} | 27 ++++-----
 .../saga/omega/format/NativeMessageFormatTest.java | 69 ++++++++++------------
 .../saga/omega/spring/OmegaSpringConfig.java       |  5 +-
 pom.xml                                            |  5 ++
 9 files changed, 201 insertions(+), 68 deletions(-)

diff --git a/omega/omega-format/pom.xml b/omega/omega-format/pom.xml
index a842cbb..f34f323 100644
--- a/omega/omega-format/pom.xml
+++ b/omega/omega-format/pom.xml
@@ -33,6 +33,10 @@
       <groupId>org.apache.servicecomb.saga</groupId>
       <artifactId>omega-transaction</artifactId>
     </dependency>
+    <dependency>
+      <groupId>com.esotericsoftware</groupId>
+      <artifactId>kryo</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>junit</groupId>
diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
new file mode 100644
index 0000000..2a0dd8d
--- /dev/null
+++ b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java
@@ -0,0 +1,52 @@
+/*
+ *  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 org.apache.servicecomb.saga.omega.format;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.servicecomb.saga.omega.transaction.OmegaException;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.KryoException;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+public class KryoMessageFormat implements MessageFormat {
+
+  private static final int DEFAULT_BUFFER_SIZE = 4096;
+
+  private static final Kryo kryo = new Kryo();
+
+  @Override
+  public byte[] serialize(Object[] objects) {
+    Output output = new Output(DEFAULT_BUFFER_SIZE, -1);
+    kryo.writeObjectOrNull(output, objects, Object[].class);
+
+    return output.toBytes();
+  }
+
+  @Override
+  public Object[] deserialize(byte[] message) {
+    try {
+      Input input = new Input(new ByteArrayInputStream(message));
+      return kryo.readObjectOrNull(input, Object[].class);
+    } catch (KryoException e) {
+      throw new OmegaException("Unable to deserialize message", e);
+    }
+  }
+}
diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java
new file mode 100644
index 0000000..8adde72
--- /dev/null
+++ b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java
@@ -0,0 +1,34 @@
+/*
+ *  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 org.apache.servicecomb.saga.omega.format;
+
+import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer;
+import org.apache.servicecomb.saga.omega.transaction.MessageSerializer;
+import org.apache.servicecomb.saga.omega.transaction.OmegaException;
+import org.apache.servicecomb.saga.omega.transaction.TxEvent;
+
+interface MessageFormat extends MessageSerializer, MessageDeserializer {
+  @Override
+  default byte[] serialize(TxEvent event) {
+    try {
+      return serialize(event.payloads());
+    } catch (OmegaException e) {
+      throw new OmegaException("Unable to serialize event with global tx id " + event.globalTxId(), e);
+    }
+  }
+}
diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
index a486e1d..383afeb 100644
--- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
+++ b/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormat.java
@@ -23,21 +23,9 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import org.apache.servicecomb.saga.omega.transaction.TxEvent;
-import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer;
-import org.apache.servicecomb.saga.omega.transaction.MessageSerializer;
 import org.apache.servicecomb.saga.omega.transaction.OmegaException;
 
-public class NativeMessageFormat implements MessageSerializer, MessageDeserializer {
-  @Override
-  public byte[] serialize(TxEvent event) {
-    try {
-      return serialize(event.payloads());
-    } catch (OmegaException e) {
-      throw new OmegaException("Unable to serialize event with global tx id " + event.globalTxId(), e);
-    }
-  }
-
+public class NativeMessageFormat implements MessageFormat {
   @Override
   public byte[] serialize(Object[] objects) {
     try {
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java
new file mode 100644
index 0000000..434067e
--- /dev/null
+++ b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java
@@ -0,0 +1,59 @@
+/*
+ *  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 org.apache.servicecomb.saga.omega.format;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class KryoMessageFormatTest extends MessageFormatTestBase {
+
+  @BeforeClass
+  public static void setUp() {
+    format = new KryoMessageFormat();
+  }
+
+  @Test
+  @Override
+  public void serializeObjectIntoBytes() throws Exception {
+    super.serializeObjectIntoBytes();
+  }
+
+  @Test
+  @Override
+  public void serializeNullIntoBytes() throws Exception {
+    super.serializeNullIntoBytes();
+  }
+
+  @Test
+  @Override
+  public void blowsUpWhenObjectIsNotDeserializable() throws Exception {
+    super.blowsUpWhenObjectIsNotDeserializable();
+  }
+
+  @Test
+  public void serializeEmptyClassIntoBytes() {
+    byte[] bytes = format.serialize(eventOf(new EmptyClass()));
+
+    Object[] message = format.deserialize(bytes);
+
+    assertThat(message[0] instanceof EmptyClass, is(true));
+  }
+}
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java
similarity index 76%
copy from omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
copy to omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java
index 1460fd2..2188447 100644
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
+++ b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java
@@ -20,18 +20,18 @@ package org.apache.servicecomb.saga.omega.format;
 import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing;
 import static java.util.Arrays.asList;
 import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertThat;
 
 import org.apache.servicecomb.saga.omega.transaction.OmegaException;
 import org.apache.servicecomb.saga.omega.transaction.TxEvent;
-import org.junit.Test;
 
-public class NativeMessageFormatTest {
+public class MessageFormatTestBase {
 
-  private final NativeMessageFormat format = new NativeMessageFormat();
+  static MessageFormat format;
 
-  @Test
   public void serializeObjectIntoBytes() throws Exception {
     byte[] bytes = format.serialize(eventOf("hello", "world"));
 
@@ -40,17 +40,14 @@ public class NativeMessageFormatTest {
     assertThat(asList(message), contains("hello", "world"));
   }
 
-  @Test
-  public void blowsUpWhenObjectIsNotSerializable() throws Exception {
-    try {
-      format.serialize(eventOf(new NotSerializable()));
-      expectFailing(OmegaException.class);
-    } catch (OmegaException e) {
-      assertThat(e.getMessage(), startsWith("Unable to serialize event with global tx id"));
-    }
+  public void serializeNullIntoBytes() throws Exception {
+    byte[] bytes = format.serialize(eventOf((Object[]) null));
+
+    Object[] message = format.deserialize(bytes);
+
+    assertThat(message, is(nullValue()));
   }
 
-  @Test
   public void blowsUpWhenObjectIsNotDeserializable() throws Exception {
     try {
       format.deserialize(new byte[0]);
@@ -60,10 +57,10 @@ public class NativeMessageFormatTest {
     }
   }
 
-  private TxEvent eventOf(Object... payloads) {
+  TxEvent eventOf(Object... payloads) {
     return new TxEvent(null, null, null, null, payloads);
   }
 
-  private static class NotSerializable {
+  static class EmptyClass {
   }
 }
diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
index 1460fd2..e07bb61 100644
--- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
+++ b/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/NativeMessageFormatTest.java
@@ -1,69 +1,62 @@
 /*
- * 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
+ *  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
+ *       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.
+ *  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 org.apache.servicecomb.saga.omega.format;
 
 import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing;
-import static java.util.Arrays.asList;
-import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.startsWith;
 import static org.junit.Assert.assertThat;
 
 import org.apache.servicecomb.saga.omega.transaction.OmegaException;
-import org.apache.servicecomb.saga.omega.transaction.TxEvent;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
-public class NativeMessageFormatTest {
+public class NativeMessageFormatTest extends MessageFormatTestBase {
 
-  private final NativeMessageFormat format = new NativeMessageFormat();
+  @BeforeClass
+  public static void setUp() {
+    format = new NativeMessageFormat();
+  }
 
   @Test
+  @Override
   public void serializeObjectIntoBytes() throws Exception {
-    byte[] bytes = format.serialize(eventOf("hello", "world"));
-
-    Object[] message = format.deserialize(bytes);
-
-    assertThat(asList(message), contains("hello", "world"));
+    super.serializeObjectIntoBytes();
   }
 
   @Test
-  public void blowsUpWhenObjectIsNotSerializable() throws Exception {
-    try {
-      format.serialize(eventOf(new NotSerializable()));
-      expectFailing(OmegaException.class);
-    } catch (OmegaException e) {
-      assertThat(e.getMessage(), startsWith("Unable to serialize event with global tx id"));
-    }
+  @Override
+  public void serializeNullIntoBytes() throws Exception {
+    super.serializeNullIntoBytes();
   }
 
   @Test
+  @Override
   public void blowsUpWhenObjectIsNotDeserializable() throws Exception {
+    super.blowsUpWhenObjectIsNotDeserializable();
+  }
+
+  @Test
+  public void blowsUpWhenSerializeEmptyClass() {
     try {
-      format.deserialize(new byte[0]);
+      format.serialize(eventOf(new EmptyClass()));
       expectFailing(OmegaException.class);
     } catch (OmegaException e) {
-      assertThat(e.getMessage(), startsWith("Unable to deserialize message"));
+      assertThat(e.getMessage(), startsWith("Unable to serialize event with global tx id"));
     }
   }
-
-  private TxEvent eventOf(Object... payloads) {
-    return new TxEvent(null, null, null, null, payloads);
-  }
-
-  private static class NotSerializable {
-  }
 }
diff --git a/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java b/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java
index 9e0ebb6..7ed1f84 100644
--- a/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java
+++ b/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java
@@ -29,7 +29,7 @@ import org.apache.servicecomb.saga.omega.context.IdGenerator;
 import org.apache.servicecomb.saga.omega.context.OmegaContext;
 import org.apache.servicecomb.saga.omega.context.ServiceConfig;
 import org.apache.servicecomb.saga.omega.context.UniqueIdGenerator;
-import org.apache.servicecomb.saga.omega.format.NativeMessageFormat;
+import org.apache.servicecomb.saga.omega.format.KryoMessageFormat;
 import org.apache.servicecomb.saga.omega.transaction.MessageHandler;
 import org.apache.servicecomb.saga.omega.transaction.MessageSender;
 import org.slf4j.Logger;
@@ -76,7 +76,8 @@ class OmegaSpringConfig {
     // TODO: 2017/12/26 connect to the one with lowest latency
     for (String address : addresses) {
       try {
-        MessageSender sender = new GrpcClientMessageSender(grpcChannel(address), new NativeMessageFormat(), new NativeMessageFormat(), serviceConfig, handler);
+        MessageSender sender = new GrpcClientMessageSender(grpcChannel(address), new KryoMessageFormat(),
+            new KryoMessageFormat(), serviceConfig, handler);
         sender.onConnected();
         senders.add(sender);
         return sender;
diff --git a/pom.xml b/pom.xml
index 145b658..2458bc8 100755
--- a/pom.xml
+++ b/pom.xml
@@ -329,6 +329,11 @@
         <artifactId>grpc-stub</artifactId>
         <version>${grpc.version}</version>
       </dependency>
+      <dependency>
+        <groupId>com.esotericsoftware</groupId>
+        <artifactId>kryo</artifactId>
+        <version>4.0.1</version>
+      </dependency>
 
       <!-- test dependencies -->
       <dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.