congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TwillRunnable
Code IndexAdd Tabnine to your IDE (free)

How to use
TwillRunnable
in
org.apache.twill.api

Best Java code snippets using org.apache.twill.api.TwillRunnable (Showing top 19 results out of 315)

origin: org.apache.twill/twill-yarn

@Override
protected void doStop() throws Exception {
 commandExecutor.shutdownNow();
 try {
  runnable.destroy();
 } catch (Throwable t) {
  // Just catch the exception, not propagate it since it's already in shutdown sequence and
  // we want all twill services properly shutdown.
  LOG.warn("Exception when calling runnable.destroy.", t);
 } finally {
  context.stop();
 }
}
origin: apache/twill

 @Override
 public void run() {
  try {
   runnable.handleCommand(message.getCommand());
   result.set(messageId);
  } catch (Exception e) {
   result.setException(e);
  }
 }
});
origin: org.apache.twill/twill-yarn

@Override
protected void doRun() throws Exception {
 runnable.run();
}
origin: apache/twill

@Override
public RuntimeSpecificationAdder add(TwillRunnable runnable, ResourceSpecification resourceSpec) {
 return add(runnable.configure().getName(), runnable, resourceSpec);
}
origin: org.apache.twill/twill-yarn

@Override
protected void triggerShutdown() {
 try {
  runnable.stop();
 } catch (Throwable t) {
  LOG.error("Exception when stopping runnable.", t);
 }
}
origin: org.apache.twill/twill-yarn

@SuppressWarnings("unchecked")
@Override
protected void doStart() throws Exception {
 for (Map.Entry<String, String> entry : containerLiveNodeData.getLogLevels().entrySet()) {
  String loggerName = entry.getKey();
  String oldLogLevel = setLogLevel(loggerName, entry.getValue());
  if (!defaultLogLevels.containsKey(loggerName)) {
   oldLogLevels.put(loggerName, oldLogLevel);
  }
 }
 commandExecutor = Executors.newSingleThreadExecutor(
  Threads.createDaemonThreadFactory("runnable-command-executor"));
 Class<?> runnableClass = classLoader.loadClass(specification.getClassName());
 Preconditions.checkArgument(TwillRunnable.class.isAssignableFrom(runnableClass),
               "Class %s is not instance of TwillRunnable.", specification.getClassName());
 runnable = Instances.newInstance((Class<TwillRunnable>) runnableClass);
 runnable.initialize(context);
}
origin: org.apache.twill/twill-api

@Override
public RuntimeSpecificationAdder add(TwillRunnable runnable, ResourceSpecification resourceSpec) {
 return add(runnable.configure().getName(), runnable, resourceSpec);
}
origin: apache/twill

@Override
protected void triggerShutdown() {
 try {
  runnable.stop();
 } catch (Throwable t) {
  LOG.error("Exception when stopping runnable.", t);
 }
}
origin: apache/twill

@SuppressWarnings("unchecked")
@Override
protected void doStart() throws Exception {
 for (Map.Entry<String, String> entry : containerLiveNodeData.getLogLevels().entrySet()) {
  String loggerName = entry.getKey();
  String oldLogLevel = setLogLevel(loggerName, entry.getValue());
  if (!defaultLogLevels.containsKey(loggerName)) {
   oldLogLevels.put(loggerName, oldLogLevel);
  }
 }
 commandExecutor = Executors.newSingleThreadExecutor(
  Threads.createDaemonThreadFactory("runnable-command-executor"));
 Class<?> runnableClass = classLoader.loadClass(specification.getClassName());
 Preconditions.checkArgument(TwillRunnable.class.isAssignableFrom(runnableClass),
               "Class %s is not instance of TwillRunnable.", specification.getClassName());
 runnable = Instances.newInstance((Class<TwillRunnable>) runnableClass);
 runnable.initialize(context);
}
origin: org.apache.twill/twill-api

