Class EndPointService
- java.lang.Object
-
- com.deviceatlas.cloud.deviceidentification.service.EndPointService
-
public class EndPointService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description EndPointService(CacheService cacheService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEndPoint(java.util.List<EndPoint> endPointL, EndPoint endPoint)
Adds an endpoint to the listjava.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)
Get the properties from a cloud end pointboolean
getAutoServerRanking()
Checks if the server ranking is in auto modeint
getAutoServerRankingMaxFailures()
Returns the maximum amount of failures for server ranking's checksint
getAutoServerRankingNumRequests()
Returns the maximum number of requestsCacheService
getCacheService()
Returns the underlying cache layerjava.util.List<java.lang.String>
getCalledServers()
Returns the servers calledjava.util.Map
getCloudService(java.lang.String userAgent, java.util.Map<java.lang.String,java.lang.String> headers)
Get device properties from DeviceAtlas cloud servicejava.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)
Treats the endPoint responseint
getCloudServiceTimeout()
Returns the cloud service's timeoutjava.lang.String
getCloudUrl()
Gets the last endpoint url used when call the serviceEndPoint[]
getEndPoints()
Gets the list of ranking endpoints (manual or auto)byte
getFailoverAction()
Gets the current action to take regarding the connection servicejava.util.List<java.lang.String>
getFatalErrors()
Returns the list of errorsEndPoint
getFirstEndPoint()
Returns the fist endpointjava.lang.String
getHeaders()
EndPoint[]
getOriginalEndPoints()
Returns the original endpoints listjava.lang.String
getRankingStatus()
Returns the current ranking statusjava.util.List<java.lang.Double>
getServerLatency(EndPoint endPoint, int numRequests)
Returns the latencies of endpointsEndPoint[]
getServersLatencies()
Get endPoints and their service latencies.EndPoint[]
getServersLatencies(int numRequests)
Get endPoints and their service latencies.boolean
isServerListManual()
true if the server list is the manual typevoid
moveEndPointOrder(EndPoint[] localEndPoints, int i)
if top endPoints failed, move them to the bottom and re-cache the listEndPoint[]
rankServers()
If auto-ranking is on then rank the DeviceAtlas cloud end-points and put in cache.void
setAutoServerRanking(boolean autoServerRanking)
Set the server ranking in auto modevoid
setAutoServerRankingMaxFailures(int autoServerRankingMaxFailures)
Sets the maximum amount of failures for server ranking's checksvoid
setAutoServerRankingNumRequests(int autoServerLatencyNumRequests)
Sets the maximum number of requestsvoid
setCalledServers(java.util.List<java.lang.String> calledServers)
Sets the servers calledvoid
setCloudServiceTimeout(int cloudServiceTimeout)
Sets the cloud service's timeoutvoid
setCloudUrl(java.lang.String lastUsedCloudUrl)
Sets the last endpoint url used when call the servicevoid
setEndPoints(EndPoint[] endPoints)
Sets the original list of endpointsvoid
setEndPointsIfNotRanked()
Sets the end pointvoid
setFailoverAction(byte failoverAction)
Sets the action levelvoid
setFirstEndPoint(EndPoint endPoint)
Sets the first endpointvoid
setLicenceKey(java.lang.String licenceKey)
Sets the licence keyvoid
setProxy(java.net.Proxy proxy)
Sets HTTP proxy settings for the remote requestsvoid
setRankingStatus(java.lang.String rankingStatus)
Sets the current ranking statusvoid
setServerListIsManual(boolean serverListIsManual)
Sets the type of server list (manual or not)
-
-
-
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
-
-
getEndPoints
public EndPoint[] getEndPoints() throws CacheException
Gets the list of ranking endpoints (manual or auto)- Returns:
- cachedEndPoints
- Throws:
CacheException
-
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
-
-