本文整理汇总了Java中org.apache.cassandra.transport.Message.Response方法的典型用法代码示例。如果您正苦于以下问题:Java Message.Response方法的具体用法?Java Message.Response怎么用?Java Message.Response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.transport.Message
的用法示例。
在下文中一共展示了Message.Response方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
List<String> cqlVersions = new ArrayList<String>();
cqlVersions.add(QueryProcessor.CQL_VERSION.toString());
List<String> compressions = new ArrayList<String>();
if (FrameCompressor.SnappyCompressor.instance != null)
compressions.add("snappy");
// LZ4 is always available since worst case scenario it default to a pure JAVA implem.
compressions.add("lz4");
Map<String, List<String>> supported = new HashMap<String, List<String>>();
supported.put(StartupMessage.CQL_VERSION, cqlVersions);
supported.put(StartupMessage.COMPRESSION, compressions);
return new SupportedMessage(supported);
}
示例2: execute
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
try
{
AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().authenticate(credentials);
state.getClientState().login(user);
return new ReadyMessage();
}
catch (AuthenticationException e)
{
return ErrorMessage.fromException(e);
}
}
示例3: execute
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
try
{
AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().legacyAuthenticate(credentials);
state.getClientState().login(user);
}
catch (AuthenticationException e)
{
return ErrorMessage.fromException(e);
}
return new ReadyMessage();
}
示例4: testLargeBatchWithProtoV4
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
@Test
public void testLargeBatchWithProtoV4() throws Exception
{
createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, Server.VERSION_4))
{
client.connect(false);
QueryMessage query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertEquals(1, resp.getWarnings().size());
}
}
示例5: testLargeBatchWithProtoV2
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
@Test
public void testLargeBatchWithProtoV2() throws Exception
{
createTable("CREATE TABLE %s (pk int PRIMARY KEY, v text)");
try (SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort, Server.VERSION_3))
{
client.connect(false);
QueryMessage query = new QueryMessage(createBatchStatement(DatabaseDescriptor.getBatchSizeWarnThreshold()), QueryOptions.DEFAULT);
Message.Response resp = client.execute(query);
assertNull(resp.getWarnings());
}
}
示例6: execute
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
List<String> cqlVersions = new ArrayList<String>();
cqlVersions.add(QueryProcessor.CQL_VERSION.toString());
List<String> compressions = new ArrayList<String>();
if (FrameCompressor.SnappyCompressor.instance != null)
compressions.add("snappy");
Map<String, List<String>> supported = new HashMap<String, List<String>>();
supported.put(StartupMessage.CQL_VERSION, cqlVersions);
supported.put(StartupMessage.COMPRESSION, compressions);
return new SupportedMessage(supported);
}
示例7: execute
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
try
{
state.getClientState().login(credentials);
return new ReadyMessage();
}
catch (AuthenticationException e)
{
return ErrorMessage.fromException(e);
}
}
示例8: execute
import org.apache.cassandra.transport.Message; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
try
{
if (options.getPageSize() == 0)
throw new ProtocolException("The page size cannot be 0");
UUID tracingId = null;
if (isTracingRequested())
{
tracingId = UUIDGen.getTimeUUID();
state.prepareTracingSession(tracingId);
}
if (state.traceNextQuery())
{
state.createTracingSession();
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("query", query);
if (options.getPageSize() > 0)
builder.put("page_size", Integer.toString(options.getPageSize()));
if(options.getConsistency() != null)
builder.put("consistency_level", options.getConsistency().name());
if(options.getSerialConsistency() != null)
builder.put("serial_consistency_level", options.getSerialConsistency().name());
Tracing.instance.begin("Execute CQL3 query", state.getClientAddress(), builder.build());
}
Message.Response response = ClientState.getCQLQueryHandler().process(query, state, options, getCustomPayload());
if (options.skipMetadata() && response instanceof ResultMessage.Rows)
((ResultMessage.Rows)response).result.metadata.setSkipMetadata();
if (tracingId != null)
response.setTracingId(tracingId);
return response;
}
catch (Exception e)
{
JVMStabilityInspector.inspectThrowable(e);
if (!((e instanceof RequestValidationException) || (e instanceof RequestExecutionException)))
logger.error("Unexpected error during query", e);
return ErrorMessage.fromException(e);
}
finally
{
Tracing.instance.stopSession();
}
}