Skip to content

Commit d181998

Browse files
committed
CHRONX-26 Review VanillaChronicle replication and move it out of sandbox
1 parent a3bbb55 commit d181998

File tree

5 files changed

+23
-36
lines changed

5 files changed

+23
-36
lines changed

chronicle-sandbox/src/main/java/net/openhft/chronicle/sandbox/tcp/VanillaChronicleTCPCommon.java

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
package net.openhft.chronicle.sandbox.tcp;
17+
package net.openhft.chronicle.tcp;
1818

1919
import net.openhft.chronicle.*;
20-
import net.openhft.chronicle.tcp.TcpUtil;
2120
import net.openhft.chronicle.tools.WrappedExcerpt;
2221
import net.openhft.lang.model.constraints.NotNull;
2322
import net.openhft.lang.model.constraints.Nullable;
@@ -47,6 +46,9 @@ public class VanillaChronicleSink implements Chronicle {
4746
private final VanillaChronicle chronicle;
4847
@NotNull
4948
private final SocketAddress address;
49+
@Nullable
50+
private SocketChannel sc = null;
51+
5052
private final VanillaChronicle.VanillaAppender excerpt;
5153
private final Logger logger;
5254
private volatile boolean closed = false;
@@ -113,9 +115,6 @@ public boolean index(long index) throws IndexOutOfBoundsException {
113115
}
114116
}
115117

116-
@Nullable
117-
private SocketChannel sc = null;
118-
119118
boolean readNext() {
120119
if (sc == null || !sc.isOpen()) {
121120
sc = createConnection();
@@ -158,21 +157,27 @@ else if (logger.isLoggable(Level.INFO))
158157

159158
private boolean readNextExcerpt(@NotNull SocketChannel sc) {
160159
try {
161-
if (closed) return false;
160+
if (closed) {
161+
return false;
162+
}
162163

163-
if (readBuffer.remaining() < TcpUtil.HEADER_SIZE +8) {
164+
// Check if there is enogh data (header plus some more data)
165+
if (readBuffer.remaining() < TcpUtil.HEADER_SIZE + 8) {
164166
if (readBuffer.remaining() == 0){
165167
readBuffer.clear();
166168
}
167169
else{
168170
readBuffer.compact();
169171
}
170-
while (readBuffer.position() < 8 + 4 + 8 + 8) {
172+
173+
// Waith till some more data has been readed
174+
while (readBuffer.position() < TcpUtil.HEADER_SIZE + 8 + 8) {
171175
if (sc.read(readBuffer) < 0) {
172176
sc.close();
173177
return false;
174178
}
175179
}
180+
176181
readBuffer.flip();
177182
}
178183

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
package net.openhft.chronicle.sandbox.tcp;
17+
package net.openhft.chronicle.tcp;
1818

19-
import net.openhft.chronicle.*;
20-
import net.openhft.chronicle.tcp.TcpUtil;
19+
import net.openhft.chronicle.Chronicle;
20+
import net.openhft.chronicle.ChronicleConfig;
21+
import net.openhft.chronicle.Excerpt;
22+
import net.openhft.chronicle.ExcerptAppender;
23+
import net.openhft.chronicle.ExcerptCommon;
24+
import net.openhft.chronicle.ExcerptTailer;
25+
import net.openhft.chronicle.VanillaChronicle;
2126
import net.openhft.chronicle.tools.WrappedExcerpt;
2227
import net.openhft.lang.model.constraints.NotNull;
2328
import net.openhft.lang.thread.NamedThreadFactory;
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616

1717
package net.openhft.chronicle;
1818

19-
import net.openhft.chronicle.sandbox.tcp.VanillaChronicleSink;
20-
import net.openhft.chronicle.sandbox.tcp.VanillaChronicleSource;
19+
import net.openhft.chronicle.tcp.VanillaChronicleSink;
20+
import net.openhft.chronicle.tcp.VanillaChronicleSource;
2121
import org.junit.Assert;
22-
import org.junit.Ignore;
2322
import org.junit.Test;
2423

2524
import java.io.IOException;
2625

27-
@Ignore
2826
public class VanillaChronicleSourceTest {
2927
@Test
3028
public void testReplication() throws IOException {
File renamed without changes.

0 commit comments

Comments
 (0)