diff options
| author | Jan Altenberg <jan@linutronix.de> | 2014-02-19 17:29:03 +0100 |
|---|---|---|
| committer | Jan Altenberg <jan@linutronix.de> | 2014-02-19 17:29:03 +0100 |
| commit | 6806a0c78d7645383a9b59e7025c8c0fa92da98c (patch) | |
| tree | aa574864122b9963d57af0eb4ce39d86bd1dcd57 /frameworks | |
| parent | d0eb7de92f33eff43fb32c413582fcb74553999f (diff) | |
| parent | 2f46ad6a6f7393dc7898672a7ea3337395bafae9 (diff) | |
Merge branch 'middleware'
Diffstat (limited to 'frameworks')
32 files changed, 1035 insertions, 45 deletions
diff --git a/frameworks/middleware/examples/celery/README b/frameworks/middleware/examples/celery/README new file mode 100644 index 0000000..9045901 --- /dev/null +++ b/frameworks/middleware/examples/celery/README @@ -0,0 +1,3 @@ +apt-get install python-celery +./worker.sh +./test.py diff --git a/frameworks/middleware/examples/celery/exec_task.py b/frameworks/middleware/examples/celery/exec_task.py new file mode 100644 index 0000000..9169250 --- /dev/null +++ b/frameworks/middleware/examples/celery/exec_task.py @@ -0,0 +1,15 @@ +import os + +from celery import Celery + +app = Celery ('tasks', broker='sqla+sqlite:///celerydb.sqlite', + backend='db+sqlite:///results.sqlite') + +@app.task +def execute (command): + return os.system (command) + +@app.task +def execute2 (command): + if os.system (command): + raise Exception ("command not found") diff --git a/frameworks/middleware/examples/celery/test.py b/frameworks/middleware/examples/celery/test.py new file mode 100755 index 0000000..7d79c8e --- /dev/null +++ b/frameworks/middleware/examples/celery/test.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +import sys +import traceback + +from exec_task import execute, execute2 + +execute.delay ("echo hello world") + +print "\n\n" + +result = execute.delay ("sleep 2") +print "result ready?", result.ready () +print "wait for result..." +ret = result.get (timeout=10) +print "task done", ret + +print "\n\n" + +result = execute.delay ("/bin/false") +print "/bin/false:", result.get (timeout=10) + +print "\n\n" + +result = execute2.delay ("/bin/treu") +try: + print "/bin/treu:", result.get (timeout=10) +except: + print "exception occured; backtrace:" + print result.traceback + +print "\n\n" + +result = execute2.delay ("/bin/true") +print "/bin/true:", result.get (timeout=10) + diff --git a/frameworks/middleware/examples/celery/worker.sh b/frameworks/middleware/examples/celery/worker.sh new file mode 100755 index 0000000..1705198 --- /dev/null +++ b/frameworks/middleware/examples/celery/worker.sh @@ -0,0 +1,2 @@ +#!/bin/sh +celery -A exec_task worker --loglevel=info diff --git a/frameworks/middleware/examples/corba/AUTHORS b/frameworks/middleware/examples/corba/AUTHORS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/corba/AUTHORS diff --git a/frameworks/middleware/examples/corba/ChangeLog b/frameworks/middleware/examples/corba/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/corba/ChangeLog diff --git a/frameworks/middleware/examples/corba/Makefile.am b/frameworks/middleware/examples/corba/Makefile.am new file mode 100644 index 0000000..72a6a67 --- /dev/null +++ b/frameworks/middleware/examples/corba/Makefile.am @@ -0,0 +1,29 @@ +IDL_COMPILER=tao_idl +IDL_COMPILER_OPT=-GI + +IDL_GEN_H_SRV = pingI.h pingS.h +IDL_GEN_S_SRV = pingS.cpp +IDL_GEN_H_CLT = pingC.h pingC.inl +IDL_GEN_S_CLT = pingC.cpp + +pingI.h: ping.idl + $(IDL_COMPILER) $(IDL_COMPILER_OPT) ping.idl + +noinst_HEADERS = $(IDL_GEN_H_SRV) $(IDL_GEN_H_CLT) + +CLEANFILES = $(IDL_GEN_H_SRV) $(IDL_GEN_S_SRV) \ + $(IDL_GEN_H_CLT) $(IDL_GEN_S_CLT) pingI.cpp + +CORBA_CFLAGS = $(TAO_CFLAGS) $(TAO_CosNaming_CFLAGS) \ + $(TAO_PortableServer_CFLAGS) $(TAO_RTCORBA_CFLAGS) +CORBA_LIBS = $(TAO_LIBS) $(TAO_CosNaming_LIBS) $(TAO_PortableServer_LIBS) \ + $(TAO_RTCORBA_LIBS) + +bin_PROGRAMS = receiver supplier +receiver_SOURCES = ping_I.cpp $(IDL_GEN_S_SRV) $(IDL_GEN_S_CLT) Receiver.cpp +receiver_CFLAGS = $(CORBA_CFLAGS) +receiver_LDADD = $(CORBA_LIBS) + +supplier_SOURCES = Supplier.cpp $(IDL_GEN_S_CLT) +supplier_CFLAGS = $(CORBA_CFLAGS) +supplier_LDADD = $(CORBA_LIBS) diff --git a/frameworks/middleware/examples/corba/NEWS b/frameworks/middleware/examples/corba/NEWS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/corba/NEWS diff --git a/frameworks/middleware/examples/corba/README b/frameworks/middleware/examples/corba/README new file mode 100644 index 0000000..5d71b99 --- /dev/null +++ b/frameworks/middleware/examples/corba/README @@ -0,0 +1,12 @@ +apt-get install -t experimental libtao-dev mpc-ace libtao-orbsvcs-dev \ +tao-cosnaming tao-idl tao-utils + +./autogen.sh +./configure +make + +Naming_Service -ORBEndpoint iiop://localhost:55555 + + +./receiver -ORBInitRef NameService=corbaloc:iiop:localhost:55555/NameService +./supplier test -ORBInitRef NameService=corbaloc:iiop:localhost:55555/NameService diff --git a/frameworks/middleware/examples/corba/autogen.sh b/frameworks/middleware/examples/corba/autogen.sh new file mode 100755 index 0000000..58c0175 --- /dev/null +++ b/frameworks/middleware/examples/corba/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/bash +automake --add-missing +autoreconf -sif diff --git a/frameworks/middleware/examples/corba/configure.ac b/frameworks/middleware/examples/corba/configure.ac new file mode 100644 index 0000000..6127c33 --- /dev/null +++ b/frameworks/middleware/examples/corba/configure.ac @@ -0,0 +1,28 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.69]) +AC_INIT([corba-example], [1.0], [manut@linutronix.de]) +AC_CONFIG_SRCDIR([Receiver.cpp]) +AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_HEADERS([config.h]) + +# Checks for programs. +AC_PROG_CXX + +# Checks for libraries. +PKG_CHECK_MODULES([TAO], [TAO]) +PKG_CHECK_MODULES([TAO_CosNaming], [TAO_CosNaming]) +PKG_CHECK_MODULES([TAO_PortableServer], [TAO_PortableServer]) +PKG_CHECK_MODULES([TAO_RTCORBA], [TAO_RTCORBA]) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_CHECK_FUNCS([clock_gettime]) + +AC_CONFIG_FILES([Makefile]) + +AC_OUTPUT diff --git a/frameworks/middleware/examples/corba/ping_I.cpp b/frameworks/middleware/examples/corba/ping_I.cpp index 309d1e8..e02924f 100644 --- a/frameworks/middleware/examples/corba/ping_I.cpp +++ b/frameworks/middleware/examples/corba/ping_I.cpp @@ -21,4 +21,3 @@ void Linutronix_Ping_i::send ( clock_gettime(CLOCK_MONOTONIC, &time_rx); std::cout<<time_rx.tv_sec<<":"<<time_rx.tv_nsec/1000<<": "<<payload<<"\n"; } - diff --git a/frameworks/middleware/examples/dbus/AUTHORS b/frameworks/middleware/examples/dbus/AUTHORS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/dbus/AUTHORS diff --git a/frameworks/middleware/examples/dbus/ChangeLog b/frameworks/middleware/examples/dbus/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/dbus/ChangeLog diff --git a/frameworks/middleware/examples/dbus/Makefile.am b/frameworks/middleware/examples/dbus/Makefile.am new file mode 100644 index 0000000..830a98e --- /dev/null +++ b/frameworks/middleware/examples/dbus/Makefile.am @@ -0,0 +1,8 @@ +bin_PROGRAMS = pingserver pingclient +pingserver_SOURCES = ping-server.c +pingserver_CFLAGS = $(DBUS_CFLAGS) +pingserver_LDADD = $(DBUS_LIBS) + +pingclient_SOURCES = ping-client.c +pingclient_CFLAGS = $(DBUS_CFLAGS) +pingclient_LDADD = $(DBUS_LIBS) diff --git a/frameworks/middleware/examples/dbus/NEWS b/frameworks/middleware/examples/dbus/NEWS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/dbus/NEWS diff --git a/frameworks/middleware/examples/dbus/README b/frameworks/middleware/examples/dbus/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frameworks/middleware/examples/dbus/README diff --git a/frameworks/middleware/examples/dbus/autogen.sh b/frameworks/middleware/examples/dbus/autogen.sh new file mode 100755 index 0000000..58c0175 --- /dev/null +++ b/frameworks/middleware/examples/dbus/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/bash +automake --add-missing +autoreconf -sif diff --git a/frameworks/middleware/examples/dbus/compile.sh b/frameworks/middleware/examples/dbus/compile.sh deleted file mode 100755 index d2b2822..0000000 --- a/frameworks/middleware/examples/dbus/compile.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -gcc -o server -lrt -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 ping-server.c -gcc -o client -lrt -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0 ping-client.c diff --git a/frameworks/middleware/examples/dbus/configure.ac b/frameworks/middleware/examples/dbus/configure.ac new file mode 100644 index 0000000..bf99b42 --- /dev/null +++ b/frameworks/middleware/examples/dbus/configure.ac @@ -0,0 +1,24 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.69]) +AC_INIT([dbus-example], [1.0], [manut@linutronix.de]) +AC_CONFIG_SRCDIR([ping-server.c]) +AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_HEADERS([config.h]) + +# Checks for programs. +AC_PROG_CC + +# Checks for libraries. +PKG_CHECK_MODULES([DBUS], [dbus-glib-1]) +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_CHECK_FUNCS([clock_gettime]) + +AC_CONFIG_FILES([Makefile]) + +AC_OUTPUT diff --git a/frameworks/middleware/examples/dbus/ping-client.c b/frameworks/middleware/examples/dbus/ping-client.c index e3035e4..ceb3205 100644 --- a/frameworks/middleware/examples/dbus/ping-client.c +++ b/frameworks/middleware/examples/dbus/ping-client.c @@ -12,10 +12,10 @@ int main (int argc, char **argv) DBusConnection *bus; DBusError error; - if (argc > 1) - v_STRING = argv[1]; - else - v_STRING = "no arg given"; + if (argc > 1) + v_STRING = argv[1]; + else + v_STRING = "no arg given"; /* Create a new event loop to run in */ loop = g_main_loop_new (NULL, FALSE); @@ -42,8 +42,8 @@ int main (int argc, char **argv) static gboolean send_ping (DBusConnection *bus) { DBusMessage *message; - struct timespec tx_time; - struct timespec done_time; + struct timespec tx_time; + struct timespec done_time; message = dbus_message_new_signal ("/de/linutronix/Ping", "de.linutronix.Ping", "Ping"); @@ -51,12 +51,16 @@ static gboolean send_ping (DBusConnection *bus) dbus_message_append_args (message, DBUS_TYPE_STRING, &v_STRING, DBUS_TYPE_INVALID); - clock_gettime(CLOCK_MONOTONIC, &tx_time); + + clock_gettime(CLOCK_MONOTONIC, &tx_time); + /* Send the signal */ dbus_connection_send (bus, message, NULL); - clock_gettime(CLOCK_MONOTONIC, &done_time); - g_print("%d:%d\n%d:%d\n\n", tx_time.tv_sec, tx_time.tv_nsec/1000, - done_time.tv_sec, done_time.tv_nsec/1000); + clock_gettime(CLOCK_MONOTONIC, &done_time); + + g_print("%d:%d\n%d:%d\n\n", tx_time.tv_sec, tx_time.tv_nsec/1000, + done_time.tv_sec, done_time.tv_nsec/1000); + /* Free the signal now we have finished with it */ dbus_message_unref (message); /* Return TRUE to tell the event loop we want to be called again */ diff --git a/frameworks/middleware/examples/dbus/ping-server.c b/frameworks/middleware/examples/dbus/ping-server.c index 36dd122..96b2397 100644 --- a/frameworks/middleware/examples/dbus/ping-server.c +++ b/frameworks/middleware/examples/dbus/ping-server.c @@ -60,7 +60,6 @@ static DBusHandlerResult signal_filter clock_gettime(CLOCK_MONOTONIC, &rx_time); g_print("ping received: %s - %d:%d\n", s, rx_time.tv_sec, rx_time.tv_nsec/1000); - // dbus_free (s); } else { g_print("ping received, but error getting message: %s\n", error.message); dbus_error_free (&error); @@ -69,4 +68,3 @@ static DBusHandlerResult signal_filter } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } - diff --git a/frameworks/middleware/examples/soap/client.py b/frameworks/middleware/examples/soap/client.py new file mode 100755 index 0000000..9cd35f2 --- /dev/null +++ b/frameworks/middleware/examples/soap/client.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +from datetime import datetime +from ZSI.client import Binding + +b = Binding(url='http://localhost:8000/') +t = b.today (5) +# t = 2014-02-18 15:59:50.571927 +conv = datetime.strptime (t, "%Y-%m-%d %H:%M:%S.%f") +print "Today: %s" % conv.strftime ("%d.%m.%Y, %H:%M") +print b.load ("string") diff --git a/frameworks/middleware/examples/soap/server.py b/frameworks/middleware/examples/soap/server.py new file mode 100755 index 0000000..32a550a --- /dev/null +++ b/frameworks/middleware/examples/soap/server.py @@ -0,0 +1,18 @@ +#!/usr/bin/python + +from datetime import datetime +from ZSI import dispatch + +def today (arg): + print "today arg:", arg + today = datetime.today () + return str (today) + +def load (arg): + print "load arg:", arg + fd = open ("/proc/loadavg", "r") + loadavg = fd.read () + sysload = loadavg.split () + return sysload[0] + +dispatch.AsServer (port=8000, rpc=True) diff --git a/frameworks/middleware/examples/xmlrpc/client.py b/frameworks/middleware/examples/xmlrpc/client.py new file mode 100755 index 0000000..2b466b7 --- /dev/null +++ b/frameworks/middleware/examples/xmlrpc/client.py @@ -0,0 +1,14 @@ +#!/usr/bin/python + +import xmlrpclib +from datetime import datetime + +proxy = xmlrpclib.ServerProxy ("http://localhost:8000/") + +today = proxy.today () +# today = 20140218T14:23:45 +converted = datetime.strptime (today.value, "%Y%m%dT%H:%M:%S") +print "Today: %s" % converted.strftime ("%d.%m.%Y, %H:%M") + +load = proxy.load () +print "system load:", load diff --git a/frameworks/middleware/examples/xmlrpc/server.py b/frameworks/middleware/examples/xmlrpc/server.py new file mode 100755 index 0000000..ebde5ee --- /dev/null +++ b/frameworks/middleware/examples/xmlrpc/server.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +from datetime import datetime +from SimpleXMLRPCServer import SimpleXMLRPCServer +import xmlrpclib + +def today (): + today = datetime.today () + return xmlrpclib.DateTime (today) + +def load (): + fd = open ("/proc/loadavg", "r") + loadavg = fd.read () + sysload = loadavg.split () + return xmlrpclib.FloatType (sysload[0]) + +server = SimpleXMLRPCServer (("localhost", 8000)) +server.register_function (today, "today") +server.register_function (load, "load") +print "Listening on port 8000..." +server.serve_forever () diff --git a/frameworks/middleware/examples/xmpp/README b/frameworks/middleware/examples/xmpp/README new file mode 100644 index 0000000..ef147ce --- /dev/null +++ b/frameworks/middleware/examples/xmpp/README @@ -0,0 +1,28 @@ +a) apt-get install libqxmpp-dev psi ejabberd + +b) edit /etc/ejabberd/ejabberd.cfg to allow inband registration: + + --8<--- + %% No username can be registered via in-band registration: + %% To enable in-band registration, replace 'deny' with 'allow' + % (note that if you remove mod_register from modules list then users will not + % be able to change their password as well as register). + % This setting is default because it's more safe. + {access, register, [{allow, all}]}. + --8<--- + +c) start psi and configure it to use 'localhost' as server and create two + accounts: <yourname>:<yourpass> + qtapp:test + +d) login with <yourname> and qtapp, add both accounts to their contact list, + and try to send messages. logoff the qtapp account. + +e) build the qt client application and start it: + +qmake +make +./client + +f) the qtapp account needs now to be online in psi, write a messagte to qtapp + the message should be displayed in the commandline diff --git a/frameworks/middleware/examples/xmpp/client.cpp b/frameworks/middleware/examples/xmpp/client.cpp new file mode 100644 index 0000000..9390438 --- /dev/null +++ b/frameworks/middleware/examples/xmpp/client.cpp @@ -0,0 +1,24 @@ +/* +* Copyright (C) 2008-2010 Manjeet Dahiya +* +* Author: +* Manjeet Dahiya +* modified 2014 by Manuel Traut <manut@linutronix.de> +*/ + +#include <QtCore/QCoreApplication> + +//#include <qxmpp/QXmppLogger.h> + +#include "myclient.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + // QXmppLogger::getLogger()->setLoggingType(QXmppLogger::StdoutLogging); + + MyClient client; + client.connectToServer("qtapp@localhost", "test"); + + return a.exec(); +} diff --git a/frameworks/middleware/examples/xmpp/myclient.cpp b/frameworks/middleware/examples/xmpp/myclient.cpp new file mode 100644 index 0000000..fa28603 --- /dev/null +++ b/frameworks/middleware/examples/xmpp/myclient.cpp @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2008-2010 Manjeet Dahiya +* +* Author: +* Manjeet Dahiya +* +* modified 2014 by Manuel Traut <manut@linutronix.de> +*/ + +#include <qxmpp/QXmppMessage.h> +#include <iostream> + +#include "myclient.h" + +MyClient::MyClient() : QXmppClient() +{ + bool check = connect(this, + SIGNAL(messageReceived(QXmppMessage)), + SLOT(message_rx(QXmppMessage))); + Q_ASSERT(check); + Q_UNUSED(check); +} + +MyClient::~MyClient() { ; } + +void MyClient::message_rx(const QXmppMessage& message) +{ + QString from = message.from(); + QString msg = message.body(); + std::cout<<from.toStdString()<<": "<<msg.toStdString()<<std::endl; + sendPacket(QXmppMessage("", from, "you mean " + msg + "??")); +} diff --git a/frameworks/middleware/examples/xmpp/myclient.h b/frameworks/middleware/examples/xmpp/myclient.h new file mode 100644 index 0000000..22d864c --- /dev/null +++ b/frameworks/middleware/examples/xmpp/myclient.h @@ -0,0 +1,17 @@ +#ifndef CLIENT_H +#define CLIENT_H + +#include <qxmpp/QXmppClient.h> + +class MyClient : public QXmppClient +{ + Q_OBJECT +public: + MyClient(); + ~MyClient(); + +public slots: + void message_rx(const QXmppMessage&); +}; + +#endif diff --git a/frameworks/middleware/examples/xmpp/xmpp.pro b/frameworks/middleware/examples/xmpp/xmpp.pro new file mode 100644 index 0000000..7f0be00 --- /dev/null +++ b/frameworks/middleware/examples/xmpp/xmpp.pro @@ -0,0 +1,15 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue Feb 18 19:47:09 2014 +###################################################################### + +TEMPLATE = app +TARGET = client +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += client.cpp myclient.cpp +HEADERS += myclient.h + +QT += network +LIBS += -lqxmpp diff --git a/frameworks/middleware/pres_middleware.tex b/frameworks/middleware/pres_middleware.tex index 2f4c462..a658f83 100644 --- a/frameworks/middleware/pres_middleware.tex +++ b/frameworks/middleware/pres_middleware.tex @@ -3,23 +3,544 @@ \title{\lq Middleware\rq} \maketitle -\subsection{DBUS} \begin{frame} -\frametitle{DBUS Communication Framework} +\frametitle{Agenda} +\begin{itemize} +\item Overview +\item XML based Middleware +\item Celery +\item D-Bus +\item CORBA +\end{itemize} +GOAL: get an idea about: + +the amount of available middleware solutions + +and for what they can be used. +\end{frame} + +\subsection{Overview} + +\begin{frame} +\frametitle{Use-case} +\begin{center} +\includegraphics[width=0.8\textheight]{images/714px-Middleware_Schema.png} +\end{center} +\tiny Source: http://commons.wikimedia.org/wiki/File:Middleware\_Schema.svg +\end{frame} + +\begin{frame} +\frametitle{Why should we use a middleware?} +\begin{itemize} +\item IPC +\item scalability +\item os abstraction +\item reusability of sw components +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Kinds of Middleware} +\begin{itemize} +\item Message Oriented Middleware (MOM) +\item Remote Procedure Calls (RPC) +\item Webapplications? +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{Requirements} +\begin{block}{Abstraction Layers} +\begin{itemize} +\item operating system +\item programing language +\item localization +\item transport +\item concurrent access +\end{itemize} +\end{block} +\end{frame} + +\begin{frame} +\frametitle{Requirements} +\begin{block}{Technical, product specific} +\begin{itemize} +\item os / language support +\item performance +\item requirement coverage +\item commerical, open-source, (long-time) support +\end{itemize} +\end{block} +\end{frame} + +\begin{frame} +\frametitle{Standards, Protocols} +\begin{itemize} +\item XML based Middleware +\item Celery - Job Queue Protocol +\item D-Bus - MOM +\item CORBA - Common Object Request Broker +\end{itemize} +\end{frame} + +\subsection{XML based Middleware} +\begin{frame} +\frametitle{popular protocols} +\begin{description} +\item[XML-RPC] Extensible Markup Language Remote Procedure Call +\item[SOAP/WSDL] many webservices are based on SOAP +\item[XMPP] Extensible Messaging and Presence Protocol +\end{description} +\end{frame} + +\begin{frame} +\frametitle{XML-RPC} +\begin{itemize} +\item native supported by Python (see example) +\item C/C++ Implementation: http://xmlrpc-c.sourceforge.net/ +\item Client- / Serverarchitecture +\item uses http as transport +\end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +server.py\#p1 +\begin{lstlisting}[language=python] +from datetime import datetime +from SimpleXMLRPCServer import SimpleXMLRPCServer +import xmlrpclib + +def today (): + today = datetime.today () + return xmlrpclib.DateTime (today) + +def load (): + fd = open ("/proc/loadavg", "r") + loadavg = fd.read () + sysload = loadavg.split () + return xmlrpclib.FloatType (sysload[0]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +server.py\#p2 +\begin{lstlisting}[language=python] +server = SimpleXMLRPCServer (("localhost", + 8000)) + +server.register_function (today, "today") +server.register_function (load, "load") + +print "Listening on port 8000..." +server.serve_forever () +\end{lstlisting} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +client.py\#p1 +\begin{lstlisting}[language=python] +import xmlrpclib +from datetime import datetime + +proxy = xmlrpclib.ServerProxy ( + "http://localhost:8000/") +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +client.py\#p2 +\begin{lstlisting}[language=python] +today = proxy.today () +# today = 20140218T14:23:45 + +conv = datetime.strptime (today.value, + "%Y%m%dT%H:%M:%S") + +print "Today:", conv.strftime ( + "%d.%m.%Y, %H:%M") + +load = proxy.load () +print "system load:", load +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +output: +\begin{lstlisting}[language=bash] + % python client.py +Today: 18.02.2014, 14:26 +system load: 0.45 +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +http payload of today rpc call seen in wireshark: +\begin{lstlisting}[language=XML] +<?xml version='1.0'?> +<methodCall> + <methodName>today</methodName> + <params></params> +</methodCall> +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XML-RPC example in Python} +http payload of today rpc response seen in wireshark: +\begin{lstlisting}[language=XML] +<?xml version='1.0'?> +<methodResponse> + <params> + <param> + <value> + <dateTime.iso8601> + 20140218T14:26:25 + </dateTime.iso8601> + </value> + </param> + </params> +</methodResponse> +\end{lstlisting} +\end{frame} + +\begin{frame} +\frametitle{SOAP/WSDL} +\begin{block}{Overview} +\begin{itemize} +\item WSDL (Web Services Description Language) + +describes the interface and spcecial datatypes +\item the SOAP protocol is used for communication +\item SOAP can be used with various transports: + +FTP, SMTP, HTTP(S), JMS +\item hopping is supported, with different transports +\item Client- / Serverarchitecture +\end{itemize} +\end{block} +\end{frame} + +\begin{frame} +\frametitle{SOAP/WSDL} +\begin{block}{Implementations} +\begin{itemize} +\item ZSI: Python +\item KDSOAP: Qt4/5 native Library (commercial) +\item gSOAP: C/C++ +\item Apache Axis2: C++, JAVA +\item Apache CXF: JAVA (+ other middleware protocols) +\item SOAP::WSDL: Perl +\item SOAP4R: Ruby +\item wsdl2objc: Objective C +\item .NET, mono +\end{itemize} +\end{block} +\end{frame} + +\begin{frame}[fragile] +\frametitle{SOAP example in Python/ZSI} +server.py +\begin{lstlisting}[language=python] +from datetime import datetime +from ZSI import dispatch + +def today (arg): + print "today arg:", arg + today = datetime.today () + return str (today) +def load (arg): + print "load arg:", arg + fd = open ("/proc/loadavg", "r") + loadavg = fd.read () + sysload = loadavg.split () + return sysload[0] + +dispatch.AsServer (port=8000, rpc=True) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{SOAP example in Python/ZSI} +client.py +\begin{lstlisting}[language=python] +from datetime import datetime +from ZSI.client import Binding + +b = Binding (url='http://localhost:8000/') +t = b.today (5) +# t = 2014-02-18 15:59:50.571927 +c = datetime.strptime (t, + "%Y-%m-%d %H:%M:%S.%f") +print "Today:", c.strftime ("%d.%m.%Y, %H:%M") +print b.load ("string") +\end{lstlisting} +\end{frame} + + +\begin{frame} +\frametitle{XMPP - Extensible Messaging and Presence Protocol} +\begin{block}{Overview} +\begin{itemize} +\item protocol for MOM based on XML +\item originally named Jabber +\item used for +\begin{itemize} + \item real-time Instant Messaging + \item publishing Presence Informations + \item Contactlist maintenance +\end{itemize} +\end{itemize} +\end{block} +\end{frame} + + +\begin{frame} +\frametitle{Extensible Messaging and Presence Protocol} +\begin{block}{IM for Industry??} +\begin{itemize} +\item free and open standard (IETF RFC 6120, 6121) +\item XMPP servers can be isolated, security is implemented (SASL, TLS) +\item TCP and HTTP(S) transports are supported +\item Priority support: multiple logins from same account, + +login with highest pority gets message +\item not just used for IM: +\begin{itemize} + \item smart grid + \item publish-subscribe systems + \item games + \item signalling for VoIP +\end{itemize} +\end{itemize} +\end{block} +\end{frame} + +\begin{frame} +\frametitle{Extensible Messaging and Presence Protocol} +\begin{block}{Extensible\dots} +\begin{itemize} +\item network management +\item collaboration tools +\item file sharing, gaming +\item remote systems control and monitoring +\item geolocation +\end{itemize} +\end{block} +\end{frame} + +\begin{frame} +\frametitle{Extensible Messaging and Presence Protocol} +\begin{block}{Implemmentations} +\dots too many to mention, have a look at + +http://xmpp.org/xmpp-software/ + +for libraries, clients and servers +\end{block} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{XMPP Client Example} +xmpp\_client.cpp +\begin{lstlisting}[language=C++] +#include <QtCore/QCoreApplication> +#include "myclient.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + MyClient client; + client.connectToServer("qtapp@localhost", + "test"); + + return app.exec(); +} +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XMPP Client Example} +myclient.h +\begin{lstlisting}[language=C++] +#include <qxmpp/QXmppClient.h> + +class MyClient : public QXmppClient +{ + Q_OBJECT + + public: + MyClient(); + ~MyClient(); + + public slots: + void message_rx(const QXmppMessage&); +}; +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XMPP Client Example} +myclient.cpp\#p1 +\begin{lstlisting}[language=C++] +#include <qxmpp/QXmppMessage.h> +#include <iostream> + +#include "myclient.h" + +MyClient::MyClient() : QXmppClient() +{ + bool check = connect(this, + SIGNAL(messageReceived(QXmppMessage)), + SLOT(message_rx(QXmppMessage))); + + Q_ASSERT(check); + Q_UNUSED(check); +} +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{XMPP Client Example} +myclient.cpp\#p2 +\begin{lstlisting}[language=C++] +MyClient::~MyClient() { ; } + +void +MyClient::message_rx(const QXmppMessage& msg) +{ + QString from = msg.from(); + QString body = msg.body(); + + std::cout<<from.toStdString()<<": "; + std::cout<<body.toStdString()<<std::endl; + + sendPacket(QXmppMessage("",from,body+"??")); +} +\end{lstlisting} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{XMPP Client Example} +\begin{itemize} +\item start ejabberd +\item start psi +\item start QT XMPP Client +\item in psi: write a message to qtapp +\item with wireshark can be seen that the connection is encrypted +\end{itemize} +\end{frame} + + +\subsection{Celery} + +\begin{frame} +\frametitle{Overview} +\begin{itemize} +\item Distributed Task Queue +\item based on message passing +\item real-time operation and scheduling +\item Tasks can be hosted on a single or on mulitple workers +\item synchronous and asynchronous execution +\item rate limit support +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{implementations} +\begin{itemize} +\item celery-project: Python +\item celery-php: PHP +\end{itemize} +\end{frame} + +\begin{frame} +\frametitle{celeryproject} +\begin{block}{supports multiple message broker} +\begin{itemize} +\item database: Django, or any supported by SQLAlchemy +\item RabbitMQ +\item Redis +\item Amazon SQS (experimental) +\end{itemize} +\end{block} +\end{frame} + +\begin{frame} +\frametitle{celeryproject} +\begin{block}{supports multiple result storage} +\begin{itemize} +\item database: any supported by SQLAlchemy +\item memcached +\item Redis +\item AMQP +\item Cassandra +\item IronCache +\end{itemize} +\end{block} +\end{frame} + +\begin{frame}[fragile] +\frametitle{celeryproject, example} +exec\_task.py +\begin{lstlisting}{language=python} +import os +from celery import Celery + +app = Celery ('tasks', broker='sqla+sqlite:///celerydb.sqlite) + +@app.task +def execute (command): + os.system (command) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{celeryproject, example} +test.py +\begin{lstlisting}{language=python} +from exec_task import execute + +execute.delay ("echo hello world") +\end{lstlisting} + +start the example: +\begin{lstlisting}{language=bash} +term1% celery -A exec_task worker +term2% ./test.py +\end{lstlisting} +\dots an example using return values and exceptions is in the example dir +\end{frame} + + +\subsection{D-Bus} + +\begin{frame} +\frametitle{D-Bus Communication Framework} \begin{block}{Facts} \begin{itemize} -\item used by GNOME, KDE4, E17, XFCE4, HAL, \dots +\item used by GNOME, KDE4, E17, XFCE4 and many applications \item for message based local IPC \item provides 1:1 - 1:n message passing +\item there is a system and a session bus \end{itemize} \end{block} \end{frame} \begin{frame} -\frametitle{DBUS Communication Framework} +\frametitle{D-Bus Communication Framework} \begin{block}{Language Support} \begin{itemize} -\item C / C++ +\item C / C++ / Objective-C \item JAVA \item Python \item Perl @@ -27,57 +548,173 @@ \item Pascal \item Ruby \item Smalltalk -\item Tcl \end{itemize} \end{block} \end{frame} \begin{frame} -\frametitle{DBUS Communication Framework} +\frametitle{D-Bus Communication Framework} \begin{block}{Framework Support} \begin{itemize} -\item QT4 (and QT3 backport) -\item glib -\item mono -\item e\_dbus (Enlightenment, E17) -\item .NET +\item QT (C++ / Python) +\item GLib (GDBus) +\item .NET (mono) +\item edbus (Enlightenment, E17) \end{itemize} \end{block} \end{frame} +\begin{frame}[fragile] +\frametitle{Desktop Integration} +open home directory with the e17 file manager +\begin{verbatim} +% mdbus2 -i +MDBUS2> org.enlightenment.FileManager \ + /org/enlightenment/FileManager \ + org.enlightenment.FileManager.OpenDirectory \ + /home/local +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{System Integration} +e.g. hotplug events +\begin{verbatim} +% mdbus2 -s -l +[SIGNAL] +org.freedesktop.UDisks.DeviceAdded +/org/freedesktop/UDisks :1.25 +('/org/freedesktop/UDisks/devices/sdb',) +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\begin{verbatim} +[SIGNAL] +org.freedesktop.DBus.ObjectManager.InterfacesAdded +/org/freedesktop/UDisks2 :1.40 +('/org/freedesktop/UDisks2/drives/WD_My_Passport_0748_57584D314335325839363238', +{'org.freedesktop.UDisks2.Drive': + {'Vendor': <'WD'>, 'Model': <'My Passport0748'>, + 'Revision': <'1015'>, 'Serial': <'57584D314335325839363238'>, + 'WWN': <''>, 'Id': <'WD-My-Passport-0748-57584D314335325839363238'>, + 'Configuration': <@a{sv} {}>, 'Media': <''>, + 'MediaCompatibility': <@as []>, 'MediaRemovable':<false>, + 'MediaAvailable': <true>, 'MediaChangeDetected': <true>, + 'Size':<uint64 1000170586112>, + 'TimeDetected': <uint64 1392720111627238>, + 'TimeMediaDetected': <uint64 1392720111627238>, + 'Optical': <false>, OpticalBlank': <false>, + 'OpticalNumTracks': <uint32 0>, + 'OpticalNumAudioTracks': <uint32 0>, + 'OpticalNumDataTracks': <uint32 0>, + 'OpticalNumSessions': <uint32 0>, + 'RotationRate': <-1>, 'ConnectionBus':<'usb'>, + 'Seat': <'seat0'>, 'Removable': <true>, 'Ejectable': <false>, + 'SortKey': <'01hotplug/1392720111627238'>, + 'CanPowerOff': <true>, + 'SiblingId':<'/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0'>}}) +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Example: Session Bus Signals} +\begin{itemize} +\item have a look at the code +\item start pingserver and pingclient +\item monitor signals with 'mdbus2 -l' +\end{itemize} +\end{frame} + +\subsection{CORBA} + \begin{frame} -\frametitle{Functional Principle} -\begin{center} -\includegraphics[height=0.8\textheight]{images/dbus.png} -\end{center} -Source: http://dbus.freedesktop.org +\frametitle{Common Object Request Broker Architecture} +\begin{itemize} +\item hosting of objects / RPC +\item typically a Client- / Serverarchitecture +\item one application can be Client and Server at the same time +\end{itemize} \end{frame} + \begin{frame} -\frametitle{Desktop Integration} +\frametitle{well-known implementations} +\begin{itemize} +\item omniORB: C++ / Python +\item ACE/TAO: C++ including RTCORBA support +\item MICO: C++ focus on security +\item JacORB: JAVA +\item IIOP.NET: .NET Remoting integration +\item ORBit2: C with C++ and Python bindings +\end{itemize} +\end{frame} + + +\begin{frame} +\frametitle{communication between different operating systems} +\begin{itemize} +\item hosting of objects is abstracted, e.g. ThreadPool +\item use of OS services, e.g. sockets is abstracted +\end{itemize} +\end{frame} + + +\begin{frame} +\frametitle{communication between programming languages} +\begin{itemize} +\item CORBA uses its own datatypes +\item datatype mapping needs to be implement for each language +\end{itemize} +\end{frame} + + +\begin{frame} +\frametitle{common transports} +\begin{itemize} +\item IIOP +\item socket +\item shared-memory +\item implementing own transports is possible +\end{itemize} +\end{frame} + + +\begin{frame} +\frametitle{Functional Principle} \begin{center} -\includegraphics[height=0.8\textheight]{images/dbus-hal.png} +\includegraphics[width=1.0\textwidth]{images/orb.jpg} \end{center} -Source: http://www.redhat.com \end{frame} -\subsection{CORBA} + \begin{frame} -\frametitle{Common Object Request Broker Architecture} -\begin{block}{abstracts} +\frametitle{Functional Principle} +\begin{block}{IDL Interface Description Language} \begin{itemize} -\item operating systems -\item programming language -\item transport protocol +\item write Interface Description +\item use IDL compiler to produce stubs and skeleton code +\item implement interfaces and use interfaces in native language +\item compile applications \end{itemize} \end{block} \end{frame} \begin{frame} \frametitle{Functional Principle} -\begin{center} -\includegraphics[height=0.8\textheight]{images/orb.jpg} -\end{center} +\begin{block}{Policies} +\begin{itemize} +\item Server- or Clientsiede Policies +\item Run-time and compile-time Policies +\item e.g. for +\begin{itemize} +\item Lifetime of objects +\item Activation of objects +\item Thread Policies +\item Connection Polies +\end{itemize} +\end{itemize} +\end{block} \end{frame} \begin{frame} @@ -134,4 +771,16 @@ Source: http://www.redhat.com \end{block} \end{frame} +\subsection{Conclusion} +\begin{frame} +\frametitle{Conclusion} +\begin{itemize} +\item many frameworks available +\item different kind of abstraction +\item special frameworks for special problems +\item which framework is best for my problem? +\item is it helpful to use multiple frameworks? +\end{itemize} +\end{frame} + \input{tailpres} |
