Class EndPointService


  • public class EndPointService
    extends java.lang.Object
    • Constructor Detail

      • EndPointService

        public EndPointService​(CacheService cacheService)
    • Method Detail

      • getFailoverAction

        public byte getFailoverAction()
        Gets the current action to take regarding the connection service
        Returns:
        failoverAction
      • setFailoverAction

        public void setFailoverAction​(byte failoverAction)
        Sets the action level
        Parameters:
        failoverAction -
      • getCacheService

        public CacheService getCacheService()
        Returns the underlying cache layer
        Returns:
        cacheService
      • isServerListManual

        public boolean isServerListManual()
        true if the server list is the manual type
        Returns:
        serverListIsManual
      • setServerListIsManual

        public void setServerListIsManual​(boolean serverListIsManual)
        Sets the type of server list (manual or not)
        Parameters:
        serverListIsManual -
      • getCloudUrl

        public java.lang.String getCloudUrl()
        Gets the last endpoint url used when call the service
        Returns:
        lastUsedCloudUrl
      • setCloudUrl

        public void setCloudUrl​(java.lang.String lastUsedCloudUrl)
        Sets the last endpoint url used when call the service
        Parameters:
        lastUsedCloudUrl -
      • getCloudServiceTimeout

        public int getCloudServiceTimeout()
        Returns the cloud service's timeout
        Returns:
        cloudServiceTimeout
      • setCloudServiceTimeout

        public void setCloudServiceTimeout​(int cloudServiceTimeout)
        Sets the cloud service's timeout
        Parameters:
        cloudServiceTimeout -
      • getAutoServerRankingMaxFailures

        public int getAutoServerRankingMaxFailures()
        Returns the maximum amount of failures for server ranking's checks
        Returns:
        autoServerRankingMaxFailures
      • setAutoServerRankingMaxFailures

        public void setAutoServerRankingMaxFailures​(int autoServerRankingMaxFailures)
        Sets the maximum amount of failures for server ranking's checks
        Parameters:
        autoServerRankingMaxFailures -
      • getAutoServerRankingNumRequests

        public int getAutoServerRankingNumRequests()
        Returns the maximum number of requests
        Returns:
        autoServerLatencyNumRequests
      • setAutoServerRankingNumRequests

        public void setAutoServerRankingNumRequests​(int autoServerLatencyNumRequests)
        Sets the maximum number of requests
      • getRankingStatus

        public java.lang.String getRankingStatus()
        Returns the current ranking status
        Returns:
        rankingStatus
      • setRankingStatus

        public void setRankingStatus​(java.lang.String rankingStatus)
        Sets the current ranking status
        Parameters:
        rankingStatus -
      • setLicenceKey

        public void setLicenceKey​(java.lang.String licenceKey)
        Sets the licence key
        Parameters:
        licenceKey -
      • getOriginalEndPoints

        public EndPoint[] getOriginalEndPoints()
        Returns the original endpoints list
        Returns:
        endPoints
      • setEndPoints

        public void setEndPoints​(EndPoint[] endPoints)
        Sets the original list of endpoints
        Parameters:
        endPoints -
      • getFirstEndPoint

        public EndPoint getFirstEndPoint()
        Returns the fist endpoint
        Returns:
        endPoints
      • setFirstEndPoint

        public void setFirstEndPoint​(EndPoint endPoint)
        Sets the first endpoint
        Parameters:
        endPoint -
      • getAutoServerRanking

        public boolean getAutoServerRanking()
        Checks if the server ranking is in auto mode
        Returns:
        autoServerRanking
      • setAutoServerRanking

        public void setAutoServerRanking​(boolean autoServerRanking)
        Set the server ranking in auto mode
        Parameters:
        autoServerRanking -
      • getFatalErrors

        public java.util.List<java.lang.String> getFatalErrors()
        Returns the list of errors
        Returns:
        fatalErrors
      • getServerLatency

        public java.util.List<java.lang.Double> getServerLatency​(EndPoint endPoint,
                                                                 int numRequests)
        Returns the latencies of endpoints
        Parameters:
        endPoint -
        numRequests -
        Returns:
        latencies
      • getServersLatencies

        public EndPoint[] getServersLatencies​(int numRequests)
        Get endPoints and their service latencies.
        Parameters:
        numRequests - Number of times to request from server
        Returns:
        An array of EndPoint objects
      • getServersLatencies

        public EndPoint[] getServersLatencies()
        Get endPoints and their service latencies.
        Returns:
        An array of EndPoint objects
      • getCalledServers

        public java.util.List<java.lang.String> getCalledServers()
        Returns the servers called
        Returns:
        calledServers
      • setCalledServers

        public void setCalledServers​(java.util.List<java.lang.String> calledServers)
        Sets the servers called
        Parameters:
        calledServers -
      • addEndPoint

        public void addEndPoint​(java.util.List<EndPoint> endPointL,
                                EndPoint endPoint)
        Adds an endpoint to the list
        Parameters:
        endPointL -
        endPoint -
      • setEndPointsIfNotRanked

        public void setEndPointsIfNotRanked()
        Sets the end point
      • rankServers

        public EndPoint[] rankServers()
                               throws CacheException
        If auto-ranking is on then rank the DeviceAtlas cloud end-points and put in cache.
        Returns:
        The ranked or re-ordered end-point list
        Throws:
        CacheException - when an error checking server latencies appears
      • setProxy

        public void setProxy​(java.net.Proxy proxy)
        Sets HTTP proxy settings for the remote requests
        Parameters:
        proxy - proxy to set for the remote requests
      • connectCloud

        public java.util.Map connectCloud​(EndPoint endPoint,
                                          java.lang.String userAgent,
                                          java.util.Map<java.lang.String,​java.lang.String> headers,
                                          java.util.List<java.lang.String> errors)
                                   throws ClientException
        Get the properties from a cloud end point
        Throws:
        ClientException
      • getHeaders

        public java.lang.String getHeaders()
      • moveEndPointOrder

        public void moveEndPointOrder​(EndPoint[] localEndPoints,
                                      int i)
                               throws CacheException
        if top endPoints failed, move them to the bottom and re-cache the list
        Parameters:
        localEndPoints -
        i -
        Throws:
        CacheException
      • getCloudServiceResponse

        public java.util.Map getCloudServiceResponse​(EndPoint[] localEndPoints,
                                                     java.lang.String userAgent,
                                                     java.util.Map<java.lang.String,​java.lang.String> headers,
                                                     java.util.List<java.lang.String> errors)
                                              throws CacheException
        Treats the endPoint response
        Parameters:
        localEndPoints -
        userAgent -
        headers -
        errors -
        Returns:
        Map
        Throws:
        CacheException
      • getCloudService

        public java.util.Map getCloudService​(java.lang.String userAgent,
                                             java.util.Map<java.lang.String,​java.lang.String> headers)
                                      throws ClientException
        Get device properties from DeviceAtlas cloud service
        Throws:
        ClientException