use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.
the class ClusterMetricsSnapshot method oldest.
/**
* Gets the oldest node in given collection.
*
* @param nodes Nodes.
* @return Oldest node or {@code null} if collection is empty.
*/
@Nullable
private static ClusterNode oldest(Collection<ClusterNode> nodes) {
long min = Long.MAX_VALUE;
ClusterNode oldest = null;
for (ClusterNode n : nodes) if (n.order() < min) {
min = n.order();
oldest = n;
}
return oldest;
}
use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.
the class IgniteKernal method ackStart.
/**
* Prints start info.
*
* @param rtBean Java runtime bean.
*/
private void ackStart(RuntimeMXBean rtBean) {
ClusterNode locNode = localNode();
if (log.isQuiet()) {
U.quiet(false, "");
U.quiet(false, "Ignite node started OK (id=" + U.id8(locNode.id()) + (F.isEmpty(igniteInstanceName) ? "" : ", instance name=" + igniteInstanceName) + ')');
}
if (log.isInfoEnabled()) {
log.info("");
String ack = "Ignite ver. " + VER_STR + '#' + BUILD_TSTAMP_STR + "-sha1:" + REV_HASH_STR;
String dash = U.dash(ack.length());
SB sb = new SB();
for (GridPortRecord rec : ctx.ports().records()) sb.a(rec.protocol()).a(":").a(rec.port()).a(" ");
String str = NL + NL + ">>> " + dash + NL + ">>> " + ack + NL + ">>> " + dash + NL + ">>> OS name: " + U.osString() + NL + ">>> CPU(s): " + locNode.metrics().getTotalCpus() + NL + ">>> Heap: " + U.heapSize(locNode, 2) + "GB" + NL + ">>> VM name: " + rtBean.getName() + NL + (igniteInstanceName == null ? "" : ">>> Ignite instance name: " + igniteInstanceName + NL) + ">>> Local node [" + "ID=" + locNode.id().toString().toUpperCase() + ", order=" + locNode.order() + ", clientMode=" + ctx.clientNode() + "]" + NL + ">>> Local node addresses: " + U.addressesAsString(locNode) + NL + ">>> Local ports: " + sb + NL;
log.info(str);
}
}
use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.
the class GridifyDefaultRangeTask method map.
/** {@inheritDoc} */
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, GridifyRangeArgument arg) {
assert !subgrid.isEmpty() : "Subgrid should not be empty: " + subgrid;
assert ignite != null : "Grid instance could not be injected";
if (splitSize < threshold && splitSize != 0 && threshold != 0) {
throw new IgniteException("Incorrect Gridify annotation parameters. Value for parameter " + "'splitSize' should not be less than parameter 'threshold' [splitSize=" + splitSize + ", threshold=" + threshold + ']');
}
Collection<ClusterNode> exclNodes = new LinkedList<>();
// Filter nodes.
if (nodeFilter != null) {
for (ClusterNode node : subgrid) {
if (!nodeFilter.apply(node, ses))
exclNodes.add(node);
}
if (exclNodes.size() == subgrid.size())
throw new IgniteException("Failed to execute on grid where all nodes excluded.");
}
int inputPerNode = splitSize;
// Calculate input elements size per node for default annotation splitSize parameter.
if (splitSize <= 0) {
// For iterable input splitSize will be assigned with threshold value.
if (threshold > 0 && arg.getInputSize() == UNKNOWN_SIZE)
inputPerNode = threshold;
else // Otherwise, splitSize equals (inputSize / nodesCount)
{
assert arg.getInputSize() != UNKNOWN_SIZE;
int gridSize = subgrid.size() - exclNodes.size();
gridSize = (gridSize <= 0 ? subgrid.size() : gridSize);
inputPerNode = calculateInputSizePerNode(gridSize, arg.getInputSize(), threshold, limitedSplit);
if (log.isDebugEnabled()) {
log.debug("Calculated input elements size per node [inputSize=" + arg.getInputSize() + ", gridSize=" + gridSize + ", threshold=" + threshold + ", limitedSplit=" + limitedSplit + ", inputPerNode=" + inputPerNode + ']');
}
}
}
GridifyArgumentBuilder argBuilder = new GridifyArgumentBuilder();
Iterator<?> inputIter = arg.getInputIterator();
while (inputIter.hasNext()) {
Collection<Object> nodeInput = new LinkedList<>();
for (int i = 0; i < inputPerNode && inputIter.hasNext(); i++) nodeInput.add(inputIter.next());
// Create job argument.
GridifyArgument jobArg = argBuilder.createJobArgument(arg, nodeInput);
ComputeJob job = new GridifyJobAdapter(jobArg);
mapper.send(job, balancer.getBalancedNode(job, exclNodes));
}
// Map method can return null because job already sent by continuous mapper.
return null;
}
use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.
the class GridifyDefaultTask method map.
/** {@inheritDoc} */
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, GridifyArgument arg) {
assert !subgrid.isEmpty() : "Subgrid should not be empty: " + subgrid;
assert ignite != null : "Grid instance could not be injected";
assert balancer != null : "Load balancer could not be injected";
ComputeJob job = new GridifyJobAdapter(arg);
ClusterNode node = balancer.getBalancedNode(job, Collections.<ClusterNode>singletonList(ignite.cluster().localNode()));
if (node != null) {
// Give preference to remote nodes.
return Collections.singletonMap(job, node);
}
return Collections.singletonMap(job, balancer.getBalancedNode(job, null));
}
use of org.apache.ignite.cluster.ClusterNode in project ignite by apache.
the class ClusterGroupAdapter method node.
/** {@inheritDoc} */
@Override
public final ClusterNode node(UUID id) {
A.notNull(id, "id");
guard();
try {
if (ids != null)
return ids.contains(id) ? ctx.discovery().node(id) : null;
else {
ClusterNode node = ctx.discovery().node(id);
return node != null && (p == null || p.apply(node)) ? node : null;
}
} finally {
unguard();
}
}
Aggregations