本文整理匯總了Java中org.apache.cassandra.exceptions.ConfigurationException類的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationException類的具體用法?Java ConfigurationException怎麽用?Java ConfigurationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConfigurationException類屬於org.apache.cassandra.exceptions包,在下文中一共展示了ConfigurationException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseChunkLength
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
/**
* Parse the chunk length (in KB) and returns it as bytes.
*
* @param chLengthKB the length of the chunk to parse
* @return the chunk length in bytes
* @throws ConfigurationException if the chunk size is too large
*/
private static Integer parseChunkLength(String chLengthKB) throws ConfigurationException
{
if (chLengthKB == null)
return null;
try
{
int parsed = Integer.parseInt(chLengthKB);
if (parsed > Integer.MAX_VALUE / 1024)
throw new ConfigurationException(format("Value of %s is too large (%s)", CHUNK_LENGTH_IN_KB,parsed));
return 1024 * parsed;
}
catch (NumberFormatException e)
{
throw new ConfigurationException("Invalid value for " + CHUNK_LENGTH_IN_KB, e);
}
}
示例2: validate
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public void validate() throws ConfigurationException
{
// if chunk length was not set (chunkLength == null), this is fine, default will be used
if (chunkLength != null)
{
if (chunkLength <= 0)
throw new ConfigurationException("Invalid negative or null " + CHUNK_LENGTH_IN_KB);
int c = chunkLength;
boolean found = false;
while (c != 0)
{
if ((c & 0x01) != 0)
{
if (found)
throw new ConfigurationException(CHUNK_LENGTH_IN_KB + " must be a power of 2");
else
found = true;
}
c >>= 1;
}
}
}
示例3: deserialize
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public CompressionParams deserialize(DataInputPlus in, int version) throws IOException
{
String compressorName = in.readUTF();
int optionCount = in.readInt();
Map<String, String> options = new HashMap<>();
for (int i = 0; i < optionCount; ++i)
{
String key = in.readUTF();
String value = in.readUTF();
options.put(key, value);
}
int chunkLength = in.readInt();
CompressionParams parameters;
try
{
parameters = new CompressionParams(compressorName, chunkLength, options);
}
catch (ConfigurationException e)
{
throw new RuntimeException("Cannot create CompressionParams for parameters", e);
}
return parameters;
}
示例4: create
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public static LZ4Compressor create(Map<String, String> args) throws ConfigurationException
{
String compressorType = validateCompressorType(args.get(LZ4_COMPRESSOR_TYPE));
Integer compressionLevel = validateCompressionLevel(args.get(LZ4_HIGH_COMPRESSION_LEVEL));
Pair<String, Integer> compressorTypeAndLevel = Pair.create(compressorType, compressionLevel);
LZ4Compressor instance = instances.get(compressorTypeAndLevel);
if (instance == null)
{
if (compressorType.equals(LZ4_FAST_COMPRESSOR) && args.get(LZ4_HIGH_COMPRESSION_LEVEL) != null)
logger.warn("'{}' parameter is ignored when '{}' is '{}'", LZ4_HIGH_COMPRESSION_LEVEL, LZ4_COMPRESSOR_TYPE, LZ4_FAST_COMPRESSOR);
instance = new LZ4Compressor(compressorType, compressionLevel);
LZ4Compressor instanceFromMap = instances.putIfAbsent(compressorTypeAndLevel, instance);
if(instanceFromMap != null)
instance = instanceFromMap;
}
return instance;
}
示例5: validateCompressorType
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public static String validateCompressorType(String compressorType) throws ConfigurationException
{
if (compressorType == null)
return DEFAULT_LZ4_COMPRESSOR_TYPE;
if (!VALID_COMPRESSOR_TYPES.contains(compressorType))
{
throw new ConfigurationException(String.format("Invalid compressor type '%s' specified for LZ4 parameter '%s'. "
+ "Valid options are %s.", compressorType, LZ4_COMPRESSOR_TYPE,
VALID_COMPRESSOR_TYPES.toString()));
}
else
{
return compressorType;
}
}
示例6: validateCompressionLevel
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public static Integer validateCompressionLevel(String compressionLevel) throws ConfigurationException
{
if (compressionLevel == null)
return DEFAULT_HIGH_COMPRESSION_LEVEL;
ConfigurationException ex = new ConfigurationException("Invalid value [" + compressionLevel + "] for parameter '"
+ LZ4_HIGH_COMPRESSION_LEVEL + "'. Value must be between 1 and 17.");
Integer level;
try
{
level = Integer.valueOf(compressionLevel);
}
catch (NumberFormatException e)
{
throw ex;
}
if (level < 1 || level > 17)
{
throw ex;
}
return level;
}
示例7: startServer
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException, URISyntaxException {
if (! started) {
EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_UNIT_RANDOM_PORT_YAML, CASSANDRA_TIMEOUT);
Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(getNativeTransportPort()).build();
Session session = cluster.connect();
String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}";
session.execute(createQuery);
String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE;
session.execute(useKeyspaceQuery);
CQLDataLoader dataLoader = new CQLDataLoader(session);
applyScripts(dataLoader, "config/cql/changelog/", "*.cql");
started = true;
}
}
示例8: startServer
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
@BeforeClass
public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException {
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(9142).build();
Session session = cluster.connect();
CQLDataLoader dataLoader = new CQLDataLoader(session);
dataLoader.load(new ClassPathCQLDataSet("config/cql/create-tables.cql", true, "cassandra_unit_keyspace"));
}
示例9: ensureMockCassandraRunningAndEstablished
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
/**
* Ensures that the Mock Cassandra instance is up and running. Will reinit
* the database every time it is called.
*
* @param cassandraKeyspace Cassandra keyspace to setup.
* @return A cluster object.
* @throws ConfigurationException
* @throws IOException
* @throws InterruptedException
* @throws TTransportException
*/
public static Cluster ensureMockCassandraRunningAndEstablished(String cassandraKeyspace) throws ConfigurationException, IOException, InterruptedException, TTransportException
{
Cluster cluster;
long timeout = 60000;
EmbeddedCassandraServerHelper.startEmbeddedCassandra(timeout);
cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build();
//Thread.sleep(20000);//time to let cassandra startup
final Metadata metadata = cluster.getMetadata();
Session session = cluster.connect();
Utils.initDatabase(DB_CQL, session);
session = cluster.connect(cassandraKeyspace);
logger.info("Connected to cluster: " + metadata.getClusterName() + '\n');
return cluster;
}
示例10: parseChunkLength
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
/**
* Parse the chunk length (in KB) and returns it as bytes.
*/
public static Integer parseChunkLength(String chLengthKB) throws ConfigurationException
{
if (chLengthKB == null)
return null;
try
{
int parsed = Integer.parseInt(chLengthKB);
if (parsed > Integer.MAX_VALUE / 1024)
throw new ConfigurationException("Value of " + CHUNK_LENGTH_KB + " is too large (" + parsed + ")");
return 1024 * parsed;
}
catch (NumberFormatException e)
{
throw new ConfigurationException("Invalid value for " + CHUNK_LENGTH_KB, e);
}
}
示例11: validateCompactionThresholds
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
private void validateCompactionThresholds() throws ConfigurationException
{
if (maxCompactionThreshold == 0)
{
logger.warn("Disabling compaction by setting max or min compaction has been deprecated, " +
"set the compaction strategy option 'enabled' to 'false' instead");
return;
}
if (minCompactionThreshold <= 1)
throw new ConfigurationException(String.format("Min compaction threshold cannot be less than 2 (got %d).", minCompactionThreshold));
if (minCompactionThreshold > maxCompactionThreshold)
throw new ConfigurationException(String.format("Min compaction threshold (got %d) cannot be greater than max compaction threshold (got %d)",
minCompactionThreshold, maxCompactionThreshold));
}
示例12: validate
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public void validate() throws ConfigurationException
{
// if chunk length was not set (chunkLength == null), this is fine, default will be used
if (chunkLength != null)
{
if (chunkLength <= 0)
throw new ConfigurationException("Invalid negative or null " + CHUNK_LENGTH_KB);
int c = chunkLength;
boolean found = false;
while (c != 0)
{
if ((c & 0x01) != 0)
{
if (found)
throw new ConfigurationException(CHUNK_LENGTH_KB + " must be a power of 2");
else
found = true;
}
c >>= 1;
}
}
validateCrcCheckChance(crcCheckChance);
}
示例13: validateOptions
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public static Map<String, String> validateOptions(Map<String, String> options) throws ConfigurationException
{
Map<String, String> uncheckedOptions = AbstractCompactionStrategy.validateOptions(options);
String size = options.containsKey(SSTABLE_SIZE_OPTION) ? options.get(SSTABLE_SIZE_OPTION) : "1";
try
{
int ssSize = Integer.parseInt(size);
if (ssSize < 1)
{
throw new ConfigurationException(String.format("%s must be larger than 0, but was %s", SSTABLE_SIZE_OPTION, ssSize));
}
}
catch (NumberFormatException ex)
{
throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", size, SSTABLE_SIZE_OPTION), ex);
}
uncheckedOptions.remove(SSTABLE_SIZE_OPTION);
uncheckedOptions = SizeTieredCompactionStrategyOptions.validateOptions(options, uncheckedOptions);
return uncheckedOptions;
}
示例14: deserialize
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public CompressionParameters deserialize(DataInput in, int version) throws IOException
{
String compressorName = in.readUTF();
int optionCount = in.readInt();
Map<String, String> options = new HashMap<String, String>();
for (int i = 0; i < optionCount; ++i)
{
String key = in.readUTF();
String value = in.readUTF();
options.put(key, value);
}
int chunkLength = in.readInt();
CompressionParameters parameters;
try
{
parameters = new CompressionParameters(compressorName, chunkLength, options);
}
catch (ConfigurationException e)
{
throw new RuntimeException("Cannot create CompressionParameters for parameters", e);
}
return parameters;
}
示例15: deserialize
import org.apache.cassandra.exceptions.ConfigurationException; //導入依賴的package包/類
public MerkleTree deserialize(DataInput in, int version) throws IOException
{
byte hashdepth = in.readByte();
long maxsize = in.readLong();
long size = in.readLong();
IPartitioner partitioner;
try
{
partitioner = FBUtilities.newPartitioner(in.readUTF());
}
catch (ConfigurationException e)
{
throw new IOException(e);
}
// full range
Token left = Token.serializer.deserialize(in);
Token right = Token.serializer.deserialize(in);
Range<Token> fullRange = new Range<>(left, right, partitioner);
MerkleTree mt = new MerkleTree(partitioner, fullRange, hashdepth, maxsize);
mt.size = size;
mt.root = Hashable.serializer.deserialize(in, version);
return mt;
}