Skip to content

Commit

Permalink
Merge pull request #23 from lasanthaS/master
Browse files Browse the repository at this point in the history
Refactor code to support Siddhi 5.0.0
  • Loading branch information
lasanthaS committed Jun 20, 2019
2 parents 9ac85ed + 58fe8ef commit 5b33a76
Show file tree
Hide file tree
Showing 89 changed files with 299 additions and 392 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ ENV/
# Rope project settings
.ropeproject
.idea/
*.iml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# under the License.


from PySiddhi4 import SiddhiLoader
from PySiddhi4.DataTypes.DoubleType import DoubleType
from PySiddhi4.DataTypes.LongType import LongType
from PySiddhi import SiddhiLoader
from PySiddhi.DataTypes.DoubleType import DoubleType
from PySiddhi.DataTypes.LongType import LongType

'''
Data Wrapping is used because python 3 doesn't distinctly support long and double data types
Expand Down Expand Up @@ -69,7 +69,7 @@ def wrapDataItem(d):
:param d:
:return:
'''
wrapped_data_proxy = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.DataWrapProxy")
wrapped_data_proxy = SiddhiLoader._loadType("io.siddhi.pythonapi.DataWrapProxy")
wrapped_data = None
if d is None:
# Constructor for null type
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions PySiddhi4/SiddhiLoader.py → PySiddhi/SiddhiLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import sys

import PySiddhi4
import PySiddhi

# Instantiate Global Variables
siddhi_api_core = None
Expand Down Expand Up @@ -91,7 +91,7 @@ def loadLibrary():
# at initialization of pyjnius
jnius_config.add_options('-Xss1280k')

jnius_config.add_options('-Djava.library.path=' + PySiddhi4.root_path + "/__PySiddhi4Proxy")
jnius_config.add_options('-Djava.library.path=' + PySiddhi.root_path + "/__PySiddhiProxy")

# Determine library class path
class_paths = ['.', os.path.join(siddhi_home, 'lib', '*')]
Expand All @@ -117,7 +117,7 @@ def loadLibrary():

# Generate references and store in backup
global t_siddhi_api_core, t_siddhi_api_core_inst, t_java_method, t_PythonJavaClass, t_JavaClass
t_siddhi_api_core = autoclass("org.wso2.siddhi.pythonapi.proxy.core.SiddhiAPICoreProxy")
t_siddhi_api_core = autoclass("io.siddhi.pythonapi.proxy.core.SiddhiAPICoreProxy")
t_siddhi_api_core_inst = t_siddhi_api_core(sys.version_info[0], sys.version_info[1])
t_java_method = java_method
t_PythonJavaClass = PythonJavaClass
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4 import SiddhiLoader
from PySiddhi4.core.debugger.SiddhiDebugger import SiddhiDebugger
from PySiddhi4.core.query.output.callback.QueryCallback import QueryCallback
from PySiddhi4.core.stream.input.InputHandler import InputHandler
from PySiddhi4.core.stream.output.StreamCallback import StreamCallback
from PySiddhi import SiddhiLoader
from PySiddhi.core.debugger.SiddhiDebugger import SiddhiDebugger
from PySiddhi.core.query.output.callback.QueryCallback import QueryCallback
from PySiddhi.core.stream.input.InputHandler import InputHandler
from PySiddhi.core.stream.output.StreamCallback import StreamCallback


class SiddhiAppRuntime(object):
'''
Wrapper on org.wso2.core.SiddhiAppRuntime
Wrapper on io.core.SiddhiAppRuntime
'''

def __init__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4 import SiddhiLoader
from PySiddhi4.DataTypes import DataWrapper
from PySiddhi4.core.SiddhiAppRuntime import SiddhiAppRuntime
from PySiddhi import SiddhiLoader
from PySiddhi.DataTypes import DataWrapper
from PySiddhi.core.SiddhiAppRuntime import SiddhiAppRuntime


