backtype.storm.task.TopologyContext.getPIDDir()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中backtype.storm.task.TopologyContext.getPIDDir()方法的一些代码示例,展示了TopologyContext.getPIDDir()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TopologyContext.getPIDDir()方法的具体详情如下:
包路径:backtype.storm.task.TopologyContext
类名称:TopologyContext
方法名:getPIDDir

TopologyContext.getPIDDir介绍

[英]If this task spawns any subprocesses, those subprocesses must immediately write their PID to this directory on the local filesystem to ensure that Storm properly destroys that process when the worker is shutdown.
[中]如果此任务生成任何子进程,这些子进程必须立即将其PID写入本地文件系统上的该目录,以确保在工作进程关闭时Storm正确地销毁该进程。

代码示例

代码示例来源:origin: alibaba/jstorm

public Number connect(Map conf, TopologyContext context) throws IOException, NoOutputException {
  JSONObject setupInfo = new JSONObject();
  setupInfo.put("pidDir", context.getPIDDir());
  setupInfo.put("conf", conf);
  setupInfo.put("context", context);
  writeMessage(setupInfo);
  return (Number) ((JSONObject) readMessage()).get("pid");
}

代码示例来源:origin: alibaba/mdrill

private String initializeSubprocess(TopologyContext context) {
  //can change this to launchSubprocess and have it return the pid (that the subprcess returns)
  ProcessBuilder builder = new ProcessBuilder(command);
  builder.directory(new File(context.getCodeDir()));
  try {
    _subprocess = builder.start();
    _processin = new DataOutputStream(_subprocess.getOutputStream());
    _processout = new BufferedReader(new InputStreamReader(_subprocess.getInputStream()));
    sendToSubprocess(context.getPIDDir());
    //subprocesses must send their pid first thing
    String subpid = _processout.readLine();
    LOG.info("Launched subprocess with pid " + subpid);
    return subpid;
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.n3twork.storm/storm-core

public Number connect(Map conf, TopologyContext context)
    throws IOException, NoOutputException {
  JSONObject setupInfo = new JSONObject();
  setupInfo.put("pidDir", context.getPIDDir());
  setupInfo.put("conf", conf);
  setupInfo.put("context", context);
  writeMessage(setupInfo);
  Number pid = (Number) ((JSONObject) readMessage()).get("pid");
  return pid;
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

public Number connect(Map conf, TopologyContext context) throws IOException, NoOutputException {
  JSONObject setupInfo = new JSONObject();
  setupInfo.put("pidDir", context.getPIDDir());
  setupInfo.put("conf", conf);
  setupInfo.put("context", context);
  writeMessage(setupInfo);
  Number pid = (Number) ((JSONObject) readMessage()).get("pid");
  return pid;
}

相关文章

微信公众号

最新文章

更多