Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 027D8D4FF for ; Tue, 21 May 2013 18:54:13 +0000 (UTC) Received: (qmail 30142 invoked by uid 500); 21 May 2013 18:54:10 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 29664 invoked by uid 500); 21 May 2013 18:54:10 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 29569 invoked by uid 99); 21 May 2013 18:54:09 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 May 2013 18:54:09 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6CD6C89145A; Tue, 21 May 2013 18:54:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jbellis@apache.org To: commits@cassandra.apache.org Date: Tue, 21 May 2013 18:54:13 -0000 Message-Id: <706351cf1aa349ea8f78f70e015e7710@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/11] git commit: merge from 1.2 merge from 1.2 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8aa6222b Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8aa6222b Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8aa6222b Branch: refs/heads/trunk Commit: 8aa6222bf16b1087f3b9a245ac3fef424269cac8 Parents: 1d2c122 40669a3 Author: Jonathan Ellis Authored: Tue May 21 13:45:22 2013 -0500 Committer: Jonathan Ellis Committed: Tue May 21 13:45:22 2013 -0500 ---------------------------------------------------------------------- CHANGES.txt | 11 ++++++++ conf/cassandra.yaml | 6 +---- src/java/org/apache/cassandra/config/Config.java | 2 + .../cassandra/config/DatabaseDescriptor.java | 8 ------ .../cassandra/hadoop/ColumnFamilyOutputFormat.java | 2 +- .../cassandra/hadoop/ColumnFamilyRecordReader.java | 2 +- .../org/apache/cassandra/hadoop/ConfigHelper.java | 17 +------------ .../apache/cassandra/thrift/TBinaryProtocol.java | 19 --------------- .../org/apache/cassandra/thrift/ThriftServer.java | 2 +- 9 files changed, 18 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/CHANGES.txt ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/conf/cassandra.yaml ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/src/java/org/apache/cassandra/config/Config.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 775e884,a5bfcf2..b33f6fd --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@@ -85,392 -91,422 +85,389 @@@ public class DatabaseDescripto private static String localDC; private static Comparator localComparator; - /** - * Inspect the classpath to find storage configuration file - */ - static URL getStorageConfigURL() throws ConfigurationException + static { - String configUrl = System.getProperty("cassandra.config"); - if (configUrl == null) - configUrl = DEFAULT_CONFIGURATION; - - URL url; - try - { - url = new URL(configUrl); - url.openStream().close(); // catches well-formed but bogus URLs - } - catch (Exception e) + // In client mode, we use a default configuration. Note that the fields of this class will be + // left unconfigured however (the partitioner or localDC will be null for instance) so this + // should be used with care. + if (Config.isClientMode()) { - ClassLoader loader = DatabaseDescriptor.class.getClassLoader(); - url = loader.getResource(configUrl); - if (url == null) - throw new ConfigurationException("Cannot locate " + configUrl); + conf = new Config(); } - - return url; - } - - static - { - if (Config.getLoadYaml()) - loadYaml(); else - conf = new Config(); - } - static void loadYaml() - { - try { - URL url = getStorageConfigURL(); - logger.info("Loading settings from " + url); - InputStream input; try { - input = url.openStream(); + applyConfig(loadConfig()); } - catch (IOException e) + catch (ConfigurationException e) { - // getStorageConfigURL should have ruled this out - throw new AssertionError(e); + logger.error("Fatal configuration error", e); + System.err.println(e.getMessage() + "\nFatal configuration error; unable to start server. See log for stacktrace."); + System.exit(1); } - org.yaml.snakeyaml.constructor.Constructor constructor = new org.yaml.snakeyaml.constructor.Constructor(Config.class); - TypeDescription seedDesc = new TypeDescription(SeedProviderDef.class); - seedDesc.putMapPropertyType("parameters", String.class, String.class); - constructor.addTypeDescription(seedDesc); - Yaml yaml = new Yaml(new Loader(constructor)); - conf = (Config)yaml.load(input); - - logger.info("Data files directories: " + Arrays.toString(conf.data_file_directories)); - logger.info("Commit log directory: " + conf.commitlog_directory); - - if (conf.commitlog_sync == null) + catch (Exception e) { - throw new ConfigurationException("Missing required directive CommitLogSync"); + logger.error("Fatal error during configuration loading", e); + System.err.println(e.getMessage() + "\nFatal error during configuration loading; unable to start server. See log for stacktrace."); + System.exit(1); } + } + } - if (conf.commitlog_sync == Config.CommitLogSync.batch) - { - if (conf.commitlog_sync_batch_window_in_ms == null) - { - throw new ConfigurationException("Missing value for commitlog_sync_batch_window_in_ms: Double expected."); - } - else if (conf.commitlog_sync_period_in_ms != null) - { - throw new ConfigurationException("Batch sync specified, but commitlog_sync_period_in_ms found. Only specify commitlog_sync_batch_window_in_ms when using batch sync"); - } - logger.debug("Syncing log with a batch window of " + conf.commitlog_sync_batch_window_in_ms); - } - else - { - if (conf.commitlog_sync_period_in_ms == null) - { - throw new ConfigurationException("Missing value for commitlog_sync_period_in_ms: Integer expected"); - } - else if (conf.commitlog_sync_batch_window_in_ms != null) - { - throw new ConfigurationException("commitlog_sync_period_in_ms specified, but commitlog_sync_batch_window_in_ms found. Only specify commitlog_sync_period_in_ms when using periodic sync."); - } - logger.debug("Syncing log with a period of " + conf.commitlog_sync_period_in_ms); - } + @VisibleForTesting + static Config loadConfig() throws ConfigurationException + { + String loaderClass = System.getProperty("cassandra.config.loader"); + ConfigurationLoader loader = loaderClass == null + ? new YamlConfigurationLoader() + : FBUtilities.construct(loaderClass, "configuration loading"); + return loader.loadConfig(); + } + + private static void applyConfig(Config config) throws ConfigurationException + { + conf = config; - if (conf.commitlog_total_space_in_mb == null) - conf.commitlog_total_space_in_mb = System.getProperty("os.arch").contains("64") ? 1024 : 32; + logger.info("Data files directories: " + Arrays.toString(conf.data_file_directories)); + logger.info("Commit log directory: " + conf.commitlog_directory); - /* evaluate the DiskAccessMode Config directive, which also affects indexAccessMode selection */ - if (conf.disk_access_mode == Config.DiskAccessMode.auto) + if (conf.commitlog_sync == null) + { + throw new ConfigurationException("Missing required directive CommitLogSync"); + } + + if (conf.commitlog_sync == Config.CommitLogSync.batch) + { + if (conf.commitlog_sync_batch_window_in_ms == null) { - conf.disk_access_mode = System.getProperty("os.arch").contains("64") ? Config.DiskAccessMode.mmap : Config.DiskAccessMode.standard; - indexAccessMode = conf.disk_access_mode; - logger.info("DiskAccessMode 'auto' determined to be " + conf.disk_access_mode + ", indexAccessMode is " + indexAccessMode ); + throw new ConfigurationException("Missing value for commitlog_sync_batch_window_in_ms: Double expected."); } - else if (conf.disk_access_mode == Config.DiskAccessMode.mmap_index_only) + else if (conf.commitlog_sync_period_in_ms != null) { - conf.disk_access_mode = Config.DiskAccessMode.standard; - indexAccessMode = Config.DiskAccessMode.mmap; - logger.info("DiskAccessMode is " + conf.disk_access_mode + ", indexAccessMode is " + indexAccessMode ); + throw new ConfigurationException("Batch sync specified, but commitlog_sync_period_in_ms found. Only specify commitlog_sync_batch_window_in_ms when using batch sync"); } - else + logger.debug("Syncing log with a batch window of " + conf.commitlog_sync_batch_window_in_ms); + } + else + { + if (conf.commitlog_sync_period_in_ms == null) { - indexAccessMode = conf.disk_access_mode; - logger.info("DiskAccessMode is " + conf.disk_access_mode + ", indexAccessMode is " + indexAccessMode ); + throw new ConfigurationException("Missing value for commitlog_sync_period_in_ms: Integer expected"); } + else if (conf.commitlog_sync_batch_window_in_ms != null) + { + throw new ConfigurationException("commitlog_sync_period_in_ms specified, but commitlog_sync_batch_window_in_ms found. Only specify commitlog_sync_period_in_ms when using periodic sync."); + } + logger.debug("Syncing log with a period of " + conf.commitlog_sync_period_in_ms); + } - logger.info("disk_failure_policy is " + conf.disk_failure_policy); + if (conf.commitlog_total_space_in_mb == null) + conf.commitlog_total_space_in_mb = System.getProperty("os.arch").contains("64") ? 1024 : 32; - /* Authentication and authorization backend, implementing IAuthenticator and IAuthorizer */ - if (conf.authenticator != null) - authenticator = FBUtilities.construct(conf.authenticator, "authenticator"); + /* evaluate the DiskAccessMode Config directive, which also affects indexAccessMode selection */ + if (conf.disk_access_mode == Config.DiskAccessMode.auto) + { + conf.disk_access_mode = System.getProperty("os.arch").contains("64") ? Config.DiskAccessMode.mmap : Config.DiskAccessMode.standard; + indexAccessMode = conf.disk_access_mode; + logger.info("DiskAccessMode 'auto' determined to be " + conf.disk_access_mode + ", indexAccessMode is " + indexAccessMode ); + } + else if (conf.disk_access_mode == Config.DiskAccessMode.mmap_index_only) + { + conf.disk_access_mode = Config.DiskAccessMode.standard; + indexAccessMode = Config.DiskAccessMode.mmap; + logger.info("DiskAccessMode is " + conf.disk_access_mode + ", indexAccessMode is " + indexAccessMode ); + } + else + { + indexAccessMode = conf.disk_access_mode; + logger.info("DiskAccessMode is " + conf.disk_access_mode + ", indexAccessMode is " + indexAccessMode ); + } - if (conf.authority != null) - { - logger.warn("Please rename 'authority' to 'authorizer' in cassandra.yaml"); - if (!conf.authority.equals("org.apache.cassandra.auth.AllowAllAuthority")) - throw new ConfigurationException("IAuthority interface has been deprecated," - + " please implement IAuthorizer instead."); - } + logger.info("disk_failure_policy is " + conf.disk_failure_policy); - if (conf.authorizer != null) - authorizer = FBUtilities.construct(conf.authorizer, "authorizer"); + /* Authentication and authorization backend, implementing IAuthenticator and IAuthorizer */ + if (conf.authenticator != null) + authenticator = FBUtilities.construct(conf.authenticator, "authenticator"); - if (conf.internode_authenticator != null) - internodeAuthenticator = FBUtilities.construct(conf.internode_authenticator, "internode_authenticator"); - else - internodeAuthenticator = new AllowAllInternodeAuthenticator(); + if (conf.authorizer != null) + authorizer = FBUtilities.construct(conf.authorizer, "authorizer"); - authenticator.validateConfiguration(); - authorizer.validateConfiguration(); - internodeAuthenticator.validateConfiguration(); + if (conf.internode_authenticator != null) + internodeAuthenticator = FBUtilities.construct(conf.internode_authenticator, "internode_authenticator"); + else + internodeAuthenticator = new AllowAllInternodeAuthenticator(); - /* Hashing strategy */ - if (conf.partitioner == null) - { - throw new ConfigurationException("Missing directive: partitioner"); - } + authenticator.validateConfiguration(); + authorizer.validateConfiguration(); + internodeAuthenticator.validateConfiguration(); - try - { - partitioner = FBUtilities.newPartitioner(System.getProperty("cassandra.partitioner", conf.partitioner)); - } - catch (Exception e) - { - throw new ConfigurationException("Invalid partitioner class " + conf.partitioner); - } - paritionerName = partitioner.getClass().getCanonicalName(); + /* Hashing strategy */ + if (conf.partitioner == null) + { + throw new ConfigurationException("Missing directive: partitioner"); + } + try + { + partitioner = FBUtilities.newPartitioner(System.getProperty("cassandra.partitioner", conf.partitioner)); + } + catch (Exception e) + { + throw new ConfigurationException("Invalid partitioner class " + conf.partitioner); + } + paritionerName = partitioner.getClass().getCanonicalName(); - /* phi convict threshold for FailureDetector */ - if (conf.phi_convict_threshold < 5 || conf.phi_convict_threshold > 16) - { - throw new ConfigurationException("phi_convict_threshold must be between 5 and 16"); - } + /* phi convict threshold for FailureDetector */ + if (conf.phi_convict_threshold < 5 || conf.phi_convict_threshold > 16) + { + throw new ConfigurationException("phi_convict_threshold must be between 5 and 16"); + } - /* Thread per pool */ - if (conf.concurrent_reads != null && conf.concurrent_reads < 2) - { - throw new ConfigurationException("concurrent_reads must be at least 2"); - } + /* Thread per pool */ + if (conf.concurrent_reads != null && conf.concurrent_reads < 2) + { + throw new ConfigurationException("concurrent_reads must be at least 2"); + } - if (conf.concurrent_writes != null && conf.concurrent_writes < 2) - { - throw new ConfigurationException("concurrent_writes must be at least 2"); - } + if (conf.concurrent_writes != null && conf.concurrent_writes < 2) + { + throw new ConfigurationException("concurrent_writes must be at least 2"); + } - if (conf.concurrent_replicates != null && conf.concurrent_replicates < 2) - { - throw new ConfigurationException("concurrent_replicates must be at least 2"); - } + if (conf.concurrent_replicates != null && conf.concurrent_replicates < 2) + { + throw new ConfigurationException("concurrent_replicates must be at least 2"); + } - if (conf.memtable_total_space_in_mb == null) - conf.memtable_total_space_in_mb = (int) (Runtime.getRuntime().maxMemory() / (3 * 1048576)); - if (conf.memtable_total_space_in_mb <= 0) - throw new ConfigurationException("memtable_total_space_in_mb must be positive"); - logger.info("Global memtable threshold is enabled at {}MB", conf.memtable_total_space_in_mb); + if (conf.memtable_total_space_in_mb == null) + conf.memtable_total_space_in_mb = (int) (Runtime.getRuntime().maxMemory() / (3 * 1048576)); + if (conf.memtable_total_space_in_mb <= 0) + throw new ConfigurationException("memtable_total_space_in_mb must be positive"); + logger.info("Global memtable threshold is enabled at {}MB", conf.memtable_total_space_in_mb); + + /* Memtable flush writer threads */ + if (conf.memtable_flush_writers != null && conf.memtable_flush_writers < 1) + { + throw new ConfigurationException("memtable_flush_writers must be at least 1"); + } + else if (conf.memtable_flush_writers == null) + { + conf.memtable_flush_writers = conf.data_file_directories.length; + } - /* Memtable flush writer threads */ - if (conf.memtable_flush_writers != null && conf.memtable_flush_writers < 1) + /* Local IP or hostname to bind services to */ + if (conf.listen_address != null) + { + try { - throw new ConfigurationException("memtable_flush_writers must be at least 1"); + listenAddress = InetAddress.getByName(conf.listen_address); } - else if (conf.memtable_flush_writers == null) + catch (UnknownHostException e) { - conf.memtable_flush_writers = conf.data_file_directories.length; + throw new ConfigurationException("Unknown listen_address '" + conf.listen_address + "'"); } + } - /* Local IP or hostname to bind services to */ - if (conf.listen_address != null) + /* Gossip Address to broadcast */ + if (conf.broadcast_address != null) + { + if (conf.broadcast_address.equals("0.0.0.0")) { - try - { - listenAddress = InetAddress.getByName(conf.listen_address); - } - catch (UnknownHostException e) - { - throw new ConfigurationException("Unknown listen_address '" + conf.listen_address + "'"); - } + throw new ConfigurationException("broadcast_address cannot be 0.0.0.0!"); } - /* Gossip Address to broadcast */ - if (conf.broadcast_address != null) + try { - if (conf.broadcast_address.equals("0.0.0.0")) - { - throw new ConfigurationException("broadcast_address cannot be 0.0.0.0!"); - } - - try - { - broadcastAddress = InetAddress.getByName(conf.broadcast_address); - } - catch (UnknownHostException e) - { - throw new ConfigurationException("Unknown broadcast_address '" + conf.broadcast_address + "'"); - } + broadcastAddress = InetAddress.getByName(conf.broadcast_address); + } + catch (UnknownHostException e) + { + throw new ConfigurationException("Unknown broadcast_address '" + conf.broadcast_address + "'"); } + } - /* Local IP or hostname to bind RPC server to */ - if (conf.rpc_address != null) + /* Local IP or hostname to bind RPC server to */ + if (conf.rpc_address != null) + { + try { - try - { - rpcAddress = InetAddress.getByName(conf.rpc_address); - } - catch (UnknownHostException e) - { - throw new ConfigurationException("Unknown host in rpc_address " + conf.rpc_address); - } + rpcAddress = InetAddress.getByName(conf.rpc_address); } - else + catch (UnknownHostException e) { - rpcAddress = FBUtilities.getLocalAddress(); + throw new ConfigurationException("Unknown host in rpc_address " + conf.rpc_address); } + } + else + { + rpcAddress = FBUtilities.getLocalAddress(); + } - if (conf.thrift_framed_transport_size_in_mb <= 0) - throw new ConfigurationException("thrift_framed_transport_size_in_mb must be positive"); + if (conf.thrift_framed_transport_size_in_mb <= 0) + throw new ConfigurationException("thrift_framed_transport_size_in_mb must be positive"); - if (conf.thrift_max_message_length_in_mb < conf.thrift_framed_transport_size_in_mb) - throw new ConfigurationException("thrift_max_message_length_in_mb must be greater than thrift_framed_transport_size_in_mb"); - - /* end point snitch */ - if (conf.endpoint_snitch == null) - { - throw new ConfigurationException("Missing endpoint_snitch directive"); - } - snitch = createEndpointSnitch(conf.endpoint_snitch); - EndpointSnitchInfo.create(); + /* end point snitch */ + if (conf.endpoint_snitch == null) + { + throw new ConfigurationException("Missing endpoint_snitch directive"); + } + snitch = createEndpointSnitch(conf.endpoint_snitch); + EndpointSnitchInfo.create(); - localDC = snitch.getDatacenter(FBUtilities.getBroadcastAddress()); - localComparator = new Comparator() + localDC = snitch.getDatacenter(FBUtilities.getBroadcastAddress()); + localComparator = new Comparator() + { + public int compare(InetAddress endpoint1, InetAddress endpoint2) { - public int compare(InetAddress endpoint1, InetAddress endpoint2) - { - boolean local1 = localDC.equals(snitch.getDatacenter(endpoint1)); - boolean local2 = localDC.equals(snitch.getDatacenter(endpoint2)); - if (local1 && !local2) - return -1; - if (local2 && !local1) - return 1; - return 0; - } - }; + boolean local1 = localDC.equals(snitch.getDatacenter(endpoint1)); + boolean local2 = localDC.equals(snitch.getDatacenter(endpoint2)); + if (local1 && !local2) + return -1; + if (local2 && !local1) + return 1; + return 0; + } + }; - /* Request Scheduler setup */ - requestSchedulerOptions = conf.request_scheduler_options; - if (conf.request_scheduler != null) + /* Request Scheduler setup */ + requestSchedulerOptions = conf.request_scheduler_options; + if (conf.request_scheduler != null) + { + try { - try - { - if (requestSchedulerOptions == null) - { - requestSchedulerOptions = new RequestSchedulerOptions(); - } - Class cls = Class.forName(conf.request_scheduler); - requestScheduler = (IRequestScheduler) cls.getConstructor(RequestSchedulerOptions.class).newInstance(requestSchedulerOptions); - } - catch (ClassNotFoundException e) - { - throw new ConfigurationException("Invalid Request Scheduler class " + conf.request_scheduler); - } - catch (Exception e) + if (requestSchedulerOptions == null) { - throw new ConfigurationException("Unable to instantiate request scheduler", e); + requestSchedulerOptions = new RequestSchedulerOptions(); } + Class cls = Class.forName(conf.request_scheduler); + requestScheduler = (IRequestScheduler) cls.getConstructor(RequestSchedulerOptions.class).newInstance(requestSchedulerOptions); } - else - { - requestScheduler = new NoScheduler(); - } - - if (conf.request_scheduler_id == RequestSchedulerId.keyspace) + catch (ClassNotFoundException e) { - requestSchedulerId = conf.request_scheduler_id; + throw new ConfigurationException("Invalid Request Scheduler class " + conf.request_scheduler); } - else + catch (Exception e) { - // Default to Keyspace - requestSchedulerId = RequestSchedulerId.keyspace; + throw new ConfigurationException("Unable to instantiate request scheduler", e); } + } + else + { + requestScheduler = new NoScheduler(); + } - if (logger.isDebugEnabled() && conf.auto_bootstrap != null) - { - logger.debug("setting auto_bootstrap to " + conf.auto_bootstrap); - } + if (conf.request_scheduler_id == RequestSchedulerId.keyspace) + { + requestSchedulerId = conf.request_scheduler_id; + } + else + { + // Default to Keyspace + requestSchedulerId = RequestSchedulerId.keyspace; + } - logger.info((conf.multithreaded_compaction ? "" : "Not ") + "using multi-threaded compaction"); + if (logger.isDebugEnabled() && conf.auto_bootstrap != null) + { + logger.debug("setting auto_bootstrap to " + conf.auto_bootstrap); + } - if (conf.in_memory_compaction_limit_in_mb != null && conf.in_memory_compaction_limit_in_mb <= 0) - { - throw new ConfigurationException("in_memory_compaction_limit_in_mb must be a positive integer"); - } + logger.info((conf.multithreaded_compaction ? "" : "Not ") + "using multi-threaded compaction"); - if (conf.concurrent_compactors == null) - conf.concurrent_compactors = FBUtilities.getAvailableProcessors(); + if (conf.in_memory_compaction_limit_in_mb != null && conf.in_memory_compaction_limit_in_mb <= 0) + { + throw new ConfigurationException("in_memory_compaction_limit_in_mb must be a positive integer"); + } - if (conf.concurrent_compactors <= 0) - throw new ConfigurationException("concurrent_compactors should be strictly greater than 0"); + if (conf.concurrent_compactors == null) + conf.concurrent_compactors = FBUtilities.getAvailableProcessors(); - /* data file and commit log directories. they get created later, when they're needed. */ - if (conf.commitlog_directory != null && conf.data_file_directories != null && conf.saved_caches_directory != null) - { - for (String datadir : conf.data_file_directories) - { - if (datadir.equals(conf.commitlog_directory)) - throw new ConfigurationException("commitlog_directory must not be the same as any data_file_directories"); - if (datadir.equals(conf.saved_caches_directory)) - throw new ConfigurationException("saved_caches_directory must not be the same as any data_file_directories"); - } + if (conf.concurrent_compactors <= 0) + throw new ConfigurationException("concurrent_compactors should be strictly greater than 0"); - if (conf.commitlog_directory.equals(conf.saved_caches_directory)) - throw new ConfigurationException("saved_caches_directory must not be the same as the commitlog_directory"); - } - else + /* data file and commit log directories. they get created later, when they're needed. */ + if (conf.commitlog_directory != null && conf.data_file_directories != null && conf.saved_caches_directory != null) + { + for (String datadir : conf.data_file_directories) { - if (conf.commitlog_directory == null) - throw new ConfigurationException("commitlog_directory missing"); - if (conf.data_file_directories == null) - throw new ConfigurationException("data_file_directories missing; at least one data directory must be specified"); - if (conf.saved_caches_directory == null) - throw new ConfigurationException("saved_caches_directory missing"); + if (datadir.equals(conf.commitlog_directory)) + throw new ConfigurationException("commitlog_directory must not be the same as any data_file_directories"); + if (datadir.equals(conf.saved_caches_directory)) + throw new ConfigurationException("saved_caches_directory must not be the same as any data_file_directories"); } - if (conf.initial_token != null) - for (String token : tokensFromString(conf.initial_token)) - partitioner.getTokenFactory().validate(token); + if (conf.commitlog_directory.equals(conf.saved_caches_directory)) + throw new ConfigurationException("saved_caches_directory must not be the same as the commitlog_directory"); + } + else + { + if (conf.commitlog_directory == null) + throw new ConfigurationException("commitlog_directory missing"); + if (conf.data_file_directories == null) + throw new ConfigurationException("data_file_directories missing; at least one data directory must be specified"); + if (conf.saved_caches_directory == null) + throw new ConfigurationException("saved_caches_directory missing"); + } + + if (conf.initial_token != null) + for (String token : tokensFromString(conf.initial_token)) + partitioner.getTokenFactory().validate(token); - try - { - // if key_cache_size_in_mb option was set to "auto" then size of the cache should be "min(5% of Heap (in MB), 100MB) - keyCacheSizeInMB = (conf.key_cache_size_in_mb == null) - ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024)), 100) - : conf.key_cache_size_in_mb; + try + { + // if key_cache_size_in_mb option was set to "auto" then size of the cache should be "min(5% of Heap (in MB), 100MB) + keyCacheSizeInMB = (conf.key_cache_size_in_mb == null) + ? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024)), 100) + : conf.key_cache_size_in_mb; - if (keyCacheSizeInMB < 0) - throw new NumberFormatException(); // to escape duplicating error message - } - catch (NumberFormatException e) - { - throw new ConfigurationException("key_cache_size_in_mb option was set incorrectly to '" - + conf.key_cache_size_in_mb + "', supported values are >= 0."); - } + if (keyCacheSizeInMB < 0) + throw new NumberFormatException(); // to escape duplicating error message + } + catch (NumberFormatException e) + { + throw new ConfigurationException("key_cache_size_in_mb option was set incorrectly to '" + + conf.key_cache_size_in_mb + "', supported values are >= 0."); + } - rowCacheProvider = FBUtilities.newCacheProvider(conf.row_cache_provider); + rowCacheProvider = FBUtilities.newCacheProvider(conf.row_cache_provider); + memoryAllocator = FBUtilities.newOffHeapAllocator(conf.memory_allocator); - if(conf.encryption_options != null) - { - logger.warn("Please rename encryption_options as server_encryption_options in the yaml"); - //operate under the assumption that server_encryption_options is not set in yaml rather than both - conf.server_encryption_options = conf.encryption_options; - } + if(conf.encryption_options != null) + { + logger.warn("Please rename encryption_options as server_encryption_options in the yaml"); + //operate under the assumption that server_encryption_options is not set in yaml rather than both + conf.server_encryption_options = conf.encryption_options; + } - // Hardcoded system tables - List systemKeyspaces = Arrays.asList(KSMetaData.systemKeyspace(), KSMetaData.traceKeyspace()); - assert systemKeyspaces.size() == Schema.systemKeyspaceNames.size(); - for (KSMetaData ksmd : systemKeyspaces) - { - // install the definition - for (CFMetaData cfm : ksmd.cfMetaData().values()) - Schema.instance.load(cfm); - Schema.instance.setTableDefinition(ksmd); - } + // Hardcoded system tables + List systemKeyspaces = Arrays.asList(KSMetaData.systemKeyspace(), KSMetaData.traceKeyspace()); + assert systemKeyspaces.size() == Schema.systemKeyspaceNames.size(); + for (KSMetaData ksmd : systemKeyspaces) + { + // install the definition + for (CFMetaData cfm : ksmd.cfMetaData().values()) + Schema.instance.load(cfm); + Schema.instance.setTableDefinition(ksmd); + } - /* Load the seeds for node contact points */ - if (conf.seed_provider == null) - { - throw new ConfigurationException("seeds configuration is missing; a minimum of one seed is required."); - } - try - { - Class seedProviderClass = Class.forName(conf.seed_provider.class_name); - seedProvider = (SeedProvider)seedProviderClass.getConstructor(Map.class).newInstance(conf.seed_provider.parameters); - } - // there are about 5 checked exceptions that could be thrown here. - catch (Exception e) - { - logger.error("Fatal configuration error", e); - System.err.println(e.getMessage() + "\nFatal configuration error; unable to start server. See log for stacktrace."); - System.exit(1); - } - if (seedProvider.getSeeds().size() == 0) - throw new ConfigurationException("The seed provider lists no seeds."); + /* Load the seeds for node contact points */ + if (conf.seed_provider == null) + { + throw new ConfigurationException("seeds configuration is missing; a minimum of one seed is required."); } - catch (ConfigurationException e) + try { - logger.error("Fatal configuration error", e); - System.err.println(e.getMessage() + "\nFatal configuration error; unable to start server. See log for stacktrace."); - System.exit(1); + Class seedProviderClass = Class.forName(conf.seed_provider.class_name); + seedProvider = (SeedProvider)seedProviderClass.getConstructor(Map.class).newInstance(conf.seed_provider.parameters); } - catch (YAMLException e) + // there are about 5 checked exceptions that could be thrown here. + catch (Exception e) { - logger.error("Fatal configuration error error", e); - System.err.println(e.getMessage() + "\nInvalid yaml; unable to start server. See log for stacktrace."); + logger.error("Fatal configuration error", e); + System.err.println(e.getMessage() + "\nFatal configuration error; unable to start server. See log for stacktrace."); System.exit(1); } + if (seedProvider.getSeeds().size() == 0) + throw new ConfigurationException("The seed provider lists no seeds."); } private static IEndpointSnitch createEndpointSnitch(String snitchClassName) throws ConfigurationException http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/src/java/org/apache/cassandra/hadoop/ColumnFamilyOutputFormat.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8aa6222b/src/java/org/apache/cassandra/hadoop/ConfigHelper.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/hadoop/ConfigHelper.java index 9d8b47e,0d12812..71e6634 --- a/src/java/org/apache/cassandra/hadoop/ConfigHelper.java +++ b/src/java/org/apache/cassandra/hadoop/ConfigHelper.java @@@ -503,20 -502,12 +502,6 @@@ public class ConfigHelpe return conf.getInt(THRIFT_FRAMED_TRANSPORT_SIZE_IN_MB, 15) * 1024 * 1024; // 15MB is default in Cassandra } - public static void setThriftMaxMessageLengthInMb(Configuration conf, int maxMessageSizeInMB) - { - conf.setInt(THRIFT_MAX_MESSAGE_LENGTH_IN_MB, maxMessageSizeInMB); - } - - /** - * @param conf The configuration to use. - * @return Value (converts MBs to Bytes) set by {@link #setThriftMaxMessageLengthInMb(Configuration, int)} or default of 16MB - */ - public static int getThriftMaxMessageLength(Configuration conf) - { - return conf.getInt(THRIFT_MAX_MESSAGE_LENGTH_IN_MB, 16) * 1024 * 1024; // 16MB is default in Cassandra - } - - @Deprecated - public static void setThriftMaxMessageLengthInMb(Configuration conf, int maxMessageSizeInMB) - { - // SEE CASSANDRA-5529 - } - public static CompressionParameters getOutputCompressionParamaters(Configuration conf) { if (getOutputCompressionClass(conf) == null)