class SiddhiManager(object):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import threading
from time import sleep
from PySiddhi4 import SiddhiLoader
from PySiddhi4.DataTypes.DataWrapper import unwrapHashMap
from PySiddhi import SiddhiLoader
from PySiddhi.DataTypes.DataWrapper import unwrapHashMap
from enum import Enum
from PySiddhi4.core.event.ComplexEvent import ComplexEvent
from PySiddhi.core.event.ComplexEvent import ComplexEvent


class SiddhiDebugger(object):
Expand All @@ -36,9 +36,9 @@ class QueryTerminal(Enum):
SiddhiDebugger allows to add breakpoints at the beginning and the end of a query.
'''
IN = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger.QueryTerminalProxy")().IN()
"io.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger.QueryTerminalProxy")().IN()
OUT = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger.QueryTerminalProxy")().OUT()
"io.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger.QueryTerminalProxy")().OUT()

@classmethod
def _map_value(cls, queryTerminalProxy):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

from abc import ABCMeta, abstractmethod
from future.utils import with_metaclass
from PySiddhi4 import SiddhiLoader
from PySiddhi import SiddhiLoader

_siddhi_debugger_callback_proxy = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger_callback.SiddhiDebuggerCallbackProxy")
"io.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger_callback.SiddhiDebuggerCallbackProxy")


class SiddhiDebuggerCallback(with_metaclass(ABCMeta, object)):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@


from enum import Enum
from PySiddhi4 import SiddhiLoader
from PySiddhi4.DataTypes.DataWrapper import unwrapData, wrapData
from PySiddhi import SiddhiLoader
from PySiddhi.DataTypes.DataWrapper import unwrapData, wrapData


class ComplexEvent(object):
'''
Wrapper on @org.wso2.siddhi.core.event.ComplexEvent
Wrapper on @io.siddhi.core.event.ComplexEvent
'''

class Type(Enum):
CURRENT = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().CURRENT(),
"io.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().CURRENT(),
EXPIRED = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().EXPIRED(),
TIMER = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().TIMER(),
RESET = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().RESET()
"io.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().EXPIRED(),
TIMER = SiddhiLoader._loadType("io.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().TIMER(),
RESET = SiddhiLoader._loadType("io.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")().RESET()

@classmethod
def _map_value(cls, type_proxy):
Expand Down Expand Up @@ -80,13 +80,13 @@ def setNext(self, next_event):

def getOutputData(self):
complex_event_static_proxy = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.ComplexEventProxy")()
"io.siddhi.pythonapi.proxy.core.event.complex_event.ComplexEventProxy")()
output_data = unwrapData(complex_event_static_proxy.getOutputData(self._complex_event_proxy))
return output_data

def setOutputData(self, datum, index):
complex_event_static_proxy = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.ComplexEventProxy")()
"io.siddhi.pythonapi.proxy.core.event.complex_event.ComplexEventProxy")()
complex_event_static_proxy.setOutputData(self._complex_event_proxy, wrapData(datum), index)

def getTimestamp(self):
Expand All @@ -103,7 +103,7 @@ def setAttribute(self, value, position):

def getType(self):
raw_type_proxy = self._complex_event_proxy.getType()
type_proxy = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")(
type_proxy = SiddhiLoader._loadType("io.siddhi.pythonapi.proxy.core.event.complex_event.TypeProxy")(
raw_type_proxy)
return ComplexEvent.Type._map_value(type_proxy)

Expand Down
12 changes: 6 additions & 6 deletions PySiddhi4/core/event/Event.py → PySiddhi/core/event/Event.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4 import SiddhiLoader
from PySiddhi import SiddhiLoader

from PySiddhi4.DataTypes import DataWrapper
from PySiddhi4.core.event import ComplexEvent
from PySiddhi.DataTypes import DataWrapper
from PySiddhi.core.event import ComplexEvent

_event_class = SiddhiLoader._loadType("org.wso2.siddhi.core.event.Event")
_event_proxy_class = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.proxy.core.event.event.EventProxy")
_event_class = SiddhiLoader._loadType("io.siddhi.core.event.Event")
_event_proxy_class = SiddhiLoader._loadType("io.siddhi.pythonapi.proxy.core.event.event.EventProxy")
_event_proxy_class_inst = _event_proxy_class()


class Event(object):
'''
Wrapper on @org.wso2.siddhi.core.event.Event
Wrapper on @io.siddhi.core.event.Event
'''

@classmethod
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@

from abc import ABCMeta, abstractmethod

from PySiddhi4 import SiddhiLoader
from PySiddhi4.core.event.Event import Event
from PySiddhi import SiddhiLoader
from PySiddhi.core.event.Event import Event

from future.utils import with_metaclass

_query_callback_proxy = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.query.output.callback.query_callback.QueryCallbackProxy")
"io.siddhi.pythonapi.proxy.core.query.output.callback.query_callback.QueryCallbackProxy")

_created_instances = [] # Hold references to prevent python from GCing Callbacks until Java does


class QueryCallback(with_metaclass(ABCMeta, object)):
'''
Callback to receive events from SiddhiAppRuntime. Should be extended by child class.
Wrapper on org.wso2.siddhi.core.query.output.callback.QueryCallback
Wrapper on io.siddhi.core.query.output.callback.QueryCallback
'''

def __init__(self):
Expand All @@ -44,10 +44,10 @@ class ReceiveCallback(SiddhiLoader._PythonJavaClass):
Innerclass to wrap around Java Interface
'''
__javainterfaces__ = [
"org/wso2/siddhi/pythonapi/proxy/core/query/output/callback/query_callback/ReceiveCallbackProxy"]
"io/siddhi/pythonapi/proxy/core/query/output/callback/query_callback/ReceiveCallbackProxy"]

