Class DefaultCloudServiceImpl

    • Method Summary

      Modifier and Type Method Description
      void createCache​(java.lang.String cacheName, java.util.Set<CloudCacheStrategy> strategies)
      Creates a instance of cache into the cloud using the specific strategy to specify the behavior of the cache instance.
      void dispatchEvent​(DistributedEvent event)
      Dispatch the event instance to the cloud.
      void forkWorker​(java.util.Map<java.lang.String,​java.lang.Object> workerConfig)
      This method start a worker over the cloud implementation to make a task and finish.
      CloudCache getCache​(java.lang.String cacheName)
      Return the instance of cache named with specific name.
      java.util.concurrent.locks.Condition getCondition​(java.lang.String conditionName, java.util.concurrent.locks.Lock lock)
      Return the distributed lock condition over specific lock object.
      Counter getCounter​(java.lang.String counterName)
      This method provides an implementation of distributed counter.
      java.util.concurrent.locks.Lock getLock​(java.lang.String lockName)
      Return the implementation of the Lock interface distributed.
      <K,​V>
      java.util.Map<K,​V>
      getMap​(java.lang.String mapName)
      This method provides an implementation of distributed map.
      <V> java.util.Queue<V> getQueue​(java.lang.String queueName)
      This method provides an implementation of distributed queue.
      java.lang.String getRegexFromDistributedLayer​(java.lang.Class<? extends LayerInterface> layerClass, java.lang.String implName)
      Returns the object that represent the distributed layer.
      <V> java.util.Set<V> getSet​(java.lang.String setName)
      This method provides an implementation of distributed set.
      boolean isLayerPublished​(java.lang.Class<? extends LayerInterface> layerClass, java.lang.String implName)
      This method verifies if the layer and name indicated are published into the cloud.
      <O> O layerInvoke​(java.lang.Class<? extends LayerInterface> layerClass, java.lang.String implName, java.lang.reflect.Method method, java.lang.Object... parameters)
      Invokes the remote instance of a layer.
      void lock​(java.lang.String resourceName)
      This method takes a resource an lock this for all the thread around the cluster and this resource has locked for all the thread for execution.
      void publishDistributedLayer​(java.lang.Class<? extends LayerInterface> layerClass, java.lang.String implName, java.lang.String regex)
      Publish a distributed layer into the cloud.
      void publishMe()
      This method must start the process of interaction with other services.
      void publishPlugin​(byte[] jarFile)
      This method send the plugin for all the nodes into the cloud.
      void shutdown()
      Shutdown hook
      void unlock​(java.lang.String resourceName)
      This method unlocks a previously locked resource.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultCloudServiceImpl

        public DefaultCloudServiceImpl()
    • Method Detail

      • getMap

        public <K,​V> java.util.Map<K,​V> getMap​(java.lang.String mapName)
        This method provides an implementation of distributed map. All the nodes on the cluster shares this instance.
        Specified by:
        getMap in interface CloudServiceImpl
        Type Parameters:
        K - Type of the map's key.
        V - Type of the map's values.
        Parameters:
        mapName - Name of the map.
        Returns:
        Return the instance of the distributed map.
      • getQueue

        public <V> java.util.Queue<V> getQueue​(java.lang.String queueName)
        This method provides an implementation of distributed queue. All the nodes on the cluster shares this instance.
        Specified by:
        getQueue in interface CloudServiceImpl
        Type Parameters:
        V - Type of the queue's values.
        Parameters:
        queueName - Name of the queue.
        Returns:
        Return the instance of the distributed queue.
      • getSet

        public <V> java.util.Set<V> getSet​(java.lang.String setName)
        This method provides an implementation of distributed set. All the nodes on the cloud shares this instance.
        Specified by:
        getSet in interface CloudServiceImpl
        Type Parameters:
        V - Type of the set's values.
        Parameters:
        setName - Name of the set.
        Returns:
        Return the instance of the distributed set.
      • getCounter

        public Counter getCounter​(java.lang.String counterName)
        This method provides an implementation of distributed counter. All the nodes on the cloud shares this instance.
        Specified by:
        getCounter in interface CloudServiceImpl
        Parameters:
        counterName - Name of the counter.
        Returns:
        Return thr instance of the counter.
      • lock

        public void lock​(java.lang.String resourceName)
                  throws java.lang.InterruptedException
        This method takes a resource an lock this for all the thread around the cluster and this resource has locked for all the thread for execution. This method is blocked until you can get the lock.
        Specified by:
        lock in interface CloudServiceImpl
        Parameters:
        resourceName - The name of the resource to lock.
        Throws:
        java.lang.InterruptedException - Interrupted exception
      • unlock

        public void unlock​(java.lang.String resourceName)
                    throws java.lang.InterruptedException
        This method unlocks a previously locked resource.
        Specified by:
        unlock in interface CloudServiceImpl
        Parameters:
        resourceName - The name of the resource locked.
        Throws:
        java.lang.InterruptedException - Interrupted exception.
      • getLock

        public java.util.concurrent.locks.Lock getLock​(java.lang.String lockName)
        Return the implementation of the Lock interface distributed.
        Specified by:
        getLock in interface CloudServiceImpl
        Parameters:
        lockName - Name of the lock.
        Returns:
        Distributed lock implementation.
      • getCondition

        public java.util.concurrent.locks.Condition getCondition​(java.lang.String conditionName,
                                                                 java.util.concurrent.locks.Lock lock)
        Return the distributed lock condition over specific lock object.
        Specified by:
        getCondition in interface CloudServiceImpl
        Parameters:
        conditionName - Lock condition name.
        lock - Specific lock object.
        Returns:
        Return the lock condition.
      • createCache

        public void createCache​(java.lang.String cacheName,
                                java.util.Set<CloudCacheStrategy> strategies)
        Creates a instance of cache into the cloud using the specific strategy to specify the behavior of the cache instance.
        Specified by:
        createCache in interface CloudServiceImpl
        Parameters:
        cacheName - Name of the cache instance.
        strategies - Set with the strategies for the cache instance.
      • getCache

        public CloudCache getCache​(java.lang.String cacheName)
        Return the instance of cache named with specific name.
        Specified by:
        getCache in interface CloudServiceImpl
        Parameters:
        cacheName - Name of the instance of cache.
        Returns:
        Instance of cache.
      • publishDistributedLayer

        public void publishDistributedLayer​(java.lang.Class<? extends LayerInterface> layerClass,
                                            java.lang.String implName,
                                            java.lang.String regex)
        Publish a distributed layer into the cloud.
        Specified by:
        publishDistributedLayer in interface CloudServiceImpl
        Parameters:
        layerClass - Layer class.
        implName - Layer implementation name.
        regex - Regex for match the implementation.
      • isLayerPublished

        public boolean isLayerPublished​(java.lang.Class<? extends LayerInterface> layerClass,
                                        java.lang.String implName)
        This method verifies if the layer and name indicated are published into the cloud.
        Specified by:
        isLayerPublished in interface CloudServiceImpl
        Parameters:
        layerClass - Layer class.
        implName - Layer implementation name.
        Returns:
        Returns true if the layer is published and false in the otherwise.
      • getRegexFromDistributedLayer

        public java.lang.String getRegexFromDistributedLayer​(java.lang.Class<? extends LayerInterface> layerClass,
                                                             java.lang.String implName)
        Returns the object that represent the distributed layer.
        Specified by:
        getRegexFromDistributedLayer in interface CloudServiceImpl
        Parameters:
        layerClass - Layer class.
        implName - Layer implementation name.
        Returns:
        Regex if exist or null.
      • publishPlugin

        public void publishPlugin​(byte[] jarFile)
        This method send the plugin for all the nodes into the cloud.
        Specified by:
        publishPlugin in interface CloudServiceImpl
        Parameters:
        jarFile - Byte array that represents the jar file.
      • layerInvoke

        public <O> O layerInvoke​(java.lang.Class<? extends LayerInterface> layerClass,
                                 java.lang.String implName,
                                 java.lang.reflect.Method method,
                                 java.lang.Object... parameters)
        Invokes the remote instance of a layer.
        Specified by:
        layerInvoke in interface CloudServiceImpl
        Type Parameters:
        O - Expected return data type.
        Parameters:
        layerClass - Layer interface class.
        implName - Implementation name.
        method - Method to invoke.
        parameters - Parameters to invoke.
        Returns:
        Invocation result.
      • publishMe

        public void publishMe()
        This method must start the process of interaction with other services.
        Specified by:
        publishMe in interface CloudServiceImpl
      • forkWorker

        public void forkWorker​(java.util.Map<java.lang.String,​java.lang.Object> workerConfig)
        This method start a worker over the cloud implementation to make a task and finish.
        Specified by:
        forkWorker in interface CloudServiceImpl
        Parameters:
        workerConfig - Map with all the parameters to configure a worker instance.