class QueryTerminal(Enum): ''' SiddhiDebugger allows to add breakpoints at the beginning and the end of a query. ''' IN = SiddhiLoader._loadType( "io.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger.QueryTerminalProxy")().IN() OUT = SiddhiLoader._loadType( "io.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger.QueryTerminalProxy")().OUT() @classmethod def _map_value(cls, queryTerminalProxy): qt_value = None if queryTerminalProxy.isValueOut(): qt_value = SiddhiDebugger.QueryTerminal.OUT elif queryTerminalProxy.isValueIn(): qt_value = SiddhiDebugger.QueryTerminal.IN else: raise TypeError("Unknown QueryTerminal Value") return SiddhiDebugger.QueryTerminal(qt_value)
def setExtension(self, name, clazz): ''' Loads an extension into Siddhi Manager. The Extension Path must be already added via SiddhiLoader.addExtensionPath. :param name: Name of extension :param clazz: Fully qualified class name of extension :return: ''' if isinstance(clazz, str): self._siddhi_manager_proxy.setExtension( name, SiddhiLoader._loadType(clazz)) else: self._siddhi_manager_proxy.setExtension(name, clazz)
# specific language governing permissions and limitations # under the License. from multiprocessing import RLock import logging from abc import ABCMeta, abstractmethod from PySiddhi import SiddhiLoader from PySiddhi.core.event.Event import Event from future.utils import with_metaclass _stream_callback_proxy = SiddhiLoader._loadType( "io.siddhi.pythonapi.proxy.core.stream.output.callback.stream_callback.StreamCallbackProxy" ) _lock = RLock() _created_instances = [ ] # Hold reference to prevent python from GC callback before java does class StreamCallback(with_metaclass(ABCMeta, object)): ''' StreamCallback is used to receive events from StreamJunction This class should be extended if one intends to get events from a Siddhi Stream. ''' # __metaclass__ = ABCMeta
# software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import logging from abc import ABCMeta, abstractmethod from PySiddhi import SiddhiLoader from PySiddhi.core.event.Event import Event from future.utils import with_metaclass _query_callback_proxy = SiddhiLoader._loadType( "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 io.siddhi.core.query.output.callback.QueryCallback ''' def __init__(self): self._query_callback_proxy_inst = _query_callback_proxy() query_callback_self = self class ReceiveCallback(SiddhiLoader._PythonJavaClass):
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. from PySiddhi import SiddhiLoader from PySiddhi.DataTypes import DataWrapper from PySiddhi.core.event import ComplexEvent _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 @io.siddhi.core.event.Event ''' @classmethod def _fromEventProxy(cls, event_proxy): ''' Internal Constructor to wrap around JAVA class Event :param event_proxy: :return:
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. from abc import ABCMeta, abstractmethod from future.utils import with_metaclass from PySiddhi import SiddhiLoader _siddhi_debugger_callback_proxy = SiddhiLoader._loadType( "io.siddhi.pythonapi.proxy.core.debugger.siddhi_debugger_callback.SiddhiDebuggerCallbackProxy") class SiddhiDebuggerCallback(with_metaclass(ABCMeta, object)): ''' Callback to get notification about the events passing through the break points. Should be extended by subclass. ''' def __init__(self): _siddhi_debugger_callback_self = self self._siddhi_debugger_callback_proxy_inst = _siddhi_debugger_callback_proxy() @abstractmethod def debugEvent(self, complexEvent, queryName, queryTerminal, debugger): '''
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. from PySiddhi import SiddhiLoader from PySiddhi.DataTypes.DataWrapper import wrapData input_handler_proxy = SiddhiLoader._loadType( "io.siddhi.pythonapi.proxy.core.stream.input.input_handler.InputHandlerProxy" ) class InputHandler(object): ''' Handles input to SiddhiAppRuntime. Wrapper on io.siddhi.core.stream.input.InputHandler ''' def __init__(self): raise NotImplementedError( "Initialize InputHandler using SiddhiAppRuntime") def __new__(cls): bare_instance = object.__new__(cls) bare_instance.input_handler_proxy = None
# Version 2.0 (the "License"); you may not use this file except # in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. from PySiddhi import SiddhiLoader _event_printer_proxy = SiddhiLoader._loadType( "io.siddhi.pythonapi.proxy.core.util.EventPrinterProxy") def PrintEvent(timestamp, inEvents, outEvents): ''' Prints Stream Event to Log :param timestamp: :param inEvents: :param outEvents: :return: ''' if inEvents is not None: inEvents = [event._event_proxy for event in inEvents] if outEvents is not None: outEvents = [event._event_proxy for event in outEvents]