org.apache.ignite.Ignite.cluster()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(173)

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

Ignite.cluster介绍

[英]Gets an instance of IgniteCluster interface.
[中]获取IgniteCluster接口的实例。

代码示例

代码示例来源:origin: apache/ignite

/**
 * Gets ID of the local node.
 *
 * @return ID of the local node.
 */
public UUID getLocalNodeId() {
  return ignite.cluster().localNode().id();
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public int getTotalBaselineNodes() {
  Collection<BaselineNode> baselineNodes = cluster.ignite().cluster().currentBaselineTopology();
  return baselineNodes != null ? baselineNodes.size() : 0;
}

代码示例来源:origin: apache/ignite

/**
 * Tests that a job is not cancelled if there are no
 * available thief nodes in projection.
 *
 * @throws Exception If failed.
 */
@Test
public void testSingleNodeProjection() throws Exception {
  ClusterGroup prj = ignite1.cluster().forNodeIds(Collections.singleton(ignite1.cluster().localNode().id()));
  executeAsync(compute(prj), new JobStealingSpreadTask(2), null).get(TASK_EXEC_TIMEOUT_MS);
  assertEquals(1, jobDistrMap.keySet().size());
  assertEquals(2, jobDistrMap.get(ignite1.cluster().localNode().id()).size());
}

代码示例来源:origin: apache/ignite

@Override public boolean apply() {
    // (SRV_NODES + 1 client node) - 1 primary - backup nodes.
    return qryClient.cluster().nodes().size() == (SRV_NODES + 1 /* client node */)
      - 1 /* Primary node */ - backups;
  }
}, 5000L);

代码示例来源:origin: apache/ignite

/**
 * Test 2 jobs on 1 node with null predicate using string task name.
 *
 * @throws IgniteCheckedException If test failed.
 */
@Test
public void testTwoJobsTaskNameNullPredicate() throws IgniteCheckedException {
  executeAsync(ignite1.compute(), JobStealingSingleNodeTask.class.getName(), null).get(TASK_EXEC_TIMEOUT_MS);
  // Verify that 1 job was stolen by second node.
  assertEquals(2, jobDistrMap.keySet().size());
  assertEquals(1, jobDistrMap.get(ignite1.cluster().localNode().id()).size());
  assertEquals(1, jobDistrMap.get(ignite2.cluster().localNode().id()).size());
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public UUID getLocalNodeId() {
  return spiAdapter.ignite.cluster().localNode().id();
}

代码示例来源:origin: apache/ignite

@Override public boolean apply() {
    return ignite1.cluster().nodes().size() == 3;
  }
}, 20000L);

代码示例来源:origin: apache/ignite

/**
 * Test 2 jobs on 1 node.
 *
 * @throws IgniteCheckedException If test failed.
 */
@Test
public void testTwoJobs() throws IgniteCheckedException {
  executeAsync(ignite1.compute(), new JobStealingSingleNodeTask(2), null).get(TASK_EXEC_TIMEOUT_MS);
  // Verify that 1 job was stolen by second node.
  assertEquals(2, jobDistrMap.keySet().size());
  assertEquals(1, jobDistrMap.get(ignite1.cluster().localNode().id()).size());
  assertEquals(1, jobDistrMap.get(ignite2.cluster().localNode().id()).size());
}

代码示例来源:origin: apache/ignite

@Override public UUID apply(Ignite g) {
    return g.cluster().localNode().id();
  }
});

代码示例来源:origin: apache/ignite

@Override public boolean apply() {
    ClusterGroup grp = client.cluster().forCacheNodes(DEFAULT_CACHE_NAME);
    return grp.nodes().size() == expNodes;
  }
}, 5000);

代码示例来源:origin: apache/ignite

/**
 * Test 2 jobs on 1 node with null predicate.
 *
 * @throws IgniteCheckedException If test failed.
 */
@Test
public void testTwoJobsNullPredicate() throws IgniteCheckedException {
  executeAsync(ignite1.compute(), new JobStealingSingleNodeTask(2), null).get(TASK_EXEC_TIMEOUT_MS);
  // Verify that 1 job was stolen by second node.
  assertEquals(2, jobDistrMap.keySet().size());
  assertEquals(1, jobDistrMap.get(ignite1.cluster().localNode().id()).size());
  assertEquals(1, jobDistrMap.get(ignite2.cluster().localNode().id()).size());
}

代码示例来源:origin: apache/ignite

/**
   * Resolves TensorFlow cluster chief job and acquires ports.
   *
   * @param spec TensorFlow cluster specification.
   */
  private void resolveAndAcquirePortsForChief(TensorFlowClusterSpec spec) {
    ClusterNode chiefNode = ignite.cluster().localNode();
    UUID chiefNodeId = chiefNode.id();
    int chiefPort = portMgr.acquirePort(chiefNodeId);

    spec.addTask(CHIEF_JOB_NAME, chiefNodeId, chiefPort);
  }
}

代码示例来源:origin: apache/ignite

@Override public boolean apply() {
    ClusterGroup grp = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME);
    return grp.nodes().size() == expNodes;
  }
}, 5000);

代码示例来源:origin: apache/ignite

/**
   * @param g Grid.
   * @param tm Transaction manager.
   */
  private void checkTm(Ignite g, IgniteTxManager tm) {
    Collection<IgniteInternalTx> txs = tm.activeTransactions();

    info(">>> Number of transactions in the set [size=" + txs.size() +
      ", nodeId=" + g.cluster().localNode().id() + ']');

    for (IgniteInternalTx tx : txs)
      assert tx.done() : "Transaction is not finished: " + tx;
  }
}

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    latch.await();
    Ignite g = startGrid("client-" + clientIdx.getAndIncrement());
    clientNodeIds.add(g.cluster().localNode().id());
    return null;
  }
}, CLIENTS, "start-client");

代码示例来源:origin: apache/ignite

@Override public Object call() throws Exception {
    long start = U.currentTimeMillis();
    Ignite grid = startGrid(Thread.currentThread().getName());
    System.out.println(
      ">>> Time to start: " + (U.currentTimeMillis() - start) +
        ", topSize=" + grid.cluster().nodes().size());
    return null;
  }
},

代码示例来源:origin: apache/ignite

/**
 * @throws Exception In case of error.
 */
@Test
public void testRemoteNodeEventStorage() throws Exception {
  IgnitePredicate<Event> filter = new TestEventFilter();
  generateEvents(ignite2);
  ClusterGroup prj = ignite1.cluster().forPredicate(F.remoteNodes(ignite1.cluster().localNode().id()));
  Collection<Event> evts = events(prj).remoteQuery(filter, 0);
  assert evts != null;
  assert evts.size() == 1;
}

代码示例来源:origin: apache/ignite

@Override public void run() {
    try {
      Ignite g3 = startGrid(3);
      info(">>> Started grid g3: " + g3.cluster().localNode().id());
    }
    catch (Exception e) {
      info(">>> Failed to start 4th node: " + e);
    }
  }
}, 1);

代码示例来源:origin: apache/ignite

@Override public boolean apply() {
    return ignite(0).cluster().forCacheNodes(cacheName).nodes().size() == 5;
  }
}, 5000);

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
  @Nullable @Override public Object execute() {
    try {
      Thread.sleep(50); // Short sleep for cancellation tests.
    }
    catch (InterruptedException ignored) {
      // No-op.
    }
    return ignite.cluster().localNode().id();
  }
}

相关文章