当前位置: 首页>>代码示例>>Java>>正文


Java ReadWriteLock.readLock方法代码示例

本文整理汇总了Java中java.util.concurrent.locks.ReadWriteLock.readLock方法的典型用法代码示例。如果您正苦于以下问题:Java ReadWriteLock.readLock方法的具体用法?Java ReadWriteLock.readLock怎么用?Java ReadWriteLock.readLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.locks.ReadWriteLock的用法示例。


在下文中一共展示了ReadWriteLock.readLock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: App

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public App(AMContext context) {
  super(App.class.getName());
  this.context = context;
  stateMachine = stateMachineFactory.make(this);
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();

  this.launchTime = context.getStartTime();
  shouldRetry = false;
  diagnostics = new ArrayList<String>();
  
  stateTimeOutMs = 
      context.getConf().getLong(AngelConf.ANGEL_AM_APPSTATE_TIMEOUT_MS,
          AngelConf.DEFAULT_ANGEL_AM_APPSTATE_TIMEOUT_MS);
  stateToTsMap = new HashMap<AppState, Long>();
  stateToTsMap.put(AppState.NEW, context.getClock().getTime());
  stopped = new AtomicBoolean(false);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:20,代码来源:App.java

示例2: LocalTranslog

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public LocalTranslog(TranslogConfig config) throws IOException {
    super(config.getShardId(), config.getIndexSettings());
    ReadWriteLock rwl = new ReentrantReadWriteLock();
    readLock = new ReleasableLock(rwl.readLock());
    writeLock = new ReleasableLock(rwl.writeLock());
    this.translogPath = config.getTranslogPath();
    // clean all files
    Files.createDirectories(this.translogPath);
    Files.walkFileTree(this.translogPath, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file,
                BasicFileAttributes attrs) throws IOException {
            Files.delete(file);
            return FileVisitResult.CONTINUE;
        }
    });
    
    // create a new directory
    writeChannel = FileChannel.open(this.translogPath.resolve(getFileNameFromId(tmpTranslogGeneration.get())), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
    writtenOffset = 0;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:LocalTranslog.java

示例3: Translog

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public Translog(TranslogConfig config, String nodeId) {
    super(config.getShardId(), config.getIndexSettings());
    this.config = null;
    recoveredTranslogs = null;
    syncScheduler = null;
    bigArrays = null;
    ReadWriteLock rwl = new ReentrantReadWriteLock();
    readLock = new ReleasableLock(rwl.readLock());
    writeLock = new ReleasableLock(rwl.writeLock());
    location = null;
    current = null;
    currentCommittingTranslog = null;
    lastCommittedTranslogFileGeneration = -1; 
    config = null;
    translogUUID = null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:Translog.java

示例4: AMWorkerGroup

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
/**
 * Create a AMWorkerGroup
 * @param groupId worker group id
 * @param context master context
 * @param workerMap workers contains in worker group
 * @param leader leader worker of worker group
 * @param splitIndex training data block index assgined to this worker group
 */
public AMWorkerGroup(WorkerGroupId groupId, AMContext context, Map<WorkerId, AMWorker> workerMap,
    WorkerId leader, int splitIndex) {
  this.context = context;
  this.groupId = groupId;
  this.workerMap = workerMap;
  this.leader = leader;
  this.splitIndex = splitIndex;

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
  stateMachine = stateMachineFactory.make(this);
  diagnostics = new ArrayList<String>();
  successWorkerSet = new HashSet<WorkerId>();
  failedWorkerSet = new HashSet<WorkerId>();
  killedWorkerSet = new HashSet<WorkerId>();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:26,代码来源:AMWorkerGroup.java

示例5: AMParameterServer

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public AMParameterServer(String ip, ParameterServerId id, AMContext context) {
  this.ip = ip;
  this.id = id;
  this.context = context;
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
  stateMachine = stateMachineFactory.make(this);
  attempts = new HashMap<PSAttemptId, PSAttempt>(2);
  this.failedAttempts = new HashSet<PSAttemptId>(2);
  maxAttempts =
      context.getConf().getInt(AngelConf.ANGEL_PS_MAX_ATTEMPTS,
          AngelConf.DEFAULT_PS_MAX_ATTEMPTS);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:15,代码来源:AMParameterServer.java

示例6: PSAttempt

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
/**
 * Init the Attempt for PS
 * @param ip excepted host for this ps attempt
 * @param psId ps id
 * @param attemptIndex attempt index
 * @param amContext Master context
 */
public PSAttempt(String ip, ParameterServerId psId, int attemptIndex, AMContext amContext) {
  this.expectedIp = ip;
  attemptId = new PSAttemptId(psId, attemptIndex);
  this.context = amContext;
  stateMachine = stateMachineFactory.make(this);
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
  metrices = new HashMap<String, String>();
  diagnostics = new ArrayList<String>();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:PSAttempt.java

示例7: setInternalRegionArguments

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
@Override
protected void setInternalRegionArguments(InternalRegionArguments ira) {
  // PR specific
  PartitionedRegion pr = mock(PartitionedRegion.class);
  BucketAdvisor ba = mock(BucketAdvisor.class);
  ReadWriteLock primaryMoveLock = new ReentrantReadWriteLock();
  Lock activeWriteLock = primaryMoveLock.readLock();
  when(ba.getActiveWriteLock()).thenReturn(activeWriteLock);
  when(ba.isPrimary()).thenReturn(true);

  ira.setPartitionedRegion(pr).setPartitionedRegionBucketRedundancy(1).setBucketAdvisor(ba);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:13,代码来源:BucketRegionJUnitTest.java

示例8: DiskWriterTask

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
DiskWriterTask(int partitionID, int writerID, BlockingQueue<FileBlock> queue) {
    super(partitionID, writerID);
    this.queue = queue;
    hasToRun = new AtomicBoolean(true);
    final ReadWriteLock rwl = new ReentrantReadWriteLock();
    countersRLock = rwl.readLock();
    countersWLock = rwl.writeLock();
    final boolean hasP = (System.getProperty("fdt.doNotForceOnClose") != null);
    doNotForceOnClose = (hasP) ? Boolean.getBoolean("fdt.doNotForceOnClose") : true;
}
 
开发者ID:fast-data-transfer,项目名称:fdt,代码行数:11,代码来源:DiskWriterTask.java

示例9: KeyAuthorizationKeyProvider

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
/**
 * The constructor takes a {@link KeyProviderCryptoExtension} and an
 * implementation of <code>KeyACLs</code>. All calls are delegated to the
 * provider keyProvider after authorization check (if required)
 * @param keyProvider 
 * @param acls
 */
public KeyAuthorizationKeyProvider(KeyProviderCryptoExtension keyProvider,
    KeyACLs acls) {
  super(keyProvider, null);
  this.provider = keyProvider;
  this.acls = acls;
  ReadWriteLock lock = new ReentrantReadWriteLock(true);
  readLock = lock.readLock();
  writeLock = lock.writeLock();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:KeyAuthorizationKeyProvider.java

示例10: KeyAuthorizationKeyProvider

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
/**
 * The constructor takes a {@link KeyProviderCryptoExtension} and an
 * implementation of <code>KeyACLs</code>. All calls are delegated to the
 * provider keyProvider after authorization check (if required)
 * @param keyProvider  the key provider
 * @param acls the Key ACLs
 */
public KeyAuthorizationKeyProvider(KeyProviderProxyReEncryptionExtension keyProvider,
    KeyACLs acls) {
  super(keyProvider, null);
  this.provider = keyProvider;
  this.acls = acls;
  ReadWriteLock lock = new ReentrantReadWriteLock(true);
  readLock = lock.readLock();
  writeLock = lock.writeLock();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:KeyAuthorizationKeyProvider.java

示例11: TranslogWriter

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public TranslogWriter(ShardId shardId, long generation, ChannelReference channelReference) throws IOException {
    super(generation, channelReference, channelReference.getChannel().position());
    this.shardId = shardId;
    ReadWriteLock rwl = new ReentrantReadWriteLock();
    readLock = new ReleasableLock(rwl.readLock());
    writeLock = new ReleasableLock(rwl.writeLock());
    this.writtenOffset = channelReference.getChannel().position();
    this.lastSyncedOffset = channelReference.getChannel().position();;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:TranslogWriter.java

示例12: ConfigurationFactoryImpl

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public ConfigurationFactoryImpl ()
{
    final ReadWriteLock lock = new ReentrantReadWriteLock ();
    this.readLock = lock.readLock ();
    this.writeLock = lock.writeLock ();

    final BundleContext context = FrameworkUtil.getBundle ( DataContext.class ).getBundleContext ();

    this.executor = new ScheduledExportedExecutorService ( "org.eclipse.scada.da.server.exporter.rest", 1 );
    this.hiveSource = new ServiceListenerHiveSource ( context, this.executor );
    this.hiveSource.open ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:ConfigurationFactoryImpl.java

示例13: LocalizedResource

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public LocalizedResource(LocalResourceRequest rsrc, Dispatcher dispatcher) {
  this.rsrc = rsrc;
  this.dispatcher = dispatcher;
  this.ref = new LinkedList<ContainerId>();

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();

  this.stateMachine = stateMachineFactory.make(this);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:LocalizedResource.java

示例14: lockIfExists

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public static boolean lockIfExists(final ReadWriteLock rwLock, boolean exclusive) {
    if (null == rwLock) {
        return false;
    }
    final Lock lock = exclusive ? rwLock.writeLock() : rwLock.readLock();
    return lockIfExists(lock);
}
 
开发者ID:yohlulz,项目名称:MLE5109-Course-samples,代码行数:8,代码来源:LockUtils.java

示例15: testReadLockDoesNotBlockReadLock

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
@Test
public void testReadLockDoesNotBlockReadLock() {
  final ReadWriteLock rwl = new CountingReadWriteLock();
  final Lock r = rwl.readLock();
  r.lock();
  assertTrue(r.tryLock());
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:8,代码来源:CountingReadWriteLockTest.java


注:本文中的java.util.concurrent.locks.ReadWriteLock.readLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。