Skip to content
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

Improve p2p bind and db lock err msgs #503

Merged
merged 21 commits into from
Jun 1, 2018
Merged

Improve p2p bind and db lock err msgs #503

merged 21 commits into from
Jun 1, 2018

Conversation

aionick
Copy link
Contributor

@aionick aionick commented May 23, 2018

Description

Please include a brief summary of the change that this pull request proposes. Include any relevant motivation and context. List any dependencies required for this change.

  • This is two PRs merged into one... most of this is separating all of the inner classes in P2pMgr out into their own files and minor refactorings associated with that. There is also some improvement to the p2p error message when unable to bind to a port and the db error messages for when 2 instances try to use the same db.

Fixes Issue #

Type of change

Insert x into the following checkboxes to confirm (eg. [x]):

  • Bug fix.
  • New feature.
  • Enhancement.
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

Testing

Please describe the tests you used to validate this pull request. Provide any relevant details for test configurations as well as any instructions to reproduce these results.

  • Used manual testing, running two kernels on the same port and then running two kernels on the same db instance for each db we support. For the refactoring bit: ran kernel with miners and checked against all existing tests cases.

Verification

Insert x into the following checkboxes to confirm (eg. [x]):

  • I have self-reviewed my own code and conformed to the style guidelines of this project.
  • New and existing tests pass locally with my changes.
  • I have added tests for my fix or feature.
  • I have made appropriate changes to the corresponding documentation.
  • My code generates no new warnings.
  • Any dependent changes have been made.

@AionJayT AionJayT added this to the v0.2.8 - University Peak milestone May 23, 2018
@AionJayT AionJayT added enhancement New feature or request bug Something isn't working labels May 23, 2018
@@ -148,7 +148,8 @@ public boolean open() {
} catch (Exception e) {
if (e instanceof NullPointerException) {
LOG.error("Failed to open the database " + this.toString()
+ ". A probable cause is that the H2 database cannot access the file path.", e);
+ ". A probable cause is that the H2 database cannot access the file path. "
+ "Check that you do not have two instances running on the same database.", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: May be change line 152 to "Check if you have two instances running" instead of "Check that you do not" and everywhere with the same statement.

@aionick
Copy link
Contributor Author

aionick commented May 25, 2018

I updated this PR because its dependent PR changed, commit 5f4ecec is the only one in here to pay attention to. Only 1 file in this PR is dependent, that is P2pMgr, and the change that I've made here is in lines 213-214, a catch SocketException block.

Sorry for the confusion

@aionick aionick closed this May 25, 2018
@AionJayT AionJayT reopened this May 25, 2018
@@ -992,79 +155,76 @@ public void run() {
tcpServer.socket().bind(new InetSocketAddress(Node.ipBytesToStr(selfIp), selfPort));
tcpServer.register(selector, SelectionKey.OP_ACCEPT);

Thread thrdIn = new Thread(new TaskInbound(), "p2p-in");
Thread thrdIn = new Thread(getInboundInstance(), "p2p-in");
// Thread thrdIn = new Thread(new TaskInbound(), "p2p-in");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this line

@AionJayT
Copy link
Collaborator

related to #69

public boolean isSyncSeedsOnly() { throw new IllegalStateException("not implemented."); }

@Override
public int getTxBroadCastRoute() { throw new IllegalStateException("not implemented."); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method should remove, also the interface class.

Copy link
Contributor

@AlexandraRoatis AlexandraRoatis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. please make sure the license for the files is correct
  2. (optional) it would be nice to pass a logger object to all the tasks and log the messages instead of using System.out; check TaskImportBlocks.java for reference
  3. (optional) throughout the code I've seen many one liner if statements; I would prefer surrounding the then clause with { and }

@@ -2,6 +2,7 @@

import static com.google.common.truth.Truth.assertThat;

import java.io.IOException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import is not used

@@ -31,6 +31,7 @@
import java.util.Arrays;
import java.util.regex.Pattern;
import org.aion.p2p.INode;
import org.aion.p2p.IPeerMetric;

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be /**

@@ -0,0 +1,15 @@
package org.aion.p2p;

public interface IPeerMetric {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have some java doc for this new interface

* @throws IOException IOException
*/
private int readHeader(final ChannelBuffer _cb, ByteBuffer readBuffer, int cnt)
throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throws IOException may be unnecessary

* @throws IOException IOException
*/
private int readBody(final ChannelBuffer _cb, ByteBuffer readBuffer, int cnt)
throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throws IOException may be unnecessary

@aionick
Copy link
Contributor Author

aionick commented Jun 1, 2018

addressed the comments, working on the optionals now

@AionJayT AionJayT merged commit 1d44cbd into aionnetwork:master-pre-merge Jun 1, 2018
@AionJayT AionJayT mentioned this pull request Jun 14, 2018
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants