diff options
| author | Nino Breuer | 2014-11-20 14:57:00 +0100 |
|---|---|---|
| committer | Nino Breuer | 2014-11-20 14:57:00 +0100 |
| commit | 64ea92982ec1755fb6e9b8eaf50927f33a76d926 (patch) | |
| tree | ea096d392187b2521168a5c8b989e001fe4ad3b7 /dozentenmodulserver/src/main/java/thrift/MasterThriftConnection.java | |
| parent | f (diff) | |
| download | tutor-module-64ea92982ec1755fb6e9b8eaf50927f33a76d926.tar.gz tutor-module-64ea92982ec1755fb6e9b8eaf50927f33a76d926.tar.xz tutor-module-64ea92982ec1755fb6e9b8eaf50927f33a76d926.zip | |
• new package for thrift classes
Diffstat (limited to 'dozentenmodulserver/src/main/java/thrift/MasterThriftConnection.java')
| -rw-r--r-- | dozentenmodulserver/src/main/java/thrift/MasterThriftConnection.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/dozentenmodulserver/src/main/java/thrift/MasterThriftConnection.java b/dozentenmodulserver/src/main/java/thrift/MasterThriftConnection.java new file mode 100644 index 00000000..6e5e6f61 --- /dev/null +++ b/dozentenmodulserver/src/main/java/thrift/MasterThriftConnection.java @@ -0,0 +1,43 @@ +package thrift; + +import org.apache.log4j.Logger; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.transport.TFramedTransport; +import org.apache.thrift.transport.TSocket; +import org.apache.thrift.transport.TTransport; +import org.apache.thrift.transport.TTransportException; +import org.openslx.imagemaster.thrift.iface.ImageServer.Client; + +public class MasterThriftConnection { + + private final static Logger LOGGER = Logger.getLogger(MasterThriftConnection.class); + + public static final String MASTERSERVER_IP = "132.230.4.16"; + public static final int MASTERSERVER_PORT = 9090; + public static final int MASTERSERVER_TIMEOUT_MS = 6000; + + final TTransport transport = new TFramedTransport(new TSocket( + MASTERSERVER_IP, MASTERSERVER_PORT, MASTERSERVER_TIMEOUT_MS)); + + public Client getMasterThriftConnection() { + + try { + transport.open(); + } catch (TTransportException e) { + LOGGER.error("Keine Verbindung möglich!"); + return null; + } + + final TProtocol protocol = new TBinaryProtocol(transport); + final Client client = new Client(protocol); + LOGGER.info("Masterserver '" + MASTERSERVER_IP + "' erreichbar."); + + return client; + } + + public void closeMasterThriftConnection() { + transport.close(); + } +} +
\ No newline at end of file |
