下面列出了怎么用com.google.common.util.concurrent.Striped的API类实例代码及写法,或者点击链接到github查看源代码。
@Inject
public FeedRefreshUpdater(SessionFactory sessionFactory, FeedUpdateService feedUpdateService, PubSubService pubSubService,
FeedQueues queues, CommaFeedConfiguration config, MetricRegistry metrics, FeedSubscriptionDAO feedSubscriptionDAO,
CacheService cache) {
this.sessionFactory = sessionFactory;
this.feedUpdateService = feedUpdateService;
this.pubSubService = pubSubService;
this.queues = queues;
this.config = config;
this.feedSubscriptionDAO = feedSubscriptionDAO;
this.cache = cache;
ApplicationSettings settings = config.getApplicationSettings();
int threads = Math.max(settings.getDatabaseUpdateThreads(), 1);
pool = new FeedRefreshExecutor("feed-refresh-updater", threads, Math.min(50 * threads, 1000), metrics);
locks = Striped.lazyWeakLock(threads * 100000);
entryCacheMiss = metrics.meter(MetricRegistry.name(getClass(), "entryCacheMiss"));
entryCacheHit = metrics.meter(MetricRegistry.name(getClass(), "entryCacheHit"));
feedUpdated = metrics.meter(MetricRegistry.name(getClass(), "feedUpdated"));
entryInserted = metrics.meter(MetricRegistry.name(getClass(), "entryInserted"));
}
@Inject
public TopicTreeImpl(@NotNull final MetricsHolder metricsHolder) {
this.subscriptionCounter = metricsHolder.getSubscriptionCounter();
this.mapCreationThreshold = TOPIC_TREE_MAP_CREATION_THRESHOLD.get();
segmentLocks = Striped.readWriteLock(64);
}
public HelixRetriggeringJobCallable(
GobblinHelixJobScheduler jobScheduler,
MutableJobCatalog jobCatalog,
Properties sysProps,
Properties jobProps,
JobListener jobListener,
GobblinHelixPlanningJobLauncherMetrics planningJobLauncherMetrics,
GobblinHelixMetrics helixMetrics,
Path appWorkDir,
HelixManager jobHelixManager,
Optional<HelixManager> taskDriverHelixManager,
HelixJobsMapping jobsMapping,
Striped<Lock> locks) {
this.jobScheduler = jobScheduler;
this.jobCatalog = jobCatalog;
this.sysProps = sysProps;
this.jobProps = jobProps;
this.jobListener = jobListener;
this.planningJobLauncherMetrics = planningJobLauncherMetrics;
this.helixMetrics = helixMetrics;
this.appWorkDir = appWorkDir;
this.jobHelixManager = jobHelixManager;
this.taskDriverHelixManager = taskDriverHelixManager;
this.isDistributeJobEnabled = isDistributeJobEnabled();
this.jobUri = jobProps.getProperty(GobblinClusterConfigurationKeys.JOB_SPEC_URI);
this.jobsMapping = jobsMapping;
this.locks = locks;
}
public TxVersionedCache(VersionedCache cache, boolean conflictFree) {
this.cache = cache;
this.conflictFree = conflictFree;
this.snapshotFilter = new SnapshotFilterImpl(cache);
this.striped = Striped.readWriteLock(128);
}
MessageIDPools() {
//Do not instantiate manually
lock = Striped.readWriteLock(InternalConfigurations.MESSAGE_ID_PRODUCER_LOCK_SIZE.get());
}
public KeyLock(int size) {
this.locks = Striped.lock(size);
}
ConcurrentCache(Cache<K, V> m) {
this.m = Objects.requireNonNull(m);
striped = Striped.readWriteLock(128);
}
ConcurrentCache(Cache<K, V> m, Striped<ReadWriteLock> striped) {
this.m = m;
this.striped = striped;
}
ConcurrentCollection(Collection<E> c, Striped<ReadWriteLock> striped) {
this.c = Objects.requireNonNull(c);
this.striped = Objects.requireNonNull(striped);
}
ConcurrentSet(Set<E> s, Striped<ReadWriteLock> striped) {
super(s, striped);
}
public StripedLocks(int stripesCount) {
striped = Striped.readWriteLock(stripesCount);
}
public DefaultBrokerCache() {
this.sharedResourceCache = CacheBuilder.newBuilder().build();
this.autoScopeCache = CacheBuilder.newBuilder().build();
this.invalidationLock = Striped.lazyWeakLock(20);
}
public StripedKeyedLocker(int stripes) {
locks = Striped.readWriteLock(stripes);
}
public StripedLock(int buckets) {
stripedLock = Striped.lock(buckets);
}