Comments (6)
recvByte and recvBool seem to be implemented, do they need to be reimplemented? A possible problem I see with them is that recvByte receives a Java byte (signed) unlike iris-go recvByte, which receives a Go byte (unsigned). To have feature-parity between iris-go and iris-java, we should use char in Java. Unfortunately when replacing byte with char in the sendByte and OpCodes, the handshake test fails, and I can't figure out why. Ideas, anyone?
from iris-java.
We shouldn't use chars, use shorts or ints instead.
from iris-java.
I have implemented the recv functions, but the whole interface is so coupled, that I cannot test the Send and Receive functionality in separation (e.g. to replace the socketIn and socketOut with in memory streams, so that I don't need anything else to validate the sent and received data).
This is one of the reasons why I suggested the separation of concerns.
Will try to resolve it somehow, if you don't like it, I will change it back.
from iris-java.
@evfool
I just added recvByte/Bool to make teh list complete. Sorry that I forgot to check them.
Receiving a Java byte is not a problem. A byte is a byte. The protocol concerns itself only with the 8 bits of that byte, it doesn't interpret them as numbers, so being signed or unsigned is irrelevant. Char doesn't work since it is 2 bytes long (same for short and int (4)). Additionally, since the only the opcodes use bytes (and the implementation of the varints), the signedness doesn't complicate things. So keep the byte as a byte.
@paplorinc
Actually, there is still a simple way to test it by going through a local network socket. IMHO it is simpler than introducing additional moving components just to test the functions. Open a server socket, and voila, you have the other end of the stream to test.
Note, however, that I think unit testing individual sends/receives will backfire during minor protocol updates (and as I'm preparing the second draft of the relay protocol, that will be soon (i.e. days, max a couple weeks)). The reason is that any updates will require rewriting all the tests. Since the binding itself is a very simple component, I think integration tests are enough, and are much more flexible and stable. Yes, I'm aware that those tests require a running Iris node, but the overhead of ensuring Iris is running is significantly lower than the associated costs of unit tests during protocol updates.
But these are my 2 cents. If you really want to go down the unit test path, I have no objections, but it will be significantly more code to maintain and won't provide added value over the integration tests. But if you do want to do this, please implement it through sockets and don't gut the protocol class. There's no need for it.
from iris-java.
Managed to separate the communication layer from the higher layer, without "gutting", "littering", "backfire"-ing and other big words.
Implemented the recvVarint and changed the sendVarint to be cleaner, more general and avoid infinite loops. In case you have objections, please let me know. Unfortunately it's still not working for negative numbers (it's one of the reasons why I have extracted the hasNextChunk method, it should probably be extended);
Also, the sendString seems to be limited to ~1000 characters, not sure what's causing that - it might simply be the PipedStreams in the tests.
I designed the send and recieve tests to use the input of one another, so that it won't be a "significant overhead" on protocol update.
If you want to rewrite the tests to use sockets, feel free to do so, though the design and tests are cleaner this way, in my opinion.
from iris-java.
Negative numbers are not needed. Those would require special handling anyway as varints were designed for unsigned only.
I'll look into the string limits in the morning.
from iris-java.
Related Issues (20)
- Tunnel chunked send timeout bug
- Add tests for connection drop/teardown
- Use custom exceptions instead of the canned java ones HOT 1
- Port the latency and throughput benchmarks over HOT 2
- Write the API docs and annotations with javadoc
- Refactor the validators class
- Rewrite the readme based on the Go/Erlang version HOT 2
- Add contextual leveled logging support HOT 1
- Tunnel race HOT 3
- Finish queueing error log messages HOT 1
- Hide the public Tunnel constructor
- Leaking threads HOT 1
- Cannot send empty message over tunnel HOT 1
- Investigate validator regex performance HOT 1
- Maybe change API to use constructors instead of factory?
- Contention during the requests HOT 1
- Add a ClosedException for returning on pending and stale ops
- Swap out the ServiceHandler interface to an abstract class HOT 1
- Add tests for handling Iris node crashes
- Anomalies during notify and interrupt races
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iris-java.