com.enioka.jqm.model.Node类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(134)

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

Node介绍

[英]Not part of any API - this an internal JQM class and may change without notice.
Persistence class for storing the definition of the different nodes that are member of the JMQ cluster.
There can be some confusion between terms: an engine is a Java process that represents a Node. There can only be one engine running the same Node at the same time.

A node is the holder of all the parameters needed for the engine to run: a list of Queues to poll (through DeploymentParameters), the different TCP ports to use, etc.
[中]不是任何API的一部分-这是一个内部JQM类,可能会在不通知的情况下更改。
持久性类,用于存储作为JMQ集群成员的不同节点的定义。
术语之间可能存在一些混淆:engine是表示节点的Java进程。同一时间只能有一个引擎运行同一个节点。
节点拥有引擎运行所需的所有参数:要轮询的队列列表(通过DeploymentParameters)、要使用的不同TCP端口等。

代码示例

代码示例来源:origin: com.enioka.jqm/jqm-engine

jqmlogger.info("\tfile produced storage directory: " + n.getDlRepo());
jqmlogger.info("\tHTTP listening interface: " + n.getDns());
jqmlogger.info("\tlooks for payloads inside: " + n.getRepo());
jqmlogger.info("\tlog level: " + n.getRootLogLevel());
jqmlogger.info("\ttemp files will be created inside: " + n.getTmpDirectory());
jqmlogger.info("\tJMX registry port: " + n.getJmxRegistryPort());
jqmlogger.info("\tJMX server port: " + n.getJmxServerPort());
jqmlogger.info("\tHTTP listening port: " + n.getPort());
jqmlogger.info("\tAPI admin enabled: " + n.getLoadApiAdmin());
jqmlogger.info("\tAPI client enabled: " + n.getLoadApiClient());
jqmlogger.info("\tAPI simple enabled: " + n.getLoapApiSimple());
List<DeploymentParameter> dps = DeploymentParameter.select(cnx, "dp_select_for_node", n.getId());
for (DeploymentParameter dp : dps)

代码示例来源:origin: com.enioka.jqm/jqm-engine

node = Node.select_single(cnx, "node_select_by_key", nodeName);
if (node.getLastSeenAlive() != null
    && Calendar.getInstance().getTimeInMillis() - node.getLastSeenAlive().getTimeInMillis() <= toWait)
  long r = Calendar.getInstance().getTimeInMillis() - node.getLastSeenAlive().getTimeInMillis();
  throw new JqmInitErrorTooSoon("Another engine named " + nodeName + " was running less than " + r / 1000
      + " seconds ago. Either stop the other node, or if it already stopped, please wait " + (toWait - r) / 1000
    + (node.getLastSeenAlive() == null ? "" : ft.format(node.getLastSeenAlive().getTime())));
QueryResult qr = cnx.runUpdate("node_update_alive_by_id", node.getId());
cnx.commit();
if (qr.nbUpdated == 0)
if (node.getJmxRegistryPort() != null && node.getJmxServerPort() != null && node.getJmxRegistryPort() > 0
    && node.getJmxServerPort() > 0)
  JmxAgent.registerAgent(node.getJmxRegistryPort(), node.getJmxServerPort(), node.getDns());
if (node.getJmxServerPort() != null && node.getJmxServerPort() > 0)
    name = new ObjectName("com.enioka.jqm:type=Node,name=" + this.node.getName());
    mbs.registerMBean(this, name);
JqmEngine.latestNodeStartedName = node.getName();
if (this.handler != null)

代码示例来源:origin: com.enioka.jqm/jqm-engine

nodeId = Node.create(cnx, nodeName, port, System.getProperty("user.dir") + "/jobs/", System.getProperty("user.dir") + "/jobs/",
    System.getProperty("user.dir") + "/tmp/", "localhost", "INFO").getId();
cnx.commit();

代码示例来源:origin: enioka/jqm

@Override
  public String getWebApiLocalUrl(DbConn cnx)
  {
    // Do not use port from engine.getNode, as it may have been set AFTER engine startup.
    Node node = Node.select_single(cnx, "node_select_by_id", this.engine.getNode().getId());
    boolean useSsl = Boolean.parseBoolean(GlobalParameter.getParameter(cnx, "enableWsApiSsl", "false"));
    return (useSsl ? "https://localhost:" : "http://localhost:") + node.getPort();
  }
}

代码示例来源:origin: com.enioka.jqm/jqm-service

if (!this.logLevel.equals(node.getRootLogLevel()))
  this.logLevel = node.getRootLogLevel();
  CommonService.setLogLevel(this.logLevel);
String np = node.getDns() + node.getPort() + node.getLoadApiAdmin() + node.getLoadApiClient() + node.getLoapApiSimple();
if (nodePrms == null)

代码示例来源:origin: com.enioka.jqm/jqm-service

webAppContext.setInitParameter("jqmnode", node.getName());
webAppContext.setInitParameter("jqmnodeid", node.getId().toString());

代码示例来源:origin: enioka/jqm

