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

Java Gossiper类代码示例

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

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



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

示例1: getRack

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
/**
 * Return the rack for which an endpoint resides in
 *
 * @param endpoint the endpoint to process
 * @return string of rack
 */
public String getRack(InetAddress endpoint)
{
    if (endpoint.equals(FBUtilities.getBroadcastAddress()))
        return myRack;

    EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
    if (epState == null || epState.getApplicationState(ApplicationState.RACK) == null)
    {
        if (psnitch == null)
        {
            if (savedEndpoints == null)
                savedEndpoints = SystemKeyspace.loadDcRackInfo();
            if (savedEndpoints.containsKey(endpoint))
                return savedEndpoints.get(endpoint).get("rack");
            return DEFAULT_RACK;
        }
        else
            return psnitch.getRack(endpoint);
    }
    return epState.getApplicationState(ApplicationState.RACK).value;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:GossipingPropertyFileSnitch.java


示例2: testRacks

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testRacks() throws IOException, ConfigurationException
{
    az = "ch-gva-1";
    CloudstackSnitch snitch = new TestCloudstackSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");

    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = new EnumMap<>(ApplicationState.class);
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("ch-zrh"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.rack("2"));
    Gossiper.instance.getEndpointStateForEndpoint(nonlocal).addApplicationStates(stateMap);

    assertEquals("ch-zrh", snitch.getDatacenter(nonlocal));
    assertEquals("2", snitch.getRack(nonlocal));

    assertEquals("ch-gva", snitch.getDatacenter(local));
    assertEquals("1", snitch.getRack(local));

}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:CloudstackSnitchTest.java


示例3: testRac

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testRac() throws IOException, ConfigurationException
{
    az = "us-central1-a";
    GoogleCloudSnitch snitch = new TestGoogleCloudSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");

    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = new EnumMap<>(ApplicationState.class);
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("europe-west1"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("a"));
    Gossiper.instance.getEndpointStateForEndpoint(nonlocal).addApplicationStates(stateMap);

    assertEquals("europe-west1", snitch.getDatacenter(nonlocal));
    assertEquals("a", snitch.getRack(nonlocal));

    assertEquals("us-central1", snitch.getDatacenter(local));
    assertEquals("a", snitch.getRack(local));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:GoogleCloudSnitchTest.java


示例4: initClient

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
public synchronized void initClient() throws ConfigurationException
{
    // We don't wait, because we're going to actually try to work on
    initClient(0);

    // sleep a while to allow gossip to warm up (the other nodes need to know about this one before they can reply).
    outer:
    while (true)
    {
        Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
        for (InetAddress address : Gossiper.instance.getLiveMembers())
        {
            if (!Gossiper.instance.isFatClient(address))
                break outer;
        }
    }

    // sleep until any schema migrations have finished
    while (!MigrationManager.isReadyForBootstrap())
    {
        Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:StorageService.java


示例5: bootstrap

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
private void bootstrap(Collection<Token> tokens)
{
    isBootstrapMode = true;
    SystemKeyspace.updateTokens(tokens); // DON'T use setToken, that makes us part of the ring locally which is incorrect until we are done bootstrapping
    if (!DatabaseDescriptor.isReplacing())
    {
        // if not an existing token then bootstrap
        List<Pair<ApplicationState, VersionedValue>> states = new ArrayList<Pair<ApplicationState, VersionedValue>>();
        states.add(Pair.create(ApplicationState.TOKENS, valueFactory.tokens(tokens)));
        states.add(Pair.create(ApplicationState.STATUS, valueFactory.bootstrapping(tokens)));
        Gossiper.instance.addLocalApplicationStates(states);
        setMode(Mode.JOINING, "sleeping " + RING_DELAY + " ms for pending range setup", true);
        Uninterruptibles.sleepUninterruptibly(RING_DELAY, TimeUnit.MILLISECONDS);
    }
    else
    {
        // Dont set any state for the node which is bootstrapping the existing token...
        tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress());
        SystemKeyspace.removeEndpoint(DatabaseDescriptor.getReplaceAddress());
    }
    if (!Gossiper.instance.seenAnySeed())
        throw new IllegalStateException("Unable to contact any seeds!");
    setMode(Mode.JOINING, "Starting to bootstrap...", true);
    new BootStrapper(FBUtilities.getBroadcastAddress(), tokens, tokenMetadata).bootstrap(); // handles token update
    logger.info("Bootstrap completed! for the tokens {}", tokens);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:StorageService.java


示例6: forceRemoveCompletion

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
/**
 * Force a remove operation to complete. This may be necessary if a remove operation
 * blocks forever due to node/stream failure. removeToken() must be called
 * first, this is a last resort measure.  No further attempt will be made to restore replicas.
 */
public void forceRemoveCompletion()
{
    if (!replicatingNodes.isEmpty()  || !tokenMetadata.getLeavingEndpoints().isEmpty())
    {
        logger.warn("Removal not confirmed for for {}", StringUtils.join(this.replicatingNodes, ","));
        for (InetAddress endpoint : tokenMetadata.getLeavingEndpoints())
        {
            UUID hostId = tokenMetadata.getHostId(endpoint);
            Gossiper.instance.advertiseTokenRemoved(endpoint, hostId);
            excise(tokenMetadata.getTokens(endpoint), endpoint);
        }
        replicatingNodes.clear();
        removingNode = null;
    }
    else
    {
        logger.warn("No tokens to force removal on, call 'removenode' first");
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:StorageService.java


示例7: testFlushUnwriteableStop

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testFlushUnwriteableStop() throws Throwable
{
    makeTable();

    DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore()))
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.stop);
        flushAndExpectError();
        Assert.assertFalse(Gossiper.instance.isEnabled());
    }
    finally
    {
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:OutOfSpaceTest.java


示例8: testRacks

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testRacks() throws IOException, ConfigurationException
{
    az = "ch-gva-1";
    CloudstackSnitch snitch = new TestCloudstackSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");

    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState,VersionedValue> stateMap = Gossiper.instance.getEndpointStateForEndpoint(nonlocal).getApplicationStateMap();
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("ch-zrh"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.rack("2"));

    assertEquals("ch-zrh", snitch.getDatacenter(nonlocal));
    assertEquals("2", snitch.getRack(nonlocal));

    assertEquals("ch-gva", snitch.getDatacenter(local));
    assertEquals("1", snitch.getRack(local));

}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:CloudstackSnitchTest.java


示例9: testRac

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testRac() throws IOException, ConfigurationException
{
    az = "us-central1-a";
    GoogleCloudSnitch snitch = new TestGoogleCloudSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");

    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState,VersionedValue> stateMap = Gossiper.instance.getEndpointStateForEndpoint(nonlocal).getApplicationStateMap();
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("europe-west1"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("a"));

    assertEquals("europe-west1", snitch.getDatacenter(nonlocal));
    assertEquals("a", snitch.getRack(nonlocal));

    assertEquals("us-central1", snitch.getDatacenter(local));
    assertEquals("a", snitch.getRack(local));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:GoogleCloudSnitchTest.java


示例10: getDatacenter

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
/**
 * Return the data center for which an endpoint resides in
 *
 * @param endpoint the endpoint to process
 * @return string of data center
 */
public String getDatacenter(InetAddress endpoint)
{
    if (endpoint.equals(FBUtilities.getBroadcastAddress()))
        return myDC;

    EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
    if (epState == null || epState.getApplicationState(ApplicationState.DC) == null)
    {
        if (psnitch == null)
        {
            if (savedEndpoints == null)
                savedEndpoints = SystemKeyspace.loadDcRackInfo();
            if (savedEndpoints.containsKey(endpoint))
                return savedEndpoints.get(endpoint).get("data_center");
            return DEFAULT_DC;
        }
        else
            return psnitch.getDatacenter(endpoint);
    }
    return epState.getApplicationState(ApplicationState.DC).value;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:28,代码来源:GossipingPropertyFileSnitch.java


示例11: maybeSetApplicationState

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
/**
 * be careful about just blindly updating ApplicationState.INTERNAL_IP everytime we read the yaml file,
 * as that can cause connections to get unnecessarily reset (via IESCS.onChange()).
 */
private void maybeSetApplicationState()
{
    if (localNodeData.dcLocalAddress == null)
        return;
    final EndpointState es = Gossiper.instance.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress());
    if (es == null)
        return;
    final VersionedValue vv = es.getApplicationState(ApplicationState.INTERNAL_IP);
    if ((vv != null && !vv.value.equals(localNodeData.dcLocalAddress.toString()))
        || vv == null)
    {
        Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP,
            StorageService.instance.valueFactory.internalIP(localNodeData.dcLocalAddress.toString()));
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:YamlFileNetworkTopologySnitch.java


示例12: run

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
public void run()
{
    double report = -1;
    try
    {
        report = getIOWait();
    }
    catch (IOException e)
    {
        // ignore;
        if (isUnix())
            logger.warn("Couldn't read /proc/stats");
    }
    if (report == -1d)
        report = compaction_severity.get();

    if (!Gossiper.instance.isEnabled())
        return;
    VersionedValue updated = StorageService.instance.valueFactory.severity(report);
    Gossiper.instance.addLocalApplicationState(ApplicationState.SEVERITY, updated);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:BackgroundActivityMonitor.java


示例13: shouldHint

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
public static boolean shouldHint(InetAddress ep)
{
    if (!DatabaseDescriptor.hintedHandoffEnabled())
    {
        HintedHandOffManager.instance.metrics.incrPastWindow(ep);
        return false;
    }

    boolean hintWindowExpired = Gossiper.instance.getEndpointDowntime(ep) > DatabaseDescriptor.getMaxHintWindow();
    if (hintWindowExpired)
    {
        HintedHandOffManager.instance.metrics.incrPastWindow(ep);
        Tracing.trace("Not hinting {} which has been down {}ms", ep, Gossiper.instance.getEndpointDowntime(ep));
    }
    return !hintWindowExpired;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:17,代码来源:StorageProxy.java


示例14: testRac

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testRac() throws IOException, ConfigurationException
{
    az = "us-east-1d";
    Ec2Snitch snitch = new TestEC2Snitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");

    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState,VersionedValue> stateMap = Gossiper.instance.getEndpointStateForEndpoint(nonlocal).getApplicationStateMap();
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("us-west"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("1a"));

    assertEquals("us-west", snitch.getDatacenter(nonlocal));
    assertEquals("1a", snitch.getRack(nonlocal));

    assertEquals("us-east", snitch.getDatacenter(local));
    assertEquals("1d", snitch.getRack(local));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:EC2SnitchTest.java


示例15: testCommitFailurePolicy_stop

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
@Test
public void testCommitFailurePolicy_stop() throws ConfigurationException
{
    CassandraDaemon daemon = new CassandraDaemon();
    daemon.completeSetup(); //startup must be completed, otherwise commit log failure must kill JVM regardless of failure policy
    StorageService.instance.registerDaemon(daemon);

    // Need storage service active so stop policy can shutdown gossip
    StorageService.instance.initServer();
    Assert.assertTrue(Gossiper.instance.isEnabled());

    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.stop);
        CommitLog.handleCommitError("Test stop error", new Throwable());
        Assert.assertFalse(Gossiper.instance.isEnabled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CommitLogFailurePolicyTest.java


示例16: main

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


示例17: gossiperStarting

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
public void gossiperStarting()
{
    super.gossiperStarting();

    Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP,
            StorageService.instance.valueFactory.internalIP(FBUtilities.getLocalAddress().getHostAddress()));

    reloadGossiperState();

    gossipStarted = true;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:GossipingPropertyFileSnitch.java


示例18: reloadGossiperState

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
private void reloadGossiperState()
{
    if (Gossiper.instance != null)
    {
        ReconnectableSnitchHelper pendingHelper = new ReconnectableSnitchHelper(this, myDC, preferLocal);
        Gossiper.instance.register(pendingHelper);
        
        pendingHelper = snitchHelperReference.getAndSet(pendingHelper);
        if (pendingHelper != null)
            Gossiper.instance.unregister(pendingHelper);
    }
    // else this will eventually rerun at gossiperStarting()
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:GossipingPropertyFileSnitch.java


示例19: getRack

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
public String getRack(InetAddress endpoint)
{
    if (endpoint.equals(FBUtilities.getBroadcastAddress()))
        return csZoneRack;
    EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
    if (state == null || state.getApplicationState(ApplicationState.RACK) == null) 
    {
        if (savedEndpoints == null)
            savedEndpoints = SystemKeyspace.loadDcRackInfo();
        if (savedEndpoints.containsKey(endpoint))
            return savedEndpoints.get(endpoint).get("rack");
        return DEFAULT_RACK;
    }
    return state.getApplicationState(ApplicationState.RACK).value;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:CloudstackSnitch.java


示例20: gossiperStarting

import org.apache.cassandra.gms.Gossiper; //导入依赖的package包/类
/**
 * Called in preparation for the initiation of the gossip loop.
 */
@Override
public synchronized void gossiperStarting()
{
    gossiperInitialized = true;
    StorageService.instance.gossipSnitchInfo();
    Gossiper.instance.register(new ReconnectableSnitchHelper(this, localNodeData.datacenter, true));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:YamlFileNetworkTopologySnitch.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ApiKey类代码示例发布时间:2022-05-22
下一篇:
Java FocusTraversalOnArray类代码示例发布时间: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