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


Java FailureDetector类代码示例

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


FailureDetector类属于org.apache.cassandra.gms包,在下文中一共展示了FailureDetector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: commitPaxos

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private static void commitPaxos(Commit proposal, ConsistencyLevel consistencyLevel) throws WriteTimeoutException
{
    Keyspace keyspace = Keyspace.open(proposal.update.metadata().ksName);

    Token tk = StorageService.getPartitioner().getToken(proposal.key);
    List<InetAddress> naturalEndpoints = StorageService.instance.getNaturalEndpoints(keyspace.getName(), tk);
    Collection<InetAddress> pendingEndpoints = StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, keyspace.getName());

    AbstractReplicationStrategy rs = keyspace.getReplicationStrategy();
    AbstractWriteResponseHandler responseHandler = rs.getWriteResponseHandler(naturalEndpoints, pendingEndpoints, consistencyLevel, null, WriteType.SIMPLE);

    MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_COMMIT, proposal, Commit.serializer);
    for (InetAddress destination : Iterables.concat(naturalEndpoints, pendingEndpoints))
    {
        if (FailureDetector.instance.isAlive(destination))
            MessagingService.instance().sendRR(message, destination, responseHandler);
    }

    responseHandler.get();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:21,代码来源:StorageProxy.java

示例3: replaySerializedMutation

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private void replaySerializedMutation(RowMutation mutation, long writtenAt)
{
    int ttl = calculateHintTTL(mutation, writtenAt);
    if (ttl <= 0)
        return; // the mutation isn't safe to replay.

    Set<InetAddress> liveEndpoints = new HashSet<InetAddress>();
    String ks = mutation.getKeyspaceName();
    Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
    for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
                                                 StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
    {
        if (endpoint.equals(FBUtilities.getBroadcastAddress()))
            mutation.apply();
        else if (FailureDetector.instance.isAlive(endpoint))
            liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
        else
            StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
    }

    if (!liveEndpoints.isEmpty())
        attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:24,代码来源:BatchlogManager.java

示例4: run

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
public void run()
{
    if (FailureDetector.instance.isAlive(neighbor))
    {
        AnticompactionRequest acr = new AnticompactionRequest(parentSession, successfulRanges);
        CassandraVersion peerVersion = SystemKeyspace.getReleaseVersion(neighbor);
        if (peerVersion != null && peerVersion.compareTo(VERSION_CHECKER) > 0)
        {
            MessagingService.instance().sendRR(acr.createMessage(), neighbor, new AnticompactionCallback(this), TimeUnit.DAYS.toMillis(1), true);
        }
        else
        {
            MessagingService.instance().sendOneWay(acr.createMessage(), neighbor);
            // immediately return after sending request
            set(neighbor);
        }
    }
    else
    {
        setException(new IOException(neighbor + " is down"));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:AnticompactionTask.java

示例5: bootstrap

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
public void bootstrap()
{
    if (logger.isDebugEnabled())
        logger.debug("Beginning bootstrap process");

    RangeStreamer streamer = new RangeStreamer(tokenMetadata, address, OperationType.BOOTSTRAP);
    streamer.addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(FailureDetector.instance));

    for (String table : Schema.instance.getNonSystemTables())
    {
        AbstractReplicationStrategy strategy = Table.open(table).getReplicationStrategy();
        streamer.addRanges(table, strategy.getPendingAddressRanges(tokenMetadata, tokens, address));
    }

    streamer.fetch();
    StorageService.instance.finishBootstrapping();
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:18,代码来源:BootStrapper.java

示例6: replaySerializedMutation

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private void replaySerializedMutation(RowMutation mutation, long writtenAt) throws IOException
{
    int ttl = calculateHintTTL(mutation, writtenAt);
    if (ttl <= 0)
        return; // the mutation isn't safe to replay.

    Set<InetAddress> liveEndpoints = new HashSet<InetAddress>();
    String ks = mutation.getTable();
    Token tk = StorageService.getPartitioner().getToken(mutation.key());
    for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
                                                 StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
    {
        if (endpoint.equals(FBUtilities.getBroadcastAddress()))
            mutation.apply();
        else if (FailureDetector.instance.isAlive(endpoint))
            liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
        else
            StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
    }

    if (!liveEndpoints.isEmpty())
        attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:24,代码来源:BatchlogManager.java

示例7: replaySerializedMutation

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private void replaySerializedMutation(Mutation mutation, long writtenAt, RateLimiter rateLimiter)
{
    int ttl = calculateHintTTL(mutation, writtenAt);
    if (ttl <= 0)
        return; // the mutation isn't safe to replay.

    Set<InetAddress> liveEndpoints = new HashSet<>();
    String ks = mutation.getKeyspaceName();
    Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
    int mutationSize = (int) Mutation.serializer.serializedSize(mutation, VERSION);

    for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
                                                 StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
    {
        rateLimiter.acquire(mutationSize);
        if (endpoint.equals(FBUtilities.getBroadcastAddress()))
            mutation.apply();
        else if (FailureDetector.instance.isAlive(endpoint))
            liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
        else
            StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
    }

    if (!liveEndpoints.isEmpty())
        attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:27,代码来源:BatchlogManager.java

示例8: replaySerializedMutation

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private void replaySerializedMutation(Mutation mutation, long writtenAt, int version, RateLimiter rateLimiter)
{
    int ttl = calculateHintTTL(mutation, writtenAt);
    if (ttl <= 0)
        return; // the mutation isn't safe to replay.

    Set<InetAddress> liveEndpoints = new HashSet<>();
    String ks = mutation.getKeyspaceName();
    Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
    int mutationSize = (int) Mutation.serializer.serializedSize(mutation, version);

    for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
                                                 StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
    {
        rateLimiter.acquire(mutationSize);
        if (endpoint.equals(FBUtilities.getBroadcastAddress()))
            mutation.apply();
        else if (FailureDetector.instance.isAlive(endpoint))
            liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
        else
            StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
    }

    if (!liveEndpoints.isEmpty())
        attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:27,代码来源:BatchlogManager.java

示例9: replaySerializedMutation

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private void replaySerializedMutation(RowMutation mutation, long writtenAt, RateLimiter rateLimiter) throws IOException
{
    int ttl = calculateHintTTL(mutation, writtenAt);
    if (ttl <= 0)
        return; // the mutation isn't safe to replay.

    Set<InetAddress> liveEndpoints = new HashSet<InetAddress>();
    String ks = mutation.getTable();
    Token tk = StorageService.getPartitioner().getToken(mutation.key());
    int mutationSize = (int) RowMutation.serializer.serializedSize(mutation, VERSION);

    for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
                                                 StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
    {
        rateLimiter.acquire(mutationSize);
        if (endpoint.equals(FBUtilities.getBroadcastAddress()))
            mutation.apply();
        else if (FailureDetector.instance.isAlive(endpoint))
            liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
        else
            StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
    }

    if (!liveEndpoints.isEmpty())
        attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
 
开发者ID:jackliu8722,项目名称:cassandra-1.2.16,代码行数:27,代码来源:BatchlogManager.java

示例10: main

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    System.out.println("Connecting to " + config.getBaseUrl());
    System.out.println("Starting the JMX server");

    MBeanServer server = getPlatformMBeanServer();
    for (Class<? extends APIMBean> clazz : asList(StorageService.class, StorageProxy.class, MessagingService.class,
            CommitLog.class, Gossiper.class, EndpointSnitchInfo.class, FailureDetector.class, CacheService.class,
            CompactionManager.class, GCInspector.class, StreamManager.class)) {
        Constructor<? extends APIMBean> c = clazz.getDeclaredConstructor(APIClient.class);
        APIMBean m = c.newInstance(client);
        server.registerMBean(m, null);
    }

    try {
        // forces check for dynamically created mbeans
        server.queryNames(null, null);
    } catch (IllegalStateException e) {
        // ignore this. Just means we started before scylla.
    }

    String jmxPort = System.getProperty("com.sun.management.jmxremote.port");
    System.out.println("JMX is enabled to receive remote connections on port: " + jmxPort);

    for (;;) {
        Thread.sleep(Long.MAX_VALUE);
    }
}
 
开发者ID:scylladb,项目名称:scylla-jmx,代码行数:28,代码来源:Main.java

示例11: 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

示例12: getLiveNaturalEndpoints

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
public List<InetAddress> getLiveNaturalEndpoints(Keyspace keyspace, RingPosition pos)
{
    List<InetAddress> endpoints = keyspace.getReplicationStrategy().getNaturalEndpoints(pos);
    List<InetAddress> liveEps = new ArrayList<>(endpoints.size());

    for (InetAddress endpoint : endpoints)
    {
        if (FailureDetector.instance.isAlive(endpoint))
            liveEps.add(endpoint);
    }

    return liveEps;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:StorageService.java

示例13: streamHints

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private Future<StreamState> streamHints()
{
    // StreamPlan will not fail if there are zero files to transfer, so flush anyway (need to get any in-memory hints, as well)
    ColumnFamilyStore hintsCF = Keyspace.open(Keyspace.SYSTEM_KS).getColumnFamilyStore(SystemKeyspace.HINTS_CF);
    FBUtilities.waitOnFuture(hintsCF.forceFlush());

    // gather all live nodes in the cluster that aren't also leaving
    List<InetAddress> candidates = new ArrayList<>(StorageService.instance.getTokenMetadata().cloneAfterAllLeft().getAllEndpoints());
    candidates.remove(FBUtilities.getBroadcastAddress());
    for (Iterator<InetAddress> iter = candidates.iterator(); iter.hasNext(); )
    {
        InetAddress address = iter.next();
        if (!FailureDetector.instance.isAlive(address))
            iter.remove();
    }

    if (candidates.isEmpty())
    {
        logger.warn("Unable to stream hints since no live endpoints seen");
        return Futures.immediateFuture(null);
    }
    else
    {
        // stream to the closest peer as chosen by the snitch
        DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), candidates);
        InetAddress hintsDestinationHost = candidates.get(0);
        InetAddress preferred = SystemKeyspace.getPreferredIP(hintsDestinationHost);

        // stream all hints -- range list will be a singleton of "the entire ring"
        Token token = StorageService.getPartitioner().getMinimumToken();
        List<Range<Token>> ranges = Collections.singletonList(new Range<>(token, token));

        return new StreamPlan("Hints").transferRanges(hintsDestinationHost,
                                                      preferred,
                                                                  Keyspace.SYSTEM_KS,
                                                                  ranges,
                                                                  SystemKeyspace.HINTS_CF)
                                                  .execute();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:41,代码来源:StorageService.java

示例14: commitPaxos

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private static void commitPaxos(Commit proposal, ConsistencyLevel consistencyLevel) throws WriteTimeoutException
{
    boolean shouldBlock = consistencyLevel != ConsistencyLevel.ANY;
    Keyspace keyspace = Keyspace.open(proposal.update.metadata().ksName);

    Token tk = StorageService.getPartitioner().getToken(proposal.key);
    List<InetAddress> naturalEndpoints = StorageService.instance.getNaturalEndpoints(keyspace.getName(), tk);
    Collection<InetAddress> pendingEndpoints = StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, keyspace.getName());

    AbstractWriteResponseHandler responseHandler = null;
    if (shouldBlock)
    {
        AbstractReplicationStrategy rs = keyspace.getReplicationStrategy();
        responseHandler = rs.getWriteResponseHandler(naturalEndpoints, pendingEndpoints, consistencyLevel, null, WriteType.SIMPLE);
    }

    MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_COMMIT, proposal, Commit.serializer);
    for (InetAddress destination : Iterables.concat(naturalEndpoints, pendingEndpoints))
    {
        if (FailureDetector.instance.isAlive(destination))
        {
            if (shouldBlock)
                MessagingService.instance().sendRR(message, destination, responseHandler);
            else
                MessagingService.instance().sendOneWay(message, destination);
        }
    }

    if (shouldBlock)
        responseHandler.get();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:32,代码来源:StorageProxy.java

示例15: deliverHintsToEndpoint

import org.apache.cassandra.gms.FailureDetector; //导入依赖的package包/类
private void deliverHintsToEndpoint(InetAddress endpoint)
{
    if (hintStore.isEmpty())
        return; // nothing to do, don't confuse users by logging a no-op handoff

    // check if hints delivery has been paused
    if (hintedHandOffPaused)
    {
        logger.debug("Hints delivery process is paused, aborting");
        return;
    }

    logger.debug("Checking remote({}) schema before delivering hints", endpoint);
    try
    {
        waitForSchemaAgreement(endpoint);
    }
    catch (TimeoutException e)
    {
        return;
    }

    if (!FailureDetector.instance.isAlive(endpoint))
    {
        logger.debug("Endpoint {} died before hint delivery, aborting", endpoint);
        return;
    }

    doDeliverHintsToEndpoint(endpoint);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:31,代码来源:HintedHandOffManager.java


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