ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [18/50] [abbrv] incubator-ignite git commit: ignite-nio - Removing message clone
Date Sun, 15 Feb 2015 08:42:00 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriteState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriteState.java
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriteState.java
deleted file mode 100644
index ba21e25..0000000
--- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriteState.java
+++ /dev/null
@@ -1,124 +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.ignite.plugin.extensions.communication;
-
-import org.apache.ignite.internal.direct.*;
-
-/**
- * TODO
- */
-public final class MessageWriteState {
-    public static MessageWriteState create(MessageFormatter formatter) {
-        MessageWriter writer = formatter.writer();
-
-        MessageWriteState state = new MessageWriteState(writer);
-
-        // TODO: rework
-        ((DirectMessageWriter)writer).state(state);
-
-        return state;
-    }
-
-    private final MessageWriter writer;
-
-    private final Stack stack;
-
-    private MessageWriteState(MessageWriter writer) {
-        this.writer = writer;
-
-        stack = new Stack(-1);
-    }
-
-    public MessageWriter writer() {
-        return writer;
-    }
-
-    public boolean isTypeWritten() {
-        return stack.current() >= 0;
-    }
-
-    public void setTypeWritten() {
-        assert stack.current() == -1;
-
-        stack.incrementCurrent();
-    }
-
-    public int index() {
-        return stack.current();
-    }
-
-    public void increment() {
-        stack.incrementCurrent();
-    }
-
-    public void forward() {
-        stack.push();
-    }
-
-    public void backward(boolean finished) {
-        if (finished)
-            stack.resetCurrent();
-
-        stack.pop();
-    }
-
-    public void reset() {
-        stack.reset();
-    }
-
-    private static class Stack {
-        private final int[] arr = new int[10];
-
-        private final int initVal;
-
-        private int pos;
-
-        private Stack(int initVal) {
-            this.initVal = initVal;
-
-            for (int i = 0; i < arr.length; i++)
-                arr[i] = initVal;
-        }
-
-        int current() {
-            return arr[pos];
-        }
-
-        void incrementCurrent() {
-            arr[pos]++;
-        }
-
-        void resetCurrent() {
-            arr[pos] = initVal;
-        }
-
-        void push() {
-            pos++;
-        }
-
-        void pop() {
-            pos--;
-        }
-
-        void reset() {
-            assert pos == 0;
-
-            resetCurrent();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
index e6117a8..ee729e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
@@ -255,4 +255,18 @@ public interface MessageWriter {
      */
     public <K, V> boolean writeMap(String name, Map<K, V> map, MessageAdapter.Type
keyType,
         MessageAdapter.Type valType);
+
+    public boolean isTypeWritten();
+
+    public void onTypeWritten();
+
+    public int state();
+
+    public void incrementState();
+
+    public void beforeInnerMessageWrite();
+
+    public void afterInnerMessageWrite(boolean finished);
+
+    public void reset();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
index 62e48d1..c49df8f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java
@@ -69,24 +69,22 @@ public class JobStealingRequest extends MessageAdapter {
 
     /** {@inheritDoc} */
     @SuppressWarnings("all")
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
-        MessageWriter writer = state.writer();
-
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
         writer.setBuffer(buf);
 
-        if (!state.isTypeWritten()) {
+        if (!writer.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            state.setTypeWritten();
+            writer.onTypeWritten();
         }
 
-        switch (state.index()) {
+        switch (writer.state()) {
             case 0:
                 if (!writer.writeInt("delta", delta))
                     return false;
 
-                state.increment();
+                writer.incrementState();
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index eb118b2..6ddb15b 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -2211,9 +2211,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
 
                         buf.order(ByteOrder.nativeOrder());
 
-                        MessageWriteState state = MessageWriteState.create(getSpiContext().messageFormatter());
-
-                        boolean written = msg.writeTo(buf, state);
+                        boolean written = msg.writeTo(buf, getSpiContext().messageFormatter().writer());
 
                         assert written;
 
@@ -3038,7 +3036,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         }
 
         /** {@inheritDoc} */
-        @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+        @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
             if (buf.remaining() < 33)
                 return false;
 
@@ -3130,7 +3128,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         }
 
         /** {@inheritDoc} */
-        @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+        @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
             if (buf.remaining() < 9)
                 return false;
 
@@ -3211,7 +3209,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         }
 
         /** {@inheritDoc} */
-        @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+        @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
             assert nodeIdBytes.length == 16;
 
             if (buf.remaining() < 17)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java
index 3fd87a5..7ffb4a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java
@@ -155,7 +155,7 @@ public class GridCommunicationSendMessageSelfTest extends GridCommonAbstractTest
         }
 
         /** {@inheritDoc} */
-        @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+        @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
 //            writer.setBuffer(buf);
 //
 //            return writer.writeByte(null, directType());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
index 22c6a04..0f5ac97 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java
@@ -231,7 +231,7 @@ public class GridIoManagerSelfTest extends GridCommonAbstractTest {
         }
 
         /** {@inheritDoc} */
-        @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+        @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
             return true;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java
b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java
index b6353b7..b185031 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java
@@ -119,7 +119,7 @@ class GridTestMessage extends MessageAdapter implements Externalizable
{
     }
 
     /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e63ce523/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java
index 8ab4b6e..8e64667 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java
@@ -115,7 +115,7 @@ public class GridTestMessage extends MessageAdapter {
 
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriteState state) {
+    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
 //        writer.setBuffer(buf);
 //
 //        if (!typeWritten) {


Mime
View raw message