Skip to content

Commit

Permalink
Release 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dbusel authored Dec 14, 2018
2 parents fb67d25 + 9350b7c commit aaeb769
Show file tree
Hide file tree
Showing 27 changed files with 209 additions and 136 deletions.
34 changes: 28 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ stages:
if: type = pull_request
- name: dev_deploy
if: branch = develop AND type = push
- name: package_build
- name: prod_deploy
if: branch = release AND type = push
- name: release
if: branch = master and type = push
jobs:
include:
Expand All @@ -26,7 +28,6 @@ jobs:
before_install:
- sudo apt-get install sshpass xml-twig-tools
script:
- mvn clean install
- sshpass -p $DEV_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP
"service iofog-connector stop"
- sshpass -p $DEV_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no daemon/target/iofog-connector-daemon-jar-with-dependencies.jar
Expand All @@ -35,12 +36,23 @@ jobs:
$DEV_MACHINE_USERNAME@$DEV_MACHINE_IP:/usr/bin/iofog-connector.jar
- sshpass -p $DEV_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP
"service iofog-connector start"
- stage: package_build
- stage: prod_deploy
before_install:
- sudo apt-get install sshpass xml-twig-tools
script:
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP
"service iofog-connector stop"
- sshpass -p $PROD_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no daemon/target/iofog-connector-daemon-jar-with-dependencies.jar
$PROD_MACHINE_USERNAME@$PROD_MACHINE_IP:/usr/bin/iofog-connectord.jar
- sshpass -p $PROD_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no client/target/iofog-connector-client-jar-with-dependencies.jar
$PROD_MACHINE_USERNAME@$PROD_MACHINE_IP:/usr/bin/iofog-connector.jar
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP
"service iofog-connector start"
- stage: release
before_install:
- sudo apt-get install sshpass xml-twig-tools
script:
- export VERSION=`xml_grep --cond='project/version' pom.xml --text_only`
- mvn clean install
- sshpass -p $STAGE_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $STAGE_MACHINE_USERNAME@$STAGE_MACHINE_IP
"rm -rf /iofog-connector-packaging-rpm/*; rm -rf /iofog-connector-packaging/*;"
- sshpass -p $STAGE_MACHINE_PASSWORD scp -o StrictHostKeyChecking=no -r iofog-connector-packaging-rpm/*
Expand Down Expand Up @@ -99,5 +111,15 @@ jobs:
package_cloud push iofog/iofog-connector/el/6 iofog-connector-${VERSION}-1.noarch.rpm;
package_cloud yank iofog/iofog-connector/el/7 iofog-connector-${VERSION}-1.noarch.rpm;
package_cloud push iofog/iofog-connector/el/7 iofog-connector-${VERSION}-1.noarch.rpm"
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP
"service iofog-connector stop; apt-get install --only-upgrade iofog-connector -y; service iofog-connector start"
before_deploy:
- git config --global user.name "${GH_USERNAME}";
- git config credential.helper "store --file=.git/credentials";
- echo "https://${GH_TOKEN}:@github.com" > .git/credentials;
- git tag ${VERSION}
deploy:
provider: releases
api_key: "${GH_TOKEN}"
name: "v${VERSION} ($(date +'%m/%d/%Y'))"
skip_cleanup: true
on:
branch: master
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.iofog</groupId>
<artifactId>iofog-connector</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
28 changes: 28 additions & 0 deletions client/src/org/eclipse/iofog/connector/utils/CmdProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.eclipse.iofog.connector.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import static org.eclipse.iofog.connector.utils.LogUtil.warning;

public class CmdProperties {

private static final String MODULE_NAME = "CmdProperties";
private static final String PROPERTIES_FILE_PATH = "cmd_messages.properties";

private static final Properties cmdProperties;

static {
cmdProperties = new Properties();
try (InputStream in = CmdProperties.class.getResourceAsStream(PROPERTIES_FILE_PATH)) {
cmdProperties.load(in);
} catch (IOException e) {
warning(String.format("%s: %s", MODULE_NAME, e.getMessage()));
}
}

public static String getVersion() {
return cmdProperties.getProperty("version");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static String showHelp() {
}

private static String showVersion() {
return "Iofog-connector " + Constants.VERSION +
return "Iofog-connector " + CmdProperties.getVersion() +
"\nCopyright (C) 2018 Edgeworx, Inc." +
"\nEclipse ioFog is provided under the Eclipse Public License (EPL2)" +
"\nhttps://www.eclipse.org/legal/epl-v20.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class Constants {
static final String CERTITICATE_FILENAME = "/etc/iofog-connector/server-cert.pem";
static final String KEY_FILENAME = "/etc/iofog-connector/server-key.pem";
static final String LOG_FILENAME = "/var/log/iofog-connector/iofog-connector-client.log";
static final String VERSION = "1.0.2";
static final String API_COMMAND_LINE = "/api/v2/commandline";

public static final int HTTPS_PORT = 443;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}
2 changes: 1 addition & 1 deletion daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.iofog</groupId>
<artifactId>iofog-connector</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
18 changes: 8 additions & 10 deletions daemon/src/org/eclipse/iofog/connector/Connector.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package org.eclipse.iofog.connector;

import io.netty.handler.ssl.SslContext;
import org.eclipse.iofog.connector.config.ConfigManager;
import org.eclipse.iofog.connector.config.Configuration;
import org.eclipse.iofog.connector.restapi.RestAPI;
Expand All @@ -22,7 +21,6 @@
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.net.ssl.SSLContext;
import java.io.FileOutputStream;
import java.util.Map.Entry;

Expand Down Expand Up @@ -57,21 +55,21 @@ public static void main(String[] args) {
startConnector();
}
} catch (Exception ex) {
LogUtil.warning(ex.getMessage());
LogUtil.error("Connector stopped with fatal error: " + ex.getMessage());
System.exit(1);
}
}

private static void startConnector() throws Exception {
SslContext sslContext = Settings.isDevMode()
? null
: SslManager.getSslContext();
SslManager.initSslContext(Settings.isDevMode());

ConfigManager.loadConfiguration();

RestAPI server = RestAPI.getInstance(sslContext);
RestAPI server = RestAPI.getInstance();
server.start();

SocketsManager socketsManager = new SocketsManager();
openPorts(socketsManager, sslContext);
openPorts(socketsManager);

synchronized (exitLock) {
System.out.println("Connector started.");
Expand All @@ -89,10 +87,10 @@ private static void startConnector() throws Exception {
System.exit(0);
}

private static void openPorts(SocketsManager socketsManager, SslContext sslContext) {
private static void openPorts(SocketsManager socketsManager) {
for (Entry<String, Configuration> e : ConfigManager.getMappings().entrySet()) {
Configuration cfg = e.getValue();
socketsManager.openPort(cfg, sslContext);
socketsManager.openPort(cfg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package org.eclipse.iofog.connector.commandline;

import org.eclipse.iofog.connector.Connector;
import org.eclipse.iofog.connector.utils.Constants;
import org.eclipse.iofog.connector.utils.CmdProperties;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -104,7 +104,7 @@ public static String showHelp() {
}

public static String showVersion() {
return "Connector " + Constants.VERSION +
return "Connector " + CmdProperties.getVersion() +
"\nCopyright (C) 2018 Edgeworx, Inc." +
"\nEclipse ioFog is provided under the Eclipse Public License (EPL2)" +
"\nhttps://www.eclipse.org/legal/epl-v20.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.ssl.SslContext;
import org.eclipse.iofog.connector.utils.Constants;
import org.eclipse.iofog.connector.utils.LogUtil;
import org.eclipse.iofog.connector.utils.Settings;

import java.util.*;

public class PrivateSocket implements Runnable {
Expand All @@ -32,17 +32,15 @@ public class PrivateSocket implements Runnable {
private boolean stopListening = false;
private PrivateSocket pairSocket;
private static Map<Channel, Channel> channelsMapping;
private SslContext sslContext;


public List<Channel> connections = new ArrayList<>();

public PrivateSocket(int port, String passCode, int maxConnections, SslContext sslContext) {
public PrivateSocket(int port, String passCode, int maxConnections) {
this.passCode = passCode;
this.port = port;
this.maxConnections = maxConnections;
PrivateSocket.channelsMapping = new HashMap<>();
this.pairSocket = null;
this.sslContext = sslContext;
}

public void run() {
Expand All @@ -51,7 +49,7 @@ public void run() {
ServerBootstrap b = new ServerBootstrap();
b.group(Constants.bossGroup, Constants.workerGroup)
.channel(NioServerSocketChannel.class);
PrivateSocketInitializer channelInitializer = new PrivateSocketInitializer(sslContext, this);
PrivateSocketInitializer channelInitializer = new PrivateSocketInitializer(this);
b.childHandler(channelInitializer);

channel = b.bind(port).sync().channel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@

package org.eclipse.iofog.connector.privatesocket;

import org.eclipse.iofog.connector.utils.Constants;
import org.eclipse.iofog.connector.utils.LogUtil;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.ssl.SslContext;
import org.eclipse.iofog.connector.utils.Constants;
import org.eclipse.iofog.connector.utils.LogUtil;

public class PrivateSocketHandler extends SimpleChannelInboundHandler<byte[]> {

private final PrivateSocket socketServer;

private boolean init = true;

public PrivateSocketHandler(SslContext sslCtx, PrivateSocket socketServer) {
public PrivateSocketHandler(PrivateSocket socketServer) {
this.socketServer = socketServer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,29 @@
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.bytes.ByteArrayDecoder;
import io.netty.handler.codec.bytes.ByteArrayEncoder;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslHandler;
import org.eclipse.iofog.connector.utils.SslManager;

public class PrivateSocketInitializer extends ChannelInitializer<SocketChannel> {

private final SslContext sslCtx;
private final PrivateSocket socketServer;

public PrivateSocketInitializer(SslContext sslCtx, PrivateSocket socketServer) {
this.sslCtx = sslCtx;
public PrivateSocketInitializer(PrivateSocket socketServer) {
this.socketServer = socketServer;
}

@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();

if (sslCtx != null) {
SslHandler sslHandler = sslCtx.newHandler(ch.alloc());
if (SslManager.getSslContext() != null) {
SslHandler sslHandler = SslManager.getSslContext().newHandler(ch.alloc());
pipeline.addLast(sslHandler);
}

pipeline.addLast(new ByteArrayDecoder());
pipeline.addLast(new ByteArrayEncoder());
pipeline.addLast(new PrivateSocketHandler(sslCtx, socketServer));
pipeline.addLast(new PrivateSocketHandler(socketServer));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,33 @@

package org.eclipse.iofog.connector.publicsocket;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import org.eclipse.iofog.connector.privatesocket.PrivateSocket;
import org.eclipse.iofog.connector.utils.Constants;
import org.eclipse.iofog.connector.utils.LogUtil;
import org.eclipse.iofog.connector.utils.Settings;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.ssl.SslContext;

public class PublicSocket implements Runnable {

private final int port;
private PrivateSocket privateSocket;

private Channel channel;
private boolean stopListening = false;
private SslContext sslContext;

public PublicSocket(int port, PrivateSocket privateSocket, SslContext sslContext) {

public PublicSocket(int port, PrivateSocket privateSocket) {
this.port = port;
this.privateSocket = privateSocket;
this.sslContext = sslContext;
}

public void run() {
while (!stopListening) {
try {
ServerBootstrap b = new ServerBootstrap();
b.group(Constants.bossGroup, Constants.workerGroup).channel(NioServerSocketChannel.class);
PublicSocketInitializer channelInitializer = new PublicSocketInitializer(privateSocket, sslContext);
PublicSocketInitializer channelInitializer = new PublicSocketInitializer(privateSocket);
b.childHandler(channelInitializer);

channel = b.bind(port).sync().channel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,28 @@

package org.eclipse.iofog.connector.publicsocket;

import org.eclipse.iofog.connector.privatesocket.PrivateSocket;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.bytes.ByteArrayDecoder;
import io.netty.handler.codec.bytes.ByteArrayEncoder;
import io.netty.handler.ssl.SslContext;
import org.eclipse.iofog.connector.privatesocket.PrivateSocket;
import org.eclipse.iofog.connector.utils.SslManager;

public class PublicSocketInitializer extends ChannelInitializer<SocketChannel> {

private final PrivateSocket privateSocket;
private final SslContext sslCtx;

public PublicSocketInitializer(PrivateSocket privateSocket, SslContext sslCtx) {
public PublicSocketInitializer(PrivateSocket privateSocket) {
this.privateSocket = privateSocket;
this.sslCtx = sslCtx;
}

@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();

if (sslCtx != null)
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
if (SslManager.getSslContext() != null)
pipeline.addLast(SslManager.getSslContext().newHandler(ch.alloc()));
pipeline.addLast(new ByteArrayDecoder());
pipeline.addLast(new ByteArrayEncoder());
pipeline.addLast(new PublicSocketHandler(privateSocket));
Expand Down
Loading

0 comments on commit aaeb769

Please sign in to comment.