com.mobiledgex.matchingengine.performancemetrics.NetTest Class Reference

Classes

enum  TestType
 

Public Member Functions

 NetTest ()
 
Comparator< SitegetSiteComparator ()
 
void setSiteComparator (Comparator< Site > siteComparator)
 
ExecutorService setExecutorService (ExecutorService executorService)
 
long ConnectAndDisconnectHostAndPort (Site site)
 
long ConnectAndDisconnect (Site site)
 
long Ping (Site site)
 
boolean doTest (boolean enable)
 
Site getSite (String hostOrL7Path)
 
boolean addSite (Site site)
 
List< SitesortedSiteList ()
 
Site bestSite ()
 
double testSite (Site site)
 
void testSites (long TimeoutMS)
 
void testSitesOnExecutor (long TimeoutMS)
 
void RunNetTest ()
 

Public Attributes

int testRounds = 3
 
boolean runTest
 
int TestIntervalMS = 100
 
int TestTimeoutMS = 2000
 

Static Public Attributes

static final String TAG = "NetTest"
 

Detailed Description

Utility class used for testing network latency

Example

NetTest netTest = new NetTest();
AppClient.RegisterClientRequest.Builder registerClientRequestBuilder = null;
try {
registerClientRequestBuilder = me.createDefaultRegisterClientRequest(context, "MobiledgeX-Samples")
.setAppName("EdgeMultiplay")
.setAppVers("1.2");
AppClient.RegisterClientRequest req = registerClientRequestBuilder.build();
AppClient.RegisterClientReply regReply = me.registerClient(req,10000);
AppClient.FindCloudletRequest findCloudletRequest = me.createDefaultFindCloudletRequest(context, location)
.setCarrierName("")
.build();
int internalPort = 7776; // This is the un-remapped port of the App definition. See the app's console definition.
AppClient.FindCloudletReply findCloudletReply = me.findCloudlet(findCloudletRequest, 10000);
String host = me.getAppConnectionManager().getHost(findCloudletReply, internalPort); // internal port to host lookup.
int port = me.getAppConnectionManager().getPublicPort(findCloudletReply, internalPort); // internal port to port lookup.
Site site = new Site(context, NetTest.TestType.CONNECT, 5, host, port);
netTest.addSite(site);
} catch (DmeDnsException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
Assert.assertFalse(String.valueOf(e.getStackTrace()), true);
} catch (NameNotFoundException pmnf) {
Assert.assertTrue("Missing package manager!", false);
}
List<Site> sites = netTest.sortedSiteList();
netTest.testSites(TimeoutMS);
List<Site> sortedSites = netTest.sortedSiteList();
for (Site s : sortedSites) {
Log.i(TAG, "Test average: " + s.average);
}

Constructor & Destructor Documentation

◆ NetTest()

com.mobiledgex.matchingengine.performancemetrics.NetTest.NetTest ( )

Constructor for NetTest

Member Function Documentation

◆ bestSite()

Site com.mobiledgex.matchingengine.performancemetrics.NetTest.bestSite ( )

Best site, from collection. return Site

◆ ConnectAndDisconnect()

long com.mobiledgex.matchingengine.performancemetrics.NetTest.ConnectAndDisconnect ( Site  site)

Test and gather stats on site using TCP connection to host.

Parameters
siteSite
Returns
long

◆ ConnectAndDisconnectHostAndPort()

long com.mobiledgex.matchingengine.performancemetrics.NetTest.ConnectAndDisconnectHostAndPort ( Site  site)

Create a client and connect/disconnect on a raw TCP server port from a device network Interface.

Parameters
site(Site)
Returns
long

◆ Ping()

long com.mobiledgex.matchingengine.performancemetrics.NetTest.Ping ( Site  site)

Basic ICMP ping. Does not set source network interface, it just pings to see if it is reachable along current default route.

Parameters
site(Site)
Returns
long

◆ RunNetTest()

void com.mobiledgex.matchingengine.performancemetrics.NetTest.RunNetTest ( )

Basic utility function to connect and disconnect from any TCP port.

◆ setExecutorService()

ExecutorService com.mobiledgex.matchingengine.performancemetrics.NetTest.setExecutorService ( ExecutorService  executorService)

Set the executorService to use if using the async Future versions.

Parameters
executorService(ExecutorService)
Returns
ExecutorService

◆ sortedSiteList()

List< Site > com.mobiledgex.matchingengine.performancemetrics.NetTest.sortedSiteList ( )

Copy of sites for gathered performance stats based on default Comparator.

Returns
List<Site>

◆ testSites()

void com.mobiledgex.matchingengine.performancemetrics.NetTest.testSites ( long  TimeoutMS)

Gather metrics for sites

◆ testSitesOnExecutor()

void com.mobiledgex.matchingengine.performancemetrics.NetTest.testSitesOnExecutor ( long  TimeoutMS)

Parallel gather of sites added to NetTest over on executorService configured in NetTest.