Skip to content

Commit

Permalink
Removing Bolt V1 and Bolt V2
Browse files Browse the repository at this point in the history
When tx failed with error, no more tx or query is allowed until the failure is cleared with a RESET message.
The client is not expected to continue a failed tx, as the tx can only be rolled back.
One of the main goal of this PR is to get rid of `ACK_FAILURE` message so that no more interaction is allowed with the tx after it is failed.
  • Loading branch information
Zhen Li authored and zhenlineo committed Sep 2, 2019
1 parent 808dfa5 commit 9ff0780
Show file tree
Hide file tree
Showing 302 changed files with 3,155 additions and 6,511 deletions.
16 changes: 8 additions & 8 deletions community/bolt/src/main/java/org/neo4j/bolt/BoltServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

import org.neo4j.bolt.dbapi.BoltGraphDatabaseManagementServiceSPI;
import org.neo4j.bolt.runtime.BoltConnectionFactory;
import org.neo4j.bolt.runtime.BoltSchedulerProvider;
import org.neo4j.bolt.runtime.BoltStateMachineFactory;
import org.neo4j.bolt.runtime.BoltStateMachineFactoryImpl;
import org.neo4j.bolt.runtime.CachedThreadPoolExecutorFactory;
import org.neo4j.bolt.runtime.scheduling.BoltSchedulerProvider;
import org.neo4j.bolt.runtime.statemachine.BoltStateMachineFactory;
import org.neo4j.bolt.runtime.statemachine.impl.BoltStateMachineFactoryImpl;
import org.neo4j.bolt.runtime.scheduling.CachedThreadPoolExecutorFactory;
import org.neo4j.bolt.runtime.DefaultBoltConnectionFactory;
import org.neo4j.bolt.runtime.ExecutorBoltSchedulerProvider;
import org.neo4j.bolt.runtime.NettyThreadFactory;
import org.neo4j.bolt.runtime.scheduling.ExecutorBoltSchedulerProvider;
import org.neo4j.bolt.runtime.scheduling.NettyThreadFactory;
import org.neo4j.bolt.security.auth.Authentication;
import org.neo4j.bolt.security.auth.BasicAuthentication;
import org.neo4j.bolt.transport.BoltProtocolFactory;
Expand Down Expand Up @@ -115,7 +115,7 @@ public void init() throws Exception
life.setLast( new ExecutorBoltSchedulerProvider( config, new CachedThreadPoolExecutorFactory( log ), jobScheduler, logService ) );
BoltConnectionFactory boltConnectionFactory =
createConnectionFactory( config, boltSchedulerProvider, throttleGroup, logService, clock );
BoltStateMachineFactory boltStateMachineFactory = createBoltFactory( authentication, clock );
BoltStateMachineFactory boltStateMachineFactory = createBoltStateMachineFactory( authentication, clock );

BoltProtocolFactory boltProtocolFactory = createBoltProtocolFactory( boltConnectionFactory, boltStateMachineFactory );

Expand Down Expand Up @@ -223,7 +223,7 @@ private BoltProtocolFactory createBoltProtocolFactory( BoltConnectionFactory con
return new DefaultBoltProtocolFactory( connectionFactory, stateMachineFactory, logService, databaseIdRepository );
}