/**
 * See {@link #getNode()}
 */
public void setNode(final Node node)
{
  this.n = node;
  this.node_id = node.getId();
}

代码示例来源:origin: com.enioka.jqm/jqm-service

if (!node.getLoadApiAdmin() && !node.getLoadApiClient() && !node.getLoapApiSimple())
    JdbcCa.prepareWebServerStores(cnx, "CN=" + node.getDns(), "./conf/keystore.pfx", "./conf/trusted.jks", pfxPassword,
        node.getDns(), "./conf/server.cer", "./conf/ca.cer");
  InetAddress[] adresses = InetAddress.getAllByName(node.getDns());
  for (InetAddress s : adresses)
      if (node.getDns().equals("0.0.0.0"))
        connector.setPort(node.getPort());
        ls.add(connector);
        jqmlogger.debug("Jetty will bind on all interfaces on port " + node.getPort());
      else if (s.isLoopbackAddress() || "localhost".equals(node.getDns()))
        connector.setPort(node.getPort());
        ls.add(connector);
        jqmlogger.debug("Jetty will bind on loopback - localhost:" + node.getPort());
        connector.setPort(node.getPort());
        ls.add(connector);
        jqmlogger.debug("Jetty will bind on " + s.getHostAddress() + ":" + node.getPort());
  jqmlogger.warn("Could not resolve name " + node.getDns() + ". Will bind on all interfaces.");
  Connector connector = new SelectChannelConnector();
  connector.setHost(null);
  connector.setPort(node.getPort());
  ls.add(connector);

代码示例来源:origin: com.enioka.jqm/jqm-engine

static void checkConfiguration(String nodeName, DbConn cnx)
  List<Node> nodes = Node.select(cnx, "node_select_by_key", nodeName);
  if (nodes.size() == 0)
  if (!StringUtils.hasText(nn.getDlRepo()) || !StringUtils.hasText(nn.getRepo()) || !StringUtils.hasText(nn.getTmpDirectory()))
  int i = cnx.runSelectSingle("dp_select_count_for_node", Integer.class, nn.getId());
  if (i == 0)

代码示例来源:origin: enioka/jqm

int port = Node.select_single(cnx, "node_select_by_id", TestHelpers.node.getId()).getPort();
HttpUriRequest rq = new HttpGet("https://" + TestHelpers.node.getDns() + ":" + port + "/ws/simple/status?id=" + i);
jqmlogger.debug(rq.getURI().toString());
CloseableHttpResponse rs = cl.execute(rq);

代码示例来源:origin: enioka/jqm

/**
 * This actually starts the different engines configured with {@link #addNode(String)}.<br>
 * This can usually only be called once (it can actually be called again but only after calling {@link #stop()}).
 */
public JqmAsyncTester start()
{
  if (hasStarted)
  {
    throw new IllegalStateException("cannot start twice");
  }
  if (nodes.isEmpty())
  {
    throw new IllegalStateException("no engines defined");
  }
  if (queues.isEmpty())
  {
    throw new IllegalStateException("no queues defined");
  }
  if (!oneQueueDeployed)
  {
    throw new IllegalStateException("no queue was ever deployed to any node");
  }
  hasStarted = true;
  for (Node n : nodes.values())
  {
    engines.put(n.getName(), JqmEngineFactory.startEngine(n.getName(), null));
  }
  return this;
}

代码示例来源:origin: com.enioka.jqm/jqm-runner-shell

pb.directory(new File(this.ji.getNode().getRepo()));
pb.redirectErrorStream(false);
env.put("JQM_JI_DELIVERY_DIR", this.deliveryDir.getAbsolutePath());
env.put("JQM_NODE_NAME", this.ji.getNode().getName());
env.put("JQM_NODE_APPLICATION_ROOT", this.ji.getNode().getRepo());
env.put("JQM_NODE_LOG_LEVEL", this.ji.getNode().getRootLogLevel());

代码示例来源:origin: enioka/jqm

@Before
public void before() throws IOException
{
  Helpers.setSingleParam("disableWsApi", "false", cnx);
  Helpers.setSingleParam("enableWsApiAuth", "false", cnx);
  File jar = FileUtils.listFiles(new File("../jqm-ws/target/"), new String[] { "war" }, false).iterator().next();
  FileUtils.copyFile(jar, new File("./webapp/jqm-ws.war"));
  addAndStartEngine();
  TestHelpers.node = Node.select_single(cnx, "node_select_by_id", TestHelpers.node.getId());
}

代码示例来源:origin: com.enioka.jqm/jqm-engine

node = Node.select_single(cnx, "node_select_by_id", node.getId());
if (node == null || node.isStop())
cnx.runUpdate("node_update_alive_by_id", node.getId());
cnx.commit();
  ResultSet rs = cnx.runSelect("ji_select_instructions_by_node", node.getId());
  while (rs.next())

代码示例来源:origin: com.enioka.jqm/jqm-tst

