本文整理汇总了Java中org.infinispan.client.hotrod.Flag类的典型用法代码示例。如果您正苦于以下问题:Java Flag类的具体用法?Java Flag怎么用?Java Flag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Flag类属于org.infinispan.client.hotrod包,在下文中一共展示了Flag类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCompleted
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
@Override
public WhitelistedRecord setCompleted(final WhitelistedRecord partialWhite) {
if (partialWhite == null || partialWhite.getRawId() == null || StringUtils.isBlank(partialWhite.getSourceName()) || partialWhite.getExpiresAt() == null) {
log.log(Level.SEVERE, "put: Cannot set whiltelist entry as completed - missing mandatory fields");
return null;
}
final String key = DigestUtils.md5Hex(partialWhite.getRawId());
if (!whitelistCache.containsKey(key)) {
return null;
}
final long ttl = (partialWhite.getExpiresAt().getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
if (ttl < 0) {
return null;
}
partialWhite.setCompleted(true);
whitelistCache.withFlags(Flag.SKIP_CACHE_LOAD).replace(key, partialWhite, ttl, TimeUnit.MILLISECONDS);
return whitelistCache.withFlags(Flag.SKIP_CACHE_LOAD).get(key);
}
示例2: getRules
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
@Override
public List<?> getRules(final String clientIPAddress) {
try {
final RemoteCache<String, Rule> ruleCache = cacheManagerForIndexableCaches.getCache(SinkitCacheName.infinispan_rules.toString());
final ImmutablePair<String, String> startEndAddresses = CIDRUtils.getStartEndAddresses(clientIPAddress);
final String clientIPAddressPaddedBigInt = startEndAddresses.getLeft();
log.log(Level.FINE, "Getting key [" + clientIPAddress + "] which actually translates to BigInteger zero padded representation " + "[" + clientIPAddressPaddedBigInt + "]");
// Let's try to hit it
Rule rule = ruleCache.withFlags(Flag.SKIP_CACHE_LOAD).get(clientIPAddressPaddedBigInt);
if (rule != null) {
return Collections.singletonList(rule);
}
QueryFactory qf = Search.getQueryFactory(ruleCache);
Query query = qf.from(Rule.class)
.having("startAddress").lte(clientIPAddressPaddedBigInt)
.and()
.having("endAddress").gte(clientIPAddressPaddedBigInt)
.toBuilder().build();
return query.list();
} catch (Exception e) {
log.log(Level.SEVERE, "getRules client address troubles", e);
// TODO: Proper Error codes.
return null;
}
}
示例3: QueryOperation
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
public QueryOperation(Codec codec, TransportFactory transportFactory, byte[] cacheName,
AtomicInteger topologyId, Flag[] flags, RemoteQuery query) {
super(codec, transportFactory, cacheName, topologyId, flags);
this.remoteQuery = query;
this.requestAvroMarshaller = new Marshaller<>(Request.class);
this.responseAvroMarshaller = new Marshaller<>(Response.class);
}
示例4: addFlags
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
public void addFlags(Flag... flags) {
List<Flag> list = this.flagsMap.get();
if (list == null) {
list = new ArrayList<Flag>();
this.flagsMap.set(list);
}
for(Flag flag : flags)
list.add(flag);
}
示例5: rulesLookup
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
/**
* There are 3 ways to find the result, in ascending order by their cost:
* 1. local cache of already found results based on clientIPAddressPaddedBigInt
* 2. getting key clientIPAddressPaddedBigInt from the cache of Rules
* 3. lookup in the cache of Rules based on subnets
* <p>
* TODO: List? Array? Map with additional data? Let's think this over.
* TODO: Replace/factor out duplicated code in .getRules out of webApiEJB
*
* @param clientIPAddressPaddedBigInt
* @return list of rules
*/
private List<Rule> rulesLookup(final String clientIPAddressPaddedBigInt, final RemoteCache<String, Rule> ruleCache) {
try {
log.log(Level.FINE, "Getting key BigInteger zero padded representation " + clientIPAddressPaddedBigInt);
// Let's search subnets
final String keyInCache = DigestUtils.md5Hex(clientIPAddressPaddedBigInt + clientIPAddressPaddedBigInt);
log.log(Level.FINE, "keyInCache: " + keyInCache + ", from: " + (clientIPAddressPaddedBigInt + clientIPAddressPaddedBigInt));
final List<Rule> cached = ruleLocalCache.get(keyInCache);
if (cached != null) {
return cached;
} else {
// Let's try to hit it
final Rule rule = ruleCache.withFlags(Flag.SKIP_CACHE_LOAD).get(clientIPAddressPaddedBigInt);
if (rule != null) {
return Collections.singletonList(rule);
}
final QueryFactory qf = Search.getQueryFactory(ruleCache);
final Query query = qf.from(Rule.class)
.having("startAddress").lte(clientIPAddressPaddedBigInt)
.and()
.having("endAddress").gte(clientIPAddressPaddedBigInt)
.toBuilder().build();
if (query != null) {
final List<Rule> result = query.list();
ruleLocalCache.put(keyInCache, result);
return result;
}
return Collections.emptyList();
}
} catch (Exception e) {
log.log(Level.SEVERE, "getRules client address troubles", e);
return null;
}
}
示例6: removeFromCache
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
@Override
public boolean removeFromCache(final IoCRecord ioCRecord) {
if (ioCRecord == null || ioCRecord.getSource() == null || ioCRecord.getFeed() == null) {
log.log(Level.SEVERE, "removeFromCache: ioCRecord itself or its source or its feed were null. Can't process that.");
return false;
}
if (ioCRecord.getSource().getId() == null || ioCRecord.getSource().getId().getValue() == null) {
log.log(Level.SEVERE, "removeFromCache: ioCRecord can't have source id null.");
return false;
}
final String key = DigestUtils.md5Hex(ioCRecord.getSource().getId().getValue());
try {
if (blacklistCache.containsKey(key)) {
final BlacklistedRecord blacklistedRecord = blacklistCache.withFlags(Flag.SKIP_CACHE_LOAD).get(key);
HashMap<String, ImmutablePair<String, String>> feedToTypeUpdate = blacklistedRecord.getSources();
if (ioCRecord.getFeed().getName() != null) {
feedToTypeUpdate.remove(ioCRecord.getFeed().getName());
} else {
log.log(Level.FINE, "removeFromCache: ioCRecord's feed was null.");
}
if (MapUtils.isEmpty(feedToTypeUpdate)) {
// As soon as there are no feeds, we remove the IoC from the cache
blacklistCache.remove(key);
} else {
blacklistedRecord.setSources(feedToTypeUpdate);
blacklistedRecord.setListed(Calendar.getInstance());
blacklistCache.replace(key, blacklistedRecord);
}
}
} catch (Exception e) {
log.log(Level.SEVERE, "removeFromCache", e);
return false;
}
return true;
}
示例7: setFlags
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
public void setFlags(Flag[] flags) {
List<Flag> list = new ArrayList<Flag>();
for(Flag flag : flags)
list.add(flag);
this.flagsMap.set(list);
}
示例8: lookupSingleVariant
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
private Set<String> lookupSingleVariant(final String lookupVariant) {
final byte[] hash = DigestUtils.sha256(lookupVariant);
final byte[] hashPrefix = ArrayUtils.subarray(hash, 0, PREFIX_LENGTH);
final String fullHashString = Hex.encodeHexString(hash);
final String hashStringPrefix = fullHashString.substring(0, PREFIX_LENGTH * 2);
GSBRecord gsbRecord = gsbCache.withFlags(Flag.SKIP_CACHE_LOAD).get(hashStringPrefix);
// if hash prefix is not in the cache then URL is not blacklisted for sure
if (gsbRecord == null) {
return null;
} else {
logger.log(Level.FINE, "lookup: hashPrefix " + hashStringPrefix + " was found in cache. It was made off: " + fullHashString + " which is lookupVariant: " + lookupVariant);
}
final HashMap<String, HashSet<String>> fullHashes;
if (Calendar.getInstance().before(gsbRecord.getFullHashesExpireAt())) {
logger.log(Level.FINE, "lookup: Full hashes for prefix " + hashStringPrefix + " are valid.");
fullHashes = gsbRecord.getFullHashes();
} else {
logger.log(Level.FINE, "lookup: Full hashes for prefix " + hashStringPrefix + " expired -> updating.");
FullHashLookupResponse resposne = gsbClient.getFullHashes(hashPrefix);
gsbRecord = GSBCachePOJOFactory.createFullHashes(resposne);
gsbCache.put(hashStringPrefix, gsbRecord);
fullHashes = gsbRecord.getFullHashes();
}
// if fullHashes are empty then return null, i.e. no matched blacklists
if (MapUtils.isEmpty(fullHashes)) {
logger.log(Level.FINE, "lookup: Valid full hashes for prefix " + hashStringPrefix + " are empty.");
return null;
} else {
final Set<String> matchedBlacklists = new HashSet<>();
for (String blacklist : fullHashes.keySet()) {
final Set<String> fullHashesOnBlacklist = fullHashes.get(blacklist);
if (fullHashesOnBlacklist != null && fullHashesOnBlacklist.contains(fullHashString)) {
logger.log(Level.FINEST, "lookup: got hit for hash prefix " + hashStringPrefix + " and full hash " + fullHashString + ": " + blacklist);
matchedBlacklists.add(blacklist);
}
}
return matchedBlacklists;
}
}
示例9: withFlags
import org.infinispan.client.hotrod.Flag; //导入依赖的package包/类
/**
*
*
* @see org.infinispan.client.hotrod.RemoteCache#withFlags(org.infinispan.client.hotrod.Flag[])
*/
@Override
public RemoteCache<K, V> withFlags(Flag... flags) {
return null;
}