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


Java ReadWriteLock.writeLock方法代码示例

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


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

示例1: AMPSAgent

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public AMPSAgent(AMContext context, PSAgentId id, Location location) {
  this.context = context;
  this.id = id;
  this.location = location;
  this.diagnostics = new ArrayList<String>();
  this.failedAttempts = new ArrayList<PSAgentAttemptId>();
  this.attempts = new HashMap<PSAgentAttemptId, PSAgentAttempt>();
  if (context.getRunningMode() == RunningMode.ANGEL_PS_PSAGENT) {
    this.stateMachine = stateMachineFactoryForAllMode.make(this);
  } else {
    this.stateMachine = stateMachineFactoryForPSMode.make(this);
  }

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  this.readLock = readWriteLock.readLock();
  this.writeLock = readWriteLock.writeLock();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:AMPSAgent.java

示例2: AMWorker

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public AMWorker(WorkerId id, AMContext context, List<TaskId> taskIds) {
  this.id = id;
  this.context = context;
  this.taskIds = taskIds;

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
  stateMachine = stateMachineFactory.make(this);
  metrics = new HashMap<String, String>();
  diagnostics = new ArrayList<String>();    
  attempts = new HashMap<WorkerAttemptId, WorkerAttempt>();
  failedAttempts = new HashSet<WorkerAttemptId>();
  
  maxAttempts =
      context.getConf().getInt(AngelConf.ANGEL_WORKER_MAX_ATTEMPTS,
          AngelConf.DEFAULT_WORKER_MAX_ATTEMPTS);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:AMWorker.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: 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

示例5: 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

示例6: YarnContainerAllocator

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public YarnContainerAllocator(AMContext context) {
  super(YarnContainerAllocator.class.getName());
  this.context = context;
  this.recordFactory = RecordFactoryProvider.getRecordFactory(null);
  stopped = new AtomicBoolean(false);
  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:10,代码来源:YarnContainerAllocator.java

示例7: 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

示例8: MemoryTokenStore

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public MemoryTokenStore() {
    this.cache = CacheBuilder.newBuilder().softValues().expireAfterAccess(120, TimeUnit.SECONDS)
            .build();
    ReadWriteLock lock = new ReentrantReadWriteLock();
    this.r = lock.readLock();
    this.w = lock.writeLock();
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:8,代码来源:MemoryTokenStore.java

示例9: PSAgentAttempt

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
public PSAgentAttempt(PSAgentAttemptId attemptId, AMContext context, Location location) {
  this.id = attemptId;
  this.context = context;
  this.location = location;
  if (context.getRunningMode() == RunningMode.ANGEL_PS_PSAGENT) {
    stateMachine = stateMachineFactoryForAllMode.make(this);
  } else {
    stateMachine = stateMachineFactoryForPSMode.make(this);
  }

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:15,代码来源:PSAgentAttempt.java

示例10: 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

示例11: Worker

import java.util.concurrent.locks.ReadWriteLock; //导入方法依赖的package包/类
/**
 * Instantiates a new Worker.
 *
 * @param conf            the conf
 * @param appId           the app id
 * @param user            the user
 * @param workerAttemptId the worker attempt id
 * @param masterLocation  the master location
 * @param initMinClock    the init min clock
 * @param isLeader        the is leader
 */
public Worker(Configuration conf, ApplicationId appId, String user,
    WorkerAttemptId workerAttemptId, Location masterLocation, int initMinClock,
    boolean isLeader) {
  this.conf = conf;
  this.stopped = new AtomicBoolean(false);
  this.workerInitFinishedFlag = new AtomicBoolean(false);
  this.exitedFlag = new AtomicBoolean(false);
  this.workerMetrics = new HashMap<String, String>();
  this.connection = TConnectionManager.getConnection(conf);

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLockForTaskNum = readWriteLock.readLock();
  writeLockForTaskNum = readWriteLock.writeLock();

  activeTaskNum = conf.getInt(AngelConf.ANGEL_TASK_ACTUAL_NUM, 1);

  this.appId = appId;
  this.user = user;
  this.masterLocation = masterLocation;
  this.workerAttemptId = workerAttemptId;
  this.isLeader = isLeader;

  this.workerAttemptIdProto = ProtobufUtil.convertToIdProto(workerAttemptId);

  this.initMinClock = initMinClock;
  this.counterUpdater = new CounterUpdater();
  WorkerContext.get().setWorker(this);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:40,代码来源:Worker.java

示例12: testWriteLockWriteUnlock

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

示例13: testWriteLockBlocksReadLock

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

示例14: testWriteLockBlocksWriteLock

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

示例15: testReadLockBlocksWriteLock

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


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