EdgeEvents API

Classes

enum  com.mobiledgex.matchingengine.edgeeventsconfig.FindCloudletEventTrigger
 
class  com.mobiledgex.matchingengine.edgeeventsconfig.UpdateConfig
 
class  com.mobiledgex.matchingengine.edgeeventsconfig.EdgeEventsConfig
 

Functions

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.postLocationUpdate (Location location)
 
synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.postLatencyUpdate (Site site, Location location)
 
synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.testPingAndPostLatencyUpdate (Location location)
 
synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.testConnectAndPostLatencyUpdate (Location location)
 
synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.testConnectAndPostLatencyUpdate (int internalPort, Location location)
 
synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.runEdgeEvents ()
 
synchronized void com.mobiledgex.matchingengine.MatchingEngine.setEnableEdgeEvents (boolean enableEdgeEvents)
 
boolean com.mobiledgex.matchingengine.MatchingEngine.isAutoMigrateEdgeEventsConnection ()
 
synchronized void com.mobiledgex.matchingengine.MatchingEngine.setAutoMigrateEdgeEventsConnection (boolean autoMigrateEdgeEventsConnection)
 
synchronized CompletableFuture< Boolean > com.mobiledgex.matchingengine.MatchingEngine.startEdgeEventsFuture (EdgeEventsConfig edgeEventsConfig)
 
synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.startEdgeEvents (EdgeEventsConfig edgeEventsConfig)
 
CompletableFuture< Boolean > com.mobiledgex.matchingengine.MatchingEngine.restartEdgeEventsFuture ()
 
synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.restartEdgeEvents () throws DmeDnsException
 
synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.switchedToNextCloudlet () throws DmeDnsException
 
CompletableFuture< Boolean > com.mobiledgex.matchingengine.MatchingEngine.stopEdgeEventsFuture ()
 
synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.stopEdgeEvents ()
 
EventBus com.mobiledgex.matchingengine.MatchingEngine.getEdgeEventsBus ()
 

Detailed Description

Function Documentation

◆ getEdgeEventsBus()

EventBus com.mobiledgex.matchingengine.MatchingEngine.getEdgeEventsBus ( )

This is an event bus for EdgeEvents. You can specify your own ExecutorService with MatchingEgnine init.

If you want to send a response back to the server, call getEdgeEventsConnection() to access Utility functions to help with the response.

Returns
The EdgeEvents bus, if any. This may be null.

◆ isAutoMigrateEdgeEventsConnection()

boolean com.mobiledgex.matchingengine.MatchingEngine.isAutoMigrateEdgeEventsConnection ( )

Automatically switched EdgeEventsConnection

Returns
boolean value whether the EdgeEventsConnection is migrated automatically.

◆ postLatencyUpdate()

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.postLatencyUpdate ( Site  site,
Location  location 
)

Outbound ClientEdgeEvent to DME. Post already collected site statistics. A DME administrator of your Application may request an client application to collect performance NetTest stats to their current AppInst with the ServerEdgeEvent EVENT_LATENCY_REQUEST.

Parameters
site
location
Returns
boolean indicating whether the site results are posted or not.

◆ postLocationUpdate()

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.postLocationUpdate ( Location  location)

Outbound Client to Server location update. If there is a closer cloudlet, this will cause a Guava ServerEdgeEvent EVENT_CLOUDLET_UPDATE message to be sent to subscribers.

Parameters
location(Android location format)
Returns
whether the message was posted.

Example

mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
if (locationResult == null) {
return;
}
String clientLocText = "";
mLastLocationResult = locationResult;
// Post into edgeEvents updater:
.thenApply(connection -> {
if (connection != null) {
connection.postLocationUpdate(locationResult.getLastLocation());
}
return null;
});
for (Location location : locationResult.getLocations()) {
// Update UI with client location data
clientLocText += "[" + location.toString() + "]";
}
TextView tv = findViewById(R.id.client_location_content);
tv.setText(clientLocText);
}
};
synchronized CompletableFuture< EdgeEventsConnection > getEdgeEventsConnectionFuture()
Definition: MatchingEngine.java:495

◆ restartEdgeEvents()

synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.restartEdgeEvents ( ) throws DmeDnsException

This is required, if the app needs to swap AppInst edge servers, and auto reconnect to the next DME's EdgeEventsConnection is disabled.

Exceptions
DmeDnsExceptionif the next DME for the EdgeEventsConnection for some reason doesn't exist in DNS yet.

◆ restartEdgeEventsFuture()

CompletableFuture< Boolean > com.mobiledgex.matchingengine.MatchingEngine.restartEdgeEventsFuture ( )

CompletableFuture wrapper for restartEdgeEvents running on MatchingEngine ExecutorService pool. The background task might throw a DmeDnsException exception, and return false.

Parameters
edgeEventsConfigthe configuration for background run EdgeEvents.

Example

◆ runEdgeEvents()

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.runEdgeEvents ( )

Fires off tasks to run EdgeEvents monitoring as per config. EdgeEvents must be enabled. This is separate from the normal SDK handled events, like latency requests and new cloudlet availability. Those EdgeEvents, you should subscribe to.

