本文整理汇总了Java中org.apache.cassandra.utils.SemanticVersion类的典型用法代码示例。如果您正苦于以下问题:Java SemanticVersion类的具体用法?Java SemanticVersion怎么用?Java SemanticVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SemanticVersion类属于org.apache.cassandra.utils包,在下文中一共展示了SemanticVersion类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateCQLVersion
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
private void validateCQLVersion(int major) throws InvalidRequestException
{
/*
* The rules are:
* - If no version are set, we don't validate anything. The reason is
* that 1) old CQL2 client might not have called set_cql_version
* and 2) some client may have removed the set_cql_version for CQL3
* when updating to 1.2.0. A CQL3 client upgrading from pre-1.2
* shouldn't be in that case however since set_cql_version uses to
* be mandatory (for CQL3).
* - Otherwise, checks the major matches whatever was set.
*/
SemanticVersion versionSet = state().getCQLVersion();
if (versionSet == null)
return;
if (versionSet.major != major)
throw new InvalidRequestException(
"Cannot execute/prepare CQL" + major + " statement since the CQL has been set to CQL" + versionSet.major
+ "(This might mean your client hasn't been upgraded correctly to use the new CQL3 methods introduced in Cassandra 1.2+).");
}
示例2: getCQLSupportedVersion
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
public static SemanticVersion[] getCQLSupportedVersion()
{
SemanticVersion cql = org.apache.cassandra.cql.QueryProcessor.CQL_VERSION;
SemanticVersion cql3 = org.apache.cassandra.cql3.QueryProcessor.CQL_VERSION;
return new SemanticVersion[]{ cql, cql3 };
}
示例3: execute
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
public Message.Response execute(QueryState state)
{
String cqlVersion = options.get(CQL_VERSION);
if (cqlVersion == null)
throw new ProtocolException("Missing value CQL_VERSION in STARTUP message");
try
{
if (new SemanticVersion(cqlVersion).compareTo(new SemanticVersion("2.99.0")) < 0)
throw new ProtocolException(String.format("CQL version %s is not supported by the binary protocol (supported version are >= 3.0.0)", cqlVersion));
}
catch (IllegalArgumentException e)
{
throw new ProtocolException(e.getMessage());
}
if (options.containsKey(COMPRESSION))
{
String compression = options.get(COMPRESSION).toLowerCase();
if (compression.equals("snappy"))
{
if (FrameCompressor.SnappyCompressor.instance == null)
throw new ProtocolException("This instance does not support Snappy compression");
connection.setCompressor(FrameCompressor.SnappyCompressor.instance);
}
else if (compression.equals("lz4"))
{
connection.setCompressor(FrameCompressor.LZ4Compressor.instance);
}
else
{
throw new ProtocolException(String.format("Unknown compression algorithm: %s", compression));
}
}
if (DatabaseDescriptor.getAuthenticator().requireAuthentication())
return new AuthenticateMessage(DatabaseDescriptor.getAuthenticator().getClass().getName());
else
return new ReadyMessage();
}
示例4: execute
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
public Message.Response execute(QueryState state)
{
ClientState cState = state.getClientState();
String cqlVersion = options.get(CQL_VERSION);
if (cqlVersion == null)
throw new ProtocolException("Missing value CQL_VERSION in STARTUP message");
try
{
cState.setCQLVersion(cqlVersion);
}
catch (InvalidRequestException e)
{
throw new ProtocolException(e.getMessage());
}
if (cState.getCQLVersion().compareTo(new SemanticVersion("2.99.0")) < 0)
throw new ProtocolException(String.format("CQL version %s is not supported by the binary protocol (supported version are >= 3.0.0)", cqlVersion));
if (options.containsKey(COMPRESSION))
{
String compression = options.get(COMPRESSION).toLowerCase();
if (compression.equals("snappy"))
{
if (FrameCompressor.SnappyCompressor.instance == null)
throw new ProtocolException("This instance does not support Snappy compression");
connection.setCompressor(FrameCompressor.SnappyCompressor.instance);
}
else
{
throw new ProtocolException(String.format("Unknown compression algorithm: %s", compression));
}
}
if (DatabaseDescriptor.getAuthenticator().requireAuthentication())
return new AuthenticateMessage(DatabaseDescriptor.getAuthenticator().getClass().getName());
else
return new ReadyMessage();
}
示例5: getCQLVersion
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
public SemanticVersion getCQLVersion()
{
return cqlVersion;
}
示例6: execute
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
public Message.Response execute(QueryState state)
{
ClientState cState = state.getClientState();
String cqlVersion = options.get(CQL_VERSION);
if (cqlVersion == null)
throw new ProtocolException("Missing value CQL_VERSION in STARTUP message");
try
{
cState.setCQLVersion(cqlVersion);
}
catch (InvalidRequestException e)
{
throw new ProtocolException(e.getMessage());
}
if (cState.getCQLVersion().compareTo(new SemanticVersion("2.99.0")) < 0)
throw new ProtocolException(String.format("CQL version %s is not supported by the binary protocol (supported version are >= 3.0.0)", cqlVersion));
if (options.containsKey(COMPRESSION))
{
String compression = options.get(COMPRESSION).toLowerCase();
if (compression.equals("snappy"))
{
if (FrameCompressor.SnappyCompressor.instance == null)
throw new ProtocolException("This instance does not support Snappy compression");
connection.setCompressor(FrameCompressor.SnappyCompressor.instance);
}
else if (compression.equals("lz4"))
{
connection.setCompressor(FrameCompressor.LZ4Compressor.instance);
}
else
{
throw new ProtocolException(String.format("Unknown compression algorithm: %s", compression));
}
}
if (DatabaseDescriptor.getAuthenticator().requireAuthentication())
return new AuthenticateMessage(DatabaseDescriptor.getAuthenticator().getClass().getName());
else
return new ReadyMessage();
}
示例7: getCQLSupportedVersion
import org.apache.cassandra.utils.SemanticVersion; //导入依赖的package包/类
public static SemanticVersion[] getCQLSupportedVersion()
{
return new SemanticVersion[]{ QueryProcessor.CQL_VERSION };
}