public interface TwillContext extends ServiceAnnouncer, DiscoveryServiceClient
TwillRunnable
.Modifier and Type | Method and Description |
---|---|
Lock |
createLock(String name)
Creates a
Lock for performing locking mechanism within the same TwillApplication . |
ServiceDiscovered |
discover(String name)
Discover service with the given name that is announced within the same
TwillApplication . |
Cancellable |
electLeader(String name,
ElectionHandler participantHandler)
Register to participate in a leader election by instances within the same
TwillApplication . |
String[] |
getApplicationArguments()
Returns the runtime arguments that are passed to the
TwillApplication . |
RunId |
getApplicationRunId()
Returns the
RunId of this running application. |
String[] |
getArguments()
Returns the runtime arguments that are passed to the
TwillRunnable . |
InetAddress |
getHost()
Returns the hostname that the runnable is running on.
|
int |
getInstanceCount()
Returns the number of running instances assigned for this
TwillRunnable . |
int |
getInstanceId()
Returns an integer id from 0 to (instanceCount - 1).
|
int |
getMaxMemoryMB()
Returns the amount of memory in MB the runnable is allowed to use.
|
RunId |
getRunId()
Returns the
RunId of this running instance of TwillRunnable . |
TwillRunnableSpecification |
getSpecification()
Returns the
TwillRunnableSpecification that was created by TwillRunnable.configure() . |
int |
getVirtualCores()
Returns the number of virtual cores the runnable is allowed to use.
|
announce, announce
RunId getRunId()
RunId
of this running instance of TwillRunnable
.int getInstanceCount()
TwillRunnable
.InetAddress getHost()
String[] getArguments()
TwillRunnable
.String[] getApplicationArguments()
TwillApplication
.TwillRunnableSpecification getSpecification()
TwillRunnableSpecification
that was created by TwillRunnable.configure()
.int getInstanceId()
int getVirtualCores()
int getMaxMemoryMB()
ServiceDiscovered discover(String name)
TwillApplication
.discover
in interface DiscoveryServiceClient
name
- Name of the serviceServiceDiscovered
object representing the result.Cancellable electLeader(String name, ElectionHandler participantHandler)
TwillApplication
.name
- Unique name for the electionCancellable
object representing this candidate's participation.Lock createLock(String name)
Lock
for performing locking mechanism within the same TwillApplication
.
The lock created is a reentrant such that if the lock is owned by the current thread, it will return immediately.name
- Unique name for the lockLock
objectCopyright © 2013-2016 The Apache Software Foundation. All rights reserved.