Skip to content

Commit

Permalink
rename SystemKeyspace to ClusterMetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed Apr 25, 2015
1 parent c610390 commit 2155044
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 66 deletions.
Expand Up @@ -36,7 +36,7 @@
import org.lealone.cluster.auth.IInternodeAuthenticator;
import org.lealone.cluster.config.EncryptionOptions.ClientEncryptionOptions;
import org.lealone.cluster.config.EncryptionOptions.ServerEncryptionOptions;
import org.lealone.cluster.db.SystemKeyspace;
import org.lealone.cluster.db.ClusterMetaData;
import org.lealone.cluster.dht.IPartitioner;
import org.lealone.cluster.exceptions.ConfigurationException;
import org.lealone.cluster.locator.AbstractReplicationStrategy;
Expand Down Expand Up @@ -333,7 +333,7 @@ public static UUID getReplaceNode() {

public static boolean isReplacing() {
if (System.getProperty("lealone.replace_address_first_boot", null) != null
&& SystemKeyspace.bootstrapComplete()) {
&& ClusterMetaData.bootstrapComplete()) {
logger.info("Replace address on first boot requested; this node is already bootstrapped");
return false;
}
Expand Down
Expand Up @@ -26,8 +26,8 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap;

public class SystemKeyspace {
private static final Logger logger = LoggerFactory.getLogger(SystemKeyspace.class);
public class ClusterMetaData {
private static final Logger logger = LoggerFactory.getLogger(ClusterMetaData.class);

//private static Connection conn;
private static Statement stmt;
Expand Down Expand Up @@ -265,9 +265,8 @@ public static int incrementAndGetGeneration() {
final int storedGeneration = generation + 1;
final int now = (int) (System.currentTimeMillis() / 1000);
if (storedGeneration >= now) {
logger.warn(
"Using stored Gossip Generation {} as it is greater than current system time {}. See CASSANDRA-3654 if you experience problems",
storedGeneration, now);
logger.warn("Using stored Gossip Generation {} as it is greater than current system time {}. "
+ "See CASSANDRA-3654 if you experience problems", storedGeneration, now);
generation = storedGeneration;
} else {
generation = now;
Expand Down
Expand Up @@ -4,14 +4,17 @@
import org.lealone.cluster.locator.AbstractReplicationStrategy;

public class Keyspace {
private static Keyspace INSTANCE = new Keyspace();

public static Keyspace open(String keyspaceName) {
return INSTANCE;
}

public static Keyspace INSTANCE = new Keyspace();
public static Iterable<Keyspace> all() {
return null;
}

AbstractReplicationStrategy replicationStrategy;
private final AbstractReplicationStrategy replicationStrategy;

public Keyspace() {
//TODO 按表或按数据库配置
Expand All @@ -22,10 +25,6 @@ public AbstractReplicationStrategy getReplicationStrategy() {
return replicationStrategy;
}

public static Iterable<Keyspace> all() {
return null;
}

public String getName() {
return null;
}
Expand Down
Expand Up @@ -32,7 +32,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.lealone.cluster.db.SystemKeyspace;
import org.lealone.cluster.db.ClusterMetaData;
import org.lealone.cluster.exceptions.ConfigurationException;
import org.lealone.cluster.gms.ApplicationState;
import org.lealone.cluster.gms.EndpointState;
Expand Down Expand Up @@ -81,7 +81,7 @@ public String getRack(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.RACK) == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("rack");
return DEFAULT_RACK;
Expand All @@ -96,7 +96,7 @@ public String getDatacenter(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.DC) == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("data_center");
return DEFAULT_DC;
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Map;

import org.lealone.cluster.db.SystemKeyspace;
import org.lealone.cluster.db.ClusterMetaData;
import org.lealone.cluster.exceptions.ConfigurationException;
import org.lealone.cluster.gms.ApplicationState;
import org.lealone.cluster.gms.EndpointState;
Expand Down Expand Up @@ -93,7 +93,7 @@ public String getRack(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.RACK) == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("rack");
return DEFAULT_RACK;
Expand All @@ -108,7 +108,7 @@ public String getDatacenter(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.DC) == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("data_center");
return DEFAULT_DC;
Expand Down
Expand Up @@ -26,7 +26,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Map;

import org.lealone.cluster.db.SystemKeyspace;
import org.lealone.cluster.db.ClusterMetaData;
import org.lealone.cluster.exceptions.ConfigurationException;
import org.lealone.cluster.gms.ApplicationState;
import org.lealone.cluster.gms.EndpointState;
Expand Down Expand Up @@ -96,7 +96,7 @@ public String getRack(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.RACK) == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("rack");
return DEFAULT_RACK;
Expand All @@ -111,7 +111,7 @@ public String getDatacenter(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.DC) == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("data_center");
return DEFAULT_DC;
Expand Down
Expand Up @@ -21,7 +21,7 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

import org.lealone.cluster.db.SystemKeyspace;
import org.lealone.cluster.db.ClusterMetaData;
import org.lealone.cluster.exceptions.ConfigurationException;
import org.lealone.cluster.gms.ApplicationState;
import org.lealone.cluster.gms.EndpointState;
Expand Down Expand Up @@ -97,7 +97,7 @@ public String getDatacenter(InetAddress endpoint) {
if (epState == null || epState.getApplicationState(ApplicationState.DC) == null) {
if (psnitch == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("data_center");
return DEFAULT_DC;
Expand All @@ -122,7 +122,7 @@ public String getRack(InetAddress endpoint) {
if (epState == null || epState.getApplicationState(ApplicationState.RACK) == null) {
if (psnitch == null) {
if (savedEndpoints == null)
savedEndpoints = SystemKeyspace.loadDcRackInfo();
savedEndpoints = ClusterMetaData.loadDcRackInfo();
if (savedEndpoints.containsKey(endpoint))
return savedEndpoints.get(endpoint).get("rack");
return DEFAULT_RACK;
Expand Down
Expand Up @@ -28,7 +28,7 @@
import org.lealone.cluster.concurrent.Stage;
import org.lealone.cluster.config.Config;
import org.lealone.cluster.config.DatabaseDescriptor;
import org.lealone.cluster.db.SystemKeyspace;
import org.lealone.cluster.db.ClusterMetaData;
import org.lealone.cluster.locator.IEndpointSnitch;
import org.lealone.cluster.metrics.ConnectionMetrics;
import org.lealone.cluster.security.SSLFactory;
Expand All @@ -46,7 +46,7 @@ public class OutboundTcpConnectionPool {

OutboundTcpConnectionPool(InetAddress remoteEp) {
id = remoteEp;
resetEndpoint = SystemKeyspace.getPreferredIP(remoteEp);
resetEndpoint = ClusterMetaData.getPreferredIP(remoteEp);
started = new CountDownLatch(1);

cmdCon = new OutboundTcpConnection(this);
Expand Down Expand Up @@ -81,7 +81,7 @@ public void resetToNewerVersion(int version) {
* @param remoteEP
*/
public void reset(InetAddress remoteEP) {
SystemKeyspace.updatePreferredIP(id, remoteEP);
ClusterMetaData.updatePreferredIP(id, remoteEP);
resetEndpoint = remoteEP;
for (OutboundTcpConnection conn : new OutboundTcpConnection[] { cmdCon, ackCon })
conn.softCloseSocket();
Expand Down

0 comments on commit 2155044

Please sign in to comment.