@SiddhiLoader._java_method(
signature='(J[Lorg/wso2/siddhi/core/event/Event;[Lorg/wso2/siddhi/core/event/Event;)V',
signature='(J[Lio/siddhi/core/event/Event;[Lio/siddhi/core/event/Event;)V',
name="receive")
def receive(self, timestamp, inEvents, outEvents):
# _lock.acquire()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4 import SiddhiLoader
from PySiddhi4.DataTypes.DataWrapper import wrapData
from PySiddhi import SiddhiLoader
from PySiddhi.DataTypes.DataWrapper import wrapData

input_handler_proxy = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.stream.input.input_handler.InputHandlerProxy")
"io.siddhi.pythonapi.proxy.core.stream.input.input_handler.InputHandlerProxy")


class InputHandler(object):
'''
Handles input to SiddhiAppRuntime.
Wrapper on org.wso2.siddhi.core.stream.input.InputHandler
Wrapper on io.siddhi.core.stream.input.InputHandler
'''

def __init__(self):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

from abc import ABCMeta, abstractmethod

from PySiddhi4 import SiddhiLoader
from PySiddhi4.core.event.Event import Event
from PySiddhi import SiddhiLoader
from PySiddhi.core.event.Event import Event

from future.utils import with_metaclass

_stream_callback_proxy = SiddhiLoader._loadType(
"org.wso2.siddhi.pythonapi.proxy.core.stream.output.callback.stream_callback.StreamCallbackProxy")
"io.siddhi.pythonapi.proxy.core.stream.output.callback.stream_callback.StreamCallbackProxy")

_lock = RLock()

