diff options
| author | Jonathan Bauer | 2015-03-02 13:22:44 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2015-03-02 13:22:44 +0100 |
| commit | ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a (patch) | |
| tree | 1e252164aa23b6b74d30c6185fda06ceddcd6041 /dozentenmodul/src/main/java/thrift/ThriftConnection.java | |
| parent | pom.xml (diff) | |
| download | tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.tar.gz tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.tar.xz tutor-module-ea9f9848a6e7a68dc90decc2e38bd3e1081ebf8a.zip | |
ThriftManager class: use getSatClient() and getMasterClient() to get the singleton instances of the thrift clients to satellite and master servers
DO NOT CREATE NEW THRIFT OBJECTS!!!
Diffstat (limited to 'dozentenmodul/src/main/java/thrift/ThriftConnection.java')
| -rw-r--r-- | dozentenmodul/src/main/java/thrift/ThriftConnection.java | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/dozentenmodul/src/main/java/thrift/ThriftConnection.java b/dozentenmodul/src/main/java/thrift/ThriftConnection.java deleted file mode 100644 index a026ef03..00000000 --- a/dozentenmodul/src/main/java/thrift/ThriftConnection.java +++ /dev/null @@ -1,77 +0,0 @@ -package thrift; - -import javax.swing.JOptionPane; - -import models.SessionData; - -import org.apache.log4j.Logger; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.transport.TSocket; -import org.apache.thrift.transport.TTransport; -import org.openslx.sat.thrift.iface.Server; -import org.openslx.sat.thrift.iface.Server.Client; -import org.openslx.sat.thrift.version.Version; - -public class ThriftConnection { - - private final static Logger LOGGER = Logger - .getLogger(ThriftConnection.class); - - private String satAddress = SessionData.session.getServerAdress(); - final TTransport transport = new TSocket(satAddress, 9090, 10000); - - public Client getThriftConnection() { - - try { - transport.open(); - } catch (Exception e) { - LOGGER.error("Keine Verbindung möglich! Satellit: " + satAddress, e); - JOptionPane.showMessageDialog(null, - "Konnte keine Verbindung zum Satellit '" + satAddress - + "' aufbauen!", "Debug-Message", - JOptionPane.ERROR_MESSAGE); - return null; - } - - final TProtocol protocol = new TBinaryProtocol(transport); - final Server.Client client = new Server.Client(protocol); - LOGGER.info("Verbindung zu " + satAddress + " wurde aufgebaut."); - - long remoteVersion; - try { - remoteVersion = client.getVersion(); - } catch (Exception e) { - LOGGER.error( - "Could not query sat server version after successful connect! Assuming untagged version 1", - e); - remoteVersion = 1; - } - String text = null; - if (remoteVersion > Version.VERSION) { - text = "Das von Ihnen verwendete Dozentenmodul ist zu alt, um mit dem Satelliten-Server zu verbinden.\n" - + "Sie verwenden Version " - + Version.VERSION - + ", der Satellit " - + remoteVersion - + "\n" - + "Aktuelle Version unter http://bwlehrpool.hs-offenburg.de/"; - } else if (remoteVersion < Version.VERSION) { - text = "Das von Ihnen verwendete Dozentenmodul ist zu neu, um mit dem Satelliten-Server zu verbinden.\n" - + "Sie verwenden Version " - + Version.VERSION - + ", der Satellit " + remoteVersion; - } - if (text != null) { - JOptionPane.showMessageDialog(null, text, "Fehler", - JOptionPane.ERROR_MESSAGE); - } - - return client; - } - - public void closeThriftConnection() { - LOGGER.info("Verbindung wird geplant getrennt."); - transport.close(); - } -} |