/**
   * Version of {@link JqmClient#getDeliverableContent(Deliverable)} which does not require the web service APIs to be enabled to work.
   * Also, returned files do not self-destruct on stream close.<br>
   * See the javadoc of the original method for details.
   * 
   * @throws FileNotFoundException
   */
  public InputStream getDeliverableContent(Deliverable file) throws FileNotFoundException
  {
    List<com.enioka.jqm.model.Deliverable> dd = com.enioka.jqm.model.Deliverable.select(cnx, "deliverable_select_by_id", file.getId());
    if (dd.isEmpty())
    {
      throw new JqmInvalidRequestException("no deliverable with this ID");
    }

    com.enioka.jqm.model.Deliverable d = dd.get(0);
    JobInstance ji = Query.create().setJobInstanceId(d.getJobId()).run().get(0);
    String nodeName = ji.getNodeName();
    Node n = nodes.get(nodeName);

    return new FileInputStream(FilenameUtils.concat(n.getDlRepo(), file.getFilePath()));
  }
}

代码示例来源:origin: com.enioka.jqm/jqm-test-helpers

TestHelpers.node = Node.create(cnx, "localhost", 0, "./target/outputfiles/", "./../", "./target/tmp", dns, "DEBUG");
TestHelpers.node2 = Node.create(cnx, "localhost2", 0, "./target/outputfiles/", "./../", "./target/tmp", dns, "DEBUG");
TestHelpers.node3 = Node.create(cnx, "localhost3", 0, "./target/outputfiles/", "./../", "./target/tmp", dns, "DEBUG");
TestHelpers.nodeMix = Node.create(cnx, "localhost4", 0, "./target/outputfiles/", "./../", "./target/tmp", dns, "DEBUG");
TestHelpers.nodeMix2 = Node.create(cnx, "localhost5", 0, "./target/outputfiles/", "./../", "./target/tmp", dns, "DEBUG");
TestHelpers.dpSlow3 = DeploymentParameter.create(cnx, node3, 1, 1000, qSlow3);
if (!(new File(TestHelpers.node.getDlRepo())).isDirectory() && !(new File(TestHelpers.node.getDlRepo())).mkdir())

代码示例来源:origin: com.enioka.jqm/jqm-tst

/**
 * Create a new node. It is not started by this method.<br>
 * This must be called before starting the tester.
 * 
 * @param nodeName
 *            the name of the node. Must be unique.
 */
public JqmAsyncTester addNode(String nodeName)
{
  if (hasStarted)
  {
    throw new IllegalStateException("tester has already started");
  }
  File resDirectoryPath = Common.createTempDirectory();
  Node node = Node.create(cnx, nodeName, 12, resDirectoryPath.getAbsolutePath(), ".", resDirectoryPath.getAbsolutePath(), "test",
      logLevel);
  cnx.commit();
  nodes.put(nodeName, node);
  setNodesLogLevel(logLevel);
  return this;
}

代码示例来源:origin: enioka/jqm

/**
 * Returns true if the libraries should be loaded in cache. Two cases: never loaded and should be reloaded (jar is more recent than
 * cache)
 */
private boolean shouldLoad(Node node, JobDef jd)
{
  if (!cache.containsKey(jd.getApplicationName()))
  {
    return true;
  }
  // If here: cache exists.
  JobDefLibrary libs = cache.get(jd.getApplicationName());
  // Is cache stale?
  Date lastLoaded = libs.loadTime;
  File jarFile = new File(FilenameUtils.concat(new File(node.getRepo()).getAbsolutePath(), jd.getJarPath()));
  File jarDir = jarFile.getParentFile();
  File libDir = new File(FilenameUtils.concat(jarDir.getAbsolutePath(), "lib"));
  if (lastLoaded.before(new Date(jarFile.lastModified())) || lastLoaded.before(new Date(jarDir.lastModified()))
      || lastLoaded.before(new Date(libDir.lastModified())))
  {
    jqmlogger.info("The cache for application " + jd.getApplicationName() + " will be reloaded");
    return true;
  }
  // If here, the cache is OK
  return false;
}

代码示例来源:origin: com.enioka.jqm/jqm-admin

Node n = Node.select_single(cnx, "node_select_by_id", id);
Calendar limit = Calendar.getInstance();
limit.add(Calendar.MINUTE, -10);
if (n.getLastSeenAlive() != null && n.getLastSeenAlive().after(limit))

代码示例来源:origin: enioka/jqm

42, "Marsu-Application", null, "Franquin", "ModuleMachin", "other", "other", true, cnx);
HttpPost post = new HttpPost("http://" + TestHelpers.node.getDns() + ":" + TestHelpers.node.getPort() + "/ws/simple/ji");
List<NameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair("applicationname", "Marsu-Application"));
HttpGet rq = new HttpGet("http://" + TestHelpers.node.getDns() + ":" + TestHelpers.node.getPort() + "/ws/simple/status?id=" + jid);
res = client.execute(rq);
Assert.assertEquals(200, res.getStatusLine().getStatusCode());

相关文章