-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NetworkInputStream #23
Closed
Closed
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
22f383c
Merge pull request #2 from alexanderkjall/master
sagenschneider 310e719
Merge pull request #3 from alexanderkjall/pr-19
sagenschneider 62f1f9c
NetworkInputStream for reading direct from buffers
cc54110
Merge branch 'master' of [email protected]:sagenschneider/pgsql2.git
4fac651
Providing deploy script for temporary use
73241a5
Merge branch 'master' of [email protected]:pgjdbc/pgsql2.git
e402c42
Merge branch 'master' of [email protected]:pgjdbc/pgsql2.git
d501c4d
Tidy up for reducing number of requests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ out/ | |
/.project | ||
/.settings/ | ||
/bin/ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>pgsql2</artifactId> | ||
<version>0.0.1</version> | ||
<name>PostgreSql ADBA</name> | ||
<description>Deploys the PostgreSql pgsql2 to OfficeFloor sourceforge for use</description> | ||
<!-- Steps to deploy: --> | ||
<!-- ssh -t [email protected] create --> | ||
<!-- mvn -f deploy-pom.xml validate --> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<pgsql2.version>1.0-SNAPSHOT</pgsql2.version> | ||
</properties> | ||
<distributionManagement> | ||
<repository> | ||
<id>repo.officefloor.sf.net</id> | ||
<name>Maven repository on SourceForge - http://www.officefloor.net/maven2</name> | ||
<url>scp://[email protected]:/home/frs/project/officefloor/maven/maven2</url> | ||
</repository> | ||
</distributionManagement> | ||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>org.apache.maven.wagon</groupId> | ||
<artifactId>wagon-ssh</artifactId> | ||
<version>3.1.0</version> | ||
</extension> | ||
</extensions> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
<executions> | ||
<execution> | ||
<id>Upload pgsql2</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>deploy-file</goal> | ||
</goals> | ||
<configuration> | ||
<file>${settings.localRepository}/org/postgresql/pgsql2/${pgsql2.version}/pgsql2-${pgsql2.version}.jar</file> | ||
<repositoryId>repo.officefloor.sf.net</repositoryId> | ||
<url>scp://[email protected]:/home/frs/project/officefloor/maven/maven2</url> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>pgsql2</artifactId> | ||
<version>0.0.1</version> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
106 changes: 106 additions & 0 deletions
106
src/main/java/org/postgresql/sql2/communication/BEFrameParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package org.postgresql.sql2.communication; | ||
|
||
import java.io.IOException; | ||
|
||
import org.postgresql.sql2.util.BinaryHelper; | ||
|
||
/** | ||
* Reads bytes from the stream from the server and produces packages on a stack | ||
*/ | ||
public class BEFrameParser { | ||
|
||
public static final char AUTHENTICATION = 'R'; | ||
public static final char CANCELLATION_KEY_DATA = 'K'; | ||
public static final char BIND_COMPLETE = '2'; | ||
public static final char CLOSE_COMPLETE = '3'; | ||
public static final char COMMAND_COMPLETE = 'C'; | ||
public static final char COPY_DATA = 'd'; | ||
public static final char COPY_DONE = 'c'; | ||
public static final char COPY_IN_RESPONSE = 'G'; | ||
public static final char COPY_OUT_RESPONSE = 'H'; | ||
public static final char COPY_BOTH_RESPONSE = 'W'; | ||
public static final char DATA_ROW = 'D'; | ||
public static final char EMPTY_QUERY_RESPONSE = 'I'; | ||
public static final char ERROR_RESPONSE = 'E'; | ||
public static final char FUNCTION_CALL_RESPONSE = 'V'; | ||
public static final char NEGOTIATE_PROTOCOL_VERSION = 'v'; | ||
public static final char NO_DATA = 'n'; | ||
public static final char NOTICE_RESPONSE = 'N'; | ||
public static final char NOTIFICATION_RESPONSE = 'A'; | ||
public static final char PARAM_DESCRIPTION = 't'; | ||
public static final char PARAM_STATUS = 'S'; | ||
public static final char PARSE_COMPLETE = '1'; | ||
public static final char PORTAL_SUSPENDED = 's'; | ||
public static final char READY_FOR_QUERY = 'Z'; | ||
public static final char ROW_DESCRIPTION = 'T'; | ||
|
||
private enum States { | ||
BETWEEN, READ_TAG, READ_LEN1, READ_LEN2, READ_LEN3, READ_LEN4 | ||
} | ||
|
||
private States state = States.BETWEEN; | ||
|
||
private byte tag; | ||
private byte len1; | ||
private byte len2; | ||
private byte len3; | ||
private byte len4; | ||
private int payloadLength; | ||
|
||
public boolean parseBEFrame(NetworkInputStream inputStream) throws IOException { | ||
|
||
// Read frame header (tag and length) | ||
if (this.state != States.READ_LEN4) { | ||
READ_HEADER: while (inputStream.available() > 0) { | ||
switch (state) { | ||
case BETWEEN: | ||
tag = (byte) inputStream.read(); | ||
state = States.READ_TAG; | ||
break; | ||
case READ_TAG: | ||
len1 = (byte) inputStream.read(); | ||
state = States.READ_LEN1; | ||
break; | ||
case READ_LEN1: | ||
len2 = (byte) inputStream.read(); | ||
state = States.READ_LEN2; | ||
break; | ||
case READ_LEN2: | ||
len3 = (byte) inputStream.read(); | ||
state = States.READ_LEN3; | ||
break; | ||
case READ_LEN3: | ||
len4 = (byte) inputStream.read(); | ||
// -4 to ignore payload length | ||
payloadLength = BinaryHelper.readInt(len1, len2, len3, len4) - 4; | ||
state = States.READ_LEN4; | ||
break READ_HEADER; | ||
case READ_LEN4: | ||
break READ_HEADER; | ||
} | ||
} | ||
} | ||
|
||
// Wait until all frame bytes available | ||
if (this.state == States.READ_LEN4) { | ||
if (this.payloadLength <= inputStream.available()) { | ||
|
||
// Reset for next frame | ||
this.state = States.BETWEEN; | ||
return true; | ||
} | ||
} | ||
|
||
// As here, buffer underflow | ||
return false; | ||
} | ||
|
||
public char getTag() { | ||
return (char) this.tag; | ||
} | ||
|
||
public int getPayloadLength() { | ||
return this.payloadLength; | ||
} | ||
|
||
} |
67 changes: 0 additions & 67 deletions
67
src/main/java/org/postgresql/sql2/communication/BeFrame.java
This file was deleted.
Oops, something went wrong.
97 changes: 0 additions & 97 deletions
97
src/main/java/org/postgresql/sql2/communication/BeFrameParser.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of commits keep coming in with some of this stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is my local deployment to make the jar available for download. This is necessary for TechEmpower to access the jar for building the OfficeFloor server to use pgsql2. We should possibly consider starting to apply to release to maven central to make early adopter interest available.