本文整理汇总了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;
}
}
}
示例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"));
}
示例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"));
}
示例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;
}
}
}
}