@Override
public RuntimeSpecificationAdder add(String name, TwillRunnable runnable,
                   final ResourceSpecification resourceSpec) {
 final TwillRunnableSpecification spec = new DefaultTwillRunnableSpecification(
                   runnable.getClass().getName(), name, runnable.configure().getConfigs());
 return new RuntimeSpecificationAdder(new LocalFileCompleter() {
  @Override
  public RunnableSetter complete(Collection<LocalFile> files) {
   runnables.put(spec.getName(), new DefaultRuntimeSpecification(spec.getName(), spec, resourceSpec, files));
   return RunnableSetter.this;
  }
 });
}
origin: org.apache.twill/twill-yarn

 @Override
 public void run() {
  try {
   runnable.handleCommand(message.getCommand());
   result.set(messageId);
  } catch (Exception e) {
   result.setException(e);
  }
 }
});
origin: apache/twill

@Override
protected void doRun() throws Exception {
 runnable.run();
}
origin: apache/twill

@Override
protected void doStop() throws Exception {
 commandExecutor.shutdownNow();
 try {
  runnable.destroy();
 } catch (Throwable t) {
  // Just catch the exception, not propagate it since it's already in shutdown sequence and
  // we want all twill services properly shutdown.
  LOG.warn("Exception when calling runnable.destroy.", t);
 } finally {
  context.stop();
 }
}
origin: org.apache.twill/twill-api

@Override
public RuntimeSpecificationAdder add(TwillRunnable runnable) {
 return add(runnable.configure().getName(), runnable);
}
origin: apache/twill

@Override
public RuntimeSpecificationAdder add(String name, TwillRunnable runnable,
                   final ResourceSpecification resourceSpec) {
 final TwillRunnableSpecification spec = new DefaultTwillRunnableSpecification(
                   runnable.getClass().getName(), name, runnable.configure().getConfigs());
 return new RuntimeSpecificationAdder(new LocalFileCompleter() {
  @Override
  public RunnableSetter complete(Collection<LocalFile> files) {
   runnables.put(spec.getName(), new DefaultRuntimeSpecification(spec.getName(), spec, resourceSpec, files));
   return RunnableSetter.this;
  }
 });
}
origin: apache/twill

@Override
public RuntimeSpecificationAdder add(TwillRunnable runnable) {
 return add(runnable.configure().getName(), runnable);
}
origin: cdapio/cdap

 @Override
 public TwillSpecification configure() {
  TwillRunnableSpecification runnableSpec = runnable.configure();
  return TwillSpecification.Builder.with()
   .setName(runnableSpec.getName())
   .withRunnable().add(runnableSpec.getName(), runnable, resourceSpec)
   .noLocalFiles()
   .anyOrder()
   .build();
 }
}
origin: org.apache.twill/twill-core

 @Override
 public TwillSpecification configure() {
  TwillRunnableSpecification runnableSpec = runnable.configure();
  return TwillSpecification.Builder.with()
   .setName(runnableSpec.getName())
   .withRunnable().add(runnableSpec.getName(), runnable, resourceSpec)
   .noLocalFiles()
   .anyOrder()
   .build();
 }
}
origin: apache/twill

 @Override
 public TwillSpecification configure() {
  TwillRunnableSpecification runnableSpec = runnable.configure();
  return TwillSpecification.Builder.with()
   .setName(runnableSpec.getName())
   .withRunnable().add(runnableSpec.getName(), runnable, resourceSpec)
   .noLocalFiles()
   .anyOrder()
   .build();
 }
}
org.apache.twill.apiTwillRunnable

Javadoc

The TwillRunnable interface should be implemented by any class whose instances are intended to be executed in a Twill cluster.

Most used methods

  • configure
    Called at submission time. Executed on the client side.
  • destroy
    Called when the TwillRunnable#run() completed. Useful for doing resource cleanup. This method would
  • handleCommand
    Called when a command is received. A normal return denotes the command has been processed successful
  • initialize
    Called when the container process starts. Executed in container machine. If any exception is thrown
  • run
  • stop
    Requests to stop the running service.

Popular in Java

  • Reading from database using SQL prepared statement
  • getContentResolver (Context)
  • getSystemService (Context)
  • findViewById (Activity)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • ImageIO (javax.imageio)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now