diff options
-rw-r--r-- | lib/junixsocket-1.3.jar | bin | 16162 -> 0 bytes | |||
-rw-r--r-- | lib/junixsocket-demo-1.3.jar | bin | 15753 -> 0 bytes | |||
-rw-r--r-- | lib/junixsocket-mysql-1.3.jar | bin | 1799 -> 0 bytes | |||
-rw-r--r-- | lib/junixsocket-rmi-1.3.jar | bin | 11598 -> 0 bytes | |||
-rw-r--r-- | pom.xml | 13 | ||||
-rw-r--r-- | src/main/java/org/openslx/Test.java | 3 | ||||
-rw-r--r-- | src/main/java/org/openslx/dnbd3/DNBD3Server.java | 30 |
7 files changed, 13 insertions, 33 deletions
diff --git a/lib/junixsocket-1.3.jar b/lib/junixsocket-1.3.jar Binary files differdeleted file mode 100644 index b26e049..0000000 --- a/lib/junixsocket-1.3.jar +++ /dev/null diff --git a/lib/junixsocket-demo-1.3.jar b/lib/junixsocket-demo-1.3.jar Binary files differdeleted file mode 100644 index 8fded38..0000000 --- a/lib/junixsocket-demo-1.3.jar +++ /dev/null diff --git a/lib/junixsocket-mysql-1.3.jar b/lib/junixsocket-mysql-1.3.jar Binary files differdeleted file mode 100644 index f576e4d..0000000 --- a/lib/junixsocket-mysql-1.3.jar +++ /dev/null diff --git a/lib/junixsocket-rmi-1.3.jar b/lib/junixsocket-rmi-1.3.jar Binary files differdeleted file mode 100644 index 37fbd91..0000000 --- a/lib/junixsocket-rmi-1.3.jar +++ /dev/null @@ -15,23 +15,12 @@ </properties> <dependencies> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> - - <!-- unix socks --> - <dependency> - <groupId>org.newsclub</groupId> - <artifactId>junixsocket</artifactId> - <version>1.3</version> - <scope>system</scope> - <systemPath>${project.basedir}/lib/junixsocket-1.3.jar</systemPath> - </dependency> - <!-- xml --> <dependency> <groupId>org.jdom</groupId> @@ -63,7 +52,6 @@ <artifactId>xercesImpl</artifactId> <version>2.10.0</version> </dependency> - </dependencies> <build> @@ -81,4 +69,5 @@ </plugin> </plugins> </build> + </project> diff --git a/src/main/java/org/openslx/Test.java b/src/main/java/org/openslx/Test.java index 4e44552..f473df5 100644 --- a/src/main/java/org/openslx/Test.java +++ b/src/main/java/org/openslx/Test.java @@ -13,6 +13,9 @@ public class Test { try { DNBD3Server server = new DNBD3Server(); + // server.doReload(); + // server.doShutdown(); + System.out.println("Exported images (atime, vid, rid, file):"); System.out.println("========================================"); List<DNBD3Image> images = server.getImages(); diff --git a/src/main/java/org/openslx/dnbd3/DNBD3Server.java b/src/main/java/org/openslx/dnbd3/DNBD3Server.java index ce575dd..5cbaa27 100644 --- a/src/main/java/org/openslx/dnbd3/DNBD3Server.java +++ b/src/main/java/org/openslx/dnbd3/DNBD3Server.java @@ -1,10 +1,10 @@ package org.openslx.dnbd3; import java.io.DataOutputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.Socket; import java.util.ArrayList; import java.util.List; @@ -15,32 +15,31 @@ import org.jdom2.filter.Filters; import org.jdom2.input.SAXBuilder; import org.jdom2.xpath.XPathExpression; import org.jdom2.xpath.XPathFactory; -import org.newsclub.net.unix.AFUNIXSocket; -import org.newsclub.net.unix.AFUNIXSocketAddress; public class DNBD3Server { - private final String UNIXSOCK = "/run/dnbd3-server.sock"; - private static final int CMDSTOP = 0; private static final int CMDRELOAD = 1; private static final int CMDINFO = 2; + private static final String HOST = "127.0.0.1"; + private static final int PORT = 5004; + public void doReload() throws IOException { - AFUNIXSocket sock = connect(); + Socket sock = new Socket(HOST, PORT); sendCommand(sock, CMDRELOAD); sock.close(); } public void doShutdown() throws IOException { - AFUNIXSocket sock = connect(); + Socket sock = new Socket(HOST, PORT); sendCommand(sock, CMDSTOP); sock.close(); } public List<DNBD3Image> getImages() throws IOException { List<DNBD3Image> images = new ArrayList<DNBD3Image>(); - AFUNIXSocket sock = connect(); + Socket sock = new Socket(HOST, PORT); sendCommand(sock, CMDINFO); try { @@ -58,7 +57,6 @@ public class DNBD3Server { file = e.getAttributeValue("file"); images.add(new DNBD3Image(atime, vid, rid, file)); } - is.close(); } catch (JDOMException ex) { ex.printStackTrace(); @@ -70,7 +68,7 @@ public class DNBD3Server { public List<DNBD3Client> getClients() throws IOException { List<DNBD3Client> clients = new ArrayList<DNBD3Client>(); - AFUNIXSocket sock = connect(); + Socket sock = new Socket(HOST, PORT); sendCommand(sock, CMDINFO); try { @@ -86,7 +84,6 @@ public class DNBD3Server { image = e.getAttributeValue("file"); clients.add(new DNBD3Client(ip, image)); } - is.close(); } catch (JDOMException ex) { ex.printStackTrace(); @@ -98,19 +95,10 @@ public class DNBD3Server { //////////////////////////////////////////////////////////////////////////////// - private AFUNIXSocket connect() throws IOException { - AFUNIXSocket sock = null; - File socketFile = new File(UNIXSOCK); - sock = AFUNIXSocket.newInstance(); - sock.connect(new AFUNIXSocketAddress(socketFile)); - return sock; - } - - private void sendCommand(AFUNIXSocket sock, int cmd) throws IOException { + private void sendCommand(Socket sock, int cmd) throws IOException { OutputStream os = sock.getOutputStream(); DataOutputStream dos = new DataOutputStream(os); dos.writeInt(cmd); - os.close(); } } |