当前位置: 首页>>代码示例>>Java>>正文


Java ClusterNode.equals方法代码示例

本文整理汇总了Java中org.apache.ignite.cluster.ClusterNode.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterNode.equals方法的具体用法?Java ClusterNode.equals怎么用?Java ClusterNode.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.cluster.ClusterNode的用法示例。


在下文中一共展示了ClusterNode.equals方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);

    ignite = (IgniteKernal)ignite();

    ClusterNode loc = ignite().cluster().localNode();

    Collection<ClusterNode> nodes = ignite().cluster().forServers().nodes();

    for (ClusterNode node : nodes) {
        if (!loc.equals(node))
            targetNodes.add(node);
    }

    if (targetNodes.isEmpty())
        throw new IgniteException("Failed to find remote server nodes [nodes=" + nodes + ']');

    BenchmarkUtils.println(cfg, "Initialized target nodes: " + F.nodeIds(targetNodes) + ']');
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:IgniteIoTestAbstractBenchmark.java

示例2: call

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public Object call() throws IgniteCheckedException {
    if (topVer != null) {
        GridCacheAffinityManager aff =
            ((IgniteKernal)ignite).context().cache().internalCache(CACHE_NAME).context().affinity();

        ClusterNode loc = ignite.cluster().localNode();

        if (loc.equals(aff.primaryByKey(key, topVer)))
            return true;

        AffinityTopologyVersion topVer0 = new AffinityTopologyVersion(topVer.topologyVersion() + 1, 0);

        assertEquals(loc, aff.primaryByKey(key, topVer0));
    }

    return null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:CacheAffinityCallSelfTest.java

示例3: map

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
    @Nullable T arg) throws IgniteException {

    for (ClusterNode node : subgrid) {
        if (node.equals(this.node))
            return Collections.singletonMap(new Job<>(remoteTask, arg), node);
    }

    throw new IgniteException("Node " + node + " is not present in subgrid.");
}
 
开发者ID:apache,项目名称:ignite,代码行数:12,代码来源:IgniteRemoteMapTask.java

示例4: writeToSocket

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void writeToSocket(ClusterNode node,
    Socket sock,
    OutputStream out,
    TcpDiscoveryAbstractMessage msg,
    long timeout) throws IOException, IgniteCheckedException {
    if (startTest && !(msg instanceof TcpDiscoveryConnectionCheckMessage)) {
        if (node.order() == errNodeOrder) {
            log.info("Fail write on message send [node=" + node.id() + ", msg=" + msg + ']');

            throw new SocketTimeoutException();
        }
        else if (locNode.order() == errNodeOrder) {
            if (sleepEndTime == 0) {
                errNext = node;

                sleepEndTime = System.currentTimeMillis() + 3000;
            }

            long sleepTime = sleepEndTime - System.currentTimeMillis();

            if (sleepTime > 0) {
                log.info("Start sleep on message send: " + msg);

                try {
                    U.sleep(sleepTime);
                }
                catch (IgniteInterruptedCheckedException e) {
                    log.error("Interrupted on socket write: " + e, e);

                    throw new IOException(e);
                }

                log.info("Stop sleep on message send: " + msg);

                if (node.equals(errNext)) {
                    log.info("Fail write after sleep [node=" + node.id() + ", msg=" + msg + ']');

                    throw new SocketTimeoutException();
                }
            }
        }
    }

    super.writeToSocket(node, sock, out, msg, timeout);
}
 
开发者ID:apache,项目名称:ignite,代码行数:47,代码来源:TcpDiscoverySelfTest.java

示例5: findKeys

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
 * Tries to find keys for two partitions: for one partition assignment should not change after node join,
 * for another primary node should change.
 *
 * @param ignite Ignite.
 * @param nodes Current nodes.
 * @return Found keys.
 */
