本文整理汇总了C#中ConsistencyLevel类的典型用法代码示例。如果您正苦于以下问题:C# ConsistencyLevel类的具体用法?C# ConsistencyLevel怎么用?C# ConsistencyLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsistencyLevel类属于命名空间,在下文中一共展示了ConsistencyLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TimeOutException
protected TimeOutException(ErrorCodes code, string message, ConsistencyLevel consistencyLevel, int received, int blockFor)
: base(code, message)
{
ConsistencyLevel = consistencyLevel;
Received = received;
BlockFor = blockFor;
}
示例2: UnavailableException
public UnavailableException(ConsistencyLevel consistency, int required, int alive)
: base(string.Format("Not enough replica available for query at consistency {0} ({1} required but only {2} alive)", consistency, required, alive))
{
this.Consistency = consistency;
this.RequiredReplicas = required;
this.AliveReplicas = alive;
}
示例3: RegisterComponents
public static void RegisterComponents()
{
var container = new UnityContainer();
var documentUri = ConfigurationManager.AppSettings["DocumentUri"];
string authKey = ConfigurationManager.AppSettings["AuthorizationKey"];
string redisConnection = ConfigurationManager.AppSettings["RedisConnection"];
// register all your components with the container here
// it is NOT necessary to register your controllers
// e.g. container.RegisterType<ITestService, TestService>();
Uri uri = new Uri(documentUri);
ConnectionPolicy connectionPolicy = new ConnectionPolicy() { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp };
ConsistencyLevel consistencyLevel = new ConsistencyLevel();
consistencyLevel = ConsistencyLevel.Session;
container.RegisterType<IApplicationUserStore, ApplicatonUserStore>();
container.RegisterType<DocumentClient>(new ContainerControlledLifetimeManager(), new InjectionConstructor(uri, authKey, connectionPolicy, consistencyLevel));
ConnectionMultiplexer connectionMulp = ConnectionMultiplexer.Connect(redisConnection);
container.RegisterInstance<IConnectionMultiplexer>(ConnectionMultiplexer.Connect(redisConnection));
container.RegisterType<IRedisRepository, RedisRepository>();
container.RegisterType<IUserRepository, UserRepository>();
var repo = container.Resolve<IRedisRepository>();
container.RegisterType<RefreshTokenProvider>(new InjectionConstructor(repo));
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
}
示例4: UnavailableException
public UnavailableException(string message, ConsistencyLevel consistencyLevel, int required, int alive)
: base(ErrorCodes.Unavailable, message)
{
ConsistencyLevel = consistencyLevel;
Required = required;
Alive = alive;
}
示例5: Execute
public Task<IEnumerable<object>> Execute(ConsistencyLevel cl, IDataMapperFactory factory)
{
IConnection connection;
if (null == (connection = _connection))
{
lock (_lock)
{
if (null == (connection = _connection))
{
connection = _cluster.GetConnection(null);
connection.OnFailure += ConnectionOnOnFailure;
Action<IFrameWriter> writer = fw => CQLCommandHelpers.WritePrepareRequest(fw, _cql);
Func<IFrameReader, IEnumerable<object>> reader = fr => CQLCommandHelpers.ReadPreparedQuery(fr, connection);
connection.Execute(writer, reader).ContinueWith(ReadPreparedQueryInfo).Wait();
Thread.MemoryBarrier();
_connection = connection;
}
}
}
Action<IFrameWriter> execWriter = fw => WriteExecuteRequest(fw, cl, factory);
Func<IFrameReader, IEnumerable<object>> execReader = fr => CQLCommandHelpers.ReadRowSet(fr, factory);
return connection.Execute(execWriter, execReader);
}
示例6: QueryProtocolOptions
internal QueryProtocolOptions(ConsistencyLevel consistency,
object[] values,
bool skipMetadata,
int pageSize,
byte[] pagingState,
ConsistencyLevel serialConsistency)
{
Consistency = consistency;
Values = values;
_skipMetadata = skipMetadata;
if (pageSize <= 0)
{
PageSize = QueryOptions.DefaultPageSize;
}
else if (pageSize == int.MaxValue)
{
PageSize = -1;
}
else
{
PageSize = pageSize;
}
PagingState = pagingState;
SerialConsistency = serialConsistency;
}
示例7: BeginExecuteQuery
public IAsyncResult BeginExecuteQuery(int _streamId, byte[] Id, string cql, RowSetMetadata Metadata, object[] values,
AsyncCallback callback, object state, object owner,
ConsistencyLevel consistency, bool isTracing)
{
var jar = SetupJob(_streamId, callback, state, owner, "EXECUTE");
BeginJob(jar, SetupKeyspace(jar, SetupPreparedQuery(jar, Id, cql, () =>
{
Evaluate(new ExecuteRequest(jar.StreamId, Id, Metadata, values, consistency, isTracing), jar.StreamId,
new Action<ResponseFrame>((frame2) =>
{
var response = FrameParser.Parse(frame2);
if (response is ResultResponse)
JobFinished(jar, (response as ResultResponse).Output);
else
_protocolErrorHandlerAction(new ErrorActionParam()
{
AbstractResponse = response,
Jar = jar
});
}));
})));
return jar;
}
示例8: Create
public IKeyspace Create(
ICassandraClient client,
string keyspaceName,
IDictionary<string, Dictionary<string, string>> keyspaceDesc,
ConsistencyLevel consistencyLevel,
FailoverPolicy failoverPolicy,
IKeyedObjectPool<Endpoint, ICassandraClient> pool)
{
switch (client.Version)
{
case CassandraVersion.v0_6_0_beta_3:
throw new NotImplementedException("Version 0.6.0 not implimented yet");
default:
case CassandraVersion.v0_5_1:
return new _051.Keyspace(
client,
keyspaceName,
keyspaceDesc,
consistencyLevel,
failoverPolicy,
pool,
monitor
);
}
}
示例9: QueryTimeoutException
public QueryTimeoutException(string message, ConsistencyLevel consistencyLevel, int received, int required)
: base(message)
{
ConsistencyLevel = consistencyLevel;
ReceivedAcknowledgements = received;
RequiredAcknowledgements = required;
}
示例10: Execute
public Task<IEnumerable<object>> Execute(ConsistencyLevel cl, IDataMapperFactory factory)
{
Action<IFrameWriter> writer = fw => WriteExecuteRequest(fw, cl, factory);
Func<IFrameReader, IEnumerable<object>> reader = fr => CQLCommandHelpers.ReadRowSet(fr, factory);
return _connection.Execute(writer, reader);
}
示例11: Execute
public Task<IEnumerable<object>> Execute(IDataMapperFactory factory, ConsistencyLevel cl)
{
IConnection connection;
if (null == (connection = _connection))
{
lock (_lock)
{
if (null == (connection = _connection))
{
connection = _cluster.GetConnection(null);
connection.OnFailure += ConnectionOnOnFailure;
Action<IFrameWriter> writer = fw => CQLCommandHelpers.WritePrepareRequest(fw, _cql);
Func<IFrameReader, IEnumerable<object>> reader = fr => CQLCommandHelpers.ReadPreparedQuery(fr, connection);
InstrumentationToken prepareToken = InstrumentationToken.Create(RequestType.Prepare, _executionFlags, _cql);
connection.Execute(writer, reader, _executionFlags, prepareToken).ContinueWith(ReadPreparedQueryInfo).Wait();
_connection = connection;
}
}
}
Action<IFrameWriter> execWriter = fw => WriteExecuteRequest(fw, cl, factory);
Func<IFrameReader, IEnumerable<object>> execReader = fr => CQLCommandHelpers.ReadRowSet(fr, factory);
InstrumentationToken queryToken = InstrumentationToken.Create(RequestType.Query, _executionFlags, _cql);
return connection.Execute(execWriter, execReader, _executionFlags, queryToken);
}
示例12: GetInsertAction
public Action GetInsertAction(ISession session, object bindableStatement, ConsistencyLevel consistency, int rowsPerId)
{
Action action = () =>
{
Trace.TraceInformation("Starting inserting from thread {0}", Thread.CurrentThread.ManagedThreadId);
var id = Guid.NewGuid();
for (var i = 0; i < rowsPerId; i++)
{
var paramsArray = new object[] { id, DateTime.Now, DateTime.Now.ToString() };
IStatement statement = null;
if (bindableStatement is SimpleStatement)
{
statement = ((SimpleStatement)bindableStatement).Bind(paramsArray).SetConsistencyLevel(consistency);
}
else if (bindableStatement is PreparedStatement)
{
statement = ((PreparedStatement)bindableStatement).Bind(paramsArray).SetConsistencyLevel(consistency);
}
else
{
throw new Exception("Can not bind a statement of type " + bindableStatement.GetType().FullName);
}
session.Execute(statement);
}
Trace.TraceInformation("Finished inserting from thread {0}", Thread.CurrentThread.ManagedThreadId);
};
return action;
}
示例13: addCoordinator
/// Coordinator management/count
public static void addCoordinator(IPAddress coordinator, ConsistencyLevel cl)
{
if (!coordinators.ContainsKey(coordinator))
coordinators.Add(coordinator, 0);
var n = coordinators[coordinator];
coordinators[coordinator] = n + 1;
achievedConsistencies.Add(cl);
}
示例14: QueryRequest
public QueryRequest(int streamId, string cqlQuery, ConsistencyLevel consistency, bool tracingEnabled)
{
this._streamId = streamId;
this._cqlQuery = cqlQuery;
this._consistency = consistency;
if (tracingEnabled)
this._flags = 0x02;
}
示例15: Reset
public static void Reset()
{
ColumnWidth = 40;
Formatter = OutputFormatter.Tab;
DebugLog = false;
Tracing = false;
CL = ConsistencyLevel.QUORUM;
}