• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IEndpointSnitch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



IEndpointSnitch类属于org.apache.cassandra.locator包,在下文中一共展示了IEndpointSnitch类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isEncryptedChannel

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
public static boolean isEncryptedChannel(InetAddress address)
{
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    switch (DatabaseDescriptor.getServerEncryptionOptions().internode_encryption)
    {
        case none:
            return false; // if nothing needs to be encrypted then return immediately.
        case all:
            break;
        case dc:
            if (snitch.getDatacenter(address).equals(snitch.getDatacenter(FBUtilities.getBroadcastAddress())))
                return false;
            break;
        case rack:
            // for rack then check if the DC's are the same.
            if (snitch.getRack(address).equals(snitch.getRack(FBUtilities.getBroadcastAddress()))
                    && snitch.getDatacenter(address).equals(snitch.getDatacenter(FBUtilities.getBroadcastAddress())))
                return false;
            break;
    }
    return true;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:OutboundTcpConnectionPool.java


示例2: RangeStreamer

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
public RangeStreamer(TokenMetadata metadata,
                     Collection<Token> tokens,
                     InetAddress address,
                     String description,
                     boolean useStrictConsistency,
                     IEndpointSnitch snitch,
                     StreamStateStore stateStore)
{
    this.metadata = metadata;
    this.tokens = tokens;
    this.address = address;
    this.description = description;
    this.streamPlan = new StreamPlan(description, true);
    this.useStrictConsistency = useStrictConsistency;
    this.snitch = snitch;
    this.stateStore = stateStore;
    streamPlan.listeners(this.stateStore);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:RangeStreamer.java


示例3: testAllocateTokensNetworkStrategy

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
public void testAllocateTokensNetworkStrategy(int rackCount, int replicas) throws UnknownHostException
{
    IEndpointSnitch oldSnitch = DatabaseDescriptor.getEndpointSnitch();
    try
    {
        DatabaseDescriptor.setEndpointSnitch(new RackInferringSnitch());
        int vn = 16;
        String ks = "BootStrapperTestNTSKeyspace" + rackCount + replicas;
        String dc = "1";
        SchemaLoader.createKeyspace(ks, KeyspaceParams.nts(dc, replicas, "15", 15), SchemaLoader.standardCFMD(ks, "Standard1"));
        TokenMetadata tm = new TokenMetadata();
        tm.clearUnsafe();
        for (int i = 0; i < rackCount; ++i)
            generateFakeEndpoints(tm, 10, vn, dc, Integer.toString(i));
        InetAddress addr = InetAddress.getByName("127." + dc + ".0.99");
        allocateTokensForNode(vn, ks, tm, addr);
        // Note: Not matching replication factor in second datacentre, but this should not affect us.
    } finally {
        DatabaseDescriptor.setEndpointSnitch(oldSnitch);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:BootStrapperTest.java


示例4: findSuitableEndpoint

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
/**
 * Find a suitable replica as leader for counter update.
 * For now, we pick a random replica in the local DC (or ask the snitch if
 * there is no replica alive in the local DC).
 * TODO: if we track the latency of the counter writes (which makes sense
 * contrarily to standard writes since there is a read involved), we could
 * trust the dynamic snitch entirely, which may be a better solution. It
 * is unclear we want to mix those latencies with read latencies, so this
 * may be a bit involved.
 */
private static InetAddress findSuitableEndpoint(String table, ByteBuffer key, String localDataCenter) throws UnavailableException
{
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(table, key);
    if (endpoints.isEmpty())
        throw new UnavailableException();

    List<InetAddress> localEndpoints = new ArrayList<InetAddress>();
    for (InetAddress endpoint : endpoints)
    {
        if (snitch.getDatacenter(endpoint).equals(localDataCenter))
            localEndpoints.add(endpoint);
    }
    if (localEndpoints.isEmpty())
    {
        // No endpoint in local DC, pick the closest endpoint according to the snitch
        snitch.sortByProximity(FBUtilities.getLocalAddress(), endpoints);
        return endpoints.get(0);
    }
    else
    {
        return localEndpoints.get(FBUtilities.threadLocalRandom().nextInt(localEndpoints.size()));
    }
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:35,代码来源:StorageProxy.java


示例5: gossipSnitchInfo

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
public void gossipSnitchInfo()
{
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    String dc = snitch.getDatacenter(FBUtilities.getBroadcastAddress());
    String rack = snitch.getRack(FBUtilities.getBroadcastAddress());
    Gossiper.instance.addLocalApplicationState(ApplicationState.DC, StorageService.instance.valueFactory.datacenter(dc));
    Gossiper.instance.addLocalApplicationState(ApplicationState.RACK, StorageService.instance.valueFactory.rack(rack));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:StorageService.java


示例6: getNewSourceRanges

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的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


示例7: sameDCPredicateFor

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static Predicate<InetAddress> sameDCPredicateFor(final String dc)
{
    final IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    return new Predicate<InetAddress>()
    {
        public boolean apply(InetAddress host)
        {
            return dc.equals(snitch.getDatacenter(host));
        }
    };
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:StorageProxy.java


示例8: findSuitableEndpoint

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
/**
 * Find a suitable replica as leader for counter update.
 * For now, we pick a random replica in the local DC (or ask the snitch if
 * there is no replica alive in the local DC).
 * TODO: if we track the latency of the counter writes (which makes sense
 * contrarily to standard writes since there is a read involved), we could
 * trust the dynamic snitch entirely, which may be a better solution. It
 * is unclear we want to mix those latencies with read latencies, so this
 * may be a bit involved.
 */
private static InetAddress findSuitableEndpoint(String keyspaceName, ByteBuffer key, String localDataCenter, ConsistencyLevel cl) throws UnavailableException
{
    Keyspace keyspace = Keyspace.open(keyspaceName);
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, key);
    if (endpoints.isEmpty())
        // TODO have a way to compute the consistency level
        throw new UnavailableException(cl, cl.blockFor(keyspace), 0);

    List<InetAddress> localEndpoints = new ArrayList<InetAddress>();
    for (InetAddress endpoint : endpoints)
    {
        if (snitch.getDatacenter(endpoint).equals(localDataCenter))
            localEndpoints.add(endpoint);
    }
    if (localEndpoints.isEmpty())
    {
        // No endpoint in local DC, pick the closest endpoint according to the snitch
        snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints);
        return endpoints.get(0);
    }
    else
    {
        return localEndpoints.get(ThreadLocalRandom.current().nextInt(localEndpoints.size()));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:37,代码来源:StorageProxy.java


示例9: setupVersion

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static void setupVersion()
{
    String req = "INSERT INTO system.%s (key, release_version, cql_version, thrift_version, native_protocol_version, data_center, rack, partitioner) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    executeOnceInternal(String.format(req, LOCAL_CF),
                        LOCAL_KEY,
                        FBUtilities.getReleaseVersionString(),
                        QueryProcessor.CQL_VERSION.toString(),
                        cassandraConstants.VERSION,
                        String.valueOf(Server.CURRENT_VERSION),
                        snitch.getDatacenter(FBUtilities.getBroadcastAddress()),
                        snitch.getRack(FBUtilities.getBroadcastAddress()),
                        DatabaseDescriptor.getPartitioner().getClass().getName());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:SystemKeyspace.java


示例10: createEndpointSnitch

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static IEndpointSnitch createEndpointSnitch(String snitchClassName) throws ConfigurationException
{
    if (!snitchClassName.contains("."))
        snitchClassName = "org.apache.cassandra.locator." + snitchClassName;
    IEndpointSnitch snitch = FBUtilities.construct(snitchClassName, "snitch");
    return conf.dynamic_snitch ? new DynamicEndpointSnitch(snitch) : snitch;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:DatabaseDescriptor.java


示例11: setUp

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws ConfigurationException
{
    IEndpointSnitch snitch = new PropertyFileSnitch();
    DatabaseDescriptor.setEndpointSnitch(snitch);
    Keyspace.setInitialized();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:StorageServiceServerTest.java


示例12: getBatchlogEndpoints

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static Collection<InetAddress> getBatchlogEndpoints(String localDataCenter, ConsistencyLevel consistencyLevel) throws UnavailableException
{
    // will include every known node in the DC, including localhost.
    TokenMetadata.Topology topology = StorageService.instance.getTokenMetadata().cloneOnlyTokenMap().getTopology();
    Collection<InetAddress> localMembers = topology.getDatacenterEndpoints().get(localDataCenter);

    // special case for single-node datacenters
    if (localMembers.size() == 1)
        return localMembers;

    // not a single-node cluster - don't count the local node.
    localMembers.remove(FBUtilities.getBroadcastAddress());

    // include only alive nodes
    List<InetAddress> candidates = new ArrayList<InetAddress>(localMembers.size());
    for (InetAddress member : localMembers)
    {
        if (FailureDetector.instance.isAlive(member))
            candidates.add(member);
    }

    if (candidates.isEmpty())
    {
        if (consistencyLevel == ConsistencyLevel.ANY)
            return Collections.singleton(FBUtilities.getBroadcastAddress());

        throw new UnavailableException(ConsistencyLevel.ONE, 1, 0);
    }

    if (candidates.size() > 2)
    {
        IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
        snitch.sortByProximity(FBUtilities.getBroadcastAddress(), candidates);
        candidates = candidates.subList(0, 2);
    }

    return candidates;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:39,代码来源:StorageProxy.java


示例13: findSuitableEndpoint

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
/**
 * Find a suitable replica as leader for counter update.
 * For now, we pick a random replica in the local DC (or ask the snitch if
 * there is no replica alive in the local DC).
 * TODO: if we track the latency of the counter writes (which makes sense
 * contrarily to standard writes since there is a read involved), we could
 * trust the dynamic snitch entirely, which may be a better solution. It
 * is unclear we want to mix those latencies with read latencies, so this
 * may be a bit involved.
 */
private static InetAddress findSuitableEndpoint(String keyspaceName, ByteBuffer key, String localDataCenter, ConsistencyLevel cl) throws UnavailableException
{
    Keyspace keyspace = Keyspace.open(keyspaceName);
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, key);
    if (endpoints.isEmpty())
        // TODO have a way to compute the consistency level
        throw new UnavailableException(cl, cl.blockFor(keyspace), 0);

    List<InetAddress> localEndpoints = new ArrayList<InetAddress>();
    for (InetAddress endpoint : endpoints)
    {
        if (snitch.getDatacenter(endpoint).equals(localDataCenter))
            localEndpoints.add(endpoint);
    }
    if (localEndpoints.isEmpty())
    {
        // No endpoint in local DC, pick the closest endpoint according to the snitch
        snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints);
        return endpoints.get(0);
    }
    else
    {
        return localEndpoints.get(FBUtilities.threadLocalRandom().nextInt(localEndpoints.size()));
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:37,代码来源:StorageProxy.java


示例14: setupVersion

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static void setupVersion()
{
    String req = "INSERT INTO system.%s (key, release_version, cql_version, thrift_version, native_protocol_version, data_center, rack, partitioner) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')";
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    processInternal(String.format(req, LOCAL_CF,
                                     LOCAL_KEY,
                                     FBUtilities.getReleaseVersionString(),
                                     QueryProcessor.CQL_VERSION.toString(),
                                     cassandraConstants.VERSION,
                                     Server.CURRENT_VERSION,
                                     snitch.getDatacenter(FBUtilities.getBroadcastAddress()),
                                     snitch.getRack(FBUtilities.getBroadcastAddress()),
                                     DatabaseDescriptor.getPartitioner().getClass().getName()));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:15,代码来源:SystemKeyspace.java


示例15: persistLocalMetadata

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
public static void persistLocalMetadata()
{
    String req = "INSERT INTO system.%s (" +
                 "key," +
                 "cluster_name," +
                 "release_version," +
                 "cql_version," +
                 "thrift_version," +
                 "native_protocol_version," +
                 "data_center," +
                 "rack," +
                 "partitioner," +
                 "rpc_address," +
                 "broadcast_address," +
                 "listen_address" +
                 ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    executeOnceInternal(String.format(req, LOCAL),
                        LOCAL,
                        DatabaseDescriptor.getClusterName(),
                        FBUtilities.getReleaseVersionString(),
                        QueryProcessor.CQL_VERSION.toString(),
                        cassandraConstants.VERSION,
                        String.valueOf(Server.CURRENT_VERSION),
                        snitch.getDatacenter(FBUtilities.getBroadcastAddress()),
                        snitch.getRack(FBUtilities.getBroadcastAddress()),
                        DatabaseDescriptor.getPartitioner().getClass().getName(),
                        DatabaseDescriptor.getRpcAddress(),
                        FBUtilities.getBroadcastAddress(),
                        FBUtilities.getLocalAddress());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:32,代码来源:SystemKeyspace.java


示例16: getBatchlogEndpoints

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static Collection<InetAddress> getBatchlogEndpoints(String localDataCenter) throws UnavailableException
{
    // will include every known node in the DC, including localhost.
    TokenMetadata.Topology topology = StorageService.instance.getTokenMetadata().cloneOnlyTokenMap().getTopology();
    Collection<InetAddress> localMembers = topology.getDatacenterEndpoints().get(localDataCenter);

    // special case for single-node datacenters
    if (localMembers.size() == 1)
        return localMembers;

    // not a single-node cluster - don't count the local node.
    localMembers.remove(FBUtilities.getBroadcastAddress());

    // include only alive nodes
    List<InetAddress> candidates = new ArrayList<InetAddress>(localMembers.size());
    for (InetAddress member : localMembers)
    {
        if (FailureDetector.instance.isAlive(member))
            candidates.add(member);
    }

    if (candidates.isEmpty())
        throw new UnavailableException(ConsistencyLevel.ONE, 1, 0);

    if (candidates.size() > 2)
    {
        IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
        snitch.sortByProximity(FBUtilities.getBroadcastAddress(), candidates);
        candidates = candidates.subList(0, 2);
    }

    return candidates;
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:34,代码来源:StorageProxy.java


示例17: findSuitableEndpoint

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
/**
 * Find a suitable replica as leader for counter update.
 * For now, we pick a random replica in the local DC (or ask the snitch if
 * there is no replica alive in the local DC).
 * TODO: if we track the latency of the counter writes (which makes sense
 * contrarily to standard writes since there is a read involved), we could
 * trust the dynamic snitch entirely, which may be a better solution. It
 * is unclear we want to mix those latencies with read latencies, so this
 * may be a bit involved.
 */
private static InetAddress findSuitableEndpoint(String tableName, ByteBuffer key, String localDataCenter, ConsistencyLevel cl) throws UnavailableException
{
    Table table = Table.open(tableName);
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(table, key);
    if (endpoints.isEmpty())
        // TODO have a way to compute the consistency level
        throw new UnavailableException(cl, cl.blockFor(table), 0);

    List<InetAddress> localEndpoints = new ArrayList<InetAddress>();
    for (InetAddress endpoint : endpoints)
    {
        if (snitch.getDatacenter(endpoint).equals(localDataCenter))
            localEndpoints.add(endpoint);
    }
    if (localEndpoints.isEmpty())
    {
        // No endpoint in local DC, pick the closest endpoint according to the snitch
        snitch.sortByProximity(FBUtilities.getBroadcastAddress(), endpoints);
        return endpoints.get(0);
    }
    else
    {
        return localEndpoints.get(FBUtilities.threadLocalRandom().nextInt(localEndpoints.size()));
    }
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:37,代码来源:StorageProxy.java


示例18: setupVersion

import org.apache.cassandra.locator.IEndpointSnitch; //导入依赖的package包/类
private static void setupVersion()
{
    String req = "INSERT INTO system.%s (key, release_version, cql_version, thrift_version, data_center, rack, partitioner) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')";
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    processInternal(String.format(req, LOCAL_CF,
                                     LOCAL_KEY,
                                     FBUtilities.getReleaseVersionString(),
                                     QueryProcessor.CQL_VERSION.toString(),
                                     Constants.VERSION,
                                     snitch.getDatacenter(FBUtilities.getBroadcastAddress()),
                                     snitch.getRack(FBUtilities.getBroadcastAddress()),
                                     DatabaseDescriptor.getPartitioner().getClass().getName()));
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:14,代码来源:SystemTable.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocateReplyMessage类代码示例发布时间:2022-05-22
下一篇:
Java SignedData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap