本文整理汇总了Java中org.apache.ignite.cluster.ClusterNode.attribute方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterNode.attribute方法的具体用法?Java ClusterNode.attribute怎么用?Java ClusterNode.attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.cluster.ClusterNode
的用法示例。
在下文中一共展示了ClusterNode.attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateBinaryConfiguration
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** */
private IgniteNodeValidationResult validateBinaryConfiguration(ClusterNode rmtNode) {
Object rmtBinaryCfg = rmtNode.attribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION);
ClusterNode locNode = ctx.discovery().localNode();
Object locBinaryCfg = locNode.attribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION);
if (!F.eq(locBinaryCfg, rmtBinaryCfg)) {
String msg = "Local node's binary configuration is not equal to remote node's binary configuration " +
"[locNodeId=%s, rmtNodeId=%s, locBinaryCfg=%s, rmtBinaryCfg=%s]";
return new IgniteNodeValidationResult(rmtNode.id(),
String.format(msg, locNode.id(), rmtNode.id(), locBinaryCfg, rmtBinaryCfg),
String.format(msg, rmtNode.id(), locNode.id(), rmtBinaryCfg, locBinaryCfg));
}
return null;
}
示例2: apply
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public boolean apply(ClusterNode node) {
String igniteInstanceName = node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME);
for (String attr : attrs) {
if (F.eq(attr, igniteInstanceName))
return true;
}
return false;
}
示例3: productVersion
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* Gets node product version based on node attributes.
*
* @param node Node to get version from.
* @return Version object.
*/
public static IgniteProductVersion productVersion(ClusterNode node) {
String verStr = node.attribute(ATTR_BUILD_VER);
String buildDate = node.attribute(ATTR_BUILD_DATE);
if (buildDate != null)
verStr += '-' + buildDate;
return IgniteProductVersion.fromString(verStr);
}
示例4: checkAttributePresence
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* Checks that node has specified attribute and prints warning if it does not.
*
* @param node Node to check.
* @param attrName Name of the attribute.
*/
private void checkAttributePresence(ClusterNode node, String attrName) {
if (node.attribute(attrName) == null)
U.warn(log, "Remote node has inconsistent configuration (required attribute was not found) " +
"[attrName=" + attrName + ", nodeId=" + node.id() +
"spiCls=" + U.getSimpleName(TcpCommunicationSpi.class) + ']');
}
示例5: checkPhysicalRam
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* Checks whether physical RAM is not exceeded.
*/
@SuppressWarnings("ConstantConditions")
private void checkPhysicalRam() {
long ram = ctx.discovery().localNode().attribute(ATTR_PHY_RAM);
if (ram != -1) {
String macs = ctx.discovery().localNode().attribute(ATTR_MACS);
long totalHeap = 0;
long totalOffheap = 0;
for (ClusterNode node : ctx.discovery().allNodes()) {
if (macs.equals(node.attribute(ATTR_MACS))) {
long heap = node.metrics().getHeapMemoryMaximum();
Long offheap = node.<Long>attribute(ATTR_OFFHEAP_SIZE);
if (heap != -1)
totalHeap += heap;
if (offheap != null)
totalOffheap += offheap;
}
}
long total = totalHeap + totalOffheap;
if (total < 0)
total = Long.MAX_VALUE;
// 4GB or 20% of available memory is expected to be used by OS and user applications
long safeToUse = ram - Math.max(4L << 30, (long)(ram * 0.2));
if (total > safeToUse) {
U.quietAndWarn(log, "Nodes started on local machine require more than 20% of physical RAM what can " +
"lead to significant slowdown due to swapping (please decrease JVM heap size, data region " +
"size or checkpoint buffer size) [required=" + (total >> 20) + "MB, available=" +
(ram >> 20) + "MB]");
}
}
}
示例6: nodeJavaMajorVersion
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* Gets Java major version running on the node.
*
* @param node Cluster node.
* @return Java major version.
* @throws IgniteCheckedException If failed to get the version.
*/
private int nodeJavaMajorVersion(ClusterNode node) throws IgniteCheckedException {
String verStr = node.<String>attribute("java.version");
int res = U.majorJavaVersion(verStr);
if (res == 0) {
U.error(log, "Failed to get java major version (unknown 'java.version' format) [ver=" +
node.<String>attribute("java.version") + "]");
}
return res;
}
示例7: validateNode
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node) {
ClusterNode locNode = ctx.discovery().localNode();
// Check version.
String locBuildVer = locNode.attribute(ATTR_BUILD_VER);
String rmtBuildVer = node.attribute(ATTR_BUILD_VER);
if (!F.eq(rmtBuildVer, locBuildVer)) {
// OS nodes don't support rolling updates.
if (!locBuildVer.equals(rmtBuildVer)) {
String errMsg = "Local node and remote node have different version numbers " +
"(node will not join, Ignite does not support rolling updates, " +
"so versions must be exactly the same) " +
"[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + rmtBuildVer +
", locNodeAddrs=" + U.addressesAsString(locNode) +
", rmtNodeAddrs=" + U.addressesAsString(node) +
", locNodeId=" + locNode.id() + ", rmtNodeId=" + node.id() + ']';
LT.warn(log, errMsg);
// Always output in debug.
if (log.isDebugEnabled())
log.debug(errMsg);
return new IgniteNodeValidationResult(node.id(), errMsg, errMsg);
}
}
return null;
}
示例8: apply
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("SuspiciousMethodCalls")
@Override public boolean apply(ClusterNode node) {
Object igniteInstanceName = node.attribute(NODE_NAME_ATTR);
return grp.contains(igniteInstanceName);
}
示例9: checkMemoryConfiguration
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* @param rmt Remote node to check.
* @throws IgniteCheckedException If check failed.
*/
private void checkMemoryConfiguration(ClusterNode rmt) throws IgniteCheckedException {
ClusterNode locNode = ctx.discovery().localNode();
if (ctx.config().isClientMode() || locNode.isDaemon() || rmt.isClient() || rmt.isDaemon())
return;
DataStorageConfiguration dsCfg = null;
Object dsCfgBytes = rmt.attribute(IgniteNodeAttributes.ATTR_DATA_STORAGE_CONFIG);
if (dsCfgBytes instanceof byte[])
dsCfg = new JdkMarshaller().unmarshal((byte[])dsCfgBytes, U.resolveClassLoader(ctx.config()));
if (dsCfg == null) {
// Try to use legacy memory configuration.
MemoryConfiguration memCfg = rmt.attribute(IgniteNodeAttributes.ATTR_MEMORY_CONFIG);
if (memCfg != null) {
dsCfg = new DataStorageConfiguration();
// All properties that are used in validation should be converted here.
dsCfg.setPageSize(memCfg.getPageSize());
}
}
if (dsCfg != null) {
DataStorageConfiguration locDsCfg = ctx.config().getDataStorageConfiguration();
if (dsCfg.getPageSize() != locDsCfg.getPageSize()) {
throw new IgniteCheckedException("Memory configuration mismatch (fix configuration or set -D" +
IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system property) [rmtNodeId=" + rmt.id() +
", locPageSize = " + locDsCfg.getPageSize() + ", rmtPageSize = " + dsCfg.getPageSize() + "]");
}
}
}
示例10: hasNearCache
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* Checks if given node has near cache enabled for the specified
* partitioned cache.
*
* @param n Node.
* @param cacheName Cache name.
* @return {@code true} if given node has near cache enabled for the
* specified partitioned cache.
*/
public static boolean hasNearCache(ClusterNode n, String cacheName) {
GridCacheAttributes[] caches = n.attribute(ATTR_CACHE);
if (caches != null)
for (GridCacheAttributes attrs : caches)
if (F.eq(cacheName, attrs.cacheName()))
return attrs.nearCacheEnabled();
return false;
}
示例11: nodeIdsForAttribute
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Set<UUID> nodeIdsForAttribute(String attrName, String attrVal, boolean includeSrvs,
boolean includeClients) {
Set<UUID> nodes = new TreeSet<>();
for (ClusterNode node : nodesList(includeSrvs, includeClients)) {
Object val = node.attribute(attrName);
if (val != null && val.toString().equals(attrVal))
nodes.add(node.id());
}
return nodes;
}
示例12: offheapSize
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* Gets total offheap size in GB rounded to specified precision.
*
* @param nodes Nodes.
* @param precision Precision.
* @return Total offheap size in GB.
*/
public static double offheapSize(Iterable<ClusterNode> nodes, int precision) {
// In bytes.
double totalOffheap = 0.0;
for (ClusterNode n : nodesPerJvm(nodes)) {
Long val = n.<Long>attribute(ATTR_DATA_REGIONS_OFFHEAP_SIZE);
if (val != null)
totalOffheap += val;
}
return roundedHeapSize(totalOffheap, precision);
}
示例13: testStoreUpdate
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* @param cache Cache.
* @param key Key.
* @param tc Transaction concurrency mode.
* @throws Exception If failed.
*/
protected void testStoreUpdate(IgniteCache<Object, Object> cache,
Object key,
@Nullable TransactionConcurrency tc)
throws Exception
{
boolean storeOnPrimary = atomicityMode() == ATOMIC || locStore || writeBehind;
assertTrue(writeMap.isEmpty());
Ignite ignite = cache.unwrap(Ignite.class);
Affinity<Object> obj = ignite.affinity(cache.getName());
ClusterNode node = obj.mapKeyToNode(key);
assertNotNull(node);
String expNode = storeOnPrimary ? (String)node.attribute(ATTR_IGNITE_INSTANCE_NAME) : ignite.name();
assertNotNull(expNode);
log.info("Put [node=" + ignite.name() +
", key=" + key +
", primary=" + node.attribute(ATTR_IGNITE_INSTANCE_NAME) +
", tx=" + tc +
", nearCache=" + (cache.getConfiguration(CacheConfiguration.class).getNearConfiguration() != null) +
", storeOnPrimary=" + storeOnPrimary + ']');
Transaction tx = tc != null ? ignite.transactions().txStart(tc, REPEATABLE_READ) : null;
try {
cache.put(key, key);
if (tx != null)
tx.commit();
}
finally {
if (tx != null)
tx.close();
}
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return writeMap.size() > 0;
}
}, 1000);
assertTrue("Store is not updated", wait);
assertEquals("Write on wrong node: " + writeMap, locStore ? 2 : 1, writeMap.size());
if (!locStore)
assertEquals(expNode, writeMap.keySet().iterator().next());
writeMap.clear();
}
示例14: getAttributeStatistic
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
* @param nodes List of cluster nodes.
* @return Statistic.
*/
@NotNull private static Map<String, Integer> getAttributeStatistic(Collection<ClusterNode> nodes) {
Map<String, Integer> backupAssignedAttribute = new HashMap<>();
backupAssignedAttribute.put(FIRST_NODE_GROUP, 0);
backupAssignedAttribute.put("B", 0);
backupAssignedAttribute.put("C", 0);
for (ClusterNode assignedNode: nodes) {
if (assignedNode == null)
continue;
String val = assignedNode.attribute(SPLIT_ATTRIBUTE_NAME);
Integer cnt = backupAssignedAttribute.get(val);
backupAssignedAttribute.put(val, cnt + 1);
}
return backupAssignedAttribute;
}
示例15: apply
import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
@Override public boolean apply(ClusterNode clusterNode) {
String igniteInstanceName = clusterNode.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME);
return !igniteInstanceName.endsWith(String.valueOf(GRID_CNT - 1)); // The last one is client only.
}