Skip to content

Commit

Permalink
Serialize from LogChannel instead of from buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Needham committed Nov 5, 2015
1 parent 1f5e0ed commit 89444f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Expand Up @@ -19,13 +19,14 @@
*/ */
package org.neo4j.com; package org.neo4j.com;


import org.jboss.netty.buffer.ChannelBuffer;

import java.io.IOException; import java.io.IOException;


import org.jboss.netty.buffer.ChannelBuffer;

import org.neo4j.helpers.collection.Visitor; import org.neo4j.helpers.collection.Visitor;
import org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation; import org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation;
import org.neo4j.kernel.impl.transaction.log.CommandWriter; import org.neo4j.kernel.impl.transaction.log.CommandWriter;
import org.neo4j.kernel.impl.transaction.log.WritableLogChannel;
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit; import org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit;
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart; import org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart;
import org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter; import org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter;
Expand All @@ -37,12 +38,12 @@
*/ */
public class CommittedTransactionSerializer implements Visitor<CommittedTransactionRepresentation,IOException> public class CommittedTransactionSerializer implements Visitor<CommittedTransactionRepresentation,IOException>
{ {
private final NetworkWritableLogChannel channel; private final WritableLogChannel channel;
private final LogEntryWriter writer; private final LogEntryWriter writer;


public CommittedTransactionSerializer( ChannelBuffer targetBuffer ) public CommittedTransactionSerializer( WritableLogChannel networkWritableLogChannel )
{ {
this.channel = new NetworkWritableLogChannel( targetBuffer ); this.channel = networkWritableLogChannel;
this.writer = new LogEntryWriter( channel, new CommandWriter( channel ) ); this.writer = new LogEntryWriter( channel, new CommandWriter( channel ) );
} }


Expand All @@ -58,4 +59,4 @@ public boolean visit( CommittedTransactionRepresentation tx ) throws IOException
writer.writeCommitEntry( commitEntry.getTxId(), commitEntry.getTimeWritten() ); writer.writeCommitEntry( commitEntry.getTxId(), commitEntry.getTimeWritten() );
return false; return false;
} }
} }
25 changes: 13 additions & 12 deletions enterprise/com/src/main/java/org/neo4j/com/Server.java
Expand Up @@ -19,6 +19,17 @@
*/ */
package org.neo4j.com; package org.neo4j.com;


import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.buffer.ChannelBuffers;
Expand All @@ -36,17 +47,6 @@
import org.jboss.netty.channel.group.DefaultChannelGroup; import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;


import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.neo4j.com.monitor.RequestMonitor; import org.neo4j.com.monitor.RequestMonitor;
import org.neo4j.helpers.Clock; import org.neo4j.helpers.Clock;
import org.neo4j.helpers.Exceptions; import org.neo4j.helpers.Exceptions;
Expand All @@ -63,6 +63,7 @@
import static java.util.concurrent.Executors.newCachedThreadPool; import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.Executors.newScheduledThreadPool; import static java.util.concurrent.Executors.newScheduledThreadPool;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;

import static org.neo4j.com.DechunkingChannelBuffer.assertSameProtocolVersion; import static org.neo4j.com.DechunkingChannelBuffer.assertSameProtocolVersion;
import static org.neo4j.com.Protocol.addLengthFieldPipes; import static org.neo4j.com.Protocol.addLengthFieldPipes;
import static org.neo4j.com.Protocol.assertChunkSizeIsWithinFrameSize; import static org.neo4j.com.Protocol.assertChunkSizeIsWithinFrameSize;
Expand Down Expand Up @@ -620,7 +621,7 @@ public void obligation( long txId ) throws IOException
public Visitor<CommittedTransactionRepresentation,IOException> transactions() public Visitor<CommittedTransactionRepresentation,IOException> transactions()
{ {
targetBuffer.writeByte( 1 ); targetBuffer.writeByte( 1 );
return new CommittedTransactionSerializer( targetBuffer ); return new CommittedTransactionSerializer( new NetworkWritableLogChannel( targetBuffer ) );
} }
} }


Expand Down

0 comments on commit 89444f7

Please sign in to comment.