# ignite-nio - Renaming
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/37e76c40 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/37e76c40 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/37e76c40 Branch: refs/heads/sprint-1 Commit: 37e76c40064575b55c39a6f8729cddad3a7cf526 Parents: 512ffc5 Author: Valentin Kulichenko <vkuliche...@gridgain.com> Authored: Sun Feb 15 00:16:21 2015 -0800 Committer: Valentin Kulichenko <vkuliche...@gridgain.com> Committed: Sun Feb 15 00:16:21 2015 -0800 ---------------------------------------------------------------------- .../internal/direct/DirectMessageWriter.java | 2 +- .../direct/DirectMessageWriterState.java | 113 +++++++++++++++++++ .../internal/direct/MessageWriterState.java | 113 ------------------- 3 files changed, 114 insertions(+), 114 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/37e76c40/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java index 0438bb2..238ecb6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java @@ -32,7 +32,7 @@ public class DirectMessageWriter implements MessageWriter { private final DirectByteBufferStream stream = new DirectByteBufferStream(null); /** State. */ - private final MessageWriterState state = new MessageWriterState(); + private final DirectMessageWriterState state = new DirectMessageWriterState(); /** {@inheritDoc} */ @Override public void setBuffer(ByteBuffer buf) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/37e76c40/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriterState.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriterState.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriterState.java new file mode 100644 index 0000000..a84060d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriterState.java @@ -0,0 +1,113 @@ +/* + * 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.internal.direct; + +import java.util.*; + +/** + * Writer state. + */ +public class DirectMessageWriterState { + /** Initial array size. */ + private static final int INIT_SIZE = 10; + + /** Initial value. */ + private static final int INIT_VAL = -1; + + /** Stack array. */ + private int[] stack; + + /** Current position. */ + private int pos; + + public DirectMessageWriterState() { + stack = new int[INIT_SIZE]; + + Arrays.fill(stack, INIT_VAL); + } + + /** + * @return Whether type is written. + */ + public boolean isTypeWritten() { + return state() >= 0; + } + + /** + * Callback called after type is written. + */ + public void onTypeWritten() { + assert state() == -1; + + incrementState(); + } + + /** + * @return Current state. + */ + public int state() { + return stack[pos]; + } + + /** + * Increments state. + */ + public void incrementState() { + stack[pos]++; + } + + /** + * Callback called before inner message is written. + */ + public void beforeInnerMessageWrite() { + pos++; + + // Growing never happen for Ignite messages, but we need + // to support it for custom messages from plugins. + if (pos == stack.length) { + int[] stack0 = stack; + + stack = new int[stack.length << 1]; + + System.arraycopy(stack0, 0, stack, 0, stack0.length); + + Arrays.fill(stack, stack0.length, stack.length, INIT_VAL); + } + } + + /** + * Callback called after inner message is written. + * + * @param finished Whether message was fully written. + */ + public void afterInnerMessageWrite(boolean finished) { + if (finished) + stack[pos] = INIT_VAL; + + pos--; + } + + /** + * Resets state. + */ + public void reset() { + assert pos == 0; + + stack[0] = INIT_VAL; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/37e76c40/modules/core/src/main/java/org/apache/ignite/internal/direct/MessageWriterState.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/MessageWriterState.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/MessageWriterState.java deleted file mode 100644 index e486ad3..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/MessageWriterState.java +++ /dev/null @@ -1,113 +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.internal.direct; - -import java.util.*; - -/** - * Writer state. - */ -public class MessageWriterState { - /** Initial array size. */ - private static final int INIT_SIZE = 10; - - /** Initial value. */ - private static final int INIT_VAL = -1; - - /** Stack array. */ - private int[] stack; - - /** Current position. */ - private int pos; - - public MessageWriterState() { - stack = new int[INIT_SIZE]; - - Arrays.fill(stack, INIT_VAL); - } - - /** - * @return Whether type is written. - */ - public boolean isTypeWritten() { - return state() >= 0; - } - - /** - * Callback called after type is written. - */ - public void onTypeWritten() { - assert state() == -1; - - incrementState(); - } - - /** - * @return Current state. - */ - public int state() { - return stack[pos]; - } - - /** - * Increments state. - */ - public void incrementState() { - stack[pos]++; - } - - /** - * Callback called before inner message is written. - */ - public void beforeInnerMessageWrite() { - pos++; - - // Growing never happen for Ignite messages, but we need - // to support it for custom messages from plugins. - if (pos == stack.length) { - int[] stack0 = stack; - - stack = new int[stack.length << 1]; - - System.arraycopy(stack0, 0, stack, 0, stack0.length); - - Arrays.fill(stack, stack0.length, stack.length, INIT_VAL); - } - } - - /** - * Callback called after inner message is written. - * - * @param finished Whether message was fully written. - */ - public void afterInnerMessageWrite(boolean finished) { - if (finished) - stack[pos] = INIT_VAL; - - pos--; - } - - /** - * Resets state. - */ - public void reset() { - assert pos == 0; - - stack[0] = INIT_VAL; - } -}