blob: 177b5884d5e24e83a381a4768fa415ed7c0ff187 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_221) on Wed Jan 29 15:38:00 PST 2020 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BasicTwillContext (Apache Twill 0.14.0 API)</title>
<meta name="date" content="2020-01-29">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="BasicTwillContext (Apache Twill 0.14.0 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/BasicTwillContext.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/twill/internal/Arguments.html" title="class in org.apache.twill.internal"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/apache/twill/internal/CompositeService.html" title="class in org.apache.twill.internal"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/twill/internal/BasicTwillContext.html" target="_top">Frames</a></li>
<li><a href="BasicTwillContext.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.twill.internal</div>
<h2 title="Class BasicTwillContext" class="title">Class BasicTwillContext</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.twill.internal.BasicTwillContext</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html" title="interface in org.apache.twill.api">ServiceAnnouncer</a>, <a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a>, <a href="../../../../org/apache/twill/discovery/DiscoveryServiceClient.html" title="interface in org.apache.twill.discovery">DiscoveryServiceClient</a></dd>
</dl>
<hr>
<br>
<pre>public final class <span class="typeNameLabel">BasicTwillContext</span>
extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>
implements <a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></pre>
<div class="block">Implementation of <a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api"><code>TwillContext</code></a> that provides the basic runtime information of a <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#BasicTwillContext-org.apache.twill.api.RunId-org.apache.twill.api.RunId-java.net.InetAddress-java.lang.String:A-java.lang.String:A-org.apache.twill.api.TwillRunnableSpecification-int-org.apache.twill.discovery.DiscoveryService-org.apache.twill.discovery.DiscoveryServiceClient-org.apache.twill.zookeeper.ZKClient-int-int-int-">BasicTwillContext</a></span>(<a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a>&nbsp;runId,
<a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a>&nbsp;appRunId,
<a href="https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html?is-external=true" title="class or interface in java.net">InetAddress</a>&nbsp;host,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;appArgs,
<a href="../../../../org/apache/twill/api/TwillRunnableSpecification.html" title="interface in org.apache.twill.api">TwillRunnableSpecification</a>&nbsp;spec,
int&nbsp;instanceId,
<a href="../../../../org/apache/twill/discovery/DiscoveryService.html" title="interface in org.apache.twill.discovery">DiscoveryService</a>&nbsp;discoveryService,
<a href="../../../../org/apache/twill/discovery/DiscoveryServiceClient.html" title="interface in org.apache.twill.discovery">DiscoveryServiceClient</a>&nbsp;discoveryServiceClient,
<a href="../../../../org/apache/twill/zookeeper/ZKClient.html" title="interface in org.apache.twill.zookeeper">ZKClient</a>&nbsp;zkClient,
int&nbsp;instanceCount,
int&nbsp;allowedMemoryMB,
int&nbsp;virtualCores)</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common">Cancellable</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#announce-java.lang.String-int-">announce</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;serviceName,
int&nbsp;port)</code>
<div class="block">Registers an endpoint that could be discovered by external party.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common">Cancellable</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#announce-java.lang.String-int-byte:A-">announce</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;serviceName,
int&nbsp;port,
byte[]&nbsp;payload)</code>
<div class="block">Registers an endpoint that could be discovered by external party with a payload.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html?is-external=true" title="class or interface in java.util.concurrent.locks">Lock</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#createLock-java.lang.String-">createLock</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</code>
<div class="block">Creates a <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html?is-external=true" title="class or interface in java.util.concurrent.locks"><code>Lock</code></a> for performing locking mechanism within the same <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/discovery/ServiceDiscovered.html" title="interface in org.apache.twill.discovery">ServiceDiscovered</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#discover-java.lang.String-">discover</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</code>
<div class="block">Discover service with the given name that is announced within the same <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common">Cancellable</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#electLeader-java.lang.String-org.apache.twill.api.ElectionHandler-">electLeader</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../../org/apache/twill/api/ElectionHandler.html" title="interface in org.apache.twill.api">ElectionHandler</a>&nbsp;participantHandler)</code>
<div class="block">Register to participate in a leader election by instances within the same <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getApplicationArguments--">getApplicationArguments</a></span>()</code>
<div class="block">Returns the runtime arguments that are passed to the <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getApplicationRunId--">getApplicationRunId</a></span>()</code>
<div class="block">Returns the <a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api"><code>RunId</code></a> of this running application.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getArguments--">getArguments</a></span>()</code>
<div class="block">Returns the runtime arguments that are passed to the <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html?is-external=true" title="class or interface in java.net">InetAddress</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getHost--">getHost</a></span>()</code>
<div class="block">Returns the hostname that the runnable is running on.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getInstanceCount--">getInstanceCount</a></span>()</code>
<div class="block">Returns the number of running instances assigned for this <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getInstanceId--">getInstanceId</a></span>()</code>
<div class="block">Returns an integer id from 0 to (instanceCount - 1).</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getMaxMemoryMB--">getMaxMemoryMB</a></span>()</code>
<div class="block">Returns the amount of memory in MB the runnable is allowed to use.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getRunId--">getRunId</a></span>()</code>
<div class="block">Returns the <a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api"><code>RunId</code></a> of this running instance of <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code><a href="../../../../org/apache/twill/api/TwillRunnableSpecification.html" title="interface in org.apache.twill.api">TwillRunnableSpecification</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getSpecification--">getSpecification</a></span>()</code>
<div class="block">Returns the <a href="../../../../org/apache/twill/api/TwillRunnableSpecification.html" title="interface in org.apache.twill.api"><code>TwillRunnableSpecification</code></a> that was created by <a href="../../../../org/apache/twill/api/TwillRunnable.html#configure--"><code>TwillRunnable.configure()</code></a>.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#getVirtualCores--">getVirtualCores</a></span>()</code>
<div class="block">Returns the number of virtual cores the runnable is allowed to use.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#setInstanceCount-int-">setInstanceCount</a></span>(int&nbsp;count)</code>&nbsp;</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/twill/internal/BasicTwillContext.html#stop--">stop</a></span>()</code>
<div class="block">Stops and frees any currently allocated resources.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="BasicTwillContext-org.apache.twill.api.RunId-org.apache.twill.api.RunId-java.net.InetAddress-java.lang.String:A-java.lang.String:A-org.apache.twill.api.TwillRunnableSpecification-int-org.apache.twill.discovery.DiscoveryService-org.apache.twill.discovery.DiscoveryServiceClient-org.apache.twill.zookeeper.ZKClient-int-int-int-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>BasicTwillContext</h4>
<pre>public&nbsp;BasicTwillContext(<a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a>&nbsp;runId,
<a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a>&nbsp;appRunId,
<a href="https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html?is-external=true" title="class or interface in java.net">InetAddress</a>&nbsp;host,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;appArgs,
<a href="../../../../org/apache/twill/api/TwillRunnableSpecification.html" title="interface in org.apache.twill.api">TwillRunnableSpecification</a>&nbsp;spec,
int&nbsp;instanceId,
<a href="../../../../org/apache/twill/discovery/DiscoveryService.html" title="interface in org.apache.twill.discovery">DiscoveryService</a>&nbsp;discoveryService,
<a href="../../../../org/apache/twill/discovery/DiscoveryServiceClient.html" title="interface in org.apache.twill.discovery">DiscoveryServiceClient</a>&nbsp;discoveryServiceClient,
<a href="../../../../org/apache/twill/zookeeper/ZKClient.html" title="interface in org.apache.twill.zookeeper">ZKClient</a>&nbsp;zkClient,
int&nbsp;instanceCount,
int&nbsp;allowedMemoryMB,
int&nbsp;virtualCores)</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getRunId--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getRunId</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a>&nbsp;getRunId()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getRunId--">TwillContext</a></code></span></div>
<div class="block">Returns the <a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api"><code>RunId</code></a> of this running instance of <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getRunId--">getRunId</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getApplicationRunId--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getApplicationRunId</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api">RunId</a>&nbsp;getApplicationRunId()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getApplicationRunId--">TwillContext</a></code></span></div>
<div class="block">Returns the <a href="../../../../org/apache/twill/api/RunId.html" title="interface in org.apache.twill.api"><code>RunId</code></a> of this running application.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getApplicationRunId--">getApplicationRunId</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getInstanceCount--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInstanceCount</h4>
<pre>public&nbsp;int&nbsp;getInstanceCount()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getInstanceCount--">TwillContext</a></code></span></div>
<div class="block">Returns the number of running instances assigned for this <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getInstanceCount--">getInstanceCount</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="setInstanceCount-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setInstanceCount</h4>
<pre>public&nbsp;void&nbsp;setInstanceCount(int&nbsp;count)</pre>
</li>
</ul>
<a name="getHost--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getHost</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html?is-external=true" title="class or interface in java.net">InetAddress</a>&nbsp;getHost()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getHost--">TwillContext</a></code></span></div>
<div class="block">Returns the hostname that the runnable is running on.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getHost--">getHost</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getArguments--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getArguments</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;getArguments()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getArguments--">TwillContext</a></code></span></div>
<div class="block">Returns the runtime arguments that are passed to the <a href="../../../../org/apache/twill/api/TwillRunnable.html" title="interface in org.apache.twill.api"><code>TwillRunnable</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getArguments--">getArguments</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getApplicationArguments--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getApplicationArguments</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;getApplicationArguments()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getApplicationArguments--">TwillContext</a></code></span></div>
<div class="block">Returns the runtime arguments that are passed to the <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getApplicationArguments--">getApplicationArguments</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getSpecification--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSpecification</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/api/TwillRunnableSpecification.html" title="interface in org.apache.twill.api">TwillRunnableSpecification</a>&nbsp;getSpecification()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getSpecification--">TwillContext</a></code></span></div>
<div class="block">Returns the <a href="../../../../org/apache/twill/api/TwillRunnableSpecification.html" title="interface in org.apache.twill.api"><code>TwillRunnableSpecification</code></a> that was created by <a href="../../../../org/apache/twill/api/TwillRunnable.html#configure--"><code>TwillRunnable.configure()</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getSpecification--">getSpecification</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getInstanceId--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInstanceId</h4>
<pre>public&nbsp;int&nbsp;getInstanceId()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getInstanceId--">TwillContext</a></code></span></div>
<div class="block">Returns an integer id from 0 to (instanceCount - 1).</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getInstanceId--">getInstanceId</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getVirtualCores--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getVirtualCores</h4>
<pre>public&nbsp;int&nbsp;getVirtualCores()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getVirtualCores--">TwillContext</a></code></span></div>
<div class="block">Returns the number of virtual cores the runnable is allowed to use.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getVirtualCores--">getVirtualCores</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="getMaxMemoryMB--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getMaxMemoryMB</h4>
<pre>public&nbsp;int&nbsp;getMaxMemoryMB()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#getMaxMemoryMB--">TwillContext</a></code></span></div>
<div class="block">Returns the amount of memory in MB the runnable is allowed to use.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#getMaxMemoryMB--">getMaxMemoryMB</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
</dl>
</li>
</ul>
<a name="announce-java.lang.String-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>announce</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common">Cancellable</a>&nbsp;announce(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;serviceName,
int&nbsp;port)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html#announce-java.lang.String-int-">ServiceAnnouncer</a></code></span></div>
<div class="block">Registers an endpoint that could be discovered by external party.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html#announce-java.lang.String-int-">announce</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html" title="interface in org.apache.twill.api">ServiceAnnouncer</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>serviceName</code> - Name of the endpoint</dd>
<dd><code>port</code> - Port of the endpoint</dd>
</dl>
</li>
</ul>
<a name="announce-java.lang.String-int-byte:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>announce</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common">Cancellable</a>&nbsp;announce(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;serviceName,
int&nbsp;port,
byte[]&nbsp;payload)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html#announce-java.lang.String-int-byte:A-">ServiceAnnouncer</a></code></span></div>
<div class="block">Registers an endpoint that could be discovered by external party with a payload.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html#announce-java.lang.String-int-byte:A-">announce</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/ServiceAnnouncer.html" title="interface in org.apache.twill.api">ServiceAnnouncer</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>serviceName</code> - Name of the endpoint</dd>
<dd><code>port</code> - Port of the endpoint</dd>
<dd><code>payload</code> - byte array payload</dd>
</dl>
</li>
</ul>
<a name="discover-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>discover</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/discovery/ServiceDiscovered.html" title="interface in org.apache.twill.discovery">ServiceDiscovered</a>&nbsp;discover(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#discover-java.lang.String-">TwillContext</a></code></span></div>
<div class="block">Discover service with the given name that is announced within the same <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#discover-java.lang.String-">discover</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/discovery/DiscoveryServiceClient.html#discover-java.lang.String-">discover</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/discovery/DiscoveryServiceClient.html" title="interface in org.apache.twill.discovery">DiscoveryServiceClient</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - Name of the service</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A <a href="../../../../org/apache/twill/discovery/ServiceDiscovered.html" title="interface in org.apache.twill.discovery"><code>ServiceDiscovered</code></a> object representing the result.</dd>
</dl>
</li>
</ul>
<a name="electLeader-java.lang.String-org.apache.twill.api.ElectionHandler-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>electLeader</h4>
<pre>public&nbsp;<a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common">Cancellable</a>&nbsp;electLeader(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name,
<a href="../../../../org/apache/twill/api/ElectionHandler.html" title="interface in org.apache.twill.api">ElectionHandler</a>&nbsp;participantHandler)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#electLeader-java.lang.String-org.apache.twill.api.ElectionHandler-">TwillContext</a></code></span></div>
<div class="block">Register to participate in a leader election by instances within the same <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#electLeader-java.lang.String-org.apache.twill.api.ElectionHandler-">electLeader</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - Unique name for the election</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A <a href="../../../../org/apache/twill/common/Cancellable.html" title="interface in org.apache.twill.common"><code>Cancellable</code></a> object representing this candidate's participation.</dd>
</dl>
</li>
</ul>
<a name="createLock-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>createLock</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html?is-external=true" title="class or interface in java.util.concurrent.locks">Lock</a>&nbsp;createLock(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;name)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html#createLock-java.lang.String-">TwillContext</a></code></span></div>
<div class="block">Creates a <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html?is-external=true" title="class or interface in java.util.concurrent.locks"><code>Lock</code></a> for performing locking mechanism within the same <a href="../../../../org/apache/twill/api/TwillApplication.html" title="interface in org.apache.twill.api"><code>TwillApplication</code></a>.
The lock created is a reentrant such that if the lock is owned by the current thread, it will return immediately.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../org/apache/twill/api/TwillContext.html#createLock-java.lang.String-">createLock</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/twill/api/TwillContext.html" title="interface in org.apache.twill.api">TwillContext</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>name</code> - Unique name for the lock</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>A <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html?is-external=true" title="class or interface in java.util.concurrent.locks"><code>Lock</code></a> object</dd>
</dl>
</li>
</ul>
<a name="stop--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>stop</h4>
<pre>public&nbsp;void&nbsp;stop()</pre>
<div class="block">Stops and frees any currently allocated resources.</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/BasicTwillContext.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/twill/internal/Arguments.html" title="class in org.apache.twill.internal"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/apache/twill/internal/CompositeService.html" title="class in org.apache.twill.internal"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/twill/internal/BasicTwillContext.html" target="_top">Frames</a></li>
<li><a href="BasicTwillContext.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2013-2020 <a href="http://www.apache.org">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>