private BoltStateMachineFactory createBoltFactory( Authentication authentication, SystemNanoClock clock )
private BoltStateMachineFactory createBoltStateMachineFactory( Authentication authentication, SystemNanoClock clock )
{
return new BoltStateMachineFactoryImpl( boltGraphDatabaseManagementServiceSPI, authentication, clock, config, logService );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import java.util.List;
import java.util.Map;

import org.neo4j.bolt.packstream.Neo4jPack;
import org.neo4j.bolt.runtime.BoltConnection;
import org.neo4j.bolt.runtime.BoltResponseHandler;
import org.neo4j.bolt.runtime.Neo4jError;
import org.neo4j.bolt.v1.packstream.PackStream;
import org.neo4j.bolt.packstream.PackStream;
import org.neo4j.kernel.api.exceptions.Status;

import static java.util.function.Function.identity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
public interface BoltResponseMessageWriter extends BoltRecordConsumer
{
void write( ResponseMessage message ) throws IOException;
void flush() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;

import org.neo4j.bolt.packstream.Neo4jPack;
import org.neo4j.bolt.runtime.BoltResponseHandler;

public interface RequestMessageDecoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.io.IOException;

import org.neo4j.bolt.packstream.Neo4jPack;

public interface ResponseMessageEncoder<T extends ResponseMessage>
{
void encode( Neo4jPack.Packer packer, T message ) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v4.messaging;
package org.neo4j.bolt.messaging;

import org.neo4j.bolt.runtime.BoltResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.util.HashMap;
import java.util.Map;

import org.neo4j.bolt.v1.messaging.Neo4jPackV1;
import org.neo4j.bolt.v2.messaging.Neo4jPackV2;
import org.neo4j.bolt.packstream.Neo4jPackV1;
import org.neo4j.bolt.packstream.Neo4jPackV2;

import static java.util.Collections.unmodifiableMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

import io.netty.buffer.ByteBuf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.transport;
package org.neo4j.bolt.packstream;

import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
Expand All @@ -29,9 +29,6 @@
import org.neo4j.bolt.messaging.BoltIOException;
import org.neo4j.bolt.transport.TransportThrottleException;
import org.neo4j.bolt.transport.TransportThrottleGroup;
import org.neo4j.bolt.v1.packstream.PackOutput;
import org.neo4j.bolt.v1.packstream.PackOutputClosedException;
import org.neo4j.bolt.v1.packstream.PackStream;
import org.neo4j.kernel.api.exceptions.Status;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.messaging;
package org.neo4j.bolt.packstream;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.messaging;
package org.neo4j.bolt.packstream;

import java.io.IOException;
import java.time.LocalDate;
Expand All @@ -29,13 +29,8 @@
import java.util.List;

import org.neo4j.bolt.messaging.BoltIOException;
import org.neo4j.bolt.messaging.Neo4jPack;
import org.neo4j.bolt.messaging.StructType;
import org.neo4j.bolt.messaging.util.PrimitiveLongIntKeyValueArray;
import org.neo4j.bolt.v1.packstream.PackInput;
import org.neo4j.bolt.v1.packstream.PackOutput;
import org.neo4j.bolt.v1.packstream.PackStream;
import org.neo4j.bolt.v1.packstream.PackType;
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.values.AnyValue;
import org.neo4j.values.AnyValueWriter;
Expand All @@ -50,7 +45,7 @@
import org.neo4j.values.virtual.RelationshipValue;
import org.neo4j.values.virtual.VirtualValues;

import static org.neo4j.bolt.v1.packstream.PackStream.UNKNOWN_SIZE;
import static org.neo4j.bolt.packstream.PackStream.UNKNOWN_SIZE;
import static org.neo4j.values.storable.Values.byteArray;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v2.messaging;
package org.neo4j.bolt.packstream;

import java.io.IOException;
import java.time.Instant;
Expand All @@ -31,12 +31,7 @@
import java.util.Arrays;

import org.neo4j.bolt.messaging.BoltIOException;
import org.neo4j.bolt.messaging.Neo4jPack;
import org.neo4j.bolt.messaging.StructType;
import org.neo4j.bolt.v1.messaging.Neo4jPackV1;
import org.neo4j.bolt.v1.packstream.PackInput;
import org.neo4j.bolt.v1.packstream.PackOutput;
import org.neo4j.bolt.v1.packstream.PackStream;
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.values.AnyValue;
import org.neo4j.values.storable.CoordinateReferenceSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

import java.io.Closeable;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.messaging;

import org.neo4j.bolt.v1.packstream.PackOutput;
package org.neo4j.bolt.packstream;

public interface PackProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

import org.neo4j.bolt.messaging.StructType;
import org.neo4j.bolt.v1.packstream.utf8.UTF8Encoder;
import org.neo4j.bolt.packstream.utf8.UTF8Encoder;

/**
* PackStream is a messaging serialisation format heavily inspired by MessagePack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

/**
* These are the primitive types that PackStream can represent. They map to the non-graph primitives of the Neo4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream;
package org.neo4j.bolt.packstream;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.messaging;

import org.neo4j.bolt.v1.packstream.PackInput;
package org.neo4j.bolt.packstream;

public interface UnpackerProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream.utf8;
package org.neo4j.bolt.packstream.utf8;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
Expand All @@ -27,7 +27,7 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.neo4j.bolt.v1.packstream.PackStream.PackStreamException;
import org.neo4j.bolt.packstream.PackStream.PackStreamException;
import org.neo4j.common.HexPrinter;

import static org.neo4j.util.FeatureToggles.getInteger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream.utf8;
package org.neo4j.bolt.packstream.utf8;

import java.nio.ByteBuffer;

Expand Down Expand Up @@ -63,7 +63,7 @@ public UTF8Encoder fastestAvailableEncoder()
try
{
return (UTF8Encoder)Class
.forName( "org.neo4j.bolt.v1.packstream.utf8.GCFreeUTF8Encoder" )
.forName( "org.neo4j.bolt.packstream.utf8.GCFreeUTF8Encoder" )
.getConstructor()
.newInstance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.packstream.utf8;
package org.neo4j.bolt.packstream.utf8;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bolt.v1.runtime;
package org.neo4j.bolt.runtime;

import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.neo4j.bolt.runtime.BoltResult;
import org.neo4j.bolt.runtime.statemachine.impl.BoltAdapterSubscriber;
import org.neo4j.graphdb.ExecutionPlanDescription;
import org.neo4j.graphdb.InputPosition;
import org.neo4j.graphdb.Notification;
Expand All @@ -41,12 +41,10 @@
import static java.lang.String.format;
import static org.neo4j.bolt.v4.messaging.AbstractStreamingMessage.STREAM_LIMIT_UNLIMITED;
import static org.neo4j.values.storable.Values.intValue;
import static org.neo4j.values.storable.Values.longValue;
import static org.neo4j.values.storable.Values.stringValue;

public class CypherAdapterStream implements BoltResult
public abstract class AbstractCypherAdapterStream implements BoltResult
{
private static final String RESULT_CONSUMED_AFTER = "result_consumed_after";
private static final String TYPE = "type";
private static final String STATS = "stats";
private static final String PROFILE = "profile";
Expand All @@ -60,12 +58,12 @@ public class CypherAdapterStream implements BoltResult
private final QueryExecution queryExecution;
private final String[] fieldNames;
protected final Clock clock;
private final TransactionStateMachineV1SPI.BoltAdapterSubscriber querySubscriber;
private final BoltAdapterSubscriber querySubscriber;

private static final Long STREAM_UNLIMITED_BATCH_SIZE = Long.MAX_VALUE;

public CypherAdapterStream( QueryExecution queryExecution,
TransactionStateMachineV1SPI.BoltAdapterSubscriber querySubscriber, Clock clock )
public AbstractCypherAdapterStream( QueryExecution queryExecution,
BoltAdapterSubscriber querySubscriber, Clock clock )
{
this.queryExecution = queryExecution;
this.fieldNames = queryExecution.fieldNames();
Expand Down Expand Up @@ -117,14 +115,9 @@ public boolean handleRecords( RecordConsumer recordConsumer, long size ) throws
return hasMore;
}

protected void addDatabaseName( RecordConsumer recordConsumer )
{
}
protected abstract void addDatabaseName( RecordConsumer recordConsumer );

protected void addRecordStreamingTime( long time, RecordConsumer recordConsumer )
{
recordConsumer.addMetadata( RESULT_CONSUMED_AFTER, longValue( time ) );
}
protected abstract void addRecordStreamingTime( long time, RecordConsumer recordConsumer );

private void addMetadata( QueryStatistics statistics, RecordConsumer recordConsumer )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import java.net.SocketAddress;
import java.util.concurrent.RejectedExecutionException;

import org.neo4j.bolt.v1.packstream.PackOutput;
import org.neo4j.bolt.v1.runtime.Job;
import org.neo4j.bolt.packstream.PackOutput;

public interface BoltConnection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.neo4j.bolt.runtime;

import org.neo4j.bolt.BoltChannel;
import org.neo4j.bolt.runtime.statemachine.BoltStateMachine;

public interface BoltConnectionFactory
{
Expand Down

0 comments on commit 9ff0780

Please sign in to comment.