private <E extends Exception> void unpackSuccessMessage( MessageHandler<E> output ) throws E, IOException { Map<String,Object> map = unpackRawMap(); output.handleSuccessMessage( map ); }
private <E extends Exception> void unpackAckFailureMessage( MessageHandler<E> output ) throws E { output.handleAckFailureMessage(); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleDiscardAllMessage(); }
private <T extends Message> T serializeAndDeserialize( T msg ) throws IOException { RecordingByteChannel channel = new RecordingByteChannel(); MessageFormat.Reader reader = new PackStreamMessageFormatV1.Reader( new PackStream.Unpacker( new BufferedChannelInput( 16 ).reset( channel ) ) ); MessageFormat.Writer writer = new PackStreamMessageFormatV1.Writer( new PackStream.Packer( new BufferedChannelOutput( channel ) ), NO_OP ); writer.write( msg ).flush(); channel.eof(); return unpack( reader, channel ); }
public static byte[] serialize( Message... messages ) throws IOException { final RecordingByteChannel rawData = new RecordingByteChannel(); final MessageFormat.Writer packer = new PackStreamMessageFormatV1.Writer( new PackStream.Packer( new BufferedChannelOutput( rawData )), NO_OP ); for ( Message message : messages ) { packer.write( message ); } packer.flush(); return rawData.getBytes(); }
private <T extends Message> T unpack( MessageFormat.Reader reader, RecordingByteChannel channel ) { // Unpack String serialized = HexPrinter.hex( channel.getBytes() ); RecordingMessageHandler messages = new RecordingMessageHandler(); try { reader.read( messages ); } catch ( Throwable e ) { throw new AssertionError( "Failed to unpack message, wire data was:\n" + serialized + "[" + channel .getBytes().length + "b]", e ); } return (T) messages.asList().get( 0 ); }
private <E extends Exception> void unpackRunMessage( MessageHandler<E> output ) throws E, IOException { String statement = unpacker.unpackString(); Map<String,Object> params = unpackRawMap(); output.handleRunMessage( statement, params ); }
private <E extends Exception> void unpackRecordMessage( MessageHandler<E> output ) throws E, IOException { long length = unpacker.unpackListHeader(); final Object[] fields = new Object[(int) length]; for ( int i = 0; i < length; i++ ) { fields[i] = unpackValue(); } output.handleRecordMessage( record( fields ) ); }
private <E extends Exception> void unpackFailureMessage( MessageHandler<E> output ) throws E, IOException { Map<String,Object> map = unpackRawMap(); String codeStr = map.containsKey( "code" ) ? (String) map.get( "code" ) : Status.General.UnknownFailure.name(); String msg = map.containsKey( "message" ) ? (String) map.get( "message" ) : "<No message supplied>"; output.handleFailureMessage( new Neo4jError( codeFromString( codeStr ), msg ) ); }
private <E extends Exception> void unpackPullAllMessage( MessageHandler<E> output ) throws E, IOException { output.handlePullAllMessage(); }
private <E extends Exception> void unpackIgnoredMessage( MessageHandler<E> output ) throws E { output.handleIgnoredMessage(); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleRecordMessage( value ); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleSuccessMessage( metadata ); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleRunMessage( statement, params ); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleFailureMessage( cause ); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleAckFailureMessage(); }
private <E extends Exception> void unpackDiscardAllMessage( MessageHandler<E> output ) throws E, IOException { output.handleDiscardAllMessage(); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handlePullAllMessage(); }
@Override public <E extends Exception> void dispatch( MessageHandler<E> consumer ) throws E { consumer.handleIgnoredMessage(); }
@Override public void visit( Record record ) throws IOException { out.handleRecordMessage( record ); } } );