Example #1
0
    def deploy_network(self, network, handler=None):
        """Deploys a network to the cluster.

        Keyword arguments:
        @param network: The network to deploy.
        @param handler: A handler to be called once complete.

        @return: self
        """
        if isinstance(network, dict):
            if handler is not None:
                self.java_obj.deployNetwork(
                    org.vertx.java.core.json.JsonObject(map_to_java(network)),
                    _DeployHandler(handler))
            else:
                self.java_obj.deployNetwork(
                    org.vertx.java.core.json.JsonObject(map_to_java(network)))
        else:
            if handler is not None:
                self.java_obj.deployNetwork(
                    network
                    if isinstance(network, basestring) else network.java_obj,
                    _DeployHandler(handler))
            else:
                self.java_obj.deployNetwork(network if isinstance(
                    network, basestring) else network.java_obj)
        return self
Example #2
0
 def bridge_with_config(self, config, inbound_permitted, outbound_permitted, bridge_config):
     a_ijson = org.vertx.java.core.json.JsonArray(map_to_java(inbound_permitted))
     a_ojson = org.vertx.java.core.json.JsonArray(map_to_java(outbound_permitted))
     self.java_obj.bridge(org.vertx.java.core.json.JsonObject(map_to_java(config)), a_ijson, a_ojson, org.vertx.java.core.json.JsonObject(map_to_java(bridge_config)))
     hook = _EventBusBridgeHook()
     self.java_obj.setHook(hook)
     return EventBusBridge(hook)
Example #3
0
 def equals(val1, val2, message=None):
     """
     Asserts that two values are equal.
     """
     if message is not None:
         org.vertx.testtools.VertxAssert.assertEquals(message, map_to_java(val1), map_to_java(val2))
     else:
         org.vertx.testtools.VertxAssert.assertEquals(map_to_java(val1), map_to_java(val2))
Example #4
0
 def bridge(self,
            config,
            inbound_permitted,
            outbound_permitted,
            auth_timeout=5 * 60 * 1000,
            auth_address=None):
     a_ijson = org.vertx.java.core.json.JsonArray(
         map_to_java(inbound_permitted))
     a_ojson = org.vertx.java.core.json.JsonArray(
         map_to_java(outbound_permitted))
     self.java_obj.bridge(
         org.vertx.java.core.json.JsonObject(map_to_java(config)), a_ijson,
         a_ojson, auth_timeout, auth_address)
Example #5
0
 def convert_msg(message):
     if isinstance(message, dict):
         message = org.vertx.java.core.json.JsonObject(map_to_java(message))
     elif isinstance(message, Buffer):
         message = message._to_java_buffer()
     elif isinstance(message, long):
         message = java.lang.Long(message)
     elif isinstance(message, float):
         message = java.lang.Double(message)
     elif isinstance(message, int):
         message = java.lang.Integer(message)
     else:
         message = map_to_java(message)
     return message
Example #6
0
 def create_child(self, body, id=None, tag=None):
   """
   Creates a child message.
   """
   if id is not None:
     if tag is not None:
       return Message(self._message.createChild(id, org.vertx.java.core.json.JsonObject(map_to_java(body)), tag))
     else:
       return Message(self._message.createChild(id, org.vertx.java.core.json.JsonObject(map_to_java(body))))
   else:
     if tag is not None:
       return Message(self._message.createChild(org.vertx.java.core.json.JsonObject(map_to_java(body)), tag))
     else:
       return Message(self._message.createChild(org.vertx.java.core.json.JsonObject(map_to_java(body))))
 def convert_msg(message):
     if isinstance(message, dict):
         message = org.vertx.java.core.json.JsonObject(map_to_java(message))
     elif isinstance(message, Buffer):
         message = message._to_java_buffer()
     elif isinstance(message, long):
         message = java.lang.Long(message)
     elif isinstance(message, float):
         message = java.lang.Double(message)
     elif isinstance(message, int):
         message = java.lang.Integer(message)
     else:
         message = map_to_java(message)
     return message
Example #8
0
def deploy_worker_verticle_to(self,
                              deployment_id,
                              group_id,
                              main,
                              config=None,
                              instances=1,
                              multi_threaded=False,
                              ha=False,
                              handler=None):
    """Deploys a worker verticle to a specific HA group.

    Keyword arguments:
    @param deploymen_id: The unique deployment ID of the deployment.
    @param group_id: The name of the group to which to deploy the verticle.
    @param main: The verticle main.
    @param config: The verticle configuration.
    @param instances: The number of instances to deploy.
    @param multi_threaded: Whether the worker verticle is multi-threaded.
    @param ha: Whether to deploy the verticle with HA.
    @param handler: An asynchronous handler to be called once deployment is complete.

    @return: self
    """
    component._component.cluster().deployWorkerVerticleTo(
        deployment_id, group_id, main,
        map_to_java(config) if config is not None else None, instances,
        multi_threaded, ha,
        DeployHandler(handler) if handler is not None else None)
    return self
