aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vLB/DNSClient
diff options
context:
space:
mode:
authorplatania <platania@research.att.com>2017-02-16 11:20:22 -0500
committerplatania <platania@research.att.com>2017-02-16 11:20:47 -0500
commit3426556541256f93d2cba65df3b9c8d1d1772861 (patch)
tree56e5b26481400d35e3e2e36be20df953793e348d /vnfs/vLB/DNSClient
parentf525cb9014ae27ddd795f933dee54a78b214a589 (diff)
Initial OpenECOMP Demo commit
Change-Id: Ibf8696196a7ac2c84ac8aa7cde1982c9c89fb64d Signed-off-by: platania <platania@research.att.com>
Diffstat (limited to 'vnfs/vLB/DNSClient')
-rw-r--r--vnfs/vLB/DNSClient/.DS_Storebin0 -> 6148 bytes
-rw-r--r--vnfs/vLB/DNSClient/LICENSE.TXT22
-rw-r--r--vnfs/vLB/DNSClient/README.txt14
-rw-r--r--vnfs/vLB/DNSClient/pom.xml51
-rw-r--r--vnfs/vLB/DNSClient/src/.DS_Storebin0 -> 6148 bytes
-rw-r--r--vnfs/vLB/DNSClient/src/main/.DS_Storebin0 -> 6148 bytes
-rw-r--r--vnfs/vLB/DNSClient/src/main/java/.DS_Storebin0 -> 6148 bytes
-rw-r--r--vnfs/vLB/DNSClient/src/main/java/DNSServer.java85
-rw-r--r--vnfs/vLB/DNSClient/src/main/java/FDClient.java73
9 files changed, 245 insertions, 0 deletions
diff --git a/vnfs/vLB/DNSClient/.DS_Store b/vnfs/vLB/DNSClient/.DS_Store
new file mode 100644
index 00000000..210fb02d
--- /dev/null
+++ b/vnfs/vLB/DNSClient/.DS_Store
Binary files differ
diff --git a/vnfs/vLB/DNSClient/LICENSE.TXT b/vnfs/vLB/DNSClient/LICENSE.TXT
new file mode 100644
index 00000000..ae12da20
--- /dev/null
+++ b/vnfs/vLB/DNSClient/LICENSE.TXT
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
diff --git a/vnfs/vLB/DNSClient/README.txt b/vnfs/vLB/DNSClient/README.txt
new file mode 100644
index 00000000..ce192bbb
--- /dev/null
+++ b/vnfs/vLB/DNSClient/README.txt
@@ -0,0 +1,14 @@
+README
+---
+
+Run the dnsclient.sh script to start the FDClient Java binary. The DNSMembershipManager should be activated first. FDClient will periodically send keep-alive messages to the FDServer.
+- java FDClient [process id] [server IP address] [port] [timeout (sec)] [debug]
+ - [process id]: ID of this process
+ - [server IP address]: IP address of the remote server
+ - [port]: port where the server listens for incoming packets
+ - [timeout (sec)]: how often send a packet to the server
+ - [debug]: verbose mode (TRUE: >=1, FALSE: <=0)
+- Example: java FDClient p1 192.168.9.100 8888 10 1
+
+Please change the default parameters in the dnsclient.sh script as appropriate for your configuration.
+
diff --git a/vnfs/vLB/DNSClient/pom.xml b/vnfs/vLB/DNSClient/pom.xml
new file mode 100644
index 00000000..cfb7db93
--- /dev/null
+++ b/vnfs/vLB/DNSClient/pom.xml
@@ -0,0 +1,51 @@
+<project>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.demo.vnf.lb</groupId>
+ <artifactId>dns-client</artifactId>
+ <name>DNS Client</name>
+ <packaging>jar</packaging>
+ <version>1.0.0</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>main.java.DNSServer</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <distributionManagement>
+ <repository>
+ <id>nexus</id>
+ <name>OpenECOMP Release Repository</name>
+ <url>https://ecomp-nexus:8443/repository/raw</url>
+ </repository>
+ </distributionManagement>
+
+</project>
diff --git a/vnfs/vLB/DNSClient/src/.DS_Store b/vnfs/vLB/DNSClient/src/.DS_Store
new file mode 100644
index 00000000..dba6f684
--- /dev/null
+++ b/vnfs/vLB/DNSClient/src/.DS_Store
Binary files differ
diff --git a/vnfs/vLB/DNSClient/src/main/.DS_Store b/vnfs/vLB/DNSClient/src/main/.DS_Store
new file mode 100644
index 00000000..9206bc71
--- /dev/null
+++ b/vnfs/vLB/DNSClient/src/main/.DS_Store
Binary files differ
diff --git a/vnfs/vLB/DNSClient/src/main/java/.DS_Store b/vnfs/vLB/DNSClient/src/main/java/.DS_Store
new file mode 100644
index 00000000..05c35472
--- /dev/null
+++ b/vnfs/vLB/DNSClient/src/main/java/.DS_Store
Binary files differ
diff --git a/vnfs/vLB/DNSClient/src/main/java/DNSServer.java b/vnfs/vLB/DNSClient/src/main/java/DNSServer.java
new file mode 100644
index 00000000..483819f3
--- /dev/null
+++ b/vnfs/vLB/DNSClient/src/main/java/DNSServer.java
@@ -0,0 +1,85 @@
+
+/*************************************************************************//**
+ *
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+
+package main.java;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+
+/*
+ * Client-side Failure Detector (FD) implementation.
+ * @param server_addr: IP address of the remote server
+ * @param port: the port that the FD service listens for incoming UDP packets
+ * @param timeout: how often the FD checks the status of client processes
+ * @param debug: debug mode on/off
+ */
+
+public class DNSServer {
+
+ public static void main(String[] args) throws IOException {
+ if(args.length != 5) {
+ System.out.println("Missing input parameters");
+ System.out.println("Usage:");
+ System.out.print("\t- java FDClient [process ID] [server IP address] [server port] [timeout (sec)] [debug]\n");
+ System.exit(0);
+ }
+ // IP address and port of the remote server
+ String PID = args[0];
+ String SERVER_ADDR = args[1];
+ int PORT = Integer.parseInt(args[2]);
+ long TIMEOUT = Long.parseLong(args[3]) * 1000; // convert the FD timeout to milliseconds
+ int debug = Integer.parseInt(args[4]);
+ boolean DEBUG;
+ if(debug <= 0)
+ DEBUG = false;
+ else
+ DEBUG = true;
+
+ // Run FD client
+ new FDClient(PID, SERVER_ADDR, PORT, TIMEOUT, DEBUG);
+
+ // Listen for reply messages
+ @SuppressWarnings("resource")
+ DatagramSocket sock = new DatagramSocket(PORT);
+ byte[] buffer = new byte[256];
+ boolean gre_tunnel_enabled = false;
+
+ while(true) {
+ DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
+ sock.receive(packet);
+ String[] content = new String(packet.getData()).trim().split(":"); // Remove leading and trailing spaces
+ String msg_type = content[0];
+ String ip = content[1];
+ // Process only PING UDP packets
+ if(msg_type.equals("PONG")) {
+ if(DEBUG) System.out.println("Reply message received from process " + ip);
+ if(!gre_tunnel_enabled) {
+ // Set GRE tunnel towards load balancer
+ String script = new String("bash /opt/FDclient/set_gre_tunnel.sh " + ip);
+ Runtime.getRuntime().exec(script);
+ if(DEBUG) System.out.println("GRE tunnel towards load balancer " + ip + " done");
+ gre_tunnel_enabled = true;
+ }
+ }
+ else {
+ if(DEBUG) System.out.println("The received message is not a PONG. Received content: " + content);
+ }
+ }
+ }
+}
diff --git a/vnfs/vLB/DNSClient/src/main/java/FDClient.java b/vnfs/vLB/DNSClient/src/main/java/FDClient.java
new file mode 100644
index 00000000..8665937a
--- /dev/null
+++ b/vnfs/vLB/DNSClient/src/main/java/FDClient.java
@@ -0,0 +1,73 @@
+
+/*************************************************************************//**
+ *
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+
+package main.java;
+
+import java.io.*;
+import java.net.*;
+
+/*
+ * Client-side Failure Detector (FD) implementation.
+ * @param server_addr: IP address of the remote server
+ * @param port: the port that the FD service listens for incoming UDP packets
+ * @param timeout: how often the FD checks the status of client processes
+ * @param debug: debug mode on/off
+ */
+
+public class FDClient implements Runnable {
+ private String PID;
+ private String SERVER_ADDR;
+ private int PORT;
+ private long TIMEOUT;
+ private boolean DEBUG;
+
+ public FDClient(String pid, String server_addr, int port, long timeout, boolean debug) throws IOException {
+ PID = pid;
+ SERVER_ADDR = server_addr;
+ PORT = port;
+ TIMEOUT = timeout;
+ DEBUG = debug;
+ (new Thread(this)).start();
+ }
+
+ @SuppressWarnings("resource")
+ @Override
+ public void run() {
+ // Define a DatagramSocket object to send packets to the server
+ try {
+ DatagramSocket sock = new DatagramSocket();
+ InetAddress IPAddress = InetAddress.getByName(SERVER_ADDR);
+
+ // Allocate buffer for the PING message
+ String content = "PING:" + PID;
+ byte[] buffer = content.getBytes();
+
+ // Sent a PING message every TIMEOUT milliseconds
+ while(true) {
+ DatagramPacket packet = new DatagramPacket(buffer, buffer.length, IPAddress, PORT);
+ sock.send(packet);
+
+ if(DEBUG) System.out.println("Sent PING message to server " + SERVER_ADDR + ":" + PORT);
+ try {
+ Thread.sleep(TIMEOUT);
+ }
+ catch(InterruptedException e) {}
+ }
+ } catch(IOException e) {}
+ }
+}