Skip to content

Commit

Permalink
Merge branch 'master' of https://BeatWolf@github.com/gridgroup/pop-ja…
Browse files Browse the repository at this point in the history
…va.git
  • Loading branch information
BeatWolf committed Oct 18, 2018
2 parents 66cb85b + 507be53 commit 4bfea65
Show file tree
Hide file tree
Showing 24 changed files with 469 additions and 181 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CHANGELOG
=========


2.0.0 (2018-XX-XX)
2.0.0 (2018-21-09)
------------------

* Initial release
* Initial release of POP-Java 2.0
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ Netbeans

Open the project as a Gradle project. Nothing more should be required.

Maven
~~~~~

.. code::
<dependency>
<groupId>ch.icosys</groupId>
<artifactId>popjava</artifactId>
<version>2.0.0</version>
</dependency>
LICENCE
-------
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = 'A Java distributed system'

group = "ch.icosys"
archivesBaseName = "popjava"
version = "1.5.3"
version = "2.0.2"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"

Expand Down Expand Up @@ -264,7 +264,7 @@ uploadArchives {
licenses {
license {
name 'The GNU Lesser General Public License, Version 3.0'
url 'https://www.gnu.org/licenses/gpl-3.0.txt'
url 'https://www.gnu.org/licenses/lgpl-3.0.txt'
}
}

Expand Down
11 changes: 10 additions & 1 deletion docs/dev/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Coding conventions

When writing new code for POP-Java you should always:

* Indent with a hard-tab ``\t``, ASCII ``0x09``
* Indent with 4 spaces
* Always surround blocks with ``{ }``
* ...
* ...
Expand Down Expand Up @@ -85,6 +85,14 @@ Creation of a new release
ossrhPassword=your-jira-password

* The signing data must be generated, e.g. with `GnuPG <http://central.sonatype.org/pages/working-with-pgp-signatures.html>`_.
* Newer (2.1+) GPG versions use a new keyring file format (.kbx). You need to convert/export your key to the old format.

``gpg --export-secret-keys -o secring.gpg``

* With the 2.1+ GPG version you also need to use a special command to list the available keys to get the correct id.

``gpg --list-keys --keyid-format short``

* More information about the Maven packaging process is given on the `OSSRH Guide <http://central.sonatype.org/pages/ossrh-guide.html>`_.


Expand Down Expand Up @@ -123,4 +131,5 @@ Creation of a new release
.. note::
* To pass this step, the deployed files are verified and thus must fulfil some `requirements <http://central.sonatype.org/pages/requirements.html>`_.
* This step was fully automatized thanks to the `Gradle Nexus Staging Plugin <https://github.com/Codearte/gradle-nexus-staging-plugin/>`_. However, it can manually be done on the `OSSRH website <https://oss.sonatype.org>`_ as described `here <http://central.sonatype.org/pages/releasing-the-deployment.html>`_.
* It takes about 2 hours to synchronize between OSSRH and the Central Repository

Original file line number Diff line number Diff line change
Expand Up @@ -730,15 +730,15 @@ public void exit() {
*/
public void printMethodInfo() {
System.out.println("===========ConstructorInfo============");
constructorInfos.forEach((mi, c) -> System.out.format("ClassId:%d.ConstructorId:%d.Sign:%s", mi.getClassId(),
constructorInfos.forEach((mi, c) -> System.out.format("ClassId:%d.ConstructorId:%d.Sign:%s\n", mi.getClassId(),
mi.getMethodId(), c.toGenericString()));

System.out.println("===========MethodInfo============");
methodInfos.forEach((mi, m) -> System.out.format("ClassId:%d.MethodId:%d.Sign:%s", mi.getClassId(),
methodInfos.forEach((mi, m) -> System.out.format("ClassId:%d.MethodId:%d.Sign:%s\n", mi.getClassId(),
mi.getMethodId(), m.toGenericString()));

System.out.println("===========SemanticsInfo============");
semantics.forEach((mi, s) -> System.out.format("ClassId:%d.ConstructorId:%d.Semantics:%d", mi.getClassId(),
semantics.forEach((mi, s) -> System.out.format("ClassId:%d.ConstructorId:%d.Semantics:%d\n", mi.getClassId(),
mi.getMethodId(), s));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import ch.icosys.popjava.core.system.POPSystem;
import ch.icosys.popjava.core.util.Configuration;
import ch.icosys.popjava.core.util.SystemUtil;

/**
* This class represent an access to a broker-side parallel object
Expand Down Expand Up @@ -187,6 +188,14 @@ public boolean isEmpty() {
return false;
}

/**
* Returns true if the IP/Host is in a private subnet
* @return
*/
public boolean isPrivateIP() {
return SystemUtil.isHostInPrivateSubnet(host);
}

/**
* Format the access point as a string value
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ public boolean hasSameAccessPoint(POPAccessPoint ap) {

return false;
}

public boolean hasAccessPointIP(String ip) {
for (int i = 0; i < accessPoints.size(); i++) {
if(accessPoints.get(i).getHost().equals(ip)){
return true;
}
}

return false;
}

@Override
public int hashCode() {
Expand Down
15 changes: 7 additions & 8 deletions workspace/popjava/src/ch/icosys/popjava/core/broker/Broker.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ private boolean invokeMethod(Request request) throws InterruptedException {
} catch (NoSuchMethodException e) {
exception = POPException.createReflectMethodNotFoundException(popInfo.getClass().getName(),
request.getClassId(), request.getMethodId(), e.getMessage());

popInfo.printMethodInfo();
System.out.println(accessPoint);
}

if (method != null) {
Expand Down Expand Up @@ -673,7 +676,7 @@ private boolean invokeMethod(Request request) throws InterruptedException {
}
}

if (tracking && remote != null) {
if (tracking && remote != null && method != null) {
registerTracking(remote, method.toGenericString(), trackingTime, inputSize, outputSize);
}

Expand Down Expand Up @@ -724,7 +727,7 @@ public boolean invoke(Request request) throws InterruptedException {
remoteCaller.set(caller);

// check for localhost only execution and throw exception if we can't
if (request.isLocalhost() && !caller.isLocalHost()) {
if (request.isLocalhost() && !caller.isLocalHost(accessPoint)) {
if (request.isSynchronous()) {
POPException exception = new POPException(POPErrorCode.METHOD_ANNOTATION_EXCEPTION,
"You can't call a localhost method from a remote location. "+caller.getRemote().getHostAddress());
Expand Down Expand Up @@ -1068,11 +1071,6 @@ public boolean initialize(List<String> argvs) {
// hadle multiple times the same protocol
String port;
while ((port = Util.removeStringFromList(argvs, prefix)) != null) {
// if we don't have a port, abort
/*
* if (port == null) { continue; }
*/

int iPort = 0;
if (port.length() > 0) {
try {
Expand Down Expand Up @@ -1105,8 +1103,9 @@ public boolean initialize(List<String> argvs) {
if (externalIP != null && !externalIP.isEmpty()) {
for (int i = 0; i < accessPoint.size(); i++) {
AccessPoint ap = new AccessPoint(accessPoint.get(i));
// TODO: The port might also be diferent
ap.setHost(externalIP);

UPNPManager.mapAccessPoint(ap, 1000);

accessPoint.addAccessPoint(ap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ public void run() {

if (System.currentTimeMillis() - lastCommunication > KEEP_ALIVE_INTERVAL) {
POPBuffer buffer = createServicePacket(PING);
send(buffer);
if(send(buffer) < 0) {
break;
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.net.ServerSocketFactory;

import ch.icosys.popjava.core.util.Configuration;
import ch.icosys.popjava.core.util.Tuple;
import ch.icosys.popjava.core.util.upnp.UPNPManager;

/**
Expand Down Expand Up @@ -90,7 +91,7 @@ private static ServerSocket createServerSocket(int port, PreOperation op, boolea

if (upnp) {
@SuppressWarnings("unused")
Future<String> externalIP = UPNPManager.registerPort(server.getLocalPort());
Future<Tuple<String, Integer>> externalIP = UPNPManager.registerPort(server.getLocalPort());
}

return server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ch.icosys.popjava.core.buffer.POPBuffer;
import ch.icosys.popjava.core.combox.Combox;
import ch.icosys.popjava.core.util.LogWriter;
import ch.icosys.popjava.core.util.SystemUtil;

public abstract class ComboxSocket<T extends Socket> extends Combox<T> {

Expand Down Expand Up @@ -285,14 +286,19 @@ public void closeInternal() {
}
} catch (IOException e) {
} finally {
try {
outputStream.close();
} catch (IOException e) {
if(outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
}
}
try {
inputStream.close();
} catch (IOException e) {
if(inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}

if (peerConnection != null) {
try {
peerConnection.close();
Expand Down Expand Up @@ -369,8 +375,8 @@ public int compare(AccessPoint o1, AccessPoint o2) {
return 1;
}

boolean privateSubnet1 = isHostInPrivateSubnet(o1.getHost());
boolean privateSubnet2 = isHostInPrivateSubnet(o2.getHost());
boolean privateSubnet1 = SystemUtil.isHostInPrivateSubnet(o1.getHost());
boolean privateSubnet2 = SystemUtil.isHostInPrivateSubnet(o2.getHost());

if (privateSubnet1 && !privateSubnet2) {
return 1;
Expand All @@ -391,8 +397,4 @@ public int compare(AccessPoint o1, AccessPoint o2) {

return aps;
}

private static boolean isHostInPrivateSubnet(String host) {
return host.startsWith("10.") || host.startsWith("172.16.") || host.startsWith("192.168.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,31 @@ protected boolean connectToServer() {

for (int i = 0; i < aps.size() && !available; i++) {
AccessPoint ap = aps.get(i);

String host = ap.getHost();
int port = ap.getPort();
try {
// Create an unbound socket
if (timeOut > 0) {
SocketAddress sockaddress = new InetSocketAddress(host, port);
peerConnection = new Socket();
peerConnection.connect(sockaddress, timeOut);

// LogWriter.writeExceptionLog(new Exception());
// LogWriter.writeExceptionLog(new Exception("Open
// connection to "+host+":"+port+" remote:
// "+peerConnection.getLocalPort()));
} else {
peerConnection = new Socket(host, port);

if(ap.getProtocol().equals(ComboxSocketFactory.PROTOCOL)) {
String host = ap.getHost();
int port = ap.getPort();
try {
// Create an unbound socket
if (timeOut > 0) {
SocketAddress sockaddress = new InetSocketAddress(host, port);
peerConnection = new Socket();
peerConnection.connect(sockaddress, timeOut);

// LogWriter.writeExceptionLog(new Exception());
// LogWriter.writeExceptionLog(new Exception("Open
// connection to "+host+":"+port+" remote:
// "+peerConnection.getLocalPort()));
} else {
peerConnection = new Socket(host, port);
}
inputStream = new BufferedInputStream(peerConnection.getInputStream());
outputStream = new BufferedOutputStream(peerConnection.getOutputStream());
available = true;
} catch (IOException e) {
available = false;
LogWriter.writeExceptionLog(e);
}
inputStream = new BufferedInputStream(peerConnection.getInputStream());
outputStream = new BufferedOutputStream(peerConnection.getOutputStream());
available = true;
} catch (IOException e) {
available = false;
LogWriter.writeExceptionLog(e);
}
}
return available;
Expand Down
Loading

0 comments on commit 4bfea65

Please sign in to comment.