Example #9
0
def deploy_module_to(self,
                     deployment_id,
                     group_id,
                     module,
                     config=None,
                     instances=1,
                     ha=False,
                     handler=None):
    """Deploys a module to a specific HA group.

    Keyword arguments:
    @param deploymen_id: The unique deployment ID of the deployment.
    @param group_id: The name of the group to which to deploy the module.
    @param module: The name of the module to deploy.
    @param config: The module configuration.
    @param instances: The number of instances to deploy.
    @param ha: Whether to deploy the module with HA.
    @param handler: An asynchronous handler to be called once deployment is complete.

    @return: self
    """
    component._component.cluster().deployModuleTo(
        deployment_id, group_id, module,
        map_to_java(config) if config is not None else None, instances, ha,
        DeployHandler(handler) if handler is not None else None)
    return self
Example #10
0
    def install_app(self, config, handler):
        """Install an application

        Keyword arguments:
        @param config: Configuration for the application
        @param proc: Proc representing the handler
        @param handler: Handler to call when a new SockJSSocket is created
        """
        java_config = org.vertx.java.core.json.JsonObject(map_to_java(config))
        self.java_obj.installApp(java_config, SockJSSocketHandler(handler))
Example #11
0
    def install_app(self, config, handler):
        """Install an application

        Keyword arguments:
        @param config: Configuration for the application
        @param proc: Proc representing the handler
        @param handler: Handler to call when a new SockJSSocket is created
        """
        java_config = org.vertx.java.core.json.JsonObject(map_to_java(config))
        self.java_obj.installApp(java_config, SockJSSocketHandler(handler))
Example #12
0
    def undeploy_network(self, network, handler=None):
        """Undeploys a network from the cluster.

        Keyword arguments:
        @param network: The network to undeploy.
        @param handler: A handler to be called once complete.

        @return: self
        """
        if isinstance(network, dict):
            if handler is not None:
                self.java_obj.undeployNetwork(org.vertx.java.core.json.JsonObject(map_to_java(network)), _UndeployHandler(handler))
            else:
                self.java_obj.undeployNetwork(org.vertx.java.core.json.JsonObject(map_to_java(network)))
        else:
            if handler is not None:
                self.java_obj.undeployNetwork(network if isinstance(network, basestring) else network.java_obj, _UndeployHandler(handler))
            else:
                self.java_obj.undeployNetwork(network if isinstance(network, basestring) else network.java_obj)
        return self
Example #13
0
def deploy_module(module_name, config=None, instances=1, handler=None):
    """Deploy a module. The actual deploy happens asynchronously

    Keyword arguments:
    @param module_name: The name of the module to deploy
    @param config: dict configuration for the module
    @param instances: Number of instances to deploy
    @param handler: an handler that will be called when deploy has completed
    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))
    org.vertx.java.deploy.impl.VertxLocator.container.deployModule(module_name, config, instances, DoneHandler(handler))
Example #14
0
def deploy_worker_verticle(main, config=None, instances=1, handler=None):
    """Deploy a worker verticle. The actual deploy happens asynchronously

    Keyword arguments:
    @param main: the main of the verticle to deploy
    @param config: dict configuration for the verticle
    @param instances: the number of instances to deploy
    @param handler: handler will be executed when deploy has completed
    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))
    org.vertx.java.deploy.impl.VertxLocator.container.deployWorkerVerticle(main, config, instances, DoneHandler(handler))
Example #15
0
def deploy_module(module_name, config=None, instances=1, handler=None):
    """Deploy a module. The actual deploy happens asynchronously

    Keyword arguments:
    @param module_name: The name of the module to deploy
    @param config: dict configuration for the module
    @param instances: Number of instances to deploy
    @param handler: handler will be executed when deploy has completed
    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))
    org.vertx.java.deploy.impl.VertxLocator.container.deployModule(
        module_name, config, instances, DoneHandler(handler))
def deploy_worker_verticle(main, config=None, instances=1, multi_threaded=False, handler=None):
    """Deploy a worker verticle. The actual deploy happens asynchronously

    Keyword arguments:
    @param main: the main of the verticle to deploy
    @param config: dict configuration for the verticle
    @param instances: the number of instances to deploy
    @param handler: an handler that will be called when deploy has completed
    @param multithreaded: enables multithreaded worker
    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))
    org.vertx.java.platform.impl.JythonVerticleFactory.container.deployWorkerVerticle(main, config, instances, multi_threaded, AsyncHandler(handler))