private IgniteBiTuple<Integer, Integer> findKeys(Ignite ignite, ClusterNode...nodes) {
    ClusterNode newNode = new TcpDiscoveryNode();

    GridTestUtils.setFieldValue(newNode, "consistentId", getTestIgniteInstanceName(4));
    GridTestUtils.setFieldValue(newNode, "id", UUID.randomUUID());

    List<ClusterNode> topNodes = new ArrayList<>();

    Collections.addAll(topNodes, nodes);

    topNodes.add(newNode);

    DiscoveryEvent discoEvt = new DiscoveryEvent(newNode, "", EventType.EVT_NODE_JOINED, newNode);

    final long topVer = ignite.cluster().topologyVersion();

    GridAffinityFunctionContextImpl ctx = new GridAffinityFunctionContextImpl(topNodes,
        null,
        discoEvt,
        new AffinityTopologyVersion(topVer + 1),
        1);

    AffinityFunction affFunc = ignite.cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getAffinity();

    List<List<ClusterNode>> newAff = affFunc.assignPartitions(ctx);

    List<List<ClusterNode>> curAff = ((IgniteKernal)ignite).context().cache().internalCache(DEFAULT_CACHE_NAME).context().
        affinity().assignments(new AffinityTopologyVersion(topVer));

    Integer key1 = null;
    Integer key2 = null;

    Affinity<Integer> aff = ignite.affinity(DEFAULT_CACHE_NAME);

    for (int i = 0; i < curAff.size(); i++) {
        if (key1 == null) {
            List<ClusterNode> oldNodes = curAff.get(i);
            List<ClusterNode> newNodes = newAff.get(i);

            if (oldNodes.equals(newNodes))
                key1 = findKey(aff, i);
        }

        if (key2 == null) {
            ClusterNode oldPrimary = F.first(curAff.get(i));
            ClusterNode newPrimary = F.first(newAff.get(i));

            if (!oldPrimary.equals(newPrimary))
                key2 = findKey(aff, i);
        }

        if (key1 != null && key2 != null)
            break;
    }

    if (key1 == null || key2 == null)
        fail("Failed to find nodes required for test.");

    return new IgniteBiTuple<>(key1, key2);
}
 
开发者ID:apache,项目名称:ignite,代码行数:69,代码来源:IgniteCacheClientNodeChangingTopologyTest.java

示例6: test

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void test() throws AssertionError {
    Affinity<?> affinity = ignite.affinity(cacheName);

    int partCnt = affinity.partitions();

    boolean hostSafe = true;

    boolean nodeSafe = true;

    for (int x = 0; x < partCnt; ++x) {
        // Results are returned with the primary node first and backups after. We want to ensure that there is at
        // least one backup on a different host.
        Collection<ClusterNode> results = affinity.mapPartitionToPrimaryAndBackups(x);

        Iterator<ClusterNode> nodes = results.iterator();

        boolean newHostSafe = false;

        boolean newNodeSafe = false;

        if (nodes.hasNext()) {
            ClusterNode primary = nodes.next();

            // For host safety, get all nodes on the same host as the primary node and ensure at least one of the
            // backups is on a different host. For node safety, make sure at least of of the backups is not the
            // primary.
            Collection<ClusterNode> neighbors = hostSafe ? ignite.cluster().forHost(primary).nodes() : null;

            while (nodes.hasNext()) {
                ClusterNode backup = nodes.next();

                if (hostSafe) {
                    if (!neighbors.contains(backup))
                        newHostSafe = true;
                }

                if (nodeSafe) {
                    if (!backup.equals(primary))
                        newNodeSafe = true;
                }
            }
        }

        hostSafe = newHostSafe;

        nodeSafe = newNodeSafe;

        if (!hostSafe && !nodeSafe)
            break;
    }

    if (hostSafe)
        return;

    if (nodeSafe)
        return;

    throw new AssertionError("Cache " + cacheName + " is endangered!");
}
 
开发者ID:apache,项目名称:ignite,代码行数:61,代码来源:CacheNodeSafeAssertion.java

示例7: startSpis

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
 * @throws Exception If failed.
 */