Cancel with stopEdgeEvents.

Parameters
dmeHostDME hostname.
dmePort
edgeEventsConfig
networkoverride network.

◆ setAutoMigrateEdgeEventsConnection()

synchronized void com.mobiledgex.matchingengine.MatchingEngine.setAutoMigrateEdgeEventsConnection ( boolean  autoMigrateEdgeEventsConnection)

When you switch AppInsts between Cloudlets, the EdgeEventsConnection should also migrate. If set to false, when notified of a newCLoudlet availability, call "switchedToNewFindCloudlet() to indicate the app has finally migrated to the new cloudlet.

Parameters
autoMigrateEdgeEventsConnection

◆ setEnableEdgeEvents()

synchronized void com.mobiledgex.matchingengine.MatchingEngine.setEnableEdgeEvents ( boolean  enableEdgeEvents)

Enable or disable edge events API.

Parameters
enableEdgeEventsthis defaults to true in the MatchingEngine.

Example

// Register the class subscribing to EdgeEvents to the EdgeEventsBus (Guava EventBus interface).
me.setEnableEdgeEvents(true); // default is true.

◆ startEdgeEvents()

synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.startEdgeEvents ( EdgeEventsConfig  edgeEventsConfig)

startEdgeEvents() begins processing as soon as a FindCloudletReply is FIND_FOUND with the EdgeEventsConfig given.

If you want to handle the EdgeEvents with a custom handler, call getEdgeEventsBus(), register your class, and @Subscribe to either these event objects:

  • FindCloudletEvent - A new cloudlet found and is available for your app to migrate to when ready.
  • ServerEdgeEvent - Optional. All raw events. Accepting raw events will disable the default EdgeEvents handler for custom app logic.

The errors on the EdgeEventsBus is useful for the app to attach a handler

  • EdgeEventsError - Errors encountered during the EdgeEvents threads will be posted here for the app to handle.
Parameters
edgeEventsConfiga events profile on how to monitor the edgeConnection state. null to use defaults.

Example

me.startEdgeEventsFuture(backgroundEdgeEventsConfig);

◆ startEdgeEventsFuture()

synchronized CompletableFuture< Boolean > com.mobiledgex.matchingengine.MatchingEngine.startEdgeEventsFuture ( EdgeEventsConfig  edgeEventsConfig)

CompletableFuture wrapper for startEdgeEvents running on MatchingEngine ExecutorService pool.

Parameters
edgeEventsConfigthe configuration for background run EdgeEvents.

Example

◆ stopEdgeEvents()

synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.stopEdgeEvents ( )

Stops processsing of DME server pushed EdgeEvents.

◆ stopEdgeEventsFuture()

CompletableFuture< Boolean > com.mobiledgex.matchingengine.MatchingEngine.stopEdgeEventsFuture ( )

Stops processsing of DME server pushed EdgeEvents. Futures version.

Returns
A future for stopEdgeEvents running on MatchingEngine's ExecutorService pool.

◆ switchedToNextCloudlet()

synchronized boolean com.mobiledgex.matchingengine.MatchingEngine.switchedToNextCloudlet ( ) throws DmeDnsException

Just an alias to restartEdgeEvents. Blocking call.

Exceptions
DmeDnsExceptionif the next DME for the EdgeEventsConnection for some reason doesn't exist in DNS yet.

◆ testConnectAndPostLatencyUpdate() [1/2]

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.testConnectAndPostLatencyUpdate ( int  internalPort,
Location  location 
)

Outbound ClientEdgeEvent to DME. Post site statistics with the most recent FindCloudletReply. A DME administrator of your Application may request an client application to collect performance stats to their current AppInst with the ServerEdgeEvent EVENT_LATENCY_REQUEST.

This utility function uses the default network path. It does not swap network interfaces.

Parameters
internalPortthe internal port of your App definition. Not the public mapped port for the edge instance.
androidformat GPS location.
Returns
boolean indicating whether the site results are posted or not.

◆ testConnectAndPostLatencyUpdate() [2/2]

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.testConnectAndPostLatencyUpdate ( Location  location)

Outbound ClientEdgeEvent to DME. Post site statistics with the most recent FindCloudletReply. A DME administrator of your Application may request an client application to collect performance NetTest stats to their current AppInst with the ServerEdgeEvent EVENT_LATENCY_REQUEST.

This utility function uses the default network path. It does not swap network interfaces.

Parameters
androidformat GPS location.
numberof samples to test
Returns
boolean indicating whether the site results are posted or not.

◆ testPingAndPostLatencyUpdate()

synchronized boolean com.mobiledgex.matchingengine.EdgeEventsConnection.testPingAndPostLatencyUpdate ( Location  location)

Outbound ClientEdgeEvent to DME. Post site statistics with the most recent FindCloudletReply. A DME administrator of your Application may request an client application to collect performance stats to their current AppInst with the ServerEdgeEvent EVENT_LATENCY_REQUEST.

Parameters
androidformat location
Returns
boolean indicating whether the site results are posted or not.