Skip to content

Commit

Permalink
Merge pull request #503 from aionick/fix_err_msgs
Browse files Browse the repository at this point in the history
Improve p2p bind and db lock err msgs
  • Loading branch information
AionJayT authored Jun 1, 2018
2 parents 3cb0eb0 + 8def32b commit 1d44cbd
Show file tree
Hide file tree
Showing 24 changed files with 2,070 additions and 1,213 deletions.
60 changes: 60 additions & 0 deletions modAionImpl/test/org/aion/zero/impl/sync/BlockPropagationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,42 @@ public long getTimestamp() {
public String getBinaryVersion() {
return "";
}

@Override
public void setPort(int _port) { throw new IllegalStateException("not implemented"); }

@Override
public void setConnection(String _connection) { throw new IllegalStateException("not implemented"); }

@Override
public IPeerMetric getPeerMetric() { throw new IllegalStateException("not implemented"); }

@Override
public void refreshTimestamp() { throw new IllegalStateException("not implemented"); }

@Override
public void setChannel(SocketChannel _channel) { throw new IllegalStateException("not implemented"); }

@Override
public void setId(byte[] _id) { throw new IllegalStateException("not implemented"); }

@Override
public void setBinaryVersion(String _revision) { throw new IllegalStateException("not implemented"); }

@Override
public boolean getIfFromBootList() { throw new IllegalStateException("not implemented"); }

@Override
public byte[] getBestBlockHash() { throw new IllegalStateException("not implemented"); }

@Override
public String getConnection() { throw new IllegalStateException("not implemented"); }

@Override
public SocketChannel getChannel() { throw new IllegalStateException("not implemented"); }

@Override
public void setFromBootList(boolean _ifBoot) { throw new IllegalStateException("not implemented"); }
}

private static class P2pMock implements IP2pMgr {
Expand Down Expand Up @@ -138,6 +174,30 @@ public void closeSocket(SocketChannel _sc, String _reason) {}
public int getSelfIdHash() {
return 0;
}

@Override
public void dropActive(int _nodeIdHash, String _reason) { throw new IllegalStateException("not implemented."); }

@Override
public void configChannel(SocketChannel _channel) {
throw new IllegalStateException("not implemented.");
}

@Override
public int getMaxActiveNodes() { throw new IllegalStateException("not implemented."); }

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

@Override
public int getMaxTempNodes() { throw new IllegalStateException("not implemented."); }

@Override
public boolean validateNode(INode _node) { throw new IllegalStateException("not implemented."); }

@Override
public int getSelfNetId() { throw new IllegalStateException("not implemented."); }

}

private static List<ECKey> generateDefaultAccounts() {
Expand Down
7 changes: 4 additions & 3 deletions modDbImpl/src/org/aion/db/impl/h2/H2MVMap.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*
* Copyright (c) 2017-2018 Aion foundation.
*
* This file is part of the aion network project.
Expand Down Expand Up @@ -31,7 +31,7 @@
* Samuel Neves through the BLAKE2 implementation.
* Zcash project team.
* Bitcoinj team.
******************************************************************************/
*/
package org.aion.db.impl.h2;

import org.aion.base.util.ByteArrayWrapper;
Expand Down Expand Up @@ -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 if you have two instances running on the same database.", e);
} else {
LOG.error("Failed to open the database " + this.toString() + " due to: ", e);
}
Expand Down
13 changes: 10 additions & 3 deletions modDbImpl/src/org/aion/db/impl/leveldb/LevelDB.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*******************************************************************************
/*
* Copyright (c) 2017-2018 Aion foundation.
*
* This file is part of the aion network project.
Expand Down Expand Up @@ -31,7 +31,7 @@
* Samuel Neves through the BLAKE2 implementation.
* Zcash project team.
* Bitcoinj team.
******************************************************************************/
*/
package org.aion.db.impl.leveldb;