private void startSpis() throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();

    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();

    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));

    timeoutProcessor.start();

    timeoutProcessor.onKernalStart(true);

    for (int i = 0; i < getSpiCount(); i++) {
        CommunicationSpi<Message> spi = getSpi(i);

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        IgniteTestResources rsrcs = new IgniteTestResources();

        GridTestNode node = new GridTestNode(rsrcs.getNodeId());

        GridSpiTestContext ctx = initSpiContext();

        ctx.setLocalNode(node);

        ctx.timeoutProcessor(timeoutProcessor);

        info(">>> Initialized context: nodeId=" + ctx.localNode().id());

        spiRsrcs.add(rsrcs);

        rsrcs.inject(spi);

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        if (useSsl) {
            IgniteMock ignite = GridTestUtils.getFieldValue(spi, IgniteSpiAdapter.class, "ignite");

            IgniteConfiguration cfg = ignite.configuration()
                .setSslContextFactory(GridTestUtils.sslFactory());

            ignite.setStaticCfg(cfg);
        }

        spi.setListener(new MessageListener(rsrcs.getNodeId()));

        node.setAttributes(spi.getNodeAttributes());
        node.setAttribute(ATTR_MACS, F.concat(U.allLocalMACs(), ", "));

        node.order(i + 1);

        nodes.add(node);

        spi.spiStart(getTestIgniteInstanceName() + (i + 1));

        spis.put(rsrcs.getNodeId(), spi);

        spi.onContextInitialized(ctx);

        ctxs.put(node, ctx);
    }

    // For each context set remote nodes.
    for (Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:75,代码来源:GridAbstractCommunicationSelfTest.java

示例8: beforeTestsStarted

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();
    lsnrs.clear();

    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();

    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));

    timeoutProcessor.start();

    timeoutProcessor.onKernalStart(true);

    for (int i = 0; i < getSpiCount(); i++) {
        CommunicationSpi<Message> spi = newCommunicationSpi();

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        IgniteTestResources rsrcs = new IgniteTestResources();

        GridTestNode node = new GridTestNode(rsrcs.getNodeId());

        node.order(i);

        GridSpiTestContext ctx = initSpiContext();

        ctx.timeoutProcessor(timeoutProcessor);

        ctx.setLocalNode(node);

        info(">>> Initialized context: nodeId=" + ctx.localNode().id());

        spiRsrcs.add(rsrcs);

        rsrcs.inject(spi);

        MessageListener lsnr = new MessageListener(rsrcs.getNodeId());

        spi.setListener(lsnr);

        lsnrs.put(rsrcs.getNodeId(), lsnr);

        info("Lsnrs: " + lsnrs);

        node.setAttributes(spi.getNodeAttributes());
        node.setAttribute(ATTR_MACS, F.concat(U.allLocalMACs(), ", "));

        nodes.add(node);

        spi.spiStart(getTestIgniteInstanceName() + (i + 1));

        spis.put(rsrcs.getNodeId(), spi);

        spi.onContextInitialized(ctx);

        ctxs.put(node, ctx);
    }

    // For each context set remote nodes.
    for (Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:69,代码来源:GridTcpCommunicationSpiMultithreadedSelfTest.java

示例9: startSpis

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
 * @param ackCnt Recovery acknowledgement count.
 * @param idleTimeout Idle connection timeout.
 * @param queueLimit Message queue limit.
 * @throws Exception If failed.
 */
private void startSpis(int ackCnt, int idleTimeout, int queueLimit) throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();

    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();

    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));

    timeoutProcessor.start();

    timeoutProcessor.onKernalStart(true);

    for (int i = 0; i < SPI_CNT; i++) {
        TcpCommunicationSpi spi = getSpi(ackCnt, idleTimeout, queueLimit);

        IgniteTestResources rsrcs = new IgniteTestResources();

        GridTestNode node = new GridTestNode(rsrcs.getNodeId());

        GridSpiTestContext ctx = initSpiContext();

        ctx.setLocalNode(node);

        ctx.timeoutProcessor(timeoutProcessor);

        spiRsrcs.add(rsrcs);

        rsrcs.inject(spi);

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        spi.setListener(new TestListener());

        node.setAttributes(spi.getNodeAttributes());

        node.order(i);

        nodes.add(node);

        spi.spiStart(getTestIgniteInstanceName() + (i + 1));

        spis.add(spi);

        spi.onContextInitialized(ctx);

        ctxs.put(node, ctx);
    }

    // For each context set remote nodes.
    for (Map.Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:64,代码来源:GridTcpCommunicationSpiRecoveryAckSelfTest.java

示例10: startSpis

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
 * @param ackCnt Recovery acknowledgement count.
 * @param idleTimeout Idle connection timeout.
 * @param queueLimit Message queue limit.
 * @throws Exception If failed.
 */
private void startSpis(int ackCnt, int idleTimeout, int queueLimit) throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();

    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();

    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));

    timeoutProcessor.start();

    timeoutProcessor.onKernalStart(true);

    for (int i = 0; i < SPI_CNT; i++) {
        TcpCommunicationSpi spi = getSpi(ackCnt, idleTimeout, queueLimit);

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        IgniteTestResources rsrcs = new IgniteTestResources();

        GridTestNode node = new GridTestNode(rsrcs.getNodeId());

        GridSpiTestContext ctx = initSpiContext();

        ctx.setLocalNode(node);

        ctx.timeoutProcessor(timeoutProcessor);

        spiRsrcs.add(rsrcs);

        rsrcs.inject(spi);

        spi.setListener(new TestListener());

        node.setAttributes(spi.getNodeAttributes());

        node.order(i);

        nodes.add(node);

        spi.spiStart(getTestIgniteInstanceName() + (i + 1));

        spis.add(spi);

        spi.onContextInitialized(ctx);

        ctxs.put(node, ctx);
    }

    // For each context set remote nodes.
    for (Map.Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:64,代码来源:IgniteTcpCommunicationRecoveryAckClosureSelfTest.java

示例11: startSpis

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
 * @throws Exception If failed.
 */
private void startSpis() throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();

    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();

    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));

    timeoutProcessor.start();

    timeoutProcessor.onKernalStart(true);

    for (int i = 0; i < SPI_CNT; i++) {
        TcpCommunicationSpi spi = getSpi(i);

        IgniteTestResources rsrcs = new IgniteTestResources();

        GridTestNode node = new GridTestNode(rsrcs.getNodeId());

        node.order(i);

        GridSpiTestContext ctx = initSpiContext();

        ctx.setLocalNode(node);

        ctx.timeoutProcessor(timeoutProcessor);

        spiRsrcs.add(rsrcs);

        rsrcs.inject(spi);

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        if (useSsl) {
            IgniteMock ignite = GridTestUtils.getFieldValue(spi, IgniteSpiAdapter.class, "ignite");

            IgniteConfiguration cfg = ignite.configuration()
                .setSslContextFactory(GridTestUtils.sslFactory());

            ignite.setStaticCfg(cfg);
        }

        spi.setListener(new TestListener());

        node.setAttributes(spi.getNodeAttributes());

        nodes.add(node);

        spi.spiStart(getTestIgniteInstanceName() + (i + 1));

        spis.add(spi);

        spi.onContextInitialized(ctx);

        ctxs.put(node, ctx);
    }

    // For each context set remote nodes.
    for (Map.Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:70,代码来源:GridTcpCommunicationSpiRecoverySelfTest.java

示例12: startSpis

import org.apache.ignite.cluster.ClusterNode; //导入方法依赖的package包/类
/**
 * @param lsnr Message listener.
 * @throws Exception If failed.
 */
private void startSpis(MessageListener lsnr) throws Exception {
    spis.clear();
    nodes.clear();
    spiRsrcs.clear();

    Map<ClusterNode, GridSpiTestContext> ctxs = new HashMap<>();

    timeoutProcessor = new GridTimeoutProcessor(new GridTestKernalContext(log));

    timeoutProcessor.start();

    timeoutProcessor.onKernalStart(true);

    for (int i = 0; i < SPI_CNT; i++) {
        CommunicationSpi<Message> spi = createSpi();

        IgniteTestResources rsrcs = new IgniteTestResources();

        GridTestNode node = new GridTestNode(rsrcs.getNodeId());

        node.setAttribute(IgniteNodeAttributes.ATTR_CLIENT_MODE, false);

        node.order(i + 1);

        GridSpiTestContext ctx = initSpiContext();

        ctx.setLocalNode(node);

        ctx.timeoutProcessor(timeoutProcessor);

        info(">>> Initialized context: nodeId=" + ctx.localNode().id());

        spiRsrcs.add(rsrcs);

        rsrcs.inject(spi);

        GridTestUtils.setFieldValue(spi, IgniteSpiAdapter.class, "igniteInstanceName", "grid-" + i);

        if (useSsl) {
            IgniteMock ignite = GridTestUtils.getFieldValue(spi, IgniteSpiAdapter.class, "ignite");

            IgniteConfiguration cfg = ignite.configuration()
                .setSslContextFactory(GridTestUtils.sslFactory());

            ignite.setStaticCfg(cfg);
        }

        spi.setListener(lsnr);

        node.setAttributes(spi.getNodeAttributes());

        nodes.add(node);

        spi.spiStart(getTestIgniteInstanceName() + (i + 1));

        spis.add(spi);

        spi.onContextInitialized(ctx);

        ctxs.put(node, ctx);
    }

    // For each context set remote nodes.
    for (Map.Entry<ClusterNode, GridSpiTestContext> e : ctxs.entrySet()) {
        for (ClusterNode n : nodes) {
            if (!n.equals(e.getKey()))
                e.getValue().remoteNodes().add(n);
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:75,代码来源:GridTcpCommunicationSpiConcurrentConnectSelfTest.java


注:本文中的org.apache.ignite.cluster.ClusterNode.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。