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

Release 1.0.13 #217

Merged
merged 23 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ jobs:
before_install:
- sudo apt-get install sshpass xml-twig-tools
script:
- export VERSION=`xml_grep --cond='project/version' pom.xml --text_only`
- export ID=-dev
- bash scripts/packaging.sh
- bash scripts/deploy.sh $DEV_MACHINE_PASSWORD $DEV_MACHINE_USERNAME $DEV_MACHINE_IP
- stage: pre_release
before_install:
- sudo apt-get install sshpass xml-twig-tools
script:
- export VERSION=`xml_grep --cond='project/version' pom.xml --text_only`
- export DEV=-dev
- export ID=-prerelease
- bash scripts/packaging.sh
- bash scripts/deploy.sh $PREPROD_MACHINE_PASSWORD $PREPROD_MACHINE_USERNAME $PREPROD_MACHINE_IP
- stage: release
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ ioFog is a service that runs constantly in the background on a Linux machine. It

There should be an ioFog code base for every processing platform that becomes part of the I/O compute fog. Network connectivity, process invocation, thread management, and other details of an ioFog will vary from platform to platform. The same ioFog principles apply to every version, but the implementation of the principles should match the native languages and structures best suited for the platform.

### Status

![](https://img.shields.io/github/release/iofog/agent.svg?style=flat)
[![Build Status](https://travis-ci.org/ioFog/Agent.svg)](https://travis-ci.org/ioFog/Agent)

![](https://img.shields.io/github/repo-size/iofog/agent.svg?style=flat)
![](https://img.shields.io/github/last-commit/iofog/agent.svg?style=flat)
![](https://img.shields.io/github/contributors/iofog/agent.svg?style=flat)
![](https://img.shields.io/github/issues/iofog/agent.svg?style=flat)

![Supports amd64 Architecture][amd64-shield]
![Supports aarch64 Architecture][arm64-shield]
![Supports armhf Architecture][arm-shield]

[arm64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
[arm-shield]: https://img.shields.io/badge/armhf-yes-green.svg

### Principles of an ioFog Agent:

* Never go down
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.eclipse</groupId>
<artifactId>iofog-agent</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
54 changes: 40 additions & 14 deletions client/src/org/eclipse/iofog/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ public class Client {

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

private static final String LOCAL_API_ENDPOINT = "http://localhost:54321/v2/commandline";
private static final String WINDOWS_IOFOG_PATH = System.getenv("IOFOG_PATH") != null ?
System.getenv("IOFOG_PATH") : "./";
private static final String SNAP_COMMON = System.getenv("SNAP_COMMON") != null ?
System.getenv("SNAP_COMMON") : "";
private static final String CONFIG_DIR = isWindows() ?
WINDOWS_IOFOG_PATH : SNAP_COMMON + "/etc/iofog-agent/";
private static final String LOCAL_API_TOKEN_PATH = CONFIG_DIR + "local-api";

private static final Properties cmdProperties;


static {
cmdProperties = new Properties();
try (InputStream in = Client.class.getResourceAsStream(PROPERTIES_FILE_PATH)) {
Expand All @@ -46,7 +56,7 @@ private static String getVersion() {
*/
private static boolean isAnotherInstanceRunning() {
try {
URL url = new URL("http://localhost:54321/v2/commandline");
URL url = new URL(LOCAL_API_ENDPOINT);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.getResponseCode();
Expand All @@ -59,7 +69,7 @@ private static boolean isAnotherInstanceRunning() {

/**
* send command-line parameters to ioFog daemon
*
*
* @param args - parameters
*
*/
Expand All @@ -71,21 +81,20 @@ private static boolean sendCommandlineParameters(String... args) {
}
params = new StringBuilder(params.toString().trim() + "\"}");
byte[] postData = params.toString().trim().getBytes(StandardCharsets.UTF_8);

URL url = new URL("http://localhost:54321/v2/commandline");

String accessToken = fetchAccessToken();

URL url = new URL(LOCAL_API_ENDPOINT);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "text/plain");
conn.setRequestProperty("Content-Length", Integer.toString(postData.length));
conn.setRequestProperty("Authorization", accessToken);
conn.setDoOutput(true);
try(DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {
wr.write(postData);
}

if (conn.getResponseCode() != 200) {
return false;
}

BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

Expand All @@ -96,17 +105,29 @@ private static boolean sendCommandlineParameters(String... args) {
}

conn.disconnect();

System.out.println(result.toString().replace("\\n", "\n"));
return true;

return conn.getResponseCode() == 200;
} catch (Exception e) {
return false;
}
}

private static String fetchAccessToken() {
String line = "";
try (BufferedReader reader = new BufferedReader(new FileReader(LOCAL_API_TOKEN_PATH))) {
line = reader.readLine();
} catch (IOException e) {
System.out.println("Local API access token is missing, try to re-install Agent.");
}

return line;
}

/**
* returns help
*
*
* @return String
*/
private static String showHelp() {
Expand Down Expand Up @@ -205,7 +226,7 @@ public static void main(String[] args) throws ParseException {
System.out.println("Enter \"service iofog-agent stop\"");
break;
case "start":
System.out.println("iofog is already running.");
System.out.println("ioFog Agent is already running.");
break;
default:
sendCommandlineParameters(args);
Expand All @@ -228,9 +249,14 @@ public static void main(String[] args) throws ParseException {
System.out.println("Enter \"service iofog-agent start\"");
break;
default:
System.out.println("iofog is not running.");
System.out.println("ioFog Agent is not running.");
}
}
}

private static boolean isWindows() {
String osName = System.getProperty("os.name");
return osName != null && osName.startsWith("Windows");
}

}
28 changes: 20 additions & 8 deletions daemon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.eclipse</groupId>
<artifactId>iofog-agent</artifactId>
<version>1.0.12</version>
<version>1.0.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -36,7 +36,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down Expand Up @@ -67,7 +67,7 @@
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
Expand All @@ -87,6 +87,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>5.0.0-M1</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -103,7 +115,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.34.Final</version>
<version>4.1.33.Final</version>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
Expand All @@ -123,22 +135,22 @@
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
<version>0.1.55</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.4</version>
<version>4.5.7</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.7.16</version>
<version>1.7.21</version>
</dependency>
</dependencies>

Expand Down
8 changes: 5 additions & 3 deletions daemon/src/org/eclipse/iofog/Daemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
public class Daemon {
private static final String MODULE_NAME = "MAIN_DAEMON";

private static final String LOCAL_API_ENDPOINT = "http://localhost:54321/v2/commandline";

/**
* check if another instance of iofog is running
*
Expand All @@ -37,7 +39,7 @@ public class Daemon {
private static boolean isAnotherInstanceRunning() {

try {
URL url = new URL("http://localhost:54321/v2/commandline");
URL url = new URL(LOCAL_API_ENDPOINT);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.getResponseCode();
Expand Down Expand Up @@ -67,7 +69,7 @@ private static boolean sendCommandlineParameters(String... args) {
params = new StringBuilder(params.toString().trim() + "\"}");
byte[] postData = params.toString().trim().getBytes(UTF_8);

URL url = new URL("http://localhost:54321/v2/commandline");
URL url = new URL(LOCAL_API_ENDPOINT);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
Expand Down Expand Up @@ -164,7 +166,7 @@ public static void main(String[] args) throws ParseException {

if (isAnotherInstanceRunning()) {
if (args[0].equals("start")) {
System.out.println("iofog is already running.");
System.out.println("ioFog Agent is already running.");
} else if (args[0].equals("stop")) {
sendCommandlineParameters(args);
}
Expand Down
16 changes: 8 additions & 8 deletions daemon/src/org/eclipse/iofog/field_agent/FieldAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.iofog.tracking.Tracker;
import org.eclipse.iofog.tracking.TrackingEventType;
import org.eclipse.iofog.tracking.TrackingInfoUtils;
import org.eclipse.iofog.utils.Constants;
import org.eclipse.iofog.utils.Orchestrator;
import org.eclipse.iofog.utils.configuration.Configuration;
import org.eclipse.iofog.utils.logging.LoggingService;
Expand Down Expand Up @@ -180,9 +179,9 @@ private boolean notProvisioned() {
connected = isControllerConnected(false);
if (!connected)
continue;
logInfo("controller connection verified");
logInfo("Controller connection verified");

logInfo("sending IOFog status...");
logInfo("Sending ioFog status...");
orchestrator.request("status", RequestType.PUT, null, status);
onPostStatusSuccess();
} catch (CertificateException | SSLHandshakeException e) {
Expand Down Expand Up @@ -243,7 +242,7 @@ private void verificationFailed(Exception e) {
connected = false;
if (!notProvisioned()) {
StatusReporter.setFieldAgentStatus().setControllerStatus(ControllerStatus.BROKEN_CERTIFICATE);
logError("controller certificate verification failed", e);
logWarning("controller certificate verification failed");
}
StatusReporter.setFieldAgentStatus().setControllerVerified(false);
}
Expand Down Expand Up @@ -340,7 +339,7 @@ private void deleteNode() {
try {
orchestrator.request("delete-node", RequestType.DELETE, null, null);
} catch (Exception e) {
logInfo("can't send delete node command");
logInfo("Can't send delete node command");
}
deProvision(false);
}
Expand Down Expand Up @@ -434,6 +433,7 @@ private void loadRegistries(boolean fromFile) {
for (int i = 0; i < registriesList.size(); i++) {
JsonObject registry = registriesList.getJsonObject(i);
Registry.RegistryBuilder registryBuilder = new Registry.RegistryBuilder()
.setId(registry.getInt("id"))
.setUrl(registry.getString("url"))
.setIsPublic(registry.getBoolean("isPublic", false));
if (!registry.getBoolean("isPublic", false)) {
Expand Down Expand Up @@ -500,7 +500,7 @@ private JsonArray loadMicroservicesJsonFile() {
* @param fromFile - load from file
*/
private List<Microservice> loadMicroservices(boolean fromFile) {
logInfo("loading microservices...");
logInfo("Loading microservices...");
if (notProvisioned() || !isControllerConnected(fromFile)) {
return new ArrayList<>();
}
Expand Down Expand Up @@ -547,7 +547,7 @@ private Function<JsonObject, Microservice> containerJsonObjectToMicroserviceFunc
microservice.setConfig(jsonObj.getString("config"));
microservice.setRebuild(jsonObj.getBoolean("rebuild"));
microservice.setRootHostAccess(jsonObj.getBoolean("rootHostAccess"));
microservice.setRegistry(jsonObj.getString("registryUrl"));
microservice.setRegistryId(jsonObj.getInt("registryId"));
microservice.setLogSize(jsonObj.getJsonNumber("logSize").longValue());
microservice.setDelete(jsonObj.getBoolean("delete"));
microservice.setDeleteWithCleanup(jsonObj.getBoolean("deleteWithCleanup"));
Expand Down Expand Up @@ -724,7 +724,7 @@ private void saveFile(JsonArray data, String filename) {
* gets IOFog instance configuration from IOFog controller
*/
private void getFogConfig() {
logInfo("get fog config");
logInfo("Get ioFog config");
if (notProvisioned() || !isControllerConnected(false)) {
return;
}
Expand Down
Loading