import org.aion.base.util.ByteArrayWrapper;
Expand Down Expand Up @@ -142,7 +142,14 @@ public boolean open() {
try {
db = JniDBFactory.factory.open(f, options);
} catch (Exception e1) {
LOG.error("Failed to open the database " + this.toString() + " due to: ", e1);
if (e1.getMessage().contains("lock")) {
LOG.error("Failed to open the database " + this.toString() +
"\nCheck if you have two instances running on the same database." +
"\nFailure due to: ", e1);
} else {
LOG.error("Failed to open the database " + this.toString() + " due to: ", e1);
}

if (e1.getMessage() != null && e1.getMessage().contains("No space left on device")) {
LOG.error("Shutdown due to lack of disk space.");
System.exit(0);
Expand Down
30 changes: 29 additions & 1 deletion modDbImpl/src/org/aion/db/impl/rocksdb/RocksDBWrapper.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (c) 2017-2018 Aion foundation.
*
* This file is part of the aion network project.
*
* The aion network project is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or any later version.
*
* The aion network project is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the aion network project source files.
* If not, see <https://www.gnu.org/licenses/>.
*
* Contributors:
* Aion foundation.
*/
package org.aion.db.impl.rocksdb;

import org.aion.base.util.ByteArrayWrapper;
Expand Down Expand Up @@ -90,7 +112,13 @@ public boolean open() {
try {
db = RocksDB.open(options, f.getAbsolutePath());
} catch (RocksDBException e) {
LOG.error("Failed to open the database " + this.toString() + " due to: ", e);
if (e.getMessage().contains("lock")) {
LOG.error("Failed to open the database " + this.toString()
+ "\nCheck if you have two instances running on the same database."
+ "\nFailure due to: ", e);
} else {
LOG.error("Failed to open the database " + this.toString() + " due to: ", e);
}

// close the connection and cleanup if needed
close();
Expand Down
57 changes: 40 additions & 17 deletions modP2p/src/org/aion/p2p/INode.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
/*
* Copyright (c) 2017-2018 Aion foundation.
*
* This file is part of the aion network project.
* This file is part of the aion network project.
*
* The aion network project is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or any later version.
* The aion network project is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or any later version.
*
* The aion network project is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* The aion network project is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the aion network project source files.
* If not, see <https://www.gnu.org/licenses/>.
*
* Contributors to the aion source files in decreasing order of code volume:
*
* Aion foundation.
* You should have received a copy of the GNU General Public License
* along with the aion network project source files.
* If not, see <https://www.gnu.org/licenses/>.
*
* Contributors:
* Aion foundation.
*/

package org.aion.p2p;

import java.math.BigInteger;
import java.nio.channels.SocketChannel;

/**
*
Expand Down Expand Up @@ -84,4 +82,29 @@ public interface INode {
void updateStatus(long _bestBlockNumber, final byte[] _bestBlockHash, BigInteger _totalDifficulty);

String getBinaryVersion();

boolean getIfFromBootList();

byte[] getBestBlockHash();

String getConnection();

SocketChannel getChannel();

void setFromBootList(boolean _ifBoot);

void setConnection(String _connection);

IPeerMetric getPeerMetric();

void refreshTimestamp();

void setChannel(SocketChannel _channel);

void setId(byte[] _id);

void setPort(int _port);

void setBinaryVersion(String _revision);

}
67 changes: 67 additions & 0 deletions modP2p/src/org/aion/p2p/INodeMgr.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
/*
* Copyright (c) 2017-2018 Aion foundation.
*
* This file is part of the aion network project.
*
* The aion network project is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or any later version.
*
* The aion network project is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the aion network project source files.
* If not, see <https://www.gnu.org/licenses/>.
*
* Contributors:
* Aion foundation.
*/
package org.aion.p2p;

import java.util.List;
import java.util.Map;

public interface INodeMgr {

void timeoutActive(final IP2pMgr _p2pMgr);
Expand All @@ -10,4 +35,46 @@ public interface INodeMgr {

void dropActive(int _nodeIdHash, final IP2pMgr _p2pMgr, String _reason);

void timeoutInbound(IP2pMgr _p2pMgr);

Map<Integer, INode> getOutboundNodes();

int activeNodesSize();

INode tempNodesTake() throws InterruptedException;

boolean isSeedIp(String _ip);

void addTempNode(INode _n);

boolean hasActiveNode(int k);

void addOutboundNode(INode _n);

void addInboundNode(INode _n);

INode allocNode(String ip, int p0);

INode getActiveNode(int k);

List<INode> getActiveNodesList();

int tempNodesSize();

INode getInboundNode(int k);

INode getOutboundNode(int k);

String dumpNodeInfo(String selfShortId);

void seedIpAdd(String _ip);

void shutdown(IP2pMgr _p2pMgr);

void ban(int _nodeIdHash);

INode getRandom();

Map<Integer, INode> getActiveNodesMap();

}
Loading

0 comments on commit 1d44cbd

Please sign in to comment.