List of usage examples for java.util.concurrent.locks ReentrantReadWriteLock ReentrantReadWriteLock
public ReentrantReadWriteLock()
From source file:nl.basvanmarwijk.mylocations.viewcontroller.LocationItemDetailFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ReentrantReadWriteLock itemLock = new ReentrantReadWriteLock(); itemReadLock = itemLock.readLock();/*from w ww . ja va2 s . c o m*/ itemWriteLock = itemLock.writeLock(); // verkrijg de locatie item uit de database final Bundle args = getArguments(); if (args.containsKey(ARG_ITEM_ID)) { final long id = args.getLong(ARG_ITEM_ID); DBManager dbManager = App.getDbManager(); Location item = dbManager.getLocationById(id); mItem = item; } }
From source file:org.apache.hadoop.hbase.quotas.FileArchiverNotifierImpl.java
public FileArchiverNotifierImpl(Connection conn, Configuration conf, FileSystem fs, TableName tn) { this.conn = conn; this.conf = conf; this.fs = fs; this.tn = tn; ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); readLock = lock.readLock();/*from www. j a v a 2 s. c om*/ writeLock = lock.writeLock(); }
From source file:org.apache.tajo.master.QueryUnit.java
public QueryUnit(QueryUnitId id, boolean isLeafTask, EventHandler eventHandler) { this.taskId = id; this.eventHandler = eventHandler; this.isLeafTask = isLeafTask; scan = new ArrayList<ScanNode>(); fetchMap = Maps.newHashMap();/*from w w w . ja va 2 s . co m*/ fragMap = Maps.newHashMap(); partitions = new ArrayList<Partition>(); attempts = Collections.emptyMap(); lastAttemptId = -1; failedAttempts = 0; ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); this.readLock = readWriteLock.readLock(); this.writeLock = readWriteLock.writeLock(); stateMachine = stateMachineFactory.make(this); }
From source file:net.myrrix.online.generation.Generation.java
public Generation(FastByIDMap<FastIDSet> knownItemIDs, FastByIDMap<float[]> X, FastByIDMap<float[]> Y, FastIDSet itemTagIDs, FastIDSet userTagIDs, List<IDCluster> userClusters, List<IDCluster> itemClusters) { // knownItemIDs may be null, specially Preconditions.checkNotNull(X);//from ww w . j av a2s .co m Preconditions.checkNotNull(Y); Preconditions.checkNotNull(itemTagIDs); Preconditions.checkNotNull(userTagIDs); Preconditions.checkNotNull(userClusters); Preconditions.checkNotNull(itemClusters); this.knownItemIDs = knownItemIDs; this.knownUserIDs = null; // Not used yet this.X = X; this.XTXsolver = null; this.Y = Y; this.YTYsolver = null; this.itemTagIDs = itemTagIDs; this.userTagIDs = userTagIDs; this.userClusters = userClusters; this.itemClusters = itemClusters; this.candidateFilter = null; this.xLock = new ReentrantReadWriteLock(); this.yLock = new ReentrantReadWriteLock(); this.knownItemLock = new ReentrantReadWriteLock(); this.knownUserLock = null; // Not used yet this.userClustersLock = new ReentrantReadWriteLock(); this.itemClustersLock = new ReentrantReadWriteLock(); recomputeState(); }
From source file:org.apache.ambari.resource.statemachine.ClusterImpl.java
public ClusterImpl(Cluster cluster, int revision) throws IOException { ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); this.readLock = readWriteLock.readLock(); this.writeLock = readWriteLock.writeLock(); this.stateMachine = stateMachineFactory.make(this); List<ServiceFSM> serviceImpls = new ArrayList<ServiceFSM>(); for (String service : cluster.getClusterDefinition(revision).getEnabledServices()) { if (hasActiveRoles(cluster, service)) { ServiceImpl serviceImpl = new ServiceImpl(cluster.getComponentDefinition(service).getActiveRoles(), this, service); serviceImpls.add(serviceImpl); }/*from w w w .jav a 2s . co m*/ } this.cls = cluster; this.services = serviceImpls; }
From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationImpl.java
public ApplicationImpl(Dispatcher dispatcher, String user, ApplicationId appId, Credentials credentials, Context context, String userFolder, int x509Version, long jwtExpiration) { this.dispatcher = dispatcher; this.user = user; this.userFolder = userFolder; this.appId = appId; this.credentials = credentials; this.aclsManager = context.getApplicationACLsManager(); this.context = context; this.x509Version = new AtomicInteger(x509Version); this.jwtExpiration = new AtomicLong(jwtExpiration); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); readLock = lock.readLock();/*from w ww.ja v a2 s . c om*/ writeLock = lock.writeLock(); stateMachine = stateMachineFactory.make(this); }
From source file:it.doqui.index.ecmengine.business.personalization.multirepository.node.index.AbstractReindexComponent.java
public AbstractReindexComponent() { shutdown = false;// w ww.j av a 2 s. co m indexerWriteLockMap = new HashMap<String, WriteLock>( RepositoryManager.getInstance().getRepositories().size()); for (Repository repository : RepositoryManager.getInstance().getRepositories()) { ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); indexerWriteLockMap.put(repository.getId(), readWriteLock.writeLock()); } }
From source file:org.apache.tajo.master.Query.java
public Query(final QueryContext context, final QueryId id, Clock clock, final long appSubmitTime, final String queryStr, final EventHandler eventHandler, final MasterPlan plan, final StorageManager sm) { this.context = context; this.conf = context.getConf(); this.id = id; this.clock = clock; this.appSubmitTime = appSubmitTime; this.queryStr = queryStr; subqueries = Maps.newHashMap();/*from w w w . j a v a 2s .c om*/ this.eventHandler = eventHandler; this.plan = plan; this.sm = sm; cursor = new ExecutionBlockCursor(plan); ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); this.readLock = readWriteLock.readLock(); this.writeLock = readWriteLock.writeLock(); stateMachine = stateMachineFactory.make(this); }
From source file:com.cloudera.oryx.ml.serving.als.model.ALSServingModel.java
/** * Creates an empty model.// w ww . j av a 2 s .c o m * * @param features number of features expected for user/item feature vectors * @param implicit whether model implements implicit feedback */ @SuppressWarnings("unchecked") ALSServingModel(int features, boolean implicit) { Preconditions.checkArgument(features > 0); X = HashObjObjMaps.newMutableMap(); Y = (ObjObjMap<String, float[]>[]) Array.newInstance(ObjObjMap.class, PARTITIONS); for (int i = 0; i < Y.length; i++) { Y[i] = HashObjObjMaps.newMutableMap(); } recentNewUsers = new HashSet<>(); recentNewItems = (Collection<String>[]) Array.newInstance(HashSet.class, PARTITIONS); for (int i = 0; i < recentNewItems.length; i++) { recentNewItems[i] = new HashSet<>(); } knownItems = HashObjObjMaps.newMutableMap(); xLock = new ReentrantReadWriteLock(); yLocks = new ReentrantReadWriteLock[Y.length]; for (int i = 0; i < yLocks.length; i++) { yLocks[i] = new ReentrantReadWriteLock(); } this.features = features; this.implicit = implicit; }
From source file:org.elasticsoftware.elasticactors.cluster.LocalActorSystemInstance.java
public LocalActorSystemInstance(PhysicalNode localNode, InternalActorSystems cluster, InternalActorSystemConfiguration configuration, NodeSelectorFactory nodeSelectorFactory) { this.configuration = configuration; this.nodeSelectorFactory = nodeSelectorFactory; this.cluster = cluster; this.shards = new ActorShard[configuration.getNumberOfShards()]; this.shardLocks = new ReadWriteLock[shards.length]; this.shardAdapters = new ActorShardAdapter[shards.length]; for (int i = 0; i < shards.length; i++) { shardLocks[i] = new ReentrantReadWriteLock(); shardAdapters[i] = new ActorShardAdapter(new ShardKey(configuration.getName(), i)); }//w w w . jav a 2s . c o m this.localNodeAdapter = new ActorNodeAdapter(new NodeKey(configuration.getName(), localNode.getId())); }