本文整理汇总了Java中org.apache.cassandra.service.StorageProxy.writeHintForMutation方法的典型用法代码示例。如果您正苦于以下问题:Java StorageProxy.writeHintForMutation方法的具体用法?Java StorageProxy.writeHintForMutation怎么用?Java StorageProxy.writeHintForMutation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.service.StorageProxy
的用法示例。
在下文中一共展示了StorageProxy.writeHintForMutation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeHintsForUndeliveredEndpoints
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void writeHintsForUndeliveredEndpoints(int startFrom)
{
try
{
// Here we deserialize mutations 2nd time from byte buffer.
// but this is ok, because timeout on batch direct delivery is rare
// (it can happen only several seconds until node is marked dead)
// so trading some cpu to keep less objects
List<Mutation> replayingMutations = replayingMutations();
for (int i = startFrom; i < replayHandlers.size(); i++)
{
Mutation undeliveredMutation = replayingMutations.get(i);
int ttl = calculateHintTTL(replayingMutations);
ReplayWriteResponseHandler handler = replayHandlers.get(i);
if (ttl > 0 && handler != null)
for (InetAddress endpoint : handler.undelivered)
StorageProxy.writeHintForMutation(undeliveredMutation, writtenAt, ttl, endpoint);
}
}
catch (IOException e)
{
logger.error("Cannot schedule hints for undelivered batch", e);
}
}
示例2: replaySerializedMutation
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void replaySerializedMutation(RowMutation mutation, long writtenAt)
{
int ttl = calculateHintTTL(mutation, writtenAt);
if (ttl <= 0)
return; // the mutation isn't safe to replay.
Set<InetAddress> liveEndpoints = new HashSet<InetAddress>();
String ks = mutation.getKeyspaceName();
Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
{
if (endpoint.equals(FBUtilities.getBroadcastAddress()))
mutation.apply();
else if (FailureDetector.instance.isAlive(endpoint))
liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
else
StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
}
if (!liveEndpoints.isEmpty())
attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
示例3: replaySerializedMutation
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void replaySerializedMutation(RowMutation mutation, long writtenAt) throws IOException
{
int ttl = calculateHintTTL(mutation, writtenAt);
if (ttl <= 0)
return; // the mutation isn't safe to replay.
Set<InetAddress> liveEndpoints = new HashSet<InetAddress>();
String ks = mutation.getTable();
Token tk = StorageService.getPartitioner().getToken(mutation.key());
for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
{
if (endpoint.equals(FBUtilities.getBroadcastAddress()))
mutation.apply();
else if (FailureDetector.instance.isAlive(endpoint))
liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
else
StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
}
if (!liveEndpoints.isEmpty())
attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
示例4: replaySerializedMutation
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void replaySerializedMutation(Mutation mutation, long writtenAt, RateLimiter rateLimiter)
{
int ttl = calculateHintTTL(mutation, writtenAt);
if (ttl <= 0)
return; // the mutation isn't safe to replay.
Set<InetAddress> liveEndpoints = new HashSet<>();
String ks = mutation.getKeyspaceName();
Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
int mutationSize = (int) Mutation.serializer.serializedSize(mutation, VERSION);
for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
{
rateLimiter.acquire(mutationSize);
if (endpoint.equals(FBUtilities.getBroadcastAddress()))
mutation.apply();
else if (FailureDetector.instance.isAlive(endpoint))
liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
else
StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
}
if (!liveEndpoints.isEmpty())
attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
示例5: replaySerializedMutation
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void replaySerializedMutation(Mutation mutation, long writtenAt, int version, RateLimiter rateLimiter)
{
int ttl = calculateHintTTL(mutation, writtenAt);
if (ttl <= 0)
return; // the mutation isn't safe to replay.
Set<InetAddress> liveEndpoints = new HashSet<>();
String ks = mutation.getKeyspaceName();
Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
int mutationSize = (int) Mutation.serializer.serializedSize(mutation, version);
for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
{
rateLimiter.acquire(mutationSize);
if (endpoint.equals(FBUtilities.getBroadcastAddress()))
mutation.apply();
else if (FailureDetector.instance.isAlive(endpoint))
liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
else
StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
}
if (!liveEndpoints.isEmpty())
attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}
示例6: replaySerializedMutation
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void replaySerializedMutation(RowMutation mutation, long writtenAt, RateLimiter rateLimiter) throws IOException
{
int ttl = calculateHintTTL(mutation, writtenAt);
if (ttl <= 0)
return; // the mutation isn't safe to replay.
Set<InetAddress> liveEndpoints = new HashSet<InetAddress>();
String ks = mutation.getTable();
Token tk = StorageService.getPartitioner().getToken(mutation.key());
int mutationSize = (int) RowMutation.serializer.serializedSize(mutation, VERSION);
for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))
{
rateLimiter.acquire(mutationSize);
if (endpoint.equals(FBUtilities.getBroadcastAddress()))
mutation.apply();
else if (FailureDetector.instance.isAlive(endpoint))
liveEndpoints.add(endpoint); // will try delivering directly instead of writing a hint.
else
StorageProxy.writeHintForMutation(mutation, ttl, endpoint);
}
if (!liveEndpoints.isEmpty())
attemptDirectDelivery(mutation, writtenAt, liveEndpoints);
}