Expand All @@ -50,9 +50,9 @@ class ReceiveCallback(SiddhiLoader._PythonJavaClass):
Innerclass to wrap around Java Interface
'''
__javainterfaces__ = [
"org/wso2/siddhi/pythonapi/proxy/core/stream/output/callback/stream_callback/ReceiveCallbackProxy"]
"io/siddhi/pythonapi/proxy/core/stream/output/callback/stream_callback/ReceiveCallbackProxy"]

@SiddhiLoader._java_method(signature='([Lorg/wso2/siddhi/core/event/Event;)V', name="receive")
@SiddhiLoader._java_method(signature='([Lio/siddhi/core/event/Event;)V', name="receive")
def receive(self, events):
if events is not None:
events = [Event._fromEventProxy(event) for event in events]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4 import SiddhiLoader
from PySiddhi import SiddhiLoader

_event_printer_proxy = SiddhiLoader._loadType("org.wso2.siddhi.pythonapi.proxy.core.util.EventPrinterProxy")
_event_printer_proxy = SiddhiLoader._loadType("io.siddhi.pythonapi.proxy.core.util.EventPrinterProxy")


def PrintEvent(timestamp, inEvents, outEvents):
Expand All @@ -34,5 +34,5 @@ def PrintEvent(timestamp, inEvents, outEvents):
outEvents = [event._event_proxy for event in outEvents]
_event_printer_proxy.printEvent(timestamp, inEvents, outEvents)

# NOTE: We are unable to call org.wso2.siddhi.core.util.EventPrinter.print directly
# NOTE: We are unable to call io.siddhi.core.util.EventPrinter.print directly
# because print is a keyword of python
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

from enum import Enum

from PySiddhi4.sp.ObjectMapping.APIObject import APIObject, NotSet
from PySiddhi4.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping
from PySiddhi4.sp.__Util import decodeField, decodeObject
from PySiddhi.sp.ObjectMapping.APIObject import APIObject, NotSet
from PySiddhi.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping
from PySiddhi.sp.__Util import decodeField, decodeObject


class AttributeConfiguration(APIObject):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import json
import logging

from PySiddhi4.sp.__Communication.RestClient import RestClient
from PySiddhi4.sp.EventSimulator.FeedSimulationConfiguration import FeedSimulationConfiguration
from PySiddhi.sp.__Communication.RestClient import RestClient
from PySiddhi.sp.EventSimulator.FeedSimulationConfiguration import FeedSimulationConfiguration
from requests.auth import HTTPBasicAuth


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4.sp.EventSimulator.SimulationProperties import SimulationProperties
from PySiddhi4.sp.EventSimulator.SimulationSource import SimulationSource
from PySiddhi4.sp.ObjectMapping.APIObject import APIObject
from PySiddhi4.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping
from PySiddhi.sp.EventSimulator.SimulationProperties import SimulationProperties
from PySiddhi.sp.EventSimulator.SimulationSource import SimulationSource
from PySiddhi.sp.ObjectMapping.APIObject import APIObject
from PySiddhi.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping


class FeedSimulationConfiguration(APIObject):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import random

from PySiddhi4.sp.ObjectMapping.APIObject import APIObject, NotSet
from PySiddhi4.sp.ObjectMapping.FieldMapping import FieldMapping
from PySiddhi4.sp.__Util import decodeField
from PySiddhi.sp.ObjectMapping.APIObject import APIObject, NotSet
from PySiddhi.sp.ObjectMapping.FieldMapping import FieldMapping
from PySiddhi.sp.__Util import decodeField

ran = random

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

from enum import Enum

from PySiddhi4.sp.EventSimulator.AttributeConfiguration import AttributeConfiguration
from PySiddhi4.sp.ObjectMapping.APIObject import APIObject, NotSet
from PySiddhi4.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping, strOrInt
from PySiddhi.sp.EventSimulator.AttributeConfiguration import AttributeConfiguration
from PySiddhi.sp.ObjectMapping.APIObject import APIObject, NotSet
from PySiddhi.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping, strOrInt


class SimulationSource(APIObject):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# specific language governing permissions and limitations
# under the License.

from PySiddhi4.sp.ObjectMapping.APIObject import APIObject
from PySiddhi4.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping
from PySiddhi.sp.ObjectMapping.APIObject import APIObject
from PySiddhi.sp.ObjectMapping.FieldMapping import FieldMapping, ListFieldMapping


class SingleSimulationConfiguration(APIObject):
Expand Down
File renamed without changes.
Loading

0 comments on commit 5b33a76

Please sign in to comment.