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


Java FailureDetector.instance方法代码示例

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


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

示例1: sendReplicationNotification

import org.apache.cassandra.gms.FailureDetector; //导入方法依赖的package包/类
/**
 * Sends a notification to a node indicating we have finished replicating data.
 *
 * @param remote node to send notification to
 */
private void sendReplicationNotification(InetAddress remote)
{
    // notify the remote token
    MessageOut msg = new MessageOut(MessagingService.Verb.REPLICATION_FINISHED);
    IFailureDetector failureDetector = FailureDetector.instance;
    if (logger.isDebugEnabled())
        logger.debug("Notifying {} of replication completion\n", remote);
    while (failureDetector.isAlive(remote))
    {
        AsyncOneResponse iar = MessagingService.instance().sendRR(msg, remote);
        try
        {
            iar.get(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
            return; // done
        }
        catch(TimeoutException e)
        {
            // try again
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:StorageService.java

示例2: getNewSourceRanges

import org.apache.cassandra.gms.FailureDetector; //导入方法依赖的package包/类
/**
 * Finds living endpoints responsible for the given ranges
 *
 * @param keyspaceName the keyspace ranges belong to
 * @param ranges the ranges to find sources for
 * @return multimap of addresses to ranges the address is responsible for
 */
private Multimap<InetAddress, Range<Token>> getNewSourceRanges(String keyspaceName, Set<Range<Token>> ranges)
{
    InetAddress myAddress = FBUtilities.getBroadcastAddress();
    Multimap<Range<Token>, InetAddress> rangeAddresses = Keyspace.open(keyspaceName).getReplicationStrategy().getRangeAddresses(tokenMetadata.cloneOnlyTokenMap());
    Multimap<InetAddress, Range<Token>> sourceRanges = HashMultimap.create();
    IFailureDetector failureDetector = FailureDetector.instance;

    // find alive sources for our new ranges
    for (Range<Token> range : ranges)
    {
        Collection<InetAddress> possibleRanges = rangeAddresses.get(range);
        IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
        List<InetAddress> sources = snitch.getSortedListByProximity(myAddress, possibleRanges);

        assert (!sources.contains(myAddress));

        for (InetAddress source : sources)
        {
            if (failureDetector.isAlive(source))
            {
                sourceRanges.put(source, range);
                break;
            }
        }
    }
    return sourceRanges;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:35,代码来源:StorageService.java

示例3: removeNode

import org.apache.cassandra.gms.FailureDetector; //导入方法依赖的package包/类
/**
 * Remove a node that has died, attempting to restore the replica count.
 * If the node is alive, decommission should be attempted.  If decommission
 * fails, then removeToken should be called.  If we fail while trying to
 * restore the replica count, finally forceRemoveCompleteion should be
 * called to forcibly remove the node without regard to replica count.
 *
 * @param hostIdString token for the node
 */
public void removeNode(String hostIdString)
{
    InetAddress myAddress = FBUtilities.getBroadcastAddress();
    UUID localHostId = tokenMetadata.getHostId(myAddress);
    UUID hostId = UUID.fromString(hostIdString);
    InetAddress endpoint = tokenMetadata.getEndpointForHostId(hostId);

    if (endpoint == null)
        throw new UnsupportedOperationException("Host ID not found.");

    Collection<Token> tokens = tokenMetadata.getTokens(endpoint);

    if (endpoint.equals(myAddress))
         throw new UnsupportedOperationException("Cannot remove self");

    if (Gossiper.instance.getLiveMembers().contains(endpoint))
        throw new UnsupportedOperationException("Node " + endpoint + " is alive and owns this ID. Use decommission command to remove it from the ring");

    // A leaving endpoint that is dead is already being removed.
    if (tokenMetadata.isLeaving(endpoint))
        logger.warn("Node {} is already being removed, continuing removal anyway", endpoint);

    if (!replicatingNodes.isEmpty())
        throw new UnsupportedOperationException("This node is already processing a removal. Wait for it to complete, or use 'removenode force' if this has failed.");

    // Find the endpoints that are going to become responsible for data
    for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())
    {
        // if the replication factor is 1 the data is lost so we shouldn't wait for confirmation
        if (Keyspace.open(keyspaceName).getReplicationStrategy().getReplicationFactor() == 1)
            continue;

        // get all ranges that change ownership (that is, a node needs
        // to take responsibility for new range)
        Multimap<Range<Token>, InetAddress> changedRanges = getChangedRangesForLeaving(keyspaceName, endpoint);
        IFailureDetector failureDetector = FailureDetector.instance;
        for (InetAddress ep : changedRanges.values())
        {
            if (failureDetector.isAlive(ep))
                replicatingNodes.add(ep);
            else
                logger.warn("Endpoint {} is down and will not receive data for re-replication of {}", ep, endpoint);
        }
    }
    removingNode = endpoint;

    tokenMetadata.addLeavingEndpoint(endpoint);
    PendingRangeCalculatorService.instance.update();

    // the gossiper will handle spoofing this node's state to REMOVING_TOKEN for us
    // we add our own token so other nodes to let us know when they're done
    Gossiper.instance.advertiseRemoving(endpoint, hostId, localHostId);

    // kick off streaming commands
    restoreReplicaCount(endpoint, myAddress);

    // wait for ReplicationFinishedVerbHandler to signal we're done
    while (!replicatingNodes.isEmpty())
    {
        Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
    }

    excise(tokens, endpoint);

    // gossiper will indicate the token has left
    Gossiper.instance.advertiseTokenRemoved(endpoint, hostId);

    replicatingNodes.clear();
    removingNode = null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:80,代码来源:StorageService.java


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