diff --git a/priam/src/main/java/com/netflix/priam/IConfiguration.java b/priam/src/main/java/com/netflix/priam/IConfiguration.java index befd55e0c..b7b7747cb 100644 --- a/priam/src/main/java/com/netflix/priam/IConfiguration.java +++ b/priam/src/main/java/com/netflix/priam/IConfiguration.java @@ -95,6 +95,10 @@ public interface IConfiguration { */ public String getDataFileLocation(); + /** + * @return Location of the hints data directory + */ + public String getHintsLocation(); /** * @return Location of local cache */ diff --git a/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java b/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java index 2a2ab298c..7c2993099 100644 --- a/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java +++ b/priam/src/main/java/com/netflix/priam/defaultimpl/PriamConfiguration.java @@ -209,6 +209,7 @@ public class PriamConfiguration implements IConfiguration private final String DEFAULT_DATA_LOCATION = "/var/lib/cassandra/data"; private final String DEFAULT_COMMIT_LOG_LOCATION = "/var/lib/cassandra/commitlog"; private final String DEFAULT_CACHE_LOCATION = "/var/lib/cassandra/saved_caches"; + private final String DEFAULT_HINTS_DIR_LOCATION = "/var/lib/cassandra/hints"; private final String DEFAULT_ENDPOINT_SNITCH = "org.apache.cassandra.locator.Ec2Snitch"; private final String DEFAULT_SEED_PROVIDER = "com.netflix.priam.cassandra.extensions.NFSeedProvider"; private final String DEFAULT_PARTITIONER = "org.apache.cassandra.dht.RandomPartitioner"; @@ -325,6 +326,7 @@ public void intialize() SystemUtils.createDirs(getCommitLogLocation()); SystemUtils.createDirs(getCacheLocation()); SystemUtils.createDirs(getDataFileLocation()); + SystemUtils.createDirs(getHintsLocation()); } private InstanceDataRetriever getInstanceDataRetriever() throws InstantiationException, IllegalAccessException, ClassNotFoundException @@ -490,6 +492,11 @@ public String getDataFileLocation() return config.get(CONFIG_DATA_LOCATION, DEFAULT_DATA_LOCATION); } + @Override + public String getHintsLocation() { + return config.get(PRIAM_PRE + ".hints.location", DEFAULT_HINTS_DIR_LOCATION); + } + @Override public String getCacheLocation() { diff --git a/priam/src/main/java/com/netflix/priam/defaultimpl/StandardTuner.java b/priam/src/main/java/com/netflix/priam/defaultimpl/StandardTuner.java index 5eb823d4c..a2bd6fdcb 100644 --- a/priam/src/main/java/com/netflix/priam/defaultimpl/StandardTuner.java +++ b/priam/src/main/java/com/netflix/priam/defaultimpl/StandardTuner.java @@ -71,6 +71,7 @@ public void writeAllProperties(String yamlLocation, String hostname, String seed map.put("saved_caches_directory", config.getCacheLocation()); map.put("commitlog_directory", config.getCommitLogLocation()); + map.put("hints_directory", config.getHintsLocation()); map.put("data_file_directories", Lists.newArrayList(config.getDataFileLocation())); boolean enableIncremental = (config.getBackupHour() >= 0 && config.isIncrBackup()) && (CollectionUtils.isEmpty(config.getBackupRacs()) || config.getBackupRacs().contains(config.getRac())); map.put("incremental_backups", enableIncremental); diff --git a/priam/src/main/java/com/netflix/priam/identity/InstanceIdentity.java b/priam/src/main/java/com/netflix/priam/identity/InstanceIdentity.java index cfb77b7a8..90ce48b10 100644 --- a/priam/src/main/java/com/netflix/priam/identity/InstanceIdentity.java +++ b/priam/src/main/java/com/netflix/priam/identity/InstanceIdentity.java @@ -66,8 +66,12 @@ public List get() private final Predicate differentHostPredicate = new Predicate() { @Override + /** + * This is used to provide the list of seed providers. + * Since 3.x backported the @see CASSANDRA-10134 we need to ensure that seed list contains all the seed(including itself) or cluster would never come up. + */ public boolean apply(PriamInstance instance) { - return (!instance.getInstanceId().equalsIgnoreCase(DUMMY_INSTANCE_ID) && !instance.getHostName().equals(myInstance.getHostName())); + return (!instance.getInstanceId().equalsIgnoreCase(DUMMY_INSTANCE_ID)); } @Override diff --git a/priam/src/main/java/com/netflix/priam/identity/token/NewTokenRetriever.java b/priam/src/main/java/com/netflix/priam/identity/token/NewTokenRetriever.java index b8fc16112..36eaf8156 100755 --- a/priam/src/main/java/com/netflix/priam/identity/token/NewTokenRetriever.java +++ b/priam/src/main/java/com/netflix/priam/identity/token/NewTokenRetriever.java @@ -70,8 +70,9 @@ public PriamInstance get() throws Exception { if (hash == max && locMap.get(config.getRac()).size() == 0) { int idx = config.getRacs().indexOf(config.getRac()); - Preconditions.checkState(idx >= 0, "Rac %s is not in Racs %s", config.getRac(), config.getRacs()); - my_slot = idx + maxSlot; + if (idx < 0) + throw new Exception(String.format("Rac %s is not in Racs %s", config.getRac(), config.getRacs())); + my_slot = idx + maxSlot; } else my_slot = config.getRacs().size() + maxSlot; diff --git a/priam/src/test/java/com/netflix/priam/FakeConfiguration.java b/priam/src/test/java/com/netflix/priam/FakeConfiguration.java index 94d4d0858..1a79cb3e4 100644 --- a/priam/src/test/java/com/netflix/priam/FakeConfiguration.java +++ b/priam/src/test/java/com/netflix/priam/FakeConfiguration.java @@ -78,6 +78,11 @@ public String getDataFileLocation() return "target/data"; } + @Override + public String getHintsLocation() { + return "target/hints"; + } + @Override public String getCacheLocation() { diff --git a/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java b/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java index 5492aeefc..09e608739 100644 --- a/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java +++ b/priam/src/test/java/com/netflix/priam/FakeConfigurationMurmur3.java @@ -78,6 +78,11 @@ public String getDataFileLocation() return "target/data"; } + @Override + public String getHintsLocation() { + return "target/hints"; + } + @Override public String getCacheLocation() {