Example #17
0
def deploy_module(module_name, config=None, instances=1, handler=None):
    """Deploy a module. The actual deploy happens asynchronously

    Keyword arguments:
    @param module_name: The name of the module to deploy
    @param config: dict configuration for the module
    @param instances: Number of instances to deploy
    @param handler: an handler that will be called when deploy has completed
    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))
    org.vertx.java.platform.impl.JythonVerticleFactory.container.deployModule(
        module_name, config, instances, AsyncHandler(handler))
Example #18
0
def create_network(network):
    """Creates a new network.

    Keyword arguments:
    @param name: The network name or dictionary configuration.

    @return: A new network instance.
    """
    if isinstance(network, dict):
        return NetworkConfig(
            org.vertx.java.core.json.JsonObject(
                _vertigo.createNetwork(map_to_java(network))))
    return NetworkConfig(_vertigo.createNetwork(network))
Example #19
0
def deploy_verticle(self, deployment_id, main, config=None, instances=1, ha=False, handler=None):
    """Deploys a verticle.

    Keyword arguments:
    @param deploymen_id: The unique deployment ID of the deployment.
    @param module: The verticle main.
    @param config: The verticle configuration.
    @param instances: The number of instances to deploy.
    @param ha: Whether to deploy the verticle with HA.
    @param handler: An asynchronous handler to be called once deployment is complete.

    @return: self
    """
    component._component.cluster().deployVerticle(deployment_id, main, map_to_java(config) if config is not None else None, instances, ha, DeployHandler(handler) if handler is not None else None)
    return self
Example #20
0
    def get_now(self, uri, handler, **headers):
        """This is a quick version of the get method where you do not want to do anything with the request
        before sing.
        With this method the request is immediately sent.
        When an HTTP response is received from the server the handler is called passing in the response.

        Keyword arguments:
        @param uri: A relative URI where to perform the GET on the server.
        @param handler: The handler to be called with the HttpClientResponse
        @param headers: A dictionary of headers to pass with the request.
        """
        if len(headers) == 0:
            self.java_obj.getNow(uri, HttpClientResponseHandler(handler))    
        else:
            self.java_obj.getNow(uri, map_to_java(headers), HttpClientResponseHandler(handler))    
Example #21
0
def deploy_module_to(self, deployment_id, group_id, module, config=None, instances=1, ha=False, handler=None):
    """Deploys a module to a specific HA group.

    Keyword arguments:
    @param deploymen_id: The unique deployment ID of the deployment.
    @param group_id: The name of the group to which to deploy the module.
    @param module: The name of the module to deploy.
    @param config: The module configuration.
    @param instances: The number of instances to deploy.
    @param ha: Whether to deploy the module with HA.
    @param handler: An asynchronous handler to be called once deployment is complete.

    @return: self
    """
    component._component.cluster().deployModuleTo(deployment_id, group_id, module, map_to_java(config) if config is not None else None, instances, ha, DeployHandler(handler) if handler is not None else None)
    return self
def deploy_verticle(main, config=None, instances=1, handler=None):
    """Deploy a verticle. The actual deploy happens asynchronously

    Keyword arguments:
    @param main: the main of the verticle to deploy
    @param config: dict configuration for the verticle
    @param instances: number of instances to deploy
    @param handler: a handler that will be called when deploy has completed

    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))

    if handler != None:
        handler = AsyncHandler(handler)
    org.vertx.java.platform.impl.JythonVerticleFactory.container.deployVerticle(main, config, instances, handler)
Example #23
0
def undeploy_network(cluster, network, handler=None):
    """Undeploys a network.

    Keyword arguments:
    @param cluster: The cluster from which to undeploy the network.
    @param context: The network configuration or name for the network to undeploy.
    @param handler: An optional asynchronous handler to be called once the undeployment
    is complete.

    @return: The current vertigo instance.
    """
    if isinstance(network, dict):
        network = _vertigo.createNetwork(org.vertx.java.core.json.JsonObject(map_to_java(network)))
    if handler is not None:
        _vertigo.undeployNetwork(cluster, network if isinstance(network, basestring) else network.java_obj, _UndeployHandler(handler))
    else:
        _vertigo.undeployNetwork(cluster, network if isinstance(network, basestring) else network.java_obj)
    return this
