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


Java SystemKeyspace.updatePeerInfo方法代码示例

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


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

示例1: updatePeerInfo

import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
private void updatePeerInfo(InetAddress endpoint)
{
    EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
    for (Map.Entry<ApplicationState, VersionedValue> entry : epState.getApplicationStateMap().entrySet())
    {
        switch (entry.getKey())
        {
            case RELEASE_VERSION:
                SystemKeyspace.updatePeerInfo(endpoint, "release_version", entry.getValue().value);
                break;
            case DC:
                SystemKeyspace.updatePeerInfo(endpoint, "data_center", entry.getValue().value);
                break;
            case RACK:
                SystemKeyspace.updatePeerInfo(endpoint, "rack", entry.getValue().value);
                break;
            case RPC_ADDRESS:
                try
                {
                    SystemKeyspace.updatePeerInfo(endpoint, "rpc_address", InetAddress.getByName(entry.getValue().value));
                }
                catch (UnknownHostException e)
                {
                    throw new RuntimeException(e);
                }
                break;
            case SCHEMA:
                SystemKeyspace.updatePeerInfo(endpoint, "schema_version", UUID.fromString(entry.getValue().value));
                break;
            case HOST_ID:
                SystemKeyspace.updatePeerInfo(endpoint, "host_id", UUID.fromString(entry.getValue().value));
                break;
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:36,代码来源:StorageService.java

示例2: testStateChangeOnRemovedNode

import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
/**
 * Tests that the system.peers table is not updated after a node has been removed. (See CASSANDRA-6053)
 */
@Test
public void testStateChangeOnRemovedNode() throws UnknownHostException
{
    StorageService ss = StorageService.instance;
    VersionedValue.VersionedValueFactory valueFactory = new VersionedValue.VersionedValueFactory(partitioner);

    // create a ring of 2 nodes
    ArrayList<Token> endpointTokens = new ArrayList<>();
    List<InetAddress> hosts = new ArrayList<>();
    Util.createInitialRing(ss, partitioner, endpointTokens, new ArrayList<Token>(), hosts, new ArrayList<UUID>(), 2);

    InetAddress toRemove = hosts.get(1);
    SystemKeyspace.updatePeerInfo(toRemove, "data_center", "dc42");
    SystemKeyspace.updatePeerInfo(toRemove, "rack", "rack42");
    assertEquals("rack42", SystemKeyspace.loadDcRackInfo().get(toRemove).get("rack"));

    // mark the node as removed
    Gossiper.instance.injectApplicationState(toRemove, ApplicationState.STATUS,
            valueFactory.left(Collections.singleton(endpointTokens.get(1)), Gossiper.computeExpireTime()));
    assertTrue(Gossiper.instance.isDeadState(Gossiper.instance.getEndpointStateForEndpoint(hosts.get(1))));

    // state changes made after the endpoint has left should be ignored
    ss.onChange(hosts.get(1), ApplicationState.RACK,
            valueFactory.rack("rack9999"));
    assertEquals("rack42", SystemKeyspace.loadDcRackInfo().get(toRemove).get("rack"));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:30,代码来源:LeaveAndBootstrapTest.java

示例3: testStateChangeOnRemovedNode

import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
/**
 * Tests that the system.peers table is not updated after a node has been removed. (See CASSANDRA-6053)
 */
@Test
public void testStateChangeOnRemovedNode() throws UnknownHostException
{
    StorageService ss = StorageService.instance;
    VersionedValue.VersionedValueFactory valueFactory = new VersionedValue.VersionedValueFactory(partitioner);

    // create a ring of 2 nodes
    ArrayList<Token> endpointTokens = new ArrayList<>();
    List<InetAddress> hosts = new ArrayList<>();
    Util.createInitialRing(ss, partitioner, endpointTokens, new ArrayList<Token>(), hosts, new ArrayList<UUID>(), 2);

    InetAddress toRemove = hosts.get(1);
    SystemKeyspace.updatePeerInfo(toRemove, "data_center", "'dc42'");
    SystemKeyspace.updatePeerInfo(toRemove, "rack", "'rack42'");
    assertEquals("rack42", SystemKeyspace.loadDcRackInfo().get(toRemove).get("rack"));

    // mark the node as removed
    Gossiper.instance.injectApplicationState(toRemove, ApplicationState.STATUS,
            valueFactory.left(Collections.singleton(endpointTokens.get(1)), Gossiper.computeExpireTime()));
    assertTrue(Gossiper.instance.isDeadState(Gossiper.instance.getEndpointStateForEndpoint(hosts.get(1))));

    // state changes made after the endpoint has left should be ignored
    ss.onChange(hosts.get(1), ApplicationState.RACK,
            valueFactory.rack("rack9999"));
    assertEquals("rack42", SystemKeyspace.loadDcRackInfo().get(toRemove).get("rack"));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:30,代码来源:LeaveAndBootstrapTest.java

示例4: onChange

import org.apache.cassandra.db.SystemKeyspace; //导入方法依赖的package包/类
public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
{
    if (state.equals(ApplicationState.STATUS))
    {
        String apStateValue = value.value;
        String[] pieces = apStateValue.split(VersionedValue.DELIMITER_STR, -1);
        assert (pieces.length > 0);

        String moveName = pieces[0];

        switch (moveName)
        {
            case VersionedValue.STATUS_BOOTSTRAPPING:
                handleStateBootstrap(endpoint);
                break;
            case VersionedValue.STATUS_NORMAL:
                handleStateNormal(endpoint);
                break;
            case VersionedValue.REMOVING_TOKEN:
            case VersionedValue.REMOVED_TOKEN:
                handleStateRemoving(endpoint, pieces);
                break;
            case VersionedValue.STATUS_LEAVING:
                handleStateLeaving(endpoint);
                break;
            case VersionedValue.STATUS_LEFT:
                handleStateLeft(endpoint, pieces);
                break;
            case VersionedValue.STATUS_MOVING:
                handleStateMoving(endpoint, pieces);
                break;
        }
    }
    else
    {
        EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
        if (epState == null || Gossiper.instance.isDeadState(epState))
        {
            logger.debug("Ignoring state change for dead or unknown endpoint: {}", endpoint);
            return;
        }

        if (getTokenMetadata().isMember(endpoint))
        {
            switch (state)
            {
                case RELEASE_VERSION:
                    SystemKeyspace.updatePeerInfo(endpoint, "release_version", value.value);
                    break;
                case DC:
                    SystemKeyspace.updatePeerInfo(endpoint, "data_center", value.value);
                    break;
                case RACK:
                    SystemKeyspace.updatePeerInfo(endpoint, "rack", value.value);
                    break;
                case RPC_ADDRESS:
                    try
                    {
                        SystemKeyspace.updatePeerInfo(endpoint, "rpc_address", InetAddress.getByName(value.value));
                    }
                    catch (UnknownHostException e)
                    {
                        throw new RuntimeException(e);
                    }
                    break;
                case SCHEMA:
                    SystemKeyspace.updatePeerInfo(endpoint, "schema_version", UUID.fromString(value.value));
                    MigrationManager.instance.scheduleSchemaPull(endpoint, epState);
                    break;
                case HOST_ID:
                    SystemKeyspace.updatePeerInfo(endpoint, "host_id", UUID.fromString(value.value));
                    break;
            }
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:77,代码来源:StorageService.java


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