Example #24
0
def deploy_worker_verticle(main,
                           config=None,
                           instances=1,
                           multi_threaded=False,
                           handler=None):
    """Deploy a worker verticle. The actual deploy happens asynchronously

    Keyword arguments:
    @param main: the main of the verticle to deploy
    @param config: dict configuration for the verticle
    @param instances: the number of instances to deploy
    @param handler: an handler that will be called when deploy has completed
    @param multithreaded: enables multithreaded worker
    """
    if config != None:
        config = org.vertx.java.core.json.JsonObject(map_to_java(config))
    org.vertx.java.platform.impl.JythonVerticleFactory.container.deployWorkerVerticle(
        main, config, instances, multi_threaded, AsyncHandler(handler))
Example #25
0
def undeploy_network(cluster, network, handler=None):
    """Undeploys a network.

    Keyword arguments:
    @param cluster: The cluster from which to undeploy the network.
    @param context: The network configuration or name for the network to undeploy.
    @param handler: An optional asynchronous handler to be called once the undeployment
    is complete.

    @return: The current vertigo instance.
    """
    if isinstance(network, dict):
        network = _vertigo.createNetwork(
            org.vertx.java.core.json.JsonObject(map_to_java(network)))
    if handler is not None:
        _vertigo.undeployNetwork(
            cluster,
            network if isinstance(network, basestring) else network.java_obj,
            _UndeployHandler(handler))
    else:
        _vertigo.undeployNetwork(
            cluster,
            network if isinstance(network, basestring) else network.java_obj)
    return this
Example #26
0
def deploy_verticle(self,
                    deployment_id,
                    main,
                    config=None,
                    instances=1,
                    ha=False,
                    handler=None):
    """Deploys a verticle.

    Keyword arguments:
    @param deploymen_id: The unique deployment ID of the deployment.
    @param module: The verticle main.
    @param config: The verticle configuration.
    @param instances: The number of instances to deploy.
    @param ha: Whether to deploy the verticle with HA.
    @param handler: An asynchronous handler to be called once deployment is complete.

    @return: self
    """
    component._component.cluster().deployVerticle(
        deployment_id, main,
        map_to_java(config) if config is not None else None, instances, ha,
        DeployHandler(handler) if handler is not None else None)
    return self
Example #27
0
 def set_config(self, config):
     """Sets the component configuration."""
     self.java_obj.setConfig(map_to_java(config))
     return self
Example #28
0
 def set_config(self, config):
   self._def.setConfig(org.vertx.java.core.json.JsonObject(map_to_java(config)))
Example #29
0
 def set_config(self, config):
     """Sets the component configuration."""
     self.java_obj.setConfig(map_to_java(config))
     return self
Example #30
0
 def _convert_data(self, data):
   return org.vertx.java.core.json.JsonObject(map_to_java(data))
 def bridge(self, config, inbound_permitted, outbound_permitted, auth_timeout=5*60*1000, auth_address=None):
     a_ijson = org.vertx.java.core.json.JsonArray(map_to_java(inbound_permitted))
     a_ojson = org.vertx.java.core.json.JsonArray(map_to_java(outbound_permitted))
     self.java_obj.bridge(org.vertx.java.core.json.JsonObject(map_to_java(config)), a_ijson, a_ojson, auth_timeout, auth_address)
Example #32
0
 def from_module(self, name, module=None, workers=1, config=None, grouping=None):
   if config is None:
     config = {}
   definition = self._def.fromModule(name, module, org.vertx.java.core.json.JsonObject(map_to_java(config)), workers)
   if grouping is not None:
     definition.groupBy(grouping._def)
   return ComponentDefinition(definition)
Example #33
0
def deploy_worker_verticle_to(self, deployment_id, group_id, main, config=None, instances=1, multi_threaded=False, ha=False, handler=None):
    """Deploys a worker verticle to a specific HA group.

    Keyword arguments:
    @param deploymen_id: The unique deployment ID of the deployment.
    @param group_id: The name of the group to which to deploy the verticle.
    @param main: The verticle main.
    @param config: The verticle configuration.
    @param instances: The number of instances to deploy.
    @param multi_threaded: Whether the worker verticle is multi-threaded.
    @param ha: Whether to deploy the verticle with HA.
    @param handler: An asynchronous handler to be called once deployment is complete.

    @return: self
    """
    component._component.cluster().deployWorkerVerticleTo(deployment_id, group_id, main, map_to_java(config) if config is not None else None, instances, multi_threaded, ha, DeployHandler(handler) if handler is not None else None)
    return self
Example #34
0
def create_network(network):
    """Creates a new network.

    Keyword arguments:
    @param name: The network name or dictionary configuration.

    @return: A new network instance.
    """
    if isinstance(network, dict):
        return NetworkConfig(org.vertx.java.core.json.JsonObject(_vertigo.createNetwork(map_to_java(network))))
    return NetworkConfig(_vertigo